Showing
9 changed files
with
816 additions
and
719 deletions
@@ -19,7 +19,7 @@ const brandsService = require(`${mRoot}/brands-service`); // students 页 model | @@ -19,7 +19,7 @@ const brandsService = require(`${mRoot}/brands-service`); // students 页 model | ||
19 | exports.index = (req, res, next) => { | 19 | exports.index = (req, res, next) => { |
20 | let channel = req.query.channel || req.cookies._Channel || 'boys'; | 20 | let channel = req.query.channel || req.cookies._Channel || 'boys'; |
21 | 21 | ||
22 | - brandsService.getBrandViewList(channel, req).then(result => { | 22 | + req.ctx(brandsService).getBrandViewList(channel, req).then(result => { |
23 | // 返回null,不cashe | 23 | // 返回null,不cashe |
24 | if (result.noCashe) { | 24 | if (result.noCashe) { |
25 | res.set('Cache-Control', 'no-cache'); | 25 | res.set('Cache-Control', 'no-cache'); |
@@ -35,7 +35,7 @@ exports.index = (req, res, next) => { | @@ -35,7 +35,7 @@ exports.index = (req, res, next) => { | ||
35 | exports.brandList = (req, res, next) => { | 35 | exports.brandList = (req, res, next) => { |
36 | let channel = req.query.channel || req.cookies._Channel || 'boys'; | 36 | let channel = req.query.channel || req.cookies._Channel || 'boys'; |
37 | 37 | ||
38 | - brandsService.getBrandList(channel, req.body.start).then(result => { | 38 | + req.ctx(brandsService).getBrandList(channel, req.body.start).then(result => { |
39 | 39 | ||
40 | res.render('brands/brand-list', Object.assign({layout: false}, result)); | 40 | res.render('brands/brand-list', Object.assign({layout: false}, result)); |
41 | 41 | ||
@@ -52,7 +52,7 @@ exports.brandInfo = (req, res, next) => { | @@ -52,7 +52,7 @@ exports.brandInfo = (req, res, next) => { | ||
52 | 52 | ||
53 | let brandId = req.query.brandId || 0; | 53 | let brandId = req.query.brandId || 0; |
54 | 54 | ||
55 | - brandsService.brandInfo(brandId, req.user.uid).then(result => { | 55 | + req.ctx(brandsService).brandInfo(brandId, req.user.uid).then(result => { |
56 | // 返回null,不cashe | 56 | // 返回null,不cashe |
57 | if (result.noCashe) { | 57 | if (result.noCashe) { |
58 | res.set('Cache-Control', 'no-cache'); | 58 | res.set('Cache-Control', 'no-cache'); |
@@ -67,7 +67,7 @@ exports.brandInfo = (req, res, next) => { | @@ -67,7 +67,7 @@ exports.brandInfo = (req, res, next) => { | ||
67 | exports.plusstarList = (req, res, next) => { | 67 | exports.plusstarList = (req, res, next) => { |
68 | let channel = req.query.channel || req.yoho.channel; | 68 | let channel = req.query.channel || req.yoho.channel; |
69 | 69 | ||
70 | - brandsService.plusstarList(channel, req).then(result => { | 70 | + req.ctx(brandsService).plusstarList(channel, req).then(result => { |
71 | // 返回null,不cashe | 71 | // 返回null,不cashe |
72 | if (result.noCashe) { | 72 | if (result.noCashe) { |
73 | res.set('Cache-Control', 'no-cache'); | 73 | res.set('Cache-Control', 'no-cache'); |
@@ -4,100 +4,159 @@ | @@ -4,100 +4,159 @@ | ||
4 | * @date: 2016/9/29 | 4 | * @date: 2016/9/29 |
5 | */ | 5 | */ |
6 | 'use strict'; | 6 | 'use strict'; |
7 | -const api = global.yoho.API; | ||
8 | -const serviceAPI = global.yoho.ServiceAPI; | ||
9 | -const config = global.yoho.config; | ||
10 | 7 | ||
11 | -/** | ||
12 | - * 分开取数,品牌一览 顶部的轮翻广告及热门品牌数据-PC | ||
13 | - * 顶部的轮翻广告及热门品牌数据 | ||
14 | - * @param string $contentCode 获取广告资源需要的位置码 | ||
15 | - */ | ||
16 | -const getBrandTopData = (contentCode) => { | ||
17 | - return serviceAPI.get('operations/api/v5/resource/get', { | ||
18 | - content_code: contentCode | ||
19 | - }, config.apiCache); | ||
20 | -}; | 8 | +module.exports = class extends global.yoho.BaseModel { |
9 | + constructor(ctx) { | ||
10 | + super(ctx); | ||
11 | + } | ||
21 | 12 | ||
22 | -/** | ||
23 | - * 分开取数,获取品牌一览 "按字母'A-Z'分组的品牌列表数据" | ||
24 | - * @param int $channel 频道标识 1:男,2:女,3:潮童,4:创意生活 | ||
25 | - */ | ||
26 | -const getBrandListData = channel => { | ||
27 | - let params = {method: 'app.brand.allBrandList'}; | 13 | + /** |
14 | + * 分开取数,品牌一览 顶部的轮翻广告及热门品牌数据-PC | ||
15 | + * 顶部的轮翻广告及热门品牌数据 | ||
16 | + * @param string $contentCode 获取广告资源需要的位置码 | ||
17 | + */ | ||
18 | + getBrandTopData(contentCode) { | ||
19 | + return this.get({ | ||
20 | + url: 'operations/api/v5/resource/get', | ||
21 | + data: { | ||
22 | + content_code: contentCode | ||
23 | + }, | ||
24 | + param: { | ||
25 | + cache: true | ||
26 | + }, | ||
27 | + api: global.yoho.ServiceAPI | ||
28 | + }); | ||
29 | + } | ||
30 | + | ||
31 | + /** | ||
32 | + * 分开取数,获取品牌一览 "按字母'A-Z'分组的品牌列表数据" | ||
33 | + * @param int $channel 频道标识 1:男,2:女,3:潮童,4:创意生活 | ||
34 | + */ | ||
35 | + getBrandListData(channel) { | ||
36 | + | ||
37 | + let data = { | ||
38 | + method: 'app.brand.allBrandList' | ||
39 | + }; | ||
28 | 40 | ||
29 | - if (!isNaN(channel)) { | ||
30 | - params.yh_channel = channel; | 41 | + if (!isNaN(channel)) { |
42 | + data.yh_channel = channel; | ||
43 | + } | ||
44 | + | ||
45 | + return this.get({ | ||
46 | + data: data, | ||
47 | + param: { | ||
48 | + code: 200, | ||
49 | + cache: true | ||
50 | + } | ||
51 | + }); | ||
31 | } | 52 | } |
32 | - return api.get('', params, config.apiCache); | ||
33 | -}; | ||
34 | 53 | ||
35 | -/** | ||
36 | - * 获取品牌简介 | ||
37 | - * | ||
38 | - * @param integer $brandId 品牌ID | ||
39 | - * @param int 用户ID | ||
40 | - * @return array 品牌介绍信息 | ||
41 | - */ | ||
42 | -const getBrandIntro = (brandId, uid) => { | ||
43 | - let param = {}; | 54 | + /** |
55 | + * 获取品牌简介 | ||
56 | + * | ||
57 | + * @param integer $brandId 品牌ID | ||
58 | + * @param int 用户ID | ||
59 | + * @return array 品牌介绍信息 | ||
60 | + */ | ||
61 | + getBrandIntro(brandId, uid) { | ||
62 | + | ||
63 | + let data = { | ||
64 | + method: 'app.brand.getBrandIntro', | ||
65 | + brand_id: brandId, | ||
66 | + uid: uid | ||
67 | + }; | ||
44 | 68 | ||
45 | - if (!uid) { | ||
46 | - param.cache = 3600; | 69 | + if (!uid) { |
70 | + data.cache = 3600; | ||
71 | + } | ||
72 | + | ||
73 | + return this.get({ | ||
74 | + data: data, | ||
75 | + param: { | ||
76 | + code: 200, | ||
77 | + cache: true | ||
78 | + } | ||
79 | + }); | ||
47 | } | 80 | } |
48 | - return api.get('', { | ||
49 | - method: 'app.brand.getBrandIntro', | ||
50 | - brand_id: brandId, | ||
51 | - uid: uid | ||
52 | - }, param, config.apiCache); | ||
53 | -}; | ||
54 | 81 | ||
55 | -/** | ||
56 | - * 获取品牌中产品图片 | ||
57 | - * @param int 品牌ID | ||
58 | - * @return array 品牌产品信息 | ||
59 | - */ | ||
60 | -const getProductByBrand = (brandId, limit) => { | ||
61 | - return api.get('', { | ||
62 | - method: 'web.search.search', | ||
63 | - brand: brandId, | ||
64 | - limit: limit | ||
65 | - }, config.apiCache); | ||
66 | -}; | 82 | + /** |
83 | + * 获取品牌中产品图片 | ||
84 | + * @param int 品牌ID | ||
85 | + * @return array 品牌产品信息 | ||
86 | + */ | ||
87 | + getProductByBrand(brandId, limit) { | ||
67 | 88 | ||
68 | -/** | ||
69 | - * 获取品牌信息 | ||
70 | - * | ||
71 | - * @param array $ids | ||
72 | - * @return array | ||
73 | - */ | ||
74 | -const getBrandInfoByIds = (ids) => { | ||
75 | - return api.get('', { | ||
76 | - method: 'web.brand.info', | ||
77 | - ids: ids instanceof Array ? ids.join(',') : parseInt(ids, 10) | ||
78 | - }, config.apiCache); | ||
79 | -}; | 89 | + let data = { |
90 | + method: 'web.search.search', | ||
91 | + brand: brandId, | ||
92 | + limit: limit | ||
93 | + }; | ||
80 | 94 | ||
81 | -/** | ||
82 | - * 获取品牌列表 | ||
83 | - * | ||
84 | - * @param int $brandType | ||
85 | - * @param string $gender | ||
86 | - * @param string $type | ||
87 | - * @return array | ||
88 | - */ | ||
89 | -const getPlusstarList = (brandType, gender) => { | ||
90 | - return serviceAPI.get('guang/api/v3/plustar/getlist', { | ||
91 | - gender: gender, | ||
92 | - brand_type: brandType | ||
93 | - }, config.apiCache); | ||
94 | -}; | 95 | + return this.get({ |
96 | + data: data, | ||
97 | + param: { | ||
98 | + code: 200, | ||
99 | + cache: true | ||
100 | + } | ||
101 | + }); | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
105 | + * 获取品牌信息 | ||
106 | + * | ||
107 | + * @param array $ids | ||
108 | + * @return array | ||
109 | + */ | ||
110 | + getBrandInfoByIds(ids) { | ||
111 | + | ||
112 | + let data = { | ||
113 | + method: 'web.brand.info', | ||
114 | + ids: ids instanceof Array ? ids.join(',') : parseInt(ids, 10) | ||
115 | + }; | ||
116 | + | ||
117 | + return this.get({ | ||
118 | + data: data, | ||
119 | + param: { | ||
120 | + code: 200, | ||
121 | + cache: true | ||
122 | + } | ||
123 | + }); | ||
124 | + } | ||
125 | + | ||
126 | + /** | ||
127 | + * 获取品牌列表 | ||
128 | + * | ||
129 | + * @param int $brandType | ||
130 | + * @param string $gender | ||
131 | + * @param string $type | ||
132 | + * @return array | ||
133 | + */ | ||
134 | + getPlusstarList(brandType, gender) { | ||
135 | + return this.get({ | ||
136 | + url: 'guang/api/v3/plustar/getlist', | ||
137 | + data: { | ||
138 | + gender: gender, | ||
139 | + brand_type: brandType | ||
140 | + }, | ||
141 | + param: { | ||
142 | + cache: true | ||
143 | + }, | ||
144 | + api: global.yoho.ServiceAPI | ||
145 | + }); | ||
146 | + } | ||
147 | + | ||
148 | + getPlusstarBrandListItem(code) { | ||
149 | + return this.get({ | ||
150 | + url: 'operations/api/v5/resource/get', | ||
151 | + data: { | ||
152 | + content_code: code | ||
153 | + }, | ||
154 | + param: { | ||
155 | + cache: 3600 | ||
156 | + }, | ||
157 | + api: global.yoho.ServiceAPI | ||
158 | + }); | ||
159 | + } | ||
95 | 160 | ||
96 | -module.exports = { | ||
97 | - getBrandTopData, | ||
98 | - getBrandListData, | ||
99 | - getBrandIntro, | ||
100 | - getProductByBrand, | ||
101 | - getPlusstarList, | ||
102 | - getBrandInfoByIds | ||
103 | }; | 161 | }; |
162 | + |
@@ -10,8 +10,9 @@ const Promise = require('bluebird'); | @@ -10,8 +10,9 @@ const Promise = require('bluebird'); | ||
10 | const co = Promise.coroutine; | 10 | const co = Promise.coroutine; |
11 | const _ = require('lodash'); | 11 | const _ = require('lodash'); |
12 | const helpers = global.yoho.helpers; | 12 | const helpers = global.yoho.helpers; |
13 | -const brandApi = require('./brands-api'); | ||
14 | -const serviceApi = global.yoho.ServiceAPI; | 13 | +const BrandApi = require('./brands-api'); |
14 | +const path = require('path'); | ||
15 | +const imgUtils = require(path.join(global.utils, 'images')); | ||
15 | 16 | ||
16 | // 品牌一览资源位CODE码 | 17 | // 品牌一览资源位CODE码 |
17 | const channelCode = { | 18 | const channelCode = { |
@@ -33,410 +34,431 @@ const LIFESTYLE = 'lifestyle'; | @@ -33,410 +34,431 @@ const LIFESTYLE = 'lifestyle'; | ||
33 | 34 | ||
34 | const GLOBAL_BASE_URI = '/product/global/list'; | 35 | const GLOBAL_BASE_URI = '/product/global/list'; |
35 | 36 | ||
36 | -/** | ||
37 | - * 获取品牌一览资源位&channelType | ||
38 | - * | ||
39 | - * @param string $channelStr | ||
40 | - * @return array | ||
41 | - */ | ||
42 | -const switchBrandParams = channel => { | ||
43 | - let req = {}; | ||
44 | - | ||
45 | - switch (channel) { | ||
46 | - | ||
47 | - case BOYS: | ||
48 | - req = { | ||
49 | - channelType: 1, | ||
50 | - brandCode: channelCode.brand_plusstar_banner_boys | ||
51 | - }; | ||
52 | - break; | ||
53 | - case GIRLS: | ||
54 | - req = { | ||
55 | - channelType: 2, | ||
56 | - brandCode: channelCode.brand_plusstar_banner_girls | ||
57 | - }; | ||
58 | - break; | ||
59 | - case KIDS: | ||
60 | - req = { | ||
61 | - channelType: 3, | ||
62 | - brandCode: channelCode.kids_brand | ||
63 | - }; | ||
64 | - break; | ||
65 | - case LIFESTYLE: | ||
66 | - req = { | ||
67 | - channelType: 4, | ||
68 | - brandCode: channelCode.lifestyle_brand | ||
69 | - }; | ||
70 | - break; | ||
71 | - default: | ||
72 | - req = { | ||
73 | - channelType: 1, | ||
74 | - brandCode: channelCode.boys_brand | ||
75 | - }; | ||
76 | - break; | 37 | +module.exports = class extends global.yoho.BaseModel { |
38 | + constructor(ctx) { | ||
39 | + super(ctx); | ||
77 | } | 40 | } |
78 | - return req; | ||
79 | -}; | ||
80 | 41 | ||
81 | -/** | ||
82 | - * 获取品牌一览页面,品牌top | ||
83 | - * @param string $channel 频道名称 | ||
84 | - */ | ||
85 | -const getBrandViewTop = channel => { | ||
86 | - return co(function*() { | ||
87 | - let switchParams = switchBrandParams(channel); | 42 | + /** |
43 | + * 获取品牌一览资源位&channelType | ||
44 | + * | ||
45 | + * @param string $channelStr | ||
46 | + * @return array | ||
47 | + */ | ||
48 | + switchBrandParams(channel) { | ||
88 | 49 | ||
89 | - let res = yield brandApi.getBrandTopData(switchParams.brandCode); | 50 | + let req = {}; |
90 | 51 | ||
91 | - let result = {}, | ||
92 | - brandAds = [], | ||
93 | - brandLogos = []; | 52 | + switch (channel) { |
94 | 53 | ||
95 | - if (!res || res.code !== 200) { | ||
96 | - return result; | 54 | + case BOYS: |
55 | + req = { | ||
56 | + channelType: 1, | ||
57 | + brandCode: channelCode.brand_plusstar_banner_boys | ||
58 | + }; | ||
59 | + break; | ||
60 | + case GIRLS: | ||
61 | + req = { | ||
62 | + channelType: 2, | ||
63 | + brandCode: channelCode.brand_plusstar_banner_girls | ||
64 | + }; | ||
65 | + break; | ||
66 | + case KIDS: | ||
67 | + req = { | ||
68 | + channelType: 3, | ||
69 | + brandCode: channelCode.kids_brand | ||
70 | + }; | ||
71 | + break; | ||
72 | + case LIFESTYLE: | ||
73 | + req = { | ||
74 | + channelType: 4, | ||
75 | + brandCode: channelCode.lifestyle_brand | ||
76 | + }; | ||
77 | + break; | ||
78 | + default: | ||
79 | + req = { | ||
80 | + channelType: 1, | ||
81 | + brandCode: channelCode.boys_brand | ||
82 | + }; | ||
83 | + break; | ||
97 | } | 84 | } |
85 | + return req; | ||
86 | + } | ||
98 | 87 | ||
99 | - // 头部10个品牌小图块 url | ||
100 | - if (res.data && res.data instanceof Array && res.data[1].data && res.data[1].data.list) { | 88 | + /** |
89 | + * 获取品牌一览页面,品牌top | ||
90 | + * @param string $channel 频道名称 | ||
91 | + */ | ||
92 | + getBrandViewTop(channel) { | ||
93 | + let that = this; | ||
94 | + let brandData = new BrandApi(that.ctx); | ||
101 | 95 | ||
102 | - _.forEach(res.data[1].data.list, subValue => { | ||
103 | - brandAds.push({ | ||
104 | - name: subValue.name, | ||
105 | - src: helpers.image(subValue.src, 80, 50, 3), | ||
106 | - url: subValue.url | ||
107 | - }); | ||
108 | - }); | ||
109 | - } | 96 | + return co(function*() { |
97 | + let switchParams = that.switchBrandParams(channel); | ||
110 | 98 | ||
111 | - // 头部品牌图块,广告位 | ||
112 | - if (res.data && res.data instanceof Array && res.data[0].data) { | ||
113 | - _.forEach(res.data[0].data, (subValue, k) => { | ||
114 | - let srcUrl; | ||
115 | - | ||
116 | - // kids lifestyle 第一张图尺寸不同 | ||
117 | - if (switchParams.channelType === 1 || switchParams.channelType === 2) { | ||
118 | - srcUrl = helpers.image(subValue.src, 222, 180, 3); | ||
119 | - } else { | ||
120 | - srcUrl = (k === 0) ? helpers.image(subValue.src, 570, 280, 3) : | ||
121 | - helpers.image(subValue.src, 280, 280, 3); | ||
122 | - } | ||
123 | - let brandPlusstarItem = { | ||
124 | - name: subValue.title, | ||
125 | - src: srcUrl, | ||
126 | - url: subValue.url | ||
127 | - }; | 99 | + let res = yield brandData.getBrandTopData(switchParams.brandCode); |
128 | 100 | ||
129 | - if (channel === BOYS || channel === GIRLS) { | ||
130 | - if (k === 0) { | ||
131 | - brandPlusstarItem.url = helpers.urlFormat('/brands/plusstar', {channel: channel}); | ||
132 | - } else { | ||
133 | - brandPlusstarItem.url = helpers.urlFormat('/brands/plusstar', {id: k, channel: channel}); | ||
134 | - } | ||
135 | - } | 101 | + let result = {}, |
102 | + brandAds = [], | ||
103 | + brandLogos = []; | ||
136 | 104 | ||
137 | - brandLogos.push(brandPlusstarItem); | ||
138 | - }); | ||
139 | - } | 105 | + if (!res || res.code !== 200) { |
106 | + return result; | ||
107 | + } | ||
140 | 108 | ||
141 | - // 整合brandTop数据结构,boys、girls | ||
142 | - if (switchParams.channelType === 1 || switchParams.channelType === 2) { | ||
143 | - result.isTab = true; | ||
144 | - } | ||
145 | - result.tabHeader = brandLogos; | ||
146 | - result.logos = brandAds; | 109 | + // 头部10个品牌小图块 url |
110 | + if (res.data && res.data instanceof Array && res.data[1].data && res.data[1].data.list) { | ||
111 | + console.log(res.data[1].data.list); | ||
112 | + _.forEach(res.data[1].data.list, subValue => { | ||
113 | + brandAds.push({ | ||
114 | + name: subValue.name, | ||
115 | + src: helpers.image(imgUtils.getImageUrl( | ||
116 | + (subValue.src.match(/(\S*)imageView2/)[1] + | ||
117 | + 'imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/' + | ||
118 | + 'background/d2hpdGU=/position/center/quality/80'), | ||
119 | + 136, 57), 136, 57), | ||
120 | + url: subValue.url | ||
121 | + }); | ||
122 | + }); | ||
123 | + } | ||
147 | 124 | ||
148 | - return result; | ||
149 | - })(); | ||
150 | -}; | 125 | + // 头部品牌图块,广告位 |
126 | + if (res.data && res.data instanceof Array && res.data[0].data) { | ||
127 | + _.forEach(res.data[0].data, (subValue, k) => { | ||
128 | + let srcUrl; | ||
151 | 129 | ||
152 | -/** | ||
153 | - * 获取品牌一览list | ||
154 | - * @param string $channel 频道名称 | ||
155 | - * @param int start 开始位置 1 开始 | ||
156 | - * @param int length 取数长度 0 取到最后 | ||
157 | - */ | ||
158 | -const getBrandViewList = (channel, start, length) => { | ||
159 | - return co(function*() { | ||
160 | - let switchParams = switchBrandParams(channel); | 130 | + // kids lifestyle 第一张图尺寸不同 |
131 | + if (switchParams.channelType === 1 || switchParams.channelType === 2) { | ||
132 | + srcUrl = helpers.image(subValue.src, 222, 180, 3); | ||
133 | + } else { | ||
134 | + srcUrl = (k === 0) ? helpers.image(subValue.src, 570, 280, 3) : | ||
135 | + helpers.image(subValue.src, 280, 280, 3); | ||
136 | + } | ||
137 | + let brandPlusstarItem = { | ||
138 | + name: subValue.title, | ||
139 | + src: srcUrl, | ||
140 | + url: subValue.url | ||
141 | + }; | ||
142 | + | ||
143 | + if (channel === BOYS || channel === GIRLS) { | ||
144 | + if (k === 0) { | ||
145 | + brandPlusstarItem.url = helpers.urlFormat('/brands/plusstar', {channel: channel}); | ||
146 | + } else { | ||
147 | + brandPlusstarItem.url = helpers.urlFormat('/brands/plusstar', {id: k, channel: channel}); | ||
148 | + } | ||
149 | + } | ||
161 | 150 | ||
162 | - let res = yield brandApi.getBrandListData(switchParams.channelType); | 151 | + brandLogos.push(brandPlusstarItem); |
152 | + }); | ||
153 | + } | ||
163 | 154 | ||
164 | - let result = [], | ||
165 | - numResult = {}; | 155 | + // 整合brandTop数据结构,boys、girls |
156 | + if (switchParams.channelType === 1 || switchParams.channelType === 2) { | ||
157 | + result.isTab = true; | ||
158 | + } | ||
159 | + result.tabHeader = brandLogos; | ||
160 | + result.logos = brandAds; | ||
166 | 161 | ||
167 | - if (!res || res.code !== 200) { | ||
168 | return result; | 162 | return result; |
169 | - } | 163 | + })(); |
164 | + } | ||
170 | 165 | ||
171 | - // 品牌list A-Z 0-9 | ||
172 | - if (res.data && res.data.all_list) { | 166 | + /** |
167 | + * 获取品牌一览list | ||
168 | + * @param string $channel 频道名称 | ||
169 | + * @param int start 开始位置 1 开始 | ||
170 | + * @param int length 取数长度 0 取到最后 | ||
171 | + */ | ||
172 | + getBrandViewList(channel, start, length) { | ||
173 | + let that = this; | ||
174 | + let brandData = new BrandApi(that.ctx); | ||
173 | 175 | ||
174 | - _.forEach(res.data.all_list, (subValue, key) => { | ||
175 | - let listTmp = []; | 176 | + return co(function*() { |
177 | + let switchParams = that.switchBrandParams(channel); | ||
176 | 178 | ||
177 | - _.forEach(subValue, ssubValue => { | ||
178 | - let extQs = {}; | ||
179 | - let baseUri = ''; | 179 | + let res = yield brandData.getBrandListData(switchParams.channelType); |
180 | 180 | ||
181 | - // 为品牌名称 | ||
182 | - let href; | 181 | + let result = [], |
182 | + numResult = {}; | ||
183 | 183 | ||
184 | - if (switchParams.channelType === 1) { | ||
185 | - Object.assign(extQs, {gender: '1,3'}); | ||
186 | - } else if (switchParams.channelType === 2) { | ||
187 | - Object.assign(extQs, {gender: '2,3'}); | ||
188 | - } | ||
189 | - let shopInfo, shopId; | ||
190 | - | ||
191 | - switch (ssubValue.type * 1) { | ||
192 | - case 1: | ||
193 | - extQs = { | ||
194 | - query: ssubValue.brand_name, | ||
195 | - brand: ssubValue.id | ||
196 | - }; | ||
197 | - ssubValue.brand_domain = 'search'; | ||
198 | - break; | ||
199 | - case 2: | ||
200 | - shopInfo = _.get(ssubValue, 'shop_info.yoho_shop_list[0]', {}); | ||
201 | - shopId = shopInfo.shop_id || ssubValue.shop_id; | ||
202 | - | ||
203 | - ssubValue.brand_domain = shopInfo.shop_domain || ssubValue.brand_domain; | ||
204 | - if (shopId) { | ||
205 | - Object.assign(extQs, {shopId: shopId}); | ||
206 | - } | ||
207 | - break; | ||
208 | - case 3: | ||
209 | - Object.assign(extQs, {brand: ssubValue.global_brand_id}); | ||
210 | - ssubValue.brand_domain = ''; | ||
211 | - baseUri = GLOBAL_BASE_URI; | ||
212 | - break; | ||
213 | - default: | ||
214 | - break; | ||
215 | - } | 184 | + if (!res || res.code !== 200) { |
185 | + return result; | ||
186 | + } | ||
216 | 187 | ||
217 | - href = helpers.urlFormat(baseUri, extQs, ssubValue.brand_domain); | 188 | + // 品牌list A-Z 0-9 |
189 | + if (res.data && res.data.all_list) { | ||
190 | + | ||
191 | + _.forEach(res.data.all_list, (subValue, key) => { | ||
192 | + let listTmp = []; | ||
193 | + | ||
194 | + _.forEach(subValue, ssubValue => { | ||
195 | + let extQs = {}; | ||
196 | + let baseUri = ''; | ||
197 | + | ||
198 | + // 为品牌名称 | ||
199 | + let href; | ||
200 | + | ||
201 | + if (switchParams.channelType === 1) { | ||
202 | + Object.assign(extQs, {gender: '1,3'}); | ||
203 | + } else if (switchParams.channelType === 2) { | ||
204 | + Object.assign(extQs, {gender: '2,3'}); | ||
205 | + } | ||
206 | + let shopInfo, shopId; | ||
207 | + | ||
208 | + switch (ssubValue.type * 1) { | ||
209 | + case 1: | ||
210 | + extQs = { | ||
211 | + query: ssubValue.brand_name, | ||
212 | + brand: ssubValue.id | ||
213 | + }; | ||
214 | + ssubValue.brand_domain = 'search'; | ||
215 | + break; | ||
216 | + case 2: | ||
217 | + shopInfo = _.get(ssubValue, 'shop_info.yoho_shop_list[0]', {}); | ||
218 | + shopId = shopInfo.shop_id || ssubValue.shop_id; | ||
219 | + | ||
220 | + ssubValue.brand_domain = shopInfo.shop_domain || ssubValue.brand_domain; | ||
221 | + if (shopId) { | ||
222 | + Object.assign(extQs, {shopId: shopId}); | ||
223 | + } | ||
224 | + break; | ||
225 | + case 3: | ||
226 | + Object.assign(extQs, {brand: ssubValue.global_brand_id}); | ||
227 | + ssubValue.brand_domain = ''; | ||
228 | + baseUri = GLOBAL_BASE_URI; | ||
229 | + break; | ||
230 | + default: | ||
231 | + break; | ||
232 | + } | ||
233 | + | ||
234 | + href = helpers.urlFormat(baseUri, extQs, ssubValue.brand_domain); | ||
235 | + | ||
236 | + let brandItem = { | ||
237 | + name: ssubValue.brand_name, | ||
238 | + key: ssubValue.id, | ||
239 | + href: href | ||
240 | + }; | ||
241 | + | ||
242 | + if (ssubValue.is_hot === 'Y') { | ||
243 | + brandItem.hot = 'hot'; | ||
244 | + } | ||
245 | + listTmp.push(brandItem); | ||
218 | 246 | ||
219 | - let brandItem = { | ||
220 | - name: ssubValue.brand_name, | ||
221 | - key: ssubValue.id, | ||
222 | - href: href | ||
223 | - }; | 247 | + }); |
224 | 248 | ||
225 | - if (ssubValue.is_hot === 'Y') { | ||
226 | - brandItem.hot = 'hot'; | 249 | + if (key.match(/\d+/g)) { |
250 | + numResult = {// 把0-9提出来 | ||
251 | + key: key, | ||
252 | + val: _.sortBy(listTmp, 'name')// 对name排序 | ||
253 | + }; | ||
254 | + } else { | ||
255 | + result.push({ | ||
256 | + key: key, | ||
257 | + val: _.sortBy(listTmp, 'name')// 对name排序 | ||
258 | + }); | ||
227 | } | 259 | } |
228 | - listTmp.push(brandItem); | ||
229 | - | ||
230 | }); | 260 | }); |
231 | 261 | ||
232 | - if (key.match(/\d+/g)) { | ||
233 | - numResult = {// 把0-9提出来 | ||
234 | - key: key, | ||
235 | - val: _.sortBy(listTmp, 'name')// 对name排序 | ||
236 | - }; | ||
237 | - } else { | ||
238 | - result.push({ | ||
239 | - key: key, | ||
240 | - val: _.sortBy(listTmp, 'name')// 对name排序 | ||
241 | - }); | ||
242 | - } | ||
243 | - }); | ||
244 | - | ||
245 | - } | ||
246 | - | ||
247 | - // 只取部分数据 | ||
248 | - let begin; | ||
249 | - | ||
250 | - if (start) { | ||
251 | - begin = (start - 1) ? (start - 1) : 0; | ||
252 | - begin = (begin > 0) ? begin : 0; | ||
253 | - result = length ? result.slice(begin, length + begin) : result.slice(begin); | ||
254 | - } | 262 | + } |
255 | 263 | ||
256 | - result = _.sortBy(result, 'key');// A-Z排序 | ||
257 | - result.push(numResult); // 0-9放到最后 | ||
258 | - result.navigation = _.map(result, 'key'); | ||
259 | - return result; | ||
260 | - })(); | ||
261 | -}; | 264 | + // 只取部分数据 |
265 | + let begin; | ||
262 | 266 | ||
263 | -/** | ||
264 | - * 获取单个广告浮窗内容 | ||
265 | - * | ||
266 | - * @param int $brandId | ||
267 | - * @param int $uid | ||
268 | - * @return array | ||
269 | - */ | ||
270 | -const getBrandInfo = (brandId, uid) => { | ||
271 | - return co(function*() { | ||
272 | - let data = {}, | ||
273 | - imgs = []; | ||
274 | - | ||
275 | - // 获取品牌简介 | ||
276 | - let res = yield brandApi.getBrandIntro(brandId, uid); | 267 | + if (start) { |
268 | + begin = (start - 1) ? (start - 1) : 0; | ||
269 | + begin = (begin > 0) ? begin : 0; | ||
270 | + result = length ? result.slice(begin, length + begin) : result.slice(begin); | ||
271 | + } | ||
277 | 272 | ||
278 | - if (!res || res.code !== 200) { | ||
279 | - return data; | ||
280 | - } | ||
281 | - if (res.data) { | ||
282 | - // 获取品牌下的产品信息 | ||
283 | - let proInfo = yield brandApi.getProductByBrand(brandId, 3); | 273 | + result = _.sortBy(result, 'key');// A-Z排序 |
274 | + result.push(numResult); // 0-9放到最后 | ||
275 | + result.navigation = _.map(result, 'key'); | ||
276 | + return result; | ||
277 | + })(); | ||
278 | + } | ||
284 | 279 | ||
285 | - if (!proInfo || proInfo.code !== 200) { | 280 | + /** |
281 | + * 获取单个广告浮窗内容 | ||
282 | + * | ||
283 | + * @param int $brandId | ||
284 | + * @param int $uid | ||
285 | + * @return array | ||
286 | + */ | ||
287 | + getBrandInfo(brandId, uid) { | ||
288 | + let that = this; | ||
289 | + let brandData = new BrandApi(that.ctx); | ||
290 | + | ||
291 | + return co(function*() { | ||
292 | + let data = {}, | ||
293 | + imgs = []; | ||
294 | + | ||
295 | + // 获取品牌简介 | ||
296 | + let res = yield brandData.getBrandIntro(brandId, uid); | ||
297 | + | ||
298 | + if (!res || res.code !== 200) { | ||
286 | return data; | 299 | return data; |
287 | } | 300 | } |
288 | - let proInfoTmp = proInfo.data.product_list ? proInfo.data.product_list : []; | 301 | + if (res.data) { |
302 | + // 获取品牌下的产品信息 | ||
303 | + let proInfo = yield brandData.getProductByBrand(brandId, 3); | ||
289 | 304 | ||
290 | - if (!_.isEmpty(proInfoTmp)) { | ||
291 | - _.forEach(proInfoTmp, subValue => { | ||
292 | - imgs.push({ | ||
293 | - src: helpers.image(subValue.default_images, 80, 100, 3) | 305 | + if (!proInfo || proInfo.code !== 200) { |
306 | + return data; | ||
307 | + } | ||
308 | + let proInfoTmp = proInfo.data.product_list ? proInfo.data.product_list : []; | ||
309 | + | ||
310 | + if (!_.isEmpty(proInfoTmp)) { | ||
311 | + _.forEach(proInfoTmp, subValue => { | ||
312 | + imgs.push({ | ||
313 | + src: helpers.image(subValue.default_images, 80, 100, 3) | ||
314 | + }); | ||
294 | }); | 315 | }); |
295 | - }); | 316 | + } |
317 | + | ||
318 | + // 整合 | ||
319 | + data = { | ||
320 | + key: res.data.brand_id, | ||
321 | + icon: helpers.image(res.data.brand_ico, 80, 50, 3), | ||
322 | + title: res.data.brand_name, | ||
323 | + content: res.data.brand_intro, | ||
324 | + subtitle: 'FEATURED ITEMS', | ||
325 | + imgs: imgs | ||
326 | + }; | ||
296 | } | 327 | } |
328 | + return data; | ||
329 | + })(); | ||
330 | + } | ||
297 | 331 | ||
298 | - // 整合 | ||
299 | - data = { | ||
300 | - key: res.data.brand_id, | ||
301 | - icon: helpers.image(res.data.brand_ico, 80, 50, 3), | ||
302 | - title: res.data.brand_name, | ||
303 | - content: res.data.brand_intro, | ||
304 | - subtitle: 'FEATURED ITEMS', | ||
305 | - imgs: imgs | ||
306 | - }; | ||
307 | - } | ||
308 | - return data; | ||
309 | - })(); | ||
310 | -}; | 332 | + /** |
333 | + * 多个品牌ID获取品牌信息 | ||
334 | + * | ||
335 | + * @param array $brandIds | ||
336 | + * @return array | ||
337 | + */ | ||
338 | + getBrandInfoByIds(brandIds) { | ||
339 | + let that = this; | ||
340 | + let brandData = new BrandApi(that.ctx); | ||
311 | 341 | ||
312 | -/** | ||
313 | - * 多个品牌ID获取品牌信息 | ||
314 | - * | ||
315 | - * @param array $brandIds | ||
316 | - * @return array | ||
317 | - */ | ||
318 | -const getBrandInfoByIds = (brandIds) => { | ||
319 | - return co(function*() { | ||
320 | - let res = yield brandApi.getBrandInfoByIds(brandIds); | 342 | + return co(function*() { |
343 | + let res = yield brandData.getBrandInfoByIds(brandIds); | ||
321 | 344 | ||
322 | - let brandsInfo = {}; | 345 | + let brandsInfo = {}; |
323 | 346 | ||
324 | - if (!res || res.code !== 200) { | ||
325 | - return brandsInfo; | ||
326 | - } | ||
327 | - if (res.data && res.code === 200) { | ||
328 | - _.forEach(res.data, (subValue, k) => { | ||
329 | - subValue.desc = _.trim(subValue.brand_intro.replace(/(\t)|(\n)|(\r)|( )/g, '') | 347 | + if (!res || res.code !== 200) { |
348 | + return brandsInfo; | ||
349 | + } | ||
350 | + if (res.data && res.code === 200) { | ||
351 | + _.forEach(res.data, (subValue, k) => { | ||
352 | + subValue.desc = _.trim(subValue.brand_intro.replace(/(\t)|(\n)|(\r)|( )/g, '') | ||
330 | .replace(/<.*?>/ig, '')); | 353 | .replace(/<.*?>/ig, '')); |
331 | - subValue.url = subValue.brand_domain; | ||
332 | - delete subValue.brand_intro; | ||
333 | - brandsInfo[k] = subValue; | ||
334 | - }); | ||
335 | - } | 354 | + subValue.url = subValue.brand_domain; |
355 | + delete subValue.brand_intro; | ||
356 | + brandsInfo[k] = subValue; | ||
357 | + }); | ||
358 | + } | ||
336 | 359 | ||
337 | - return brandsInfo; | ||
338 | - })(); | ||
339 | -}; | 360 | + return brandsInfo; |
361 | + })(); | ||
362 | + } | ||
340 | 363 | ||
341 | -/** | ||
342 | - * 获取plusstar品牌列表项目 | ||
343 | - * | ||
344 | - * @param string $channel | ||
345 | - * @return array | ||
346 | - */ | ||
347 | -const getPlusstarBrandListItem = (channel) => { | ||
348 | - return co(function*() { | ||
349 | - let code = channel === 'girls' ? channelCode.brand_plusstar_banner_girls : | ||
350 | - channelCode.brand_plusstar_banner_boys; | 364 | + /** |
365 | + * 获取plusstar品牌列表项目 | ||
366 | + * | ||
367 | + * @param string $channel | ||
368 | + * @return array | ||
369 | + */ | ||
370 | + getPlusstarBrandListItem(channel) { | ||
371 | + let that = this; | ||
372 | + let brandData = new BrandApi(that.ctx); | ||
351 | 373 | ||
352 | - // 资源位数据 | ||
353 | - let resource = yield serviceApi.get('operations/api/v5/resource/get', {content_code: code}, {cache: 3600}); | 374 | + return co(function*() { |
375 | + let code = channel === 'girls' ? channelCode.brand_plusstar_banner_girls : | ||
376 | + channelCode.brand_plusstar_banner_boys; | ||
354 | 377 | ||
355 | - let items = []; | 378 | + // 资源位数据 |
379 | + let resource = yield brandData.getPlusstarBrandListItem(code); | ||
356 | 380 | ||
357 | - if (!resource || resource.code !== 200) { | ||
358 | - return items; | ||
359 | - } | ||
360 | - if (resource.data && resource.code === 200) { | ||
361 | - items[0] = {name: '所有品牌', src: '', url: helpers.urlFormat('/brands', {channel: channel}), brandType: ''}; | ||
362 | - items[1] = {name: '设计新潮', src: '', url: '', brandType: 4}; | ||
363 | - items[2] = {name: '潮流经典', src: '', url: '', brandType: 1}; | ||
364 | - items[3] = {name: '明星潮牌', src: '', url: '', brandType: 2}; | ||
365 | - items[4] = {name: '原创潮牌', src: '', url: '', brandType: 3}; | ||
366 | - | ||
367 | - let resourceData = resource.data, | ||
368 | - pos = 0; | ||
369 | - | ||
370 | - _.forEach(items, (subValue, k) => { | ||
371 | - if (_.isEmpty(subValue.url)) { | ||
372 | - subValue.url = helpers.urlFormat('/brands/plusstar', {id: k, channel: channel}); | ||
373 | - } | 381 | + let items = []; |
374 | 382 | ||
375 | - if (pos in resourceData[0].data) { | ||
376 | - subValue.src = helpers.image(resourceData[0].data[pos].src, 222, 180, 1); | ||
377 | - subValue.name = resourceData[0].data[pos].title; | ||
378 | - } | ||
379 | - pos++; | ||
380 | - }); | ||
381 | - } | ||
382 | - | ||
383 | - return items; | ||
384 | - })(); | ||
385 | -}; | ||
386 | - | ||
387 | -/** | ||
388 | - * 获取Plustar列表 | ||
389 | - * | ||
390 | - * @param string $brandType | ||
391 | - * @param string $gender | ||
392 | - * @return array | ||
393 | - */ | ||
394 | -const getPlustarList = (brandType, gender) => { | ||
395 | - return co(function*() { | ||
396 | - let list = yield brandApi.getPlusstarList(brandType, gender); | 383 | + if (!resource || resource.code !== 200) { |
384 | + return items; | ||
385 | + } | ||
386 | + if (resource.data && resource.code === 200) { | ||
387 | + items[0] = {name: '所有品牌', src: '', url: helpers.urlFormat('/brands', | ||
388 | + {channel: channel}), brandType: ''}; | ||
389 | + items[1] = {name: '设计新潮', src: '', url: '', brandType: 4}; | ||
390 | + items[2] = {name: '潮流经典', src: '', url: '', brandType: 1}; | ||
391 | + items[3] = {name: '明星潮牌', src: '', url: '', brandType: 2}; | ||
392 | + items[4] = {name: '原创潮牌', src: '', url: '', brandType: 3}; | ||
393 | + | ||
394 | + let resourceData = resource.data, | ||
395 | + pos = 0; | ||
396 | + | ||
397 | + _.forEach(items, (subValue, k) => { | ||
398 | + if (_.isEmpty(subValue.url)) { | ||
399 | + subValue.url = helpers.urlFormat('/brands/plusstar', {id: k, channel: channel}); | ||
400 | + } | ||
397 | 401 | ||
398 | - let brandList = {}, | ||
399 | - data = {}, | ||
400 | - brandsIds = [], | ||
401 | - result = {brandsIds: [], data: {}}; | 402 | + if (pos in resourceData[0].data) { |
403 | + subValue.src = helpers.image(resourceData[0].data[pos].src, 222, 180, 1); | ||
404 | + subValue.name = resourceData[0].data[pos].title; | ||
405 | + } | ||
406 | + pos++; | ||
407 | + }); | ||
408 | + } | ||
402 | 409 | ||
403 | - if (!list || list.code !== 200) { | ||
404 | - return result; | ||
405 | - } | ||
406 | - if (list.data && list.data.data && list.data.data.list) { | ||
407 | - brandList = list.data.data.list[0]; | ||
408 | - } | ||
409 | - if (brandList.data) { | ||
410 | - _.forEach(brandList.data, brand => { | ||
411 | - let src = ''; | 410 | + return items; |
411 | + })(); | ||
412 | + } | ||
412 | 413 | ||
413 | - if (brand.data[0]) { | ||
414 | - src = helpers.image(brand.data[0].src, 320, 160, 1); | ||
415 | - } | ||
416 | - data[brand.brand_id] = { | ||
417 | - brand_id: brand.brand_id, | ||
418 | - name: brand.brand_name, | ||
419 | - sort_id: brand.sort_id, | ||
420 | - src: src, | ||
421 | - desc: '', | ||
422 | - url: '' | ||
423 | - }; | ||
424 | - brandsIds.push(brand.brand_id); | ||
425 | - }); | 414 | + /** |
415 | + * 获取Plustar列表 | ||
416 | + * | ||
417 | + * @param string $brandType | ||
418 | + * @param string $gender | ||
419 | + * @return array | ||
420 | + */ | ||
421 | + getPlustarList(brandType, gender) { | ||
422 | + let that = this; | ||
423 | + let brandData = new BrandApi(that.ctx); | ||
424 | + | ||
425 | + return co(function*() { | ||
426 | + let list = yield brandData.getPlusstarList(brandType, gender); | ||
427 | + | ||
428 | + let brandList = {}, | ||
429 | + data = {}, | ||
430 | + brandsIds = [], | ||
431 | + result = {brandsIds: [], data: {}}; | ||
432 | + | ||
433 | + if (!list || list.code !== 200) { | ||
434 | + return result; | ||
435 | + } | ||
436 | + if (list.data && list.data.data && list.data.data.list) { | ||
437 | + brandList = list.data.data.list[0]; | ||
438 | + } | ||
439 | + if (brandList.data) { | ||
440 | + _.forEach(brandList.data, brand => { | ||
441 | + let src = ''; | ||
426 | 442 | ||
427 | - result.brandsIds = brandsIds; | ||
428 | - result.data = data; | ||
429 | - } | 443 | + if (brand.data[0]) { |
444 | + src = helpers.image(brand.data[0].src, 320, 160, 1); | ||
445 | + } | ||
446 | + data[brand.brand_id] = { | ||
447 | + brand_id: brand.brand_id, | ||
448 | + name: brand.brand_name, | ||
449 | + sort_id: brand.sort_id, | ||
450 | + src: src, | ||
451 | + desc: '', | ||
452 | + url: '' | ||
453 | + }; | ||
454 | + brandsIds.push(brand.brand_id); | ||
455 | + }); | ||
430 | 456 | ||
431 | - return result; | ||
432 | - })(); | ||
433 | -}; | 457 | + result.brandsIds = brandsIds; |
458 | + result.data = data; | ||
459 | + } | ||
434 | 460 | ||
435 | -module.exports = { | ||
436 | - getBrandViewTop, | ||
437 | - getBrandViewList, | ||
438 | - getBrandInfo, | ||
439 | - getBrandInfoByIds, | ||
440 | - getPlusstarBrandListItem, | ||
441 | - getPlustarList | 461 | + return result; |
462 | + })(); | ||
463 | + } | ||
442 | }; | 464 | }; |
@@ -9,7 +9,7 @@ const Promise = require('bluebird'); | @@ -9,7 +9,7 @@ const Promise = require('bluebird'); | ||
9 | const co = Promise.coroutine; | 9 | const co = Promise.coroutine; |
10 | const api = global.yoho.API; | 10 | const api = global.yoho.API; |
11 | const headerModel = require('../../../doraemon/models/header'); | 11 | const headerModel = require('../../../doraemon/models/header'); |
12 | -const brandsModel = require('./brands-model'); | 12 | +const BrandsModel = require('./brands-model'); |
13 | const _ = require('lodash'); | 13 | const _ = require('lodash'); |
14 | const helpers = global.yoho.helpers; | 14 | const helpers = global.yoho.helpers; |
15 | const pager = require(`${global.utils}/pager`).setPager; | 15 | const pager = require(`${global.utils}/pager`).setPager; |
@@ -20,294 +20,314 @@ const KIDS = 'kids'; | @@ -20,294 +20,314 @@ const KIDS = 'kids'; | ||
20 | const LIFESTYLE = 'lifestyle'; | 20 | const LIFESTYLE = 'lifestyle'; |
21 | const queryString = require('querystring'); | 21 | const queryString = require('querystring'); |
22 | 22 | ||
23 | -/** | ||
24 | - * 获取品牌一览资源位&channelType | ||
25 | - * | ||
26 | - * @param string $channelStr | ||
27 | - * @return array | ||
28 | - */ | ||
29 | -const getGenderByChannel = channel => { | ||
30 | - let gender = ''; | ||
31 | - | ||
32 | - switch (channel) { | ||
33 | - | ||
34 | - case BOYS: | ||
35 | - gender = '1,3'; | ||
36 | - break; | ||
37 | - case GIRLS: | ||
38 | - gender = '2,3'; | ||
39 | - break; | ||
40 | - default: | ||
41 | - gender = '1,2,3'; | ||
42 | - break; | 23 | +module.exports = class extends global.yoho.BaseModel { |
24 | + constructor(ctx) { | ||
25 | + super(ctx); | ||
43 | } | 26 | } |
44 | - return gender; | ||
45 | -}; | ||
46 | 27 | ||
47 | -const getHomeurlByChannel = channel => { | ||
48 | - let home; | ||
49 | - | ||
50 | - switch (channel) { | ||
51 | - case GIRLS: | ||
52 | - home = helpers.urlFormat('/woman', {}, 'new'); | ||
53 | - break; | ||
54 | - case LIFESTYLE: | ||
55 | - home = helpers.urlFormat('/lifestyle', {}, 'new'); | ||
56 | - break; | ||
57 | - case KIDS: | ||
58 | - home = helpers.urlFormat('/kids', {}, 'new'); | ||
59 | - break; | ||
60 | - default: | ||
61 | - home = helpers.urlFormat(''); | ||
62 | - break; | 28 | + /** |
29 | + * 获取品牌一览资源位&channelType | ||
30 | + * | ||
31 | + * @param string $channelStr | ||
32 | + * @return array | ||
33 | + */ | ||
34 | + getGenderByChannel(channel) { | ||
35 | + let gender = ''; | ||
36 | + | ||
37 | + switch (channel) { | ||
38 | + | ||
39 | + case BOYS: | ||
40 | + gender = '1,3'; | ||
41 | + break; | ||
42 | + case GIRLS: | ||
43 | + gender = '2,3'; | ||
44 | + break; | ||
45 | + default: | ||
46 | + gender = '1,2,3'; | ||
47 | + break; | ||
48 | + } | ||
49 | + return gender; | ||
63 | } | 50 | } |
64 | - return home; | ||
65 | -}; | ||
66 | 51 | ||
67 | -// 添加网站的SEO | ||
68 | -const seoMap = { | ||
69 | - boys: { | ||
70 | - title: '品牌一览|男装品牌排行榜,男装品牌大全|YOHO!BUY 有货 100%正品保证', | ||
71 | - keywords: '品牌一览,男装品牌,男装品牌排行榜,男装品牌大全,YOHO!BUY 有货', | ||
72 | - description: 'YOHO!BUY 有货男装品牌一览汇集国内国际各大男装品牌大全,为广大爱好时尚的男士青年提供品牌男装、' + | ||
73 | - '休闲男装、商务男装.YOHO!BUY 有货,100%正品保证' | ||
74 | - }, | ||
75 | - girls: { | ||
76 | - title: '品牌一览|女装品牌排行榜,女装品牌大全|YOHO!BUY 有货 100%正品保证', | ||
77 | - keywords: '品牌一览,女装品牌,女装品牌排行榜,女装品牌大全,YOHO!BUY 有货', | ||
78 | - description: 'YOHO!BUY 有货女装品牌一览汇集国内国际各大女装品牌,为广大爱美女生提供品牌女装、休闲女装、' + | ||
79 | - '商务女装.买品牌女装就上YOHO!BUY 有货,100%正品保证' | ||
80 | - }, | ||
81 | - kids: { | ||
82 | - title: '品牌一览|童装童鞋品牌,儿童鞋包配饰排行榜,潮童品牌大全|YOHO!BUY 有货 100%正品保证', | ||
83 | - keywords: '童装品牌,童装童鞋排行榜,儿童鞋包配饰排行榜,潮童品牌大全,品牌一览,YOHO!BUY 有货', | ||
84 | - description: 'YOHO!BUY 有货童装品牌一览汇集国内国际各大童装品牌大全,为广大爱好潮流的儿童提供品牌童装、童鞋,' + | ||
85 | - '儿童鞋包配饰.YOHO!BUY 有货,100%正品保证' | ||
86 | - }, | ||
87 | - lifestyle: { | ||
88 | - title: '品牌一览|数码3c,居家,玩具娱乐,文具,美妆品牌|YOHO!BUY 有货 100%正品保证', | ||
89 | - keywords: '数码3c品牌,居家品牌,玩具娱乐品牌,文具品牌,美妆品牌', | ||
90 | - description: 'YOHO!BUY 有货女装品牌一览汇集国内国际各大数码3c品牌,居家品牌,玩具娱乐品牌,文具品牌,' + | ||
91 | - '美妆品牌.买创意生活家居就上YOHO!BUY 有货,100%正品保证' | ||
92 | - }, | ||
93 | - 'boys-plusstar': { | ||
94 | - title: '品牌plusstar,男装潮流品牌简介|YOHO!BUY有货', | ||
95 | - keywords: '品牌plusstar,男装潮流品牌简介', | ||
96 | - description: 'YOHO!BUY 有货男装品牌一览汇集国内国际各大男装品牌,为广大爱美男生提供品牌男装、' + | ||
97 | - '休闲男装、商务男装.买品牌男装就上YOHO!BUY 有货,100%正品保证' | ||
98 | - }, | ||
99 | - 'girls-plusstar': { | ||
100 | - title: '品牌plusstar,女装潮流品牌简介|YOHO!BUY有货', | ||
101 | - keywords: '品牌plusstar,女装潮流品牌简介', | ||
102 | - description: 'YOHO!BUY 有货女装品牌一览汇集国内国际各大女装品牌,为广大爱美女生提供品牌女装、' + | ||
103 | - '休闲女装、商务女装.买品牌女装就上YOHO!BUY 有货,100%正品保证' | 52 | + getHomeurlByChannel(channel) { |
53 | + let home; | ||
54 | + | ||
55 | + switch (channel) { | ||
56 | + case GIRLS: | ||
57 | + home = helpers.urlFormat('/woman', {}, 'new'); | ||
58 | + break; | ||
59 | + case LIFESTYLE: | ||
60 | + home = helpers.urlFormat('/lifestyle', {}, 'new'); | ||
61 | + break; | ||
62 | + case KIDS: | ||
63 | + home = helpers.urlFormat('/kids', {}, 'new'); | ||
64 | + break; | ||
65 | + default: | ||
66 | + home = helpers.urlFormat(''); | ||
67 | + break; | ||
68 | + } | ||
69 | + return home; | ||
104 | } | 70 | } |
105 | -}; | ||
106 | 71 | ||
107 | -/** | ||
108 | - * plusstar 分页链接伪静态 | ||
109 | - * @param string uri | ||
110 | - * @param string originUrl 动态地址 | ||
111 | - */ | ||
112 | -const staticUrl = (uri, originUrl) => { | ||
113 | - originUrl = queryString.parse(_.split(originUrl, '?')[1]); | ||
114 | - return `${uri}id${originUrl.id || 0}-p${originUrl.page || 1}/`; | ||
115 | -}; | ||
116 | - | ||
117 | -/** | ||
118 | - * 获取品牌一览list | ||
119 | - * @param string $channel 频道名称 | ||
120 | - * @param int start 开始位置 1 开始 | ||
121 | - * @param int length 取数长度 0 取到最后 | ||
122 | - */ | ||
123 | -exports.getBrandViewList = (channel) => { | ||
124 | - let apiMethod = [ | ||
125 | - headerModel.requestHeaderData(channel), | ||
126 | - brandsModel.getBrandViewTop(channel), | ||
127 | - brandsModel.getBrandViewList(channel) // 分屏加载 | ||
128 | - ]; | ||
129 | - | ||
130 | - return api.all(apiMethod).then(result => { | ||
131 | - let responseData = { | ||
132 | - module: 'brands', | ||
133 | - page: 'brands', | ||
134 | - noCashe: false | 72 | + // 添加网站的SEO |
73 | + seoMap() { | ||
74 | + return { | ||
75 | + boys: { | ||
76 | + title: '品牌一览|男装品牌排行榜,男装品牌大全|YOHO!BUY 有货 100%正品保证', | ||
77 | + keywords: '品牌一览,男装品牌,男装品牌排行榜,男装品牌大全,YOHO!BUY 有货', | ||
78 | + description: 'YOHO!BUY 有货男装品牌一览汇集国内国际各大男装品牌大全,为广大爱好时尚的男士青年提供品牌男装、' + | ||
79 | + '休闲男装、商务男装.YOHO!BUY 有货,100%正品保证' | ||
80 | + }, | ||
81 | + girls: { | ||
82 | + title: '品牌一览|女装品牌排行榜,女装品牌大全|YOHO!BUY 有货 100%正品保证', | ||
83 | + keywords: '品牌一览,女装品牌,女装品牌排行榜,女装品牌大全,YOHO!BUY 有货', | ||
84 | + description: 'YOHO!BUY 有货女装品牌一览汇集国内国际各大女装品牌,为广大爱美女生提供品牌女装、休闲女装、' + | ||
85 | + '商务女装.买品牌女装就上YOHO!BUY 有货,100%正品保证' | ||
86 | + }, | ||
87 | + kids: { | ||
88 | + title: '品牌一览|童装童鞋品牌,儿童鞋包配饰排行榜,潮童品牌大全|YOHO!BUY 有货 100%正品保证', | ||
89 | + keywords: '童装品牌,童装童鞋排行榜,儿童鞋包配饰排行榜,潮童品牌大全,品牌一览,YOHO!BUY 有货', | ||
90 | + description: 'YOHO!BUY 有货童装品牌一览汇集国内国际各大童装品牌大全,为广大爱好潮流的儿童提供品牌童装、童鞋,' + | ||
91 | + '儿童鞋包配饰.YOHO!BUY 有货,100%正品保证' | ||
92 | + }, | ||
93 | + lifestyle: { | ||
94 | + title: '品牌一览|数码3c,居家,玩具娱乐,文具,美妆品牌|YOHO!BUY 有货 100%正品保证', | ||
95 | + keywords: '数码3c品牌,居家品牌,玩具娱乐品牌,文具品牌,美妆品牌', | ||
96 | + description: 'YOHO!BUY 有货女装品牌一览汇集国内国际各大数码3c品牌,居家品牌,玩具娱乐品牌,文具品牌,' + | ||
97 | + '美妆品牌.买创意生活家居就上YOHO!BUY 有货,100%正品保证' | ||
98 | + }, | ||
99 | + 'boys-plusstar': { | ||
100 | + title: '品牌plusstar,男装潮流品牌简介|YOHO!BUY有货', | ||
101 | + keywords: '品牌plusstar,男装潮流品牌简介', | ||
102 | + description: 'YOHO!BUY 有货男装品牌一览汇集国内国际各大男装品牌,为广大爱美男生提供品牌男装、' + | ||
103 | + '休闲男装、商务男装.买品牌男装就上YOHO!BUY 有货,100%正品保证' | ||
104 | + }, | ||
105 | + 'girls-plusstar': { | ||
106 | + title: '品牌plusstar,女装潮流品牌简介|YOHO!BUY有货', | ||
107 | + keywords: '品牌plusstar,女装潮流品牌简介', | ||
108 | + description: 'YOHO!BUY 有货女装品牌一览汇集国内国际各大女装品牌,为广大爱美女生提供品牌女装、' + | ||
109 | + '休闲女装、商务女装.买品牌女装就上YOHO!BUY 有货,100%正品保证' | ||
110 | + } | ||
135 | }; | 111 | }; |
112 | + } | ||
136 | 113 | ||
137 | - // 头部数据 | ||
138 | - Object.assign(responseData, result[0]); | ||
139 | - | ||
140 | - // 品牌一览列表 | ||
141 | - responseData.brands = result[1]; | ||
142 | - responseData.brands.navigation = result[2].navigation; | ||
143 | - responseData.brands.category = result[2]; | 114 | + /** |
115 | + * plusstar 分页链接伪静态 | ||
116 | + * @param string uri | ||
117 | + * @param string originUrl 动态地址 | ||
118 | + */ | ||
119 | + staticUrl(uri, originUrl) { | ||
120 | + originUrl = queryString.parse(_.split(originUrl, '?')[1]); | ||
121 | + return `${uri}id${originUrl.id || 0}-p${originUrl.page || 1}/`; | ||
122 | + } | ||
144 | 123 | ||
145 | - // 导航pathNav | ||
146 | - responseData.brands.pathNav = [ | ||
147 | - { | ||
148 | - href: getHomeurlByChannel(channel), | ||
149 | - name: `${_.toUpper(channel)}首页`, | ||
150 | - pathTitle: 'YOHO!BUY 有货' | ||
151 | - }, | ||
152 | - { | ||
153 | - href: helpers.urlFormat('/brands'), | ||
154 | - name: '品牌一览', | ||
155 | - pathTitle: '品牌一览' | ||
156 | - } | 124 | + /** |
125 | + * 获取品牌一览list | ||
126 | + * @param string $channel 频道名称 | ||
127 | + * @param int start 开始位置 1 开始 | ||
128 | + * @param int length 取数长度 0 取到最后 | ||
129 | + */ | ||
130 | + getBrandViewList(channel) { | ||
131 | + let that = this; | ||
132 | + let brandsModelCtx = new BrandsModel(that.ctx); | ||
133 | + | ||
134 | + let apiMethod = [ | ||
135 | + headerModel.requestHeaderData(channel), | ||
136 | + brandsModelCtx.getBrandViewTop(channel), | ||
137 | + brandsModelCtx.getBrandViewList(channel) // 分屏加载 | ||
157 | ]; | 138 | ]; |
158 | 139 | ||
159 | - // SEO | ||
160 | - Object.assign(responseData, seoMap[channel]); | ||
161 | - | ||
162 | - // 数据出错不cashe | ||
163 | - if (_.isEmpty(result[0].headerData) || _.isEmpty(result[1]) || _.isEmpty(result[2])) { | ||
164 | - responseData.noCashe = true; | ||
165 | - } | ||
166 | - return responseData; | ||
167 | - }); | ||
168 | -}; | 140 | + return api.all(apiMethod).then(result => { |
141 | + let responseData = { | ||
142 | + module: 'brands', | ||
143 | + page: 'brands', | ||
144 | + noCashe: false | ||
145 | + }; | ||
146 | + | ||
147 | + // 头部数据 | ||
148 | + Object.assign(responseData, result[0]); | ||
149 | + | ||
150 | + // 品牌一览列表 | ||
151 | + responseData.brands = result[1]; | ||
152 | + responseData.brands.navigation = result[2].navigation; | ||
153 | + responseData.brands.category = result[2]; | ||
154 | + | ||
155 | + // 导航pathNav | ||
156 | + responseData.brands.pathNav = [ | ||
157 | + { | ||
158 | + href: that.getHomeurlByChannel(channel), | ||
159 | + name: `${_.toUpper(channel)}首页`, | ||
160 | + pathTitle: 'YOHO!BUY 有货' | ||
161 | + }, | ||
162 | + { | ||
163 | + href: helpers.urlFormat('/brands'), | ||
164 | + name: '品牌一览', | ||
165 | + pathTitle: '品牌一览' | ||
166 | + } | ||
167 | + ]; | ||
169 | 168 | ||
170 | -/** | ||
171 | - * brandList-Ajax调用 | ||
172 | - */ | ||
173 | -exports.getBrandList = (channel, start) => { | ||
174 | - let apiMethod = [ | ||
175 | - brandsModel.getBrandViewList(channel, start) | ||
176 | - ]; | ||
177 | - | ||
178 | - return api.all(apiMethod).then(result => { | ||
179 | - let responseData = {}; | ||
180 | - | ||
181 | - // 品牌一览列表 | ||
182 | - responseData.category = result[0]; | ||
183 | - return responseData; | ||
184 | - }); | ||
185 | -}; | 169 | + // SEO |
170 | + Object.assign(responseData, that.seoMap[channel]); | ||
186 | 171 | ||
187 | -/** | ||
188 | - * 品牌接口数据 | ||
189 | - * | ||
190 | - * @param string brandId 获取品牌ID | ||
191 | - * @return json | ||
192 | - */ | ||
193 | -exports.brandInfo = (brandId, uid) => { | ||
194 | - let apiMethod = [ | ||
195 | - brandsModel.getBrandInfo(brandId, uid) | ||
196 | - ]; | ||
197 | - | ||
198 | - return api.all(apiMethod).then(result => { | ||
199 | - let responseData = { | ||
200 | - code: _.isEmpty(result[0]) ? 400 : 200, | ||
201 | - brand: _.isEmpty(result[0]) ? '' : result[0], | ||
202 | - noCashe: false | ||
203 | - }; | ||
204 | - | ||
205 | - // 数据出错不cashe | ||
206 | - if (_.isEmpty(result[0])) { | ||
207 | - responseData.noCashe = true; | ||
208 | - } | ||
209 | - return responseData; | ||
210 | - }); | ||
211 | -}; | 172 | + // 数据出错不cashe |
173 | + if (_.isEmpty(result[0].headerData) || _.isEmpty(result[1]) || _.isEmpty(result[2])) { | ||
174 | + responseData.noCashe = true; | ||
175 | + } | ||
176 | + return responseData; | ||
177 | + }); | ||
178 | + } | ||
212 | 179 | ||
213 | -/** | ||
214 | - * 多个品牌ID获取品牌信息 | ||
215 | - * | ||
216 | - * @param array $brandIds | ||
217 | - * @return array | ||
218 | - */ | ||
219 | -exports.plusstarList = (channel, req) => { | ||
220 | - return co(function*() { | ||
221 | - let headerData = yield headerModel.requestHeaderData(channel); | ||
222 | - | ||
223 | - let responseData = { | ||
224 | - module: 'brands', | ||
225 | - page: 'brands', | ||
226 | - brandsHomePage: true, | ||
227 | - noCashe: false | ||
228 | - }; | 180 | + /** |
181 | + * brandList-Ajax调用 | ||
182 | + */ | ||
183 | + getBrandList(channel, start) { | ||
184 | + let that = this; | ||
185 | + let brandsModelCtx = new BrandsModel(that.ctx); | ||
229 | 186 | ||
230 | - let id = req.query.id || '', | ||
231 | - gender = req.query.gender || getGenderByChannel(channel), | ||
232 | - limit = 20, | ||
233 | - page = parseInt(req.query.page, 10) || 1; | 187 | + let apiMethod = [ |
188 | + brandsModelCtx.getBrandViewList(channel, start) | ||
189 | + ]; | ||
234 | 190 | ||
235 | - let items = yield brandsModel.getPlusstarBrandListItem(channel); | 191 | + return api.all(apiMethod).then(result => { |
192 | + let responseData = {}; | ||
236 | 193 | ||
237 | - let brandType = 1; | 194 | + // 品牌一览列表 |
195 | + responseData.category = result[0]; | ||
196 | + return responseData; | ||
197 | + }); | ||
198 | + } | ||
238 | 199 | ||
239 | - if (+id !== 0 && items[id]) { | ||
240 | - brandType = items[id].brandType; | ||
241 | - } | ||
242 | - let plustarList = yield brandsModel.getPlustarList(brandType, gender); | 200 | + /** |
201 | + * 品牌接口数据 | ||
202 | + * | ||
203 | + * @param string brandId 获取品牌ID | ||
204 | + * @return json | ||
205 | + */ | ||
206 | + brandInfo(brandId, uid) { | ||
207 | + let that = this; | ||
208 | + let brandsModelCtx = new BrandsModel(that.ctx); | ||
209 | + | ||
210 | + let apiMethod = [ | ||
211 | + brandsModelCtx.getBrandInfo(brandId, uid) | ||
212 | + ]; | ||
243 | 213 | ||
244 | - let list = plustarList.data; | 214 | + return api.all(apiMethod).then(result => { |
215 | + let responseData = { | ||
216 | + code: _.isEmpty(result[0]) ? 400 : 200, | ||
217 | + brand: _.isEmpty(result[0]) ? '' : result[0], | ||
218 | + noCashe: false | ||
219 | + }; | ||
245 | 220 | ||
246 | - // 数据出错不cashe | ||
247 | - if (_.isEmpty(headerData.headerData) || _.isEmpty(items) || _.isEmpty(list)) { | ||
248 | - responseData.noCashe = true; | ||
249 | - } | ||
250 | - let brandIds = [], | ||
251 | - brands = [], | ||
252 | - pageList = {}; | ||
253 | - | ||
254 | - brandIds = plustarList.brandsIds.slice((page - 1) * limit, page * limit); | ||
255 | - if (plustarList.brandsIds.length > limit) { | ||
256 | - pageList = pager(Math.ceil(plustarList.brandsIds.length / limit), { | ||
257 | - page: page, | ||
258 | - id: id | ||
259 | - }); | ||
260 | - | ||
261 | - // url 伪静态 | ||
262 | - _.forEach(pageList.pages, (val) => { | ||
263 | - val.url = staticUrl(`/${channel}-brands/plusstar/`, val.url); | ||
264 | - }); | ||
265 | - if (pageList.nextPage) { | ||
266 | - pageList.nextPage.url = staticUrl(`/${channel}-brands/plusstar/`, pageList.nextPage.url); | ||
267 | - } | ||
268 | - if (pageList.prePage) { | ||
269 | - pageList.prePage.url = staticUrl(`/${channel}-brands/plusstar/`, pageList.prePage.url); | 221 | + // 数据出错不cashe |
222 | + if (_.isEmpty(result[0])) { | ||
223 | + responseData.noCashe = true; | ||
270 | } | 224 | } |
271 | - } | 225 | + return responseData; |
226 | + }); | ||
227 | + } | ||
272 | 228 | ||
273 | - if (brandIds.length > 0) { | ||
274 | - // 获取品牌信息 | ||
275 | - let brandsInfo = yield brandsModel.getBrandInfoByIds(brandIds); | 229 | + /** |
230 | + * 多个品牌ID获取品牌信息 | ||
231 | + * | ||
232 | + * @param array $brandIds | ||
233 | + * @return array | ||
234 | + */ | ||
235 | + plusstarList(channel, req) { | ||
236 | + let that = this; | ||
237 | + let brandsModelCtx = new BrandsModel(that.ctx); | ||
238 | + | ||
239 | + return co(function*() { | ||
240 | + let headerData = yield headerModel.requestHeaderData(channel); | ||
241 | + | ||
242 | + let responseData = { | ||
243 | + module: 'brands', | ||
244 | + page: 'brands', | ||
245 | + brandsHomePage: true, | ||
246 | + noCashe: false | ||
247 | + }; | ||
248 | + | ||
249 | + let id = req.query.id || '', | ||
250 | + gender = req.query.gender || that.getGenderByChannel(channel), | ||
251 | + limit = 20, | ||
252 | + page = parseInt(req.query.page, 10) || 1; | ||
253 | + | ||
254 | + let items = yield brandsModelCtx.getPlusstarBrandListItem(channel); | ||
255 | + | ||
256 | + let brandType = 1; | ||
257 | + | ||
258 | + if (+id !== 0 && items[id]) { | ||
259 | + brandType = items[id].brandType; | ||
260 | + } | ||
261 | + let plustarList = yield brandsModelCtx.getPlustarList(brandType, gender); | ||
276 | 262 | ||
277 | - _.forEach(brandIds, brandId => { | ||
278 | - if (brandsInfo[brandId]) { | ||
279 | - list[brandId].desc = brandsInfo[brandId].desc; | ||
280 | - list[brandId].url = helpers.urlFormat('', {gender: gender}, brandsInfo[brandId].url); | ||
281 | - } | ||
282 | - brands.push(list[brandId]); | ||
283 | - }); | 263 | + let list = plustarList.data; |
284 | 264 | ||
285 | // 数据出错不cashe | 265 | // 数据出错不cashe |
286 | - if (_.isEmpty(brandsInfo)) { | 266 | + if (_.isEmpty(headerData.headerData) || _.isEmpty(items) || _.isEmpty(list)) { |
287 | responseData.noCashe = true; | 267 | responseData.noCashe = true; |
288 | } | 268 | } |
289 | - } | ||
290 | - let data = { | ||
291 | - brandsHomePage: true, | ||
292 | - brands: { | ||
293 | - items: brands, | ||
294 | - tabs: items | 269 | + let brandIds = [], |
270 | + brands = [], | ||
271 | + pageList = {}; | ||
272 | + | ||
273 | + brandIds = plustarList.brandsIds.slice((page - 1) * limit, page * limit); | ||
274 | + if (plustarList.brandsIds.length > limit) { | ||
275 | + pageList = pager(Math.ceil(plustarList.brandsIds.length / limit), { | ||
276 | + page: page, | ||
277 | + id: id | ||
278 | + }); | ||
279 | + | ||
280 | + // url 伪静态 | ||
281 | + _.forEach(pageList.pages, (val) => { | ||
282 | + val.url = that.staticUrl(`/${channel}-brands/plusstar/`, val.url); | ||
283 | + }); | ||
284 | + if (pageList.nextPage) { | ||
285 | + pageList.nextPage.url = that.staticUrl(`/${channel}-brands/plusstar/`, pageList.nextPage.url); | ||
286 | + } | ||
287 | + if (pageList.prePage) { | ||
288 | + pageList.prePage.url = that.staticUrl(`/${channel}-brands/plusstar/`, pageList.prePage.url); | ||
289 | + } | ||
290 | + } | ||
295 | 291 | ||
292 | + if (brandIds.length > 0) { | ||
293 | + // 获取品牌信息 | ||
294 | + let brandsInfo = yield brandsModelCtx.getBrandInfoByIds(brandIds); | ||
295 | + | ||
296 | + _.forEach(brandIds, brandId => { | ||
297 | + if (brandsInfo[brandId]) { | ||
298 | + list[brandId].desc = brandsInfo[brandId].desc; | ||
299 | + list[brandId].url = helpers.urlFormat('', {gender: gender}, brandsInfo[brandId].url); | ||
300 | + } | ||
301 | + brands.push(list[brandId]); | ||
302 | + }); | ||
303 | + | ||
304 | + // 数据出错不cashe | ||
305 | + if (_.isEmpty(brandsInfo)) { | ||
306 | + responseData.noCashe = true; | ||
307 | + } | ||
296 | } | 308 | } |
297 | - }; | 309 | + let data = { |
310 | + brandsHomePage: true, | ||
311 | + brands: { | ||
312 | + items: brands, | ||
313 | + tabs: items | ||
314 | + | ||
315 | + } | ||
316 | + }; | ||
298 | 317 | ||
299 | - // 头部数据 | ||
300 | - Object.assign(responseData, headerData); | 318 | + // 头部数据 |
319 | + Object.assign(responseData, headerData); | ||
301 | 320 | ||
302 | - // 产品信息 | ||
303 | - Object.assign(responseData, data); | 321 | + // 产品信息 |
322 | + Object.assign(responseData, data); | ||
304 | 323 | ||
305 | - // 页码 | ||
306 | - Object.assign(responseData, pageList); | 324 | + // 页码 |
325 | + Object.assign(responseData, pageList); | ||
307 | 326 | ||
308 | - // SEO | ||
309 | - Object.assign(responseData, seoMap[`${channel}-plusstar`] || {}); | ||
310 | - return responseData; | ||
311 | - })(); | 327 | + // SEO |
328 | + Object.assign(responseData, that.seoMap[`${channel}-plusstar`] || {}); | ||
329 | + return responseData; | ||
330 | + })(); | ||
312 | 331 | ||
332 | + } | ||
313 | }; | 333 | }; |
@@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
36 | <div class="brands-logo clearfix"> | 36 | <div class="brands-logo clearfix"> |
37 | {{#each logos}} | 37 | {{#each logos}} |
38 | <a href="{{url}}" title="{{name}}" target="_blank"> | 38 | <a href="{{url}}" title="{{name}}" target="_blank"> |
39 | - <img class="lazy" data-original="{{image2 src}}"> | 39 | + <img class="lazy" src="{{image2 src w=136 h=57}}"> |
40 | </a> | 40 | </a> |
41 | {{/each}} | 41 | {{/each}} |
42 | </div> | 42 | </div> |
@@ -318,6 +318,7 @@ const _getSkuDataByProductBaseInfo = (data) => { | @@ -318,6 +318,7 @@ const _getSkuDataByProductBaseInfo = (data) => { | ||
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | + console.log(goods.images_list); | ||
321 | _.get(goods, 'images_list', []).forEach((good) => { | 322 | _.get(goods, 'images_list', []).forEach((good) => { |
322 | if (good.image_url) { | 323 | if (good.image_url) { |
323 | goodsDetail.thumbs.push({ | 324 | goodsDetail.thumbs.push({ |
@@ -287,5 +287,6 @@ | @@ -287,5 +287,6 @@ | ||
287 | <div class="code-down-box"> | 287 | <div class="code-down-box"> |
288 | <div class="code-img"></div> | 288 | <div class="code-img"></div> |
289 | <h5 class="code-title">下载手机客户端</h5> | 289 | <h5 class="code-title">下载手机客户端</h5> |
290 | + <i class="iconfont icon-del"></i> | ||
290 | </div> | 291 | </div> |
291 | {{/ headerData}} | 292 | {{/ headerData}} |
@@ -987,21 +987,8 @@ function searchSuggestHistory() { | @@ -987,21 +987,8 @@ function searchSuggestHistory() { | ||
987 | } | 987 | } |
988 | 988 | ||
989 | $(function() { | 989 | $(function() { |
990 | - var windowWidth = document.documentElement.clientWidth; | ||
991 | - | ||
992 | - if (windowWidth <= 1440) { | 990 | + $('.code-down-box').bind('click', '.icon-del', function() { |
993 | $('.code-down-box').hide(); | 991 | $('.code-down-box').hide(); |
994 | - } | ||
995 | - | ||
996 | - $(window).resize(function() { | ||
997 | - var innerWindowWidth = window.innerWidth; | ||
998 | - | ||
999 | - if (innerWindowWidth > 1440 && innerWindowWidth <= windowWidth) { | ||
1000 | - $('.code-down-box').show(); | ||
1001 | - | ||
1002 | - } else { | ||
1003 | - $('.code-down-box').hide(); | ||
1004 | - } | ||
1005 | }); | 992 | }); |
1006 | }); | 993 | }); |
1007 | 994 |
@@ -1494,7 +1494,7 @@ | @@ -1494,7 +1494,7 @@ | ||
1494 | border: none; | 1494 | border: none; |
1495 | background-color: transparent; | 1495 | background-color: transparent; |
1496 | z-index: 990; | 1496 | z-index: 990; |
1497 | - display: none; | 1497 | + display: block; |
1498 | 1498 | ||
1499 | .code-img { | 1499 | .code-img { |
1500 | width: 117px; | 1500 | width: 117px; |
@@ -1511,10 +1511,17 @@ | @@ -1511,10 +1511,17 @@ | ||
1511 | line-height: 20px; | 1511 | line-height: 20px; |
1512 | text-align: center; | 1512 | text-align: center; |
1513 | } | 1513 | } |
1514 | -} | ||
1515 | 1514 | ||
1516 | -@media screen and (min-width: 1440px) { | ||
1517 | - .code-down-box { | ||
1518 | - display: block; | 1515 | + .icon-del { |
1516 | + position: absolute; | ||
1517 | + top: -13px; | ||
1518 | + right: -10px; | ||
1519 | + display: inline-block; | ||
1520 | + font-size: 30px; | ||
1521 | + cursor: pointer; | ||
1522 | + | ||
1523 | + &:before { | ||
1524 | + content: "\e60d"; | ||
1525 | + } | ||
1519 | } | 1526 | } |
1520 | } | 1527 | } |
-
Please register or login to post a comment