Authored by 毕凯

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

Feature/user vip



See merge request !1021
... ... @@ -5,7 +5,8 @@
*/
'use strict';
const channelModel = require('../models/channel');
const homeModel = require('../../home/models/index');
// const homeModel = require('../../home/models/index');
const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
const helpers = global.yoho.helpers;
... ... @@ -213,27 +214,27 @@ exports.shopRecom = (req, res, next) => {
/**
* 获取用户vip信息
*/
exports.userVip = (req, res, next) => {
let uid = req.user.uid;
if (!uid) {
res.json({
code: 555,
msg: '未登录'
});
} else {
req.ctx(homeModel).getGradeGrade(uid, req.query.channel || 1).then(result => {
if (result.code === 200) {
res.json({
code: 200,
current_vip_level: result.data.current_vip_level,
});
} else {
res.json({
code: 500,
msg: '出错了',
});
}
}).catch(next);
}
};
// exports.userVip = (req, res, next) => {
// let uid = req.user.uid;
// if (!uid) {
// res.json({
// code: 555,
// msg: '未登录'
// });
// } else {
// req.ctx(homeModel).getGradeGrade(uid, req.query.channel || 1).then(result => {
// if (result.code === 200) {
// res.json({
// code: 200,
// current_vip_level: result.data.current_vip_level,
// });
// } else {
// res.json({
// code: 500,
// msg: '出错了',
// });
// }
// }).catch(next);
// }
// };
... ...
... ... @@ -35,7 +35,7 @@ router.get('/brands/delBrandHistory', brandController.delBrandHistory); // 删
// 5.2新楼层功能
router.post('/channel/shopRecom', channel.shopRecom); // 店铺推荐收藏状态
router.post('/channel/userVip', channel.userVip);
// router.post('/channel/userVip', channel.userVip);
// 自定义频道,市场推广-智汇
// 此页面做的早,写死发给市场,与自定义的不兼容,所以需要写死
... ...
... ... @@ -246,7 +246,12 @@ const shop = {
});
}
res.render('newshop/shop-reds', finalResult);
// 店铺收藏开关
let shppFavHide = _.get(req.app.locals.wap, 'shop.removeCollect', false);
res.render('newshop/shop-reds', _.assign(finalResult, {
shppFavHide: shppFavHide
}));
})().catch(next);
},
... ...
... ... @@ -13,7 +13,8 @@
<p class="store-name">{{shopInfo.shop_name}}</p>
<div class="fav-box clearfix">
<div class="favs pull-left">粉丝数: {{favCount}} </div>
<div class="not-collect pull-left" id="collect" data-bp-id="shop_branner_collect_1"></div>
{{!-- 店铺收藏开关 data-switch --}}
<div class="not-collect pull-left {{#if shppFavHide}}hide{{/if}}" data-switch="{{shppFavHide}}" id="collect" data-bp-id="shop_branner_collect_1"></div>
</div>
</div>
{{/if}}
... ...
... ... @@ -328,24 +328,24 @@ function ajaxResource() {
});
// vip专属等级查询
$.ajax({
method: 'POST',
url: '/channel/userVip',
data: {
channel: 1,
},
success: function(data) {
let vip = $('.vip-only');
if (data.code === 200 && Number(data.current_vip_level) !== 0) {
vip.show();
vip.find('.vip' + data.current_vip_level).show();
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
// $.ajax({
// method: 'POST',
// url: '/channel/userVip',
// data: {
// channel: 1,
// },
// success: function(data) {
// let vip = $('.vip-only');
// if (data.code === 200 && Number(data.current_vip_level) !== 0) {
// vip.show();
// vip.find('.vip' + data.current_vip_level).show();
// }
// },
// error: function() {
// tip.show('网络断开连接了~');
// }
// });
checkShop();
... ...
... ... @@ -85,22 +85,24 @@ $collectShopIcon.on('click', () => {
// 获取是否收藏
(function() {
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: shopId,
},
success: function(data) {
if (data.collect) {
$collectShopIcon.addClass('coled');
if ($('.not-collect').data('switch') !== true) {
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: shopId,
},
success: function(data) {
if (data.collect) {
$collectShopIcon.addClass('coled');
}
},
error: function() {
tip.show('网络断开连接了~');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
});
}
}());
... ...
... ... @@ -65,25 +65,27 @@ let defaultOpt = require('common/query-param');
});
}
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: $('.shopId').val(),
uid: uid
},
success: function(data) {
if (data.collect) {
$collect.attr('class', 'already-collect');
if ($('.not-collect').data('switch') !== true) {
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: $('.shopId').val(),
uid: uid
},
success: function(data) {
if (data.collect) {
$collect.attr('class', 'already-collect');
}
},
error: function() {
tip.show('网络断开连接了~');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
});
}
if ($('.popularity-title').data('skns')) {
$.ajax({
type: 'GET',
... ...
... ... @@ -24,24 +24,26 @@ lazyLoad($('.lazy'), lazyLoadParams);
/**
* 异步检测是否已经收藏
*/
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: shopId
},
success: function(data) {
if (data.collect) {
$collect.attr('class', 'already-collect pull-left');
if ($('.not-collect').data('switch') !== true) {
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: shopId
},
success: function(data) {
if (data.collect) {
$collect.attr('class', 'already-collect pull-left');
}
},
error: function() {
tip.show('网络断开连接了~');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
});
}
/**
* 店铺轮播图
... ...
... ... @@ -60,24 +60,26 @@ require('common');
});
}
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: $('.shopid').val(),
},
success: function(data) {
if (data.collect) {
$collect.attr('class', 'already-collect');
if ($('.not-collect').data('switch') !== true) {
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: $('.shopid').val(),
},
success: function(data) {
if (data.collect) {
$collect.attr('class', 'already-collect');
}
},
error: function() {
tip.show('网络断开连接了~');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
});
}
}());
// 默认筛选条件
... ...