Authored by 毕凯

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

个人中心为你优选开关



See merge request !1023
... ... @@ -4,6 +4,7 @@ const mRoot = '../models';
const headerModel = require('../../../doraemon/models/header'); // 头部model
const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
const newHomeModel = require(`${mRoot}/new-home`);
const _ = require('lodash');
let yhchannels = {
'1,3': 1,
... ... @@ -46,6 +47,11 @@ exports.index = (req, res, next) => {
};
req.ctx(newHomeModel).index(params).then(result => {
res.render('new-home', Object.assign(responseData, result));
// 为你优选开关
let recommendHide = _.get(req.app.locals.wap, 'ucenter.removePrefe', false);
res.render('new-home', Object.assign(responseData, result, {
recommendHide: recommendHide
}));
}).catch(next);
};
... ...
... ... @@ -161,7 +161,7 @@
{{> content}}
</div>
</div>
<div id="new-recommend-c">
<div id="new-recommend-c" class="{{#if recommendHide}}hide{{/if}}" data-switch="{{recommendHide}}">
<div class="toper">
<div class="title">为你优选</div>
</div>
... ...
... ... @@ -31,27 +31,29 @@ class NewRecommend extends Page {
}
getRecommend() {
this.ajax({
url: '/product/new-recommend/getRecommend',
}).then((result) => {
if (result) {
if (result.goods.length > 0) {
let goodsData = {
goods: result.goods
};
let $goodsData = $(this.view.goodsRender(goodsData));
this.selector.$goodsContainer.append($goodsData);
lazyLoad($goodsData.find('img.lazy'));
window.rePosFooter();
} else {
this.selector.$recommendC.remove();
if (this.selector.$recommendC.data('switch') !== true) {
this.ajax({
url: '/product/new-recommend/getRecommend',
}).then((result) => {
if (result) {
if (result.goods.length > 0) {
let goodsData = {
goods: result.goods
};
let $goodsData = $(this.view.goodsRender(goodsData));
this.selector.$goodsContainer.append($goodsData);
lazyLoad($goodsData.find('img.lazy'));
window.rePosFooter();
} else {
this.selector.$recommendC.remove();
}
}
}
}).catch(error => {
console.error(error);
this.selector.$recommendC.remove();
});
}).catch(error => {
console.error(error);
this.selector.$recommendC.remove();
});
}
}
}
... ...