Merge branch 'hotfix/smslogin' of git.yoho.cn:fe/yohobuywap-node into hotfix/smslogin
Showing
7 changed files
with
18 additions
and
10 deletions
@@ -172,8 +172,12 @@ class BuyNowController { | @@ -172,8 +172,12 @@ class BuyNowController { | ||
172 | use_yoho_coin: req.body.use_yoho_coin | 172 | use_yoho_coin: req.body.use_yoho_coin |
173 | }); | 173 | }); |
174 | 174 | ||
175 | - result.data.use_yoho_coin = paymentProcess.transPrice(_.get(result, 'data.use_yoho_coin')); | ||
176 | - result.data.yohoCoinCompute = paymentProcess.yohoCoinCompute(result.data); | 175 | + let finalResult = _.get(result, 'data', {}); |
176 | + | ||
177 | + if (finalResult) { | ||
178 | + _.set(finalResult, 'use_yoho_coin', paymentProcess.transPrice(_.get(result, 'data.use_yoho_coin'))); | ||
179 | + _.set(finalResult, 'yohoCoinCompute', paymentProcess.yohoCoinCompute(result.data)); | ||
180 | + } | ||
177 | return res.json(result.data); | 181 | return res.json(result.data); |
178 | })().catch(next); | 182 | })().catch(next); |
179 | } | 183 | } |
@@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | +const _ = require('lodash'); | ||
9 | const helpers = global.yoho.helpers; | 10 | const helpers = global.yoho.helpers; |
10 | 11 | ||
11 | // const utils = '../../../utils'; | 12 | // const utils = '../../../utils'; |
@@ -122,7 +123,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -122,7 +123,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
122 | let adList = result.data[0].data; | 123 | let adList = result.data[0].data; |
123 | let build = []; | 124 | let build = []; |
124 | 125 | ||
125 | - adList.forEach(ad => { | 126 | + _.forEach(adList, ad => { |
126 | build.push({ | 127 | build.push({ |
127 | img: helpers.image(ad.src, 640, 240), | 128 | img: helpers.image(ad.src, 640, 240), |
128 | url: ad.url | 129 | url: ad.url |
@@ -285,7 +285,7 @@ class DetailModel extends global.yoho.BaseModel { | @@ -285,7 +285,7 @@ class DetailModel extends global.yoho.BaseModel { | ||
285 | 285 | ||
286 | if (getArticleContent[i].text && textPosition === 1) { | 286 | if (getArticleContent[i].text && textPosition === 1) { |
287 | descriptionText = _.get(getArticleContent[i], 'text.data.text'); | 287 | descriptionText = _.get(getArticleContent[i], 'text.data.text'); |
288 | - _.set(result, 'getArticle.descriptionText', descriptionText.replace(/<\/?[^>]*>/g, '')); | 288 | + _.set(result, 'getArticle.descriptionText', _.replace(descriptionText, /<\/?[^>]*>/g, '')); |
289 | textPosition++; | 289 | textPosition++; |
290 | } | 290 | } |
291 | } | 291 | } |
@@ -139,10 +139,10 @@ exports.recordContent = (req, res, next) => { | @@ -139,10 +139,10 @@ exports.recordContent = (req, res, next) => { | ||
139 | 139 | ||
140 | req.ctx(indexModel).recordContent(uid, udid, page, limit).then((result) => { | 140 | req.ctx(indexModel).recordContent(uid, udid, page, limit).then((result) => { |
141 | 141 | ||
142 | - if (result.browseRecord && result.browseRecord.length === 0) { | 142 | + if (result && result.browseRecord && result.browseRecord.length === 0) { |
143 | res.json(false); | 143 | res.json(false); |
144 | } else { | 144 | } else { |
145 | - res.render('browse-record-content', Object.assign({ | 145 | + res.render('browse-record-content', _.assign({ |
146 | layout: false | 146 | layout: false |
147 | }, result)); | 147 | }, result)); |
148 | } | 148 | } |
@@ -274,7 +274,7 @@ const local = { | @@ -274,7 +274,7 @@ const local = { | ||
274 | 274 | ||
275 | passport.authenticate('local', (err, user) => { | 275 | passport.authenticate('local', (err, user) => { |
276 | if (err || !user) { | 276 | if (err || !user) { |
277 | - if (err.code === 4189) { | 277 | + if (_.get(err, 'code') === 4189) { |
278 | let obj = { | 278 | let obj = { |
279 | code: 4189, | 279 | code: 4189, |
280 | message: err || '登录出错请重试', | 280 | message: err || '登录出错请重试', |
@@ -416,9 +416,10 @@ const getCategoryGoods = (req, res, next) => { | @@ -416,9 +416,10 @@ const getCategoryGoods = (req, res, next) => { | ||
416 | params.limit = 24; | 416 | params.limit = 24; |
417 | 417 | ||
418 | req.ctx(searchModel).getCategoryGoods(params).then((result) => { | 418 | req.ctx(searchModel).getCategoryGoods(params).then((result) => { |
419 | - if (result.data.product_list && result.data.product_list.length > 0) { | 419 | + let productList = _.get(result, 'data.product_list', []); |
420 | 420 | ||
421 | - let product_list = productProcess.processProductList(result.data.product_list || [], { | 421 | + if (productList.length > 0) { |
422 | + let product_list = productProcess.processProductList(productList, { | ||
422 | isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'), | 423 | isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'), |
423 | gender: _coverChannel[params.coverChannel], | 424 | gender: _coverChannel[params.coverChannel], |
424 | showSimilar: params.shop_id || params.material === 'true' ? false : true | 425 | showSimilar: params.shop_id || params.material === 'true' ? false : true |
@@ -427,7 +428,7 @@ const getCategoryGoods = (req, res, next) => { | @@ -427,7 +428,7 @@ const getCategoryGoods = (req, res, next) => { | ||
427 | res.render('search/page', { | 428 | res.render('search/page', { |
428 | layout: false, | 429 | layout: false, |
429 | new: product_list, | 430 | new: product_list, |
430 | - total: result.data.total, | 431 | + total: _.get(result, 'data.total', 0) |
431 | }); | 432 | }); |
432 | } else { | 433 | } else { |
433 | res.json({}); | 434 | res.json({}); |
@@ -525,7 +525,9 @@ const pushGoodsInfo = (finalDetail, goodsList, isApp) => { | @@ -525,7 +525,9 @@ const pushGoodsInfo = (finalDetail, goodsList, isApp) => { | ||
525 | if (value.collocation) { | 525 | if (value.collocation) { |
526 | _.forEach(value.collocation, (item, subKey) => { | 526 | _.forEach(value.collocation, (item, subKey) => { |
527 | _.forEach(item.goods, (thItem, thKey) => { | 527 | _.forEach(item.goods, (thItem, thKey) => { |
528 | + if (thItem) { | ||
528 | finalDetail[key].collocation[subKey].goods[thKey] = goodsObj[thItem.id]; | 529 | finalDetail[key].collocation[subKey].goods[thKey] = goodsObj[thItem.id]; |
530 | + } | ||
529 | }); | 531 | }); |
530 | }); | 532 | }); |
531 | } | 533 | } |
-
Please register or login to post a comment