Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
hongweigao
9 years ago
Commit
15bca19fb6c39d0ddb8e47a6d05e32f33ef744d8
1 parent
a5bac3ff
品牌一览
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
40 deletions
apps/brands/controllers/brands.js
apps/brands/models/brands-api.js
apps/brands/models/brands-model.js
apps/brands/models/brands-service.js
apps/brands/router.js
apps/brands/controllers/brands.js
View file @
15bca19
...
...
@@ -6,7 +6,6 @@
'use strict'
;
const
mRoot
=
'../models'
;
const
helpers
=
global
.
yoho
.
helpers
;
const
brandsModel
=
require
(
`
$
{
mRoot
}
/brands-service`
)
; /
/
students
页
model
...
...
apps/brands/models/brands-api.js
View file @
15bca19
...
...
@@ -17,14 +17,16 @@ const getBrandTopData = (contentCode) => {
content_code
:
contentCode
});
};
/**
* 分开取数,获取品牌一览 "按字母'A-Z'分组的品牌列表数据"
* @param int $channel 频道标识 1:男,2:女,3:潮童,4:创意生活
*/
const
getBrandListData
=
channel
=>
{
let
params
=
{
method
:
'app.brand.brandlist'
};
if
(
!
isNaN
(
channel
))
{
params
.
yh_channel
=
channel
;
if
(
!
isNaN
(
channel
))
{
params
.
yh_channel
=
channel
;
}
return
api
.
get
(
''
,
params
);
};
...
...
apps/brands/models/brands-model.js
View file @
15bca19
...
...
@@ -11,22 +11,24 @@ const co = Promise.coroutine;
const
_
=
require
(
'lodash'
);
const
helpers
=
global
.
yoho
.
helpers
;
const
brandApi
=
require
(
'./brands-api'
);
//品牌一览资源位CODE码
// 品牌一览资源位CODE码
const
channelCode
=
{
boys_brand
:
'8b16b7baf9a66fbe553a6caa97d2ce2a'
,
girls_brand
:
'c95ae9e40f0add10549b819f821ad626'
,
kids_brand
:
'c575c6bfdfa4125fae7d24bbec7119c8'
,
lifestyle_brand
:
'84b7926282fdef92f1039bdcf77c18ba'
,
brand_list
:
'f0f72b1e8f30e6ad086dfc4401f3a856'
,
//品牌列表资源位CODE码
brand_list
:
'f0f72b1e8f30e6ad086dfc4401f3a856'
,
//
品牌列表资源位CODE码
brand_plusstar_banner_boys
:
'd0149783b8dd2adaf083fd10556c39a9'
,
brand_plusstar_banner_girls
:
'd0149783b8dd2adaf083fd10556c39a9'
,
brand_plusstarindex_boys
:
'a833aed63d28457156310e97faa7fa37'
,
//plusstarindex男首资源位
brand_plusstarindex_girls
:
'6e4f162be3b3ba44f3bfcf1c38bdb745'
,
//plusstarindex女首资源位
brand_plusstarindex_boys
:
'a833aed63d28457156310e97faa7fa37'
,
// plusstarindex男首资源位
brand_plusstarindex_girls
:
'6e4f162be3b3ba44f3bfcf1c38bdb745'
// plusstarindex女首资源位
};
const
BOYS
=
'boys'
;
const
GIRLS
=
'girls'
;
const
KIDS
=
'kids'
;
const
LIFESTYLE
=
'lifestyle'
;
/**
* 获取品牌一览资源位&channelType
*
...
...
@@ -42,35 +44,35 @@ const switchBrandParams = channel => {
req
=
{
channelType
:
1
,
brandCode
:
channelCode
.
brand_plusstar_banner_boys
}
}
;
break
;
case
GIRLS
:
req
=
{
channelType
:
2
,
brandCode
:
channelCode
.
brand_plusstar_banner_girls
}
}
;
break
;
case
KIDS
:
req
=
{
channelType
:
3
,
brandCode
:
channelCode
.
kids_brand
}
}
;
break
;
case
LIFESTYLE
:
req
=
{
channelType
:
4
,
brandCode
:
channelCode
.
lifestyle_brand
}
}
;
break
;
default
:
req
=
{
channelType
:
1
,
brandCode
:
channelCode
.
boys_brand
}
}
;
break
;
}
return
req
;
}
}
;
/**
* 获取品牌一览页面,品牌top
...
...
@@ -78,7 +80,7 @@ const switchBrandParams = channel => {
*/
const
getBrandViewTop
=
channel
=>
{
return
co
(
function
*
()
{
let
switchParams
=
switchBrandParams
(
channel
);
let
switchParams
=
switchBrandParams
(
channel
);
let
res
=
yield
brandApi
.
getBrandTopData
(
switchParams
.
brandCode
);
...
...
@@ -86,36 +88,38 @@ const getBrandViewTop = channel => {
brandAds
=
[],
brandLogos
=
[];
//头部10个品牌小图块 url
//
头部10个品牌小图块 url
if
(
res
.
data
[
1
].
data
&&
res
.
data
[
1
].
data
.
list
)
{
_
.
forEach
(
res
.
data
[
1
].
data
.
list
,
subValue
=>
{
brandAds
.
push
({
name
:
subValue
.
name
,
src
:
helpers
.
image
(
subValue
.
src
,
80
,
50
,
3
),
url
:
helpers
.
urlFormat
(
subValue
.
url
)
})
})
;
});
}
//头部品牌图块,广告位
// 头部品牌图块,广告位
if
(
res
.
data
[
0
].
data
)
{
_
.
forEach
(
res
.
data
[
0
].
data
,
subValue
=>
{
let
srcUrl
;
//kids lifestyle 第一张图尺寸不同
// kids lifestyle 第一张图尺寸不同
if
(
switchParams
.
channelType
===
1
||
switchParams
.
channelType
===
2
)
{
srcUrl
=
helpers
.
image
(
subValue
.
src
,
222
,
180
,
3
);
}
else
{
srcUrl
=
(
subValue
===
0
)
?
helpers
.
image
(
subValue
.
src
,
570
,
280
,
3
)
:
helpers
.
image
(
subValue
.
src
,
280
,
280
,
3
);
}
else
{
srcUrl
=
(
subValue
===
0
)
?
helpers
.
image
(
subValue
.
src
,
570
,
280
,
3
)
:
helpers
.
image
(
subValue
.
src
,
280
,
280
,
3
);
}
brandLogos
.
push
({
name
:
subValue
.
title
,
src
:
srcUrl
,
url
:
helpers
.
urlFormat
(
subValue
.
url
)
})
})
;
});
}
//整合brandTop数据结构,boys、girls
//
整合brandTop数据结构,boys、girls
if
(
switchParams
.
channelType
===
1
||
switchParams
.
channelType
===
2
)
{
result
.
isTab
=
true
;
}
...
...
@@ -125,22 +129,24 @@ const getBrandViewTop = channel => {
return
result
;
})();
};
/*
* 获取品牌一览list
* @param string $channel 频道名称
* @param int start 开始位置 1 开始
* @param int length 取数长度 0 取到最后
*/
const
getBrandViewList
=
(
channel
,
start
,
length
)
=>
{
const
getBrandViewList
=
(
channel
,
start
,
length
)
=>
{
return
co
(
function
*
()
{
let
switchParams
=
switchBrandParams
(
channel
);
let
switchParams
=
switchBrandParams
(
channel
);
let
res
=
yield
brandApi
.
getBrandListData
(
switchParams
.
brandCode
);
let
result
=
{},
navigation
=
[];
//品牌list A-Z 0-9
//
品牌list A-Z 0-9
if
(
res
.
data
.
brands
)
{
let
listTmp
=
{};
...
...
@@ -149,15 +155,15 @@ const getBrandViewList = (channel, start, length) =>{
// continue;
// }
_
.
forEach
(
subValue
,
ssubValue
=>
{
//为品牌名称
//
为品牌名称
let
brandName
=
ssubValue
.
brand_name
,
href
;
if
(
switchParams
.
channelType
===
1
)
{
href
=
helpers
.
urlFormat
(
ssubValue
.
brand_domain
)
+
'?gender=1,3'
;
}
else
if
(
switchParams
.
channelType
===
2
)
{
}
else
if
(
switchParams
.
channelType
===
2
)
{
href
=
helpers
.
urlFormat
(
ssubValue
.
brand_domain
)
+
'?gender=2,3'
;
}
else
{
}
else
{
href
=
helpers
.
urlFormat
(
ssubValue
.
brand_domain
);
}
...
...
@@ -165,25 +171,32 @@ const getBrandViewList = (channel, start, length) =>{
name
:
ssubValue
.
brand_name
,
key
:
ssubValue
.
id
,
href
:
href
}
}
;
if
(
ssubValue
.
is_hot
===
'Y'
)
{
listTmp
[
brandName
].
hot
=
'hot'
;
}
})
//按键值排序
})
});
// 按键值排序
});
}
//只取部分数据
// begin = ($start - 1) ? ($start - 1) : 0;
// begin = ($begin > 0) ? $begin : 0;
// result = $length ? array_slice($result, $begin, $length) : array_slice($result, $begin);
// $result['navigation'] = $navigation;
// 只取部分数据
let
begin
,
end
;
begin
=
(
start
-
1
)
?
(
start
-
1
)
:
0
;
begin
=
(
begin
>
0
)
?
begin
:
0
;
end
=
length
-
begin
;
result
=
length
?
result
.
slice
(
begin
,
end
)
:
result
.
slice
(
begin
,
end
);
result
.
navigation
=
navigation
;
return
result
;
})();
};
module
.
exports
=
{
getBrandViewTop
,
getBrandViewList
...
...
apps/brands/models/brands-service.js
View file @
15bca19
...
...
@@ -7,13 +7,14 @@
const
api
=
global
.
yoho
.
API
;
const
headerModel
=
require
(
'../../../doraemon/models/header'
);
const
brandsModel
=
require
(
'./brands-model'
);
/*
* 获取品牌一览list
* @param string $channel 频道名称
* @param int start 开始位置 1 开始
* @param int length 取数长度 0 取到最后
*/
exports
.
getBrandViewList
=
(
channel
,
req
)
=>
{
exports
.
getBrandViewList
=
(
channel
)
=>
{
let
apiMethod
=
[
headerModel
.
requestHeaderData
(
channel
),
brandsModel
.
getBrandViewTop
(
channel
),
...
...
@@ -28,6 +29,7 @@ exports.getBrandViewList = (channel, req) => {
// 头部数据
Object
.
assign
(
responseData
,
result
[
0
]);
// 品牌一览列表
responseData
.
brands
=
result
[
1
];
...
...
apps/brands/router.js
View file @
15bca19
...
...
@@ -12,7 +12,7 @@ const cRoot = './controllers';
const
router
=
express
.
Router
();
// eslint-disable-line
const
brandsController
=
require
(
`
$
{
cRoot
}
/brands`
)
;
//品牌一览
//
品牌一览
router
.
get
(
''
,
brandsController
.
index
);
...
...
Please
register
or
login
to post a comment