Authored by 郭成尧

bug-fixed

@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 * @Author: Targaryen 3 * @Author: Targaryen
4 * @Date: 2017-01-04 15:17:51 4 * @Date: 2017-01-04 15:17:51
5 * @Last Modified by: Targaryen 5 * @Last Modified by: Targaryen
6 - * @Last Modified time: 2017-03-20 14:03:48 6 + * @Last Modified time: 2017-03-31 17:25:34
7 */ 7 */
8 8
9 'use strict'; 9 'use strict';
@@ -29,7 +29,7 @@ const payCenter = (req, res, next) => { @@ -29,7 +29,7 @@ const payCenter = (req, res, next) => {
29 let orderCode = req.query.order_code; 29 let orderCode = req.query.order_code;
30 let uid = req.user.uid; 30 let uid = req.user.uid;
31 let sessionKey = req.session.TOKEN; 31 let sessionKey = req.session.TOKEN;
32 - let userAgent = req.get('User-Agent'); 32 + let userAgent = req.get('User-Agent') || '';
33 let hasWxShare = Boolean(userAgent.match(/MicroMessenger/i) && userAgent.match(/MicroMessenger/i).length > 0); 33 let hasWxShare = Boolean(userAgent.match(/MicroMessenger/i) && userAgent.match(/MicroMessenger/i).length > 0);
34 34
35 if (!orderCode || !uid) { 35 if (!orderCode || !uid) {
@@ -99,7 +99,7 @@ const getPageData = (gender, sortId, uid, udid, page, tag, authorId, isApp, show @@ -99,7 +99,7 @@ const getPageData = (gender, sortId, uid, udid, page, tag, authorId, isApp, show
99 return getArticleList(gender, sortId, uid, udid, page, tag, authorId).then(article => { 99 return getArticleList(gender, sortId, uid, udid, page, tag, authorId).then(article => {
100 let result = {}; 100 let result = {};
101 101
102 - if (!article.data.list.artList) { 102 + if (!_.get(article, 'data.list.artList', false)) {
103 return result; 103 return result;
104 } 104 }
105 105
@@ -27,8 +27,8 @@ exports.getUser = (req, res, next) => { @@ -27,8 +27,8 @@ exports.getUser = (req, res, next) => {
27 }; 27 };
28 28
29 detailModel.getUserProfile(uid).then((data) => { 29 detailModel.getUserProfile(uid).then((data) => {
30 - result.isStudent = data.data && data.data.vip_info && data.data.vip_info.is_student ? true : false;  
31 - result.vipLevel = (data.data && data.data.vip_info && data.data.vip_info.cur_level) || '0'; 30 + result.isStudent = _.get(data, 'data.vip_info.is_student', false);
  31 + result.vipLevel = _.get(data, 'data.vip_info.cur_level', '0');
32 req.__User__ = result; 32 req.__User__ = result;
33 next(); 33 next();
34 }).catch(next); 34 }).catch(next);