Authored by 毕凯

Merge branch 'feature/userVip' into 'feature/qps'

Feature/user vip



See merge request !1021
@@ -5,7 +5,8 @@ @@ -5,7 +5,8 @@
5 */ 5 */
6 'use strict'; 6 'use strict';
7 const channelModel = require('../models/channel'); 7 const channelModel = require('../models/channel');
8 -const homeModel = require('../../home/models/index'); 8 +
  9 +// const homeModel = require('../../home/models/index');
9 const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab 10 const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
10 11
11 const helpers = global.yoho.helpers; 12 const helpers = global.yoho.helpers;
@@ -213,27 +214,27 @@ exports.shopRecom = (req, res, next) => { @@ -213,27 +214,27 @@ exports.shopRecom = (req, res, next) => {
213 /** 214 /**
214 * 获取用户vip信息 215 * 获取用户vip信息
215 */ 216 */
216 -exports.userVip = (req, res, next) => {  
217 - let uid = req.user.uid;  
218 -  
219 - if (!uid) {  
220 - res.json({  
221 - code: 555,  
222 - msg: '未登录'  
223 - });  
224 - } else {  
225 - req.ctx(homeModel).getGradeGrade(uid, req.query.channel || 1).then(result => {  
226 - if (result.code === 200) {  
227 - res.json({  
228 - code: 200,  
229 - current_vip_level: result.data.current_vip_level,  
230 - });  
231 - } else {  
232 - res.json({  
233 - code: 500,  
234 - msg: '出错了',  
235 - });  
236 - }  
237 - }).catch(next);  
238 - }  
239 -}; 217 +// exports.userVip = (req, res, next) => {
  218 +// let uid = req.user.uid;
  219 +
  220 +// if (!uid) {
  221 +// res.json({
  222 +// code: 555,
  223 +// msg: '未登录'
  224 +// });
  225 +// } else {
  226 +// req.ctx(homeModel).getGradeGrade(uid, req.query.channel || 1).then(result => {
  227 +// if (result.code === 200) {
  228 +// res.json({
  229 +// code: 200,
  230 +// current_vip_level: result.data.current_vip_level,
  231 +// });
  232 +// } else {
  233 +// res.json({
  234 +// code: 500,
  235 +// msg: '出错了',
  236 +// });
  237 +// }
  238 +// }).catch(next);
  239 +// }
  240 +// };
@@ -35,7 +35,7 @@ router.get('/brands/delBrandHistory', brandController.delBrandHistory); // 删 @@ -35,7 +35,7 @@ router.get('/brands/delBrandHistory', brandController.delBrandHistory); // 删
35 35
36 // 5.2新楼层功能 36 // 5.2新楼层功能
37 router.post('/channel/shopRecom', channel.shopRecom); // 店铺推荐收藏状态 37 router.post('/channel/shopRecom', channel.shopRecom); // 店铺推荐收藏状态
38 -router.post('/channel/userVip', channel.userVip); 38 +// router.post('/channel/userVip', channel.userVip);
39 39
40 // 自定义频道,市场推广-智汇 40 // 自定义频道,市场推广-智汇
41 // 此页面做的早,写死发给市场,与自定义的不兼容,所以需要写死 41 // 此页面做的早,写死发给市场,与自定义的不兼容,所以需要写死
@@ -246,7 +246,12 @@ const shop = { @@ -246,7 +246,12 @@ const shop = {
246 }); 246 });
247 } 247 }
248 248
249 - res.render('newshop/shop-reds', finalResult); 249 + // 店铺收藏开关
  250 + let shppFavHide = _.get(req.app.locals.wap, 'shop.removeCollect', false);
  251 +
  252 + res.render('newshop/shop-reds', _.assign(finalResult, {
  253 + shppFavHide: shppFavHide
  254 + }));
250 })().catch(next); 255 })().catch(next);
251 }, 256 },
252 257
@@ -13,7 +13,8 @@ @@ -13,7 +13,8 @@
13 <p class="store-name">{{shopInfo.shop_name}}</p> 13 <p class="store-name">{{shopInfo.shop_name}}</p>
14 <div class="fav-box clearfix"> 14 <div class="fav-box clearfix">
15 <div class="favs pull-left">粉丝数: {{favCount}} </div> 15 <div class="favs pull-left">粉丝数: {{favCount}} </div>
16 - <div class="not-collect pull-left" id="collect" data-bp-id="shop_branner_collect_1"></div> 16 + {{!-- 店铺收藏开关 data-switch --}}
  17 + <div class="not-collect pull-left {{#if shppFavHide}}hide{{/if}}" data-switch="{{shppFavHide}}" id="collect" data-bp-id="shop_branner_collect_1"></div>
17 </div> 18 </div>
18 </div> 19 </div>
19 {{/if}} 20 {{/if}}
@@ -328,24 +328,24 @@ function ajaxResource() { @@ -328,24 +328,24 @@ function ajaxResource() {
328 }); 328 });
329 329
330 // vip专属等级查询 330 // vip专属等级查询
331 - $.ajax({  
332 - method: 'POST',  
333 - url: '/channel/userVip',  
334 - data: {  
335 - channel: 1,  
336 - },  
337 - success: function(data) {  
338 - let vip = $('.vip-only');  
339 -  
340 - if (data.code === 200 && Number(data.current_vip_level) !== 0) {  
341 - vip.show();  
342 - vip.find('.vip' + data.current_vip_level).show();  
343 - }  
344 - },  
345 - error: function() {  
346 - tip.show('网络断开连接了~');  
347 - }  
348 - }); 331 + // $.ajax({
  332 + // method: 'POST',
  333 + // url: '/channel/userVip',
  334 + // data: {
  335 + // channel: 1,
  336 + // },
  337 + // success: function(data) {
  338 + // let vip = $('.vip-only');
  339 +
  340 + // if (data.code === 200 && Number(data.current_vip_level) !== 0) {
  341 + // vip.show();
  342 + // vip.find('.vip' + data.current_vip_level).show();
  343 + // }
  344 + // },
  345 + // error: function() {
  346 + // tip.show('网络断开连接了~');
  347 + // }
  348 + // });
349 349
350 checkShop(); 350 checkShop();
351 351
@@ -85,22 +85,24 @@ $collectShopIcon.on('click', () => { @@ -85,22 +85,24 @@ $collectShopIcon.on('click', () => {
85 85
86 // 获取是否收藏 86 // 获取是否收藏
87 (function() { 87 (function() {
88 - $.ajax({  
89 - type: 'GET',  
90 - url: location.protocol + '//m.yohobuy.com/product/index/shopFav',  
91 - xhrFields: {  
92 - withCredentials: true  
93 - },  
94 - data: {  
95 - shopId: shopId,  
96 - },  
97 - success: function(data) {  
98 - if (data.collect) {  
99 - $collectShopIcon.addClass('coled'); 88 + if ($('.not-collect').data('switch') !== true) {
  89 + $.ajax({
  90 + type: 'GET',
  91 + url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
  92 + xhrFields: {
  93 + withCredentials: true
  94 + },
  95 + data: {
  96 + shopId: shopId,
  97 + },
  98 + success: function(data) {
  99 + if (data.collect) {
  100 + $collectShopIcon.addClass('coled');
  101 + }
  102 + },
  103 + error: function() {
  104 + tip.show('网络断开连接了~');
100 } 105 }
101 - },  
102 - error: function() {  
103 - tip.show('网络断开连接了~');  
104 - }  
105 - }); 106 + });
  107 + }
106 }()); 108 }());
@@ -65,25 +65,27 @@ let defaultOpt = require('common/query-param'); @@ -65,25 +65,27 @@ let defaultOpt = require('common/query-param');
65 }); 65 });
66 } 66 }
67 67
68 - $.ajax({  
69 - type: 'GET',  
70 - url: location.protocol + '//m.yohobuy.com/product/index/shopFav',  
71 - xhrFields: {  
72 - withCredentials: true  
73 - },  
74 - data: {  
75 - shopId: $('.shopId').val(),  
76 - uid: uid  
77 - },  
78 - success: function(data) {  
79 - if (data.collect) {  
80 - $collect.attr('class', 'already-collect'); 68 + if ($('.not-collect').data('switch') !== true) {
  69 + $.ajax({
  70 + type: 'GET',
  71 + url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
  72 + xhrFields: {
  73 + withCredentials: true
  74 + },
  75 + data: {
  76 + shopId: $('.shopId').val(),
  77 + uid: uid
  78 + },
  79 + success: function(data) {
  80 + if (data.collect) {
  81 + $collect.attr('class', 'already-collect');
  82 + }
  83 + },
  84 + error: function() {
  85 + tip.show('网络断开连接了~');
81 } 86 }
82 - },  
83 - error: function() {  
84 - tip.show('网络断开连接了~');  
85 - }  
86 - }); 87 + });
  88 + }
87 if ($('.popularity-title').data('skns')) { 89 if ($('.popularity-title').data('skns')) {
88 $.ajax({ 90 $.ajax({
89 type: 'GET', 91 type: 'GET',
@@ -24,24 +24,26 @@ lazyLoad($('.lazy'), lazyLoadParams); @@ -24,24 +24,26 @@ lazyLoad($('.lazy'), lazyLoadParams);
24 /** 24 /**
25 * 异步检测是否已经收藏 25 * 异步检测是否已经收藏
26 */ 26 */
27 -$.ajax({  
28 - type: 'GET',  
29 - url: location.protocol + '//m.yohobuy.com/product/index/shopFav',  
30 - xhrFields: {  
31 - withCredentials: true  
32 - },  
33 - data: {  
34 - shopId: shopId  
35 - },  
36 - success: function(data) {  
37 - if (data.collect) {  
38 - $collect.attr('class', 'already-collect pull-left'); 27 +if ($('.not-collect').data('switch') !== true) {
  28 + $.ajax({
  29 + type: 'GET',
  30 + url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
  31 + xhrFields: {
  32 + withCredentials: true
  33 + },
  34 + data: {
  35 + shopId: shopId
  36 + },
  37 + success: function(data) {
  38 + if (data.collect) {
  39 + $collect.attr('class', 'already-collect pull-left');
  40 + }
  41 + },
  42 + error: function() {
  43 + tip.show('网络断开连接了~');
39 } 44 }
40 - },  
41 - error: function() {  
42 - tip.show('网络断开连接了~');  
43 - }  
44 -}); 45 + });
  46 +}
45 47
46 /** 48 /**
47 * 店铺轮播图 49 * 店铺轮播图
@@ -60,24 +60,26 @@ require('common'); @@ -60,24 +60,26 @@ require('common');
60 }); 60 });
61 } 61 }
62 62
63 - $.ajax({  
64 - type: 'GET',  
65 - url: location.protocol + '//m.yohobuy.com/product/index/shopFav',  
66 - xhrFields: {  
67 - withCredentials: true  
68 - },  
69 - data: {  
70 - shopId: $('.shopid').val(),  
71 - },  
72 - success: function(data) {  
73 - if (data.collect) {  
74 - $collect.attr('class', 'already-collect'); 63 + if ($('.not-collect').data('switch') !== true) {
  64 + $.ajax({
  65 + type: 'GET',
  66 + url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
  67 + xhrFields: {
  68 + withCredentials: true
  69 + },
  70 + data: {
  71 + shopId: $('.shopid').val(),
  72 + },
  73 + success: function(data) {
  74 + if (data.collect) {
  75 + $collect.attr('class', 'already-collect');
  76 + }
  77 + },
  78 + error: function() {
  79 + tip.show('网络断开连接了~');
75 } 80 }
76 - },  
77 - error: function() {  
78 - tip.show('网络断开连接了~');  
79 - }  
80 - }); 81 + });
  82 + }
81 }()); 83 }());
82 84
83 // 默认筛选条件 85 // 默认筛选条件