Authored by yyq

个人中心我的评论

@@ -5,8 +5,6 @@ @@ -5,8 +5,6 @@
5 5
6 'use strict'; 6 'use strict';
7 7
8 -  
9 -const cookie = global.yoho.cookie;  
10 const logger = global.yoho.logger; 8 const logger = global.yoho.logger;
11 const commentModel = require('../models/comment'); 9 const commentModel = require('../models/comment');
12 const _ = require('lodash'); 10 const _ = require('lodash');
@@ -14,7 +12,7 @@ const _ = require('lodash'); @@ -14,7 +12,7 @@ const _ = require('lodash');
14 12
15 // comment page 13 // comment page
16 exports.index = (req, res, next) => { 14 exports.index = (req, res, next) => {
17 - let uid = cookie.getUid(req); 15 + let uid = req.user.uid;
18 let isComment = req.query.isComment; 16 let isComment = req.query.isComment;
19 let page = req.query.page || 1; 17 let page = req.query.page || 1;
20 18
@@ -42,7 +40,7 @@ exports.saveComment = (req, res, next) => { @@ -42,7 +40,7 @@ exports.saveComment = (req, res, next) => {
42 40
43 // get post args 41 // get post args
44 let data = { 42 let data = {
45 - uid: cookie.getUid(req), 43 + uid: req.user.uid,
46 productSkn: req.body.productSkn, 44 productSkn: req.body.productSkn,
47 productId: req.body.productId, 45 productId: req.body.productId,
48 content: req.body.content, 46 content: req.body.content,
@@ -57,5 +55,6 @@ exports.saveComment = (req, res, next) => { @@ -57,5 +55,6 @@ exports.saveComment = (req, res, next) => {
57 }) 55 })
58 .catch(error => { 56 .catch(error => {
59 logger.error(`home--comment: ${error}`); 57 logger.error(`home--comment: ${error}`);
  58 + next();
60 }); 59 });
61 }; 60 };
@@ -61,12 +61,13 @@ exports.getCommentList = (uid, isComment, page, limit) => { @@ -61,12 +61,13 @@ exports.getCommentList = (uid, isComment, page, limit) => {
61 erpSkuId: v.erpSkuId 61 erpSkuId: v.erpSkuId
62 }; 62 };
63 63
64 - if (isComment && v.hasOwnPeroperty('comment')) { 64 + if (isComment === v.hasOwnProperty('comment')) {
  65 + if (isComment) {
65 good.remark = v.comment; 66 good.remark = v.comment;
66 } 67 }
67 -  
68 order.goods.push(good); 68 order.goods.push(good);
69 commentList.goodsNum++; 69 commentList.goodsNum++;
  70 + }
70 }); 71 });
71 72
72 order.goods.length && commentList.orders.push(order); 73 order.goods.length && commentList.orders.push(order);
@@ -103,7 +104,7 @@ exports.saveShareOrder = data => { @@ -103,7 +104,7 @@ exports.saveShareOrder = data => {
103 let process = function*() { 104 let process = function*() {
104 let res = api.post('', { 105 let res = api.post('', {
105 method: 'show.saveShareOrder', 106 method: 'show.saveShareOrder',
106 - data: data 107 + parameters: JSON.stringify(data)
107 }); 108 });
108 109
109 return res; 110 return res;
@@ -122,7 +122,7 @@ router.get('/QRcode', [getCommonHeader, getHomeNav], personalController.QRcode); @@ -122,7 +122,7 @@ router.get('/QRcode', [getCommonHeader, getHomeNav], personalController.QRcode);
122 122
123 123
124 // 我的评论 124 // 我的评论
125 -router.get('/comment', commentController.index); 125 +router.get('/comment', [getCommonHeader, getHomeNav], commentController.index);
126 router.post('/comment/saveComment', commentController.saveComment); 126 router.post('/comment/saveComment', commentController.saveComment);
127 127
128 // 我的咨询 128 // 我的咨询