Authored by yyq

brand跳转

@@ -24,7 +24,7 @@ const getBrandTopData = (contentCode) => { @@ -24,7 +24,7 @@ const getBrandTopData = (contentCode) => {
24 * @param int $channel 频道标识 1:男,2:女,3:潮童,4:创意生活 24 * @param int $channel 频道标识 1:男,2:女,3:潮童,4:创意生活
25 */ 25 */
26 const getBrandListData = channel => { 26 const getBrandListData = channel => {
27 - let params = {method: 'app.brand.brandlist'}; 27 + let params = {method: 'app.brand.allBrandList'};
28 28
29 if (!isNaN(channel)) { 29 if (!isNaN(channel)) {
30 params.yh_channel = channel; 30 params.yh_channel = channel;
@@ -31,6 +31,8 @@ const GIRLS = 'girls'; @@ -31,6 +31,8 @@ const GIRLS = 'girls';
31 const KIDS = 'kids'; 31 const KIDS = 'kids';
32 const LIFESTYLE = 'lifestyle'; 32 const LIFESTYLE = 'lifestyle';
33 33
  34 +const GLOBAL_BASE_URI = '/product/global/list';
  35 +
34 /** 36 /**
35 * 获取品牌一览资源位&channelType 37 * 获取品牌一览资源位&channelType
36 * 38 *
@@ -167,13 +169,14 @@ const getBrandViewList = (channel, start, length) => { @@ -167,13 +169,14 @@ const getBrandViewList = (channel, start, length) => {
167 } 169 }
168 170
169 // 品牌list A-Z 0-9 171 // 品牌list A-Z 0-9
170 - if (res.data && res.data.brands) { 172 + if (res.data && res.data.all_list) {
171 173
172 - _.forEach(res.data.brands, (subValue, key) => { 174 + _.forEach(res.data.all_list, (subValue, key) => {
173 let listTmp = []; 175 let listTmp = [];
174 176
175 _.forEach(subValue, ssubValue => { 177 _.forEach(subValue, ssubValue => {
176 let extQs = {}; 178 let extQs = {};
  179 + let baseUri = '';
177 180
178 // 为品牌名称 181 // 为品牌名称
179 let href; 182 let href;
@@ -183,22 +186,35 @@ const getBrandViewList = (channel, start, length) => { @@ -183,22 +186,35 @@ const getBrandViewList = (channel, start, length) => {
183 } else if (switchParams.channelType === 2) { 186 } else if (switchParams.channelType === 2) {
184 Object.assign(extQs, {gender: '2,3'}); 187 Object.assign(extQs, {gender: '2,3'});
185 } 188 }
  189 + let shopInfo, shopId;
186 190
187 switch (ssubValue.type * 1) { 191 switch (ssubValue.type * 1) {
188 case 1: 192 case 1:
189 - extQs = {query: ssubValue.brand_domain}; 193 + extQs = {
  194 + query: ssubValue.brand_domain,
  195 + brand: ssubValue.id
  196 + };
190 ssubValue.brand_domain = 'search'; 197 ssubValue.brand_domain = 'search';
191 break; 198 break;
192 case 2: 199 case 2:
193 - if (ssubValue.shop_id) {  
194 - Object.assign(extQs, {shopId: ssubValue.shop_id}); 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});
195 } 206 }
196 break; 207 break;
  208 + case 3:
  209 + Object.assign(extQs, {brand: ssubValue.id});
  210 + ssubValue.brand_domain = '';
  211 + baseUri = GLOBAL_BASE_URI;
  212 + break;
197 default: 213 default:
198 break; 214 break;
199 } 215 }
200 216
201 - href = helpers.urlFormat('', extQs, ssubValue.brand_domain); 217 + href = helpers.urlFormat(baseUri, extQs, ssubValue.brand_domain);
202 218
203 let brandItem = { 219 let brandItem = {
204 name: ssubValue.brand_name, 220 name: ssubValue.brand_name,
@@ -174,7 +174,6 @@ exports.newWithChannel = (req, res, next) => { @@ -174,7 +174,6 @@ exports.newWithChannel = (req, res, next) => {
174 exports.brand = (req, res, next) => { 174 exports.brand = (req, res, next) => {
175 let brandDomain = req.query.domain; 175 let brandDomain = req.query.domain;
176 let shopId = req.query.shopId; 176 let shopId = req.query.shopId;
177 - let resData = {};  
178 177
179 // shopId存在,直接走店铺 178 // shopId存在,直接走店铺
180 if (shopId) { 179 if (shopId) {
@@ -198,13 +197,11 @@ exports.brand = (req, res, next) => { @@ -198,13 +197,11 @@ exports.brand = (req, res, next) => {
198 case 2: // 店铺 197 case 2: // 店铺
199 return shop(brandInfo.shopId, req, res, next, brandInfo); 198 return shop(brandInfo.shopId, req, res, next, brandInfo);
200 default: // 品牌 199 default: // 品牌
201 - return list.getBrandData(req.query, Object.assign({uid: req.user.uid}, brandInfo),  
202 - req.yoho.channel).then(result => {  
203 - Object.assign(resData, result, {  
204 - page: 'list'  
205 - });  
206 - res.render('list/brand', resData);  
207 - }); 200 + res.redirect(helpers.urlFormat('', {
  201 + query: brandInfo.brandDomain,
  202 + brand: brandInfo.brandId
  203 + }, 'search'));
  204 + break;
208 } 205 }
209 }).catch(next); 206 }).catch(next);
210 }; 207 };