Merge branch 'hotfix/fix-shop-links' into 'master'
修改活动模板中店铺链接 See merge request !1703
Showing
7 changed files
with
72 additions
and
3 deletions
@@ -146,3 +146,11 @@ exports.shop = function(req, res, next) { | @@ -146,3 +146,11 @@ exports.shop = function(req, res, next) { | ||
146 | res.jsonp(result); | 146 | res.jsonp(result); |
147 | }).catch(next); | 147 | }).catch(next); |
148 | }; | 148 | }; |
149 | + | ||
150 | +exports.getShopByIds = function(req, res, next) { | ||
151 | + let shopIds = req.query.shopIds || '0'; | ||
152 | + | ||
153 | + req.ctx(model).getShopByIds(shopIds).then(result => { | ||
154 | + res.jsonp(result); | ||
155 | + }).catch(next); | ||
156 | +}; |
@@ -369,9 +369,9 @@ class featureModel extends global.yoho.BaseModel { | @@ -369,9 +369,9 @@ class featureModel extends global.yoho.BaseModel { | ||
369 | if (componentType === 'shopAndProduct') { | 369 | if (componentType === 'shopAndProduct') { |
370 | let shop = f.component[0]; | 370 | let shop = f.component[0]; |
371 | 371 | ||
372 | - shop.jumpUrl = `//m.yohobuy.com/product/shop?shop_id=${shop.shopId}&openby:yohobuy= | ||
373 | - {"action":"go.shop","params":{"shop_id":"${shop.shopId}","shop_template_type":"2"}}`; | 372 | + shop.jumpUrl = `//m.yohobuy.com/product/index/brand?shop_id=${shop.shopId}&openby:yohobuy={"action":"go.shop","params":{"shop_id":"${shop.shopId}","shop_template_type":"2"}}`;// eslint-disable-line |
374 | shop.numOfOneRow = '3'; | 373 | shop.numOfOneRow = '3'; |
374 | + | ||
375 | if (shop.searchCondition) { | 375 | if (shop.searchCondition) { |
376 | shop.searchCondition.limit = '3'; // 强制把数量限制为3个 | 376 | shop.searchCondition.limit = '3'; // 强制把数量限制为3个 |
377 | if (shop.favourite_prds_enable === '1') { | 377 | if (shop.favourite_prds_enable === '1') { |
@@ -382,6 +382,7 @@ class featureModel extends global.yoho.BaseModel { | @@ -382,6 +382,7 @@ class featureModel extends global.yoho.BaseModel { | ||
382 | shop.newStyle = _.get(f, 'component[0].newStyle') === '1'; | 382 | shop.newStyle = _.get(f, 'component[0].newStyle') === '1'; |
383 | } | 383 | } |
384 | } else if (shop.defaultSkn) { | 384 | } else if (shop.defaultSkn) { |
385 | + | ||
385 | componentArr.push(shop); | 386 | componentArr.push(shop); |
386 | } | 387 | } |
387 | 388 |
@@ -113,6 +113,16 @@ class individuationModel extends global.yoho.BaseModel { | @@ -113,6 +113,16 @@ class individuationModel extends global.yoho.BaseModel { | ||
113 | }); | 113 | }); |
114 | } | 114 | } |
115 | 115 | ||
116 | + getShopByIds(shopIds) { | ||
117 | + return this.get({ | ||
118 | + data: { | ||
119 | + method: 'app.shops.batchGetShops', | ||
120 | + shop_ids: shopIds | ||
121 | + }, | ||
122 | + param: {cache: true} | ||
123 | + }); | ||
124 | + } | ||
125 | + | ||
116 | } | 126 | } |
117 | 127 | ||
118 | module.exports = individuationModel; | 128 | module.exports = individuationModel; |
@@ -271,6 +271,7 @@ router.get('/redbag/2017', redbag.index); | @@ -271,6 +271,7 @@ router.get('/redbag/2017', redbag.index); | ||
271 | router.get('/individuation', individuation.productLst); | 271 | router.get('/individuation', individuation.productLst); |
272 | router.get('/individuation/coupon', individuation.coupon); | 272 | router.get('/individuation/coupon', individuation.coupon); |
273 | router.get('/individuation/shop', individuation.shop); | 273 | router.get('/individuation/shop', individuation.shop); |
274 | +router.get('/individuation/getShopByIds', individuation.getShopByIds); // 通过ID获取店铺基本信息 | ||
274 | 275 | ||
275 | // 活动页模版 | 276 | // 活动页模版 |
276 | router.get('/feature/:code.html', feature.index); | 277 | router.get('/feature/:code.html', feature.index); |
@@ -111,7 +111,7 @@ | @@ -111,7 +111,7 @@ | ||
111 | 111 | ||
112 | {{#isEqualOr type 'shopAndProduct'}} | 112 | {{#isEqualOr type 'shopAndProduct'}} |
113 | <!--一个店铺带两个商品--> | 113 | <!--一个店铺带两个商品--> |
114 | - <div class="shop-product-container {{#isEqualOr position '1'}}right{{^}}left{{/isEqualOr}}"> | 114 | + <div class="shop-product-container {{#isEqualOr position '1'}}right{{^}}left{{/isEqualOr}}" id="s_p_{{shopId}}" data-shopId="{{shopId}}"> |
115 | <div class="product-container single-item3 {{#isEqualOr position '1'}}right{{^}}left{{/isEqualOr}} shop-wrapper"> | 115 | <div class="product-container single-item3 {{#isEqualOr position '1'}}right{{^}}left{{/isEqualOr}} shop-wrapper"> |
116 | <a class="shop-container" href="{{jumpUrl}}" target="_blank"> | 116 | <a class="shop-container" href="{{jumpUrl}}" target="_blank"> |
117 | <div class="feature-shop-info"> | 117 | <div class="feature-shop-info"> |
@@ -316,6 +316,51 @@ function shopGroupInit() { | @@ -316,6 +316,51 @@ function shopGroupInit() { | ||
316 | }); | 316 | }); |
317 | } | 317 | } |
318 | 318 | ||
319 | +/** | ||
320 | + * 获取店铺+商品组中的店铺信息,并更换店铺链接为新店铺链接 | ||
321 | + */ | ||
322 | +function getShopProductLinks() { | ||
323 | + let shopArr = { | ||
324 | + ids: [], | ||
325 | + shopIds: [] | ||
326 | + }; | ||
327 | + | ||
328 | + $('.shop-product-container').each(function() { | ||
329 | + let shopId = $(this).data('shopid'); | ||
330 | + let id = $(this)[0].id; | ||
331 | + | ||
332 | + console.log(id, shopId); | ||
333 | + | ||
334 | + if (shopId && id) { | ||
335 | + shopArr.ids.push(id); | ||
336 | + shopArr.shopIds.push(shopId); | ||
337 | + } | ||
338 | + }); | ||
339 | + | ||
340 | + if (shopArr.ids.length > 0 && shopArr.shopIds.length > 0 && (shopArr.ids.length === shopArr.shopIds.length)) { | ||
341 | + $.ajax({ | ||
342 | + url: '//m.yohobuy.com/activity/individuation/getShopByIds', | ||
343 | + data: {shopIds: shopArr.shopIds.join(',')}, | ||
344 | + dataType: 'jsonp' | ||
345 | + }).then(res => { | ||
346 | + if (res.data && res.data.length > 0) { | ||
347 | + for (let i = 0; i < res.data.length; i++) { | ||
348 | + let shopInfo = res.data[i]; | ||
349 | + let index = shopArr.shopIds.indexOf(shopInfo.shops_id); | ||
350 | + let is_red_shop = shopInfo.is_red_shop ? ',"is_red_shop":"1"' : ''; | ||
351 | + | ||
352 | + if (index >= 0) { | ||
353 | + let divId = shopArr.ids[index]; | ||
354 | + let shopUrl = `//m.yohobuy.com/product/index/brand?shop_id=${shopInfo.shops_id}&openby:yohobuy={"action":"go.shop","params":{"shop_id":"${shopInfo.shops_id}","shop_template_type":"${shopInfo.shop_template_type}","shop_name":"${shopInfo.shop_name}"${is_red_shop}}}`;// eslint-disable-line | ||
355 | + console.log(shopUrl); | ||
356 | + $('#' + divId).find('.shop-wrapper a').attr('href', shopUrl); | ||
357 | + } | ||
358 | + } | ||
359 | + } | ||
360 | + }); | ||
361 | + } | ||
362 | +} | ||
363 | + | ||
319 | function convertTime(time) { | 364 | function convertTime(time) { |
320 | var anHour = 3600, | 365 | var anHour = 3600, |
321 | aMinute = 60, | 366 | aMinute = 60, |
@@ -881,6 +926,7 @@ function activityPlan() { | @@ -881,6 +926,7 @@ function activityPlan() { | ||
881 | } | 926 | } |
882 | } | 927 | } |
883 | 928 | ||
929 | +// 单独改变未完成的楼层的高度 | ||
884 | function changeShopAndProductHeightSingle(parent, className) { | 930 | function changeShopAndProductHeightSingle(parent, className) { |
885 | let img = $(parent).find('.' + className); | 931 | let img = $(parent).find('.' + className); |
886 | 932 | ||
@@ -997,6 +1043,8 @@ $(function() { | @@ -997,6 +1043,8 @@ $(function() { | ||
997 | 1043 | ||
998 | changeShopAndProductHeight(); | 1044 | changeShopAndProductHeight(); |
999 | 1045 | ||
1046 | + getShopProductLinks(); | ||
1047 | + | ||
1000 | // 小程序相关处理 | 1048 | // 小程序相关处理 |
1001 | if (!window.WeixinJSBridge || !window.WeixinJSBridge.invoke) { | 1049 | if (!window.WeixinJSBridge || !window.WeixinJSBridge.invoke) { |
1002 | document.addEventListener('WeixinJSBridgeReady', miniProgramHandleInit, false); | 1050 | document.addEventListener('WeixinJSBridgeReady', miniProgramHandleInit, false); |
-
Please register or login to post a comment