Authored by 陈峰

降级字段判断用lodash

1 'use strict'; 1 'use strict';
2 2
3 const mRoot = '../models'; 3 const mRoot = '../models';
  4 +const _ = require('lodash');
4 const recommendForYouModel = require(`${mRoot}/recommend-for-you`); // 领取优惠券 model 5 const recommendForYouModel = require(`${mRoot}/recommend-for-you`); // 领取优惠券 model
5 6
6 exports.userCenter = (req, res, next) => { 7 exports.userCenter = (req, res, next) => {
@@ -33,7 +34,7 @@ exports.cart = (req, res, next) => { @@ -33,7 +34,7 @@ exports.cart = (req, res, next) => {
33 uid = req.user.uid || 0, 34 uid = req.user.uid || 0,
34 yhChannel = req.query.yh_channel || '1', 35 yhChannel = req.query.yh_channel || '1',
35 limit = 30; 36 limit = 30;
36 - if (req.app.locals.wap.cart.removePrefer) { 37 + if (_.get(req, 'app.locals.wap.cart.removePrefer', false)) {
37 return res.send(''); 38 return res.send('');
38 } 39 }
39 recommendForYouModel.getPreference({ 40 recommendForYouModel.getPreference({
@@ -133,7 +133,7 @@ const list = (req, res, next) => { @@ -133,7 +133,7 @@ const list = (req, res, next) => {
133 const index = (req, res, next) => { 133 const index = (req, res, next) => {
134 let title = '搜索'; 134 let title = '搜索';
135 ((render) => { 135 ((render) => {
136 - if (req.app.locals.wap.search.removeHotSearch) { 136 + if (_.get(req, 'app.locals.wap.search.removeHotSearch', false)) {
137 render([]); 137 render([]);
138 } else { 138 } else {
139 searchModel.getSearchIndex().then((result) => { 139 searchModel.getSearchIndex().then((result) => {