Authored by 刘传洋

comment

@@ -27,10 +27,29 @@ exports.index = (req, res, next) => { @@ -27,10 +27,29 @@ exports.index = (req, res, next) => {
27 }); 27 });
28 28
29 res.render('comment', localData); 29 res.render('comment', localData);
  30 +
  31 + // res.render('comment', {
  32 + //
  33 + // });
30 }) 34 })
31 .catch(next); 35 .catch(next);
32 }; 36 };
33 37
  38 +exports.commentList4Order = (req, res, next) => {
  39 + let uid = req.user.uid;
  40 + let orderId = req.query.orderId;
  41 +
  42 + commentModel.getCommentList4Order(uid, orderId)
  43 + .then(data => {
  44 + let result = _.merge({
  45 + module: 'home',
  46 + page: 'comment'
  47 + }, data);
  48 +
  49 + res.render('comment', result);
  50 + })
  51 + .catch(next);
  52 +};
34 53
35 exports.saveComment = (req, res, next) => { 54 exports.saveComment = (req, res, next) => {
36 // only ajax 55 // only ajax
@@ -99,6 +99,86 @@ exports.getCommentList = (uid, isComment, page, limit) => { @@ -99,6 +99,86 @@ exports.getCommentList = (uid, isComment, page, limit) => {
99 return co(process)(); 99 return co(process)();
100 }; 100 };
101 101
  102 +exports.getCommentList4Order = (uid, orderId) => {
  103 +
  104 + // limit = limit || 10;
  105 +
  106 + const process = function*() {
  107 +
  108 + let result = yield api.post('', {
  109 + method: 'web.show.queryOrderProductCommentList',
  110 + uid: uid,
  111 + orderId: orderId
  112 + });
  113 +
  114 + let isComment = true;
  115 +
  116 + let commentList = {
  117 + isComment: isComment,
  118 + goodsNum: 0,
  119 + orders: []
  120 + };
  121 + //let pagerObj = {};
  122 +
  123 + // 接口返回成功, 处理数据
  124 + if (result.code === 200 && !_.isEmpty(result.data)) {
  125 + _.forEach(result.data, (value) => {
  126 +
  127 + let order = {
  128 + orderNum: value.orderCode,
  129 + orderTime: value.createTime,
  130 + orderId: value.orderId,
  131 + goods: []
  132 + };
  133 +
  134 + _.forEach(value.orderGoods, (v) => {
  135 + let cnAlphabet = v.cnAlphabet || '';
  136 + let good = {
  137 + href: helpers.getUrlBySkc(v.productId, v.goodsId, cnAlphabet),
  138 + thumb: imgUtils.getImageUrl(v.imageUrl, 100, 100),
  139 + name: v.productName || '',
  140 + productSkn: v.productSkn,
  141 + productId: v.productId,
  142 + goodsId: v.goodsId,
  143 + erpSkuId: v.erpSkuId
  144 + };
  145 +
  146 + if (isComment === v.hasOwnProperty('comment')) {
  147 + if (isComment) {
  148 + good.remark = v.comment;
  149 + }
  150 + order.goods.push(good);
  151 + commentList.goodsNum++;
  152 + }
  153 + });
  154 +
  155 + order.goods.length && commentList.orders.push(order);
  156 + });
  157 +
  158 +
  159 + //let total = commentList.orders.length;
  160 +
  161 + // let totalPage = Math.ceil(total / limit);
  162 + // let begin = (page - 1) * limit;
  163 +
  164 + // commentList.orders = commentList.orders.slice(begin, begin + limit); // [begin, begin+limit)
  165 +
  166 + // pagerObj = pager(total, {
  167 + // isComment: isComment ? 'Y' : 'N'//,
  168 + // //page: page
  169 + // });
  170 + } else {
  171 + commentList.empty = isComment ? NO_COMMENTED_GOODS : NO_UNCOMMENT_GOODS; // 空数据 提示文字
  172 + }
  173 +
  174 + return {
  175 + comment: commentList// ,
  176 + // pager: pagerObj
  177 + };
  178 + };
  179 +
  180 + return co(process)();
  181 +};
102 182
103 exports.saveShareOrder = data => { 183 exports.saveShareOrder = data => {
104 let process = function*() { 184 let process = function*() {
@@ -126,6 +126,7 @@ router.get('/QRcode', [getCommonHeader, getHomeNav], personalController.QRcode); @@ -126,6 +126,7 @@ router.get('/QRcode', [getCommonHeader, getHomeNav], personalController.QRcode);
126 // 我的评论 126 // 我的评论
127 router.get('/comment', [getCommonHeader, getHomeNav], commentController.index); 127 router.get('/comment', [getCommonHeader, getHomeNav], commentController.index);
128 router.post('/comment/saveComment', commentController.saveComment); 128 router.post('/comment/saveComment', commentController.saveComment);
  129 +router.get('/comment/');
129 130
130 // 我的咨询 131 // 我的咨询
131 router.get('/consult', [getCommonHeader, getHomeNav], consultController.index); 132 router.get('/consult', [getCommonHeader, getHomeNav], consultController.index);
@@ -24,19 +24,18 @@ @@ -24,19 +24,18 @@
24 </div> 24 </div>
25 <p class="comment-table-header table-header clearfix"> 25 <p class="comment-table-header table-header clearfix">
26 <span class="info">商品信息</span> 26 <span class="info">商品信息</span>
27 - <span class="time">评论</span>  
28 - <span class="type">状态/操作</span> 27 + <span class="type">操作</span>
29 </p> 28 </p>
30 29
31 {{#if orders.length }} 30 {{#if orders.length }}
32 <table class="comment-table"> 31 <table class="comment-table">
33 {{#each orders}} 32 {{#each orders}}
34 - <tr> 33 + <!--<tr>
35 <th colspan="4"> 34 <th colspan="4">
36 订单编号:{{orderNum}} 35 订单编号:{{orderNum}}
37 <span class="right">下单时间:{{orderTime}}</span> 36 <span class="right">下单时间:{{orderTime}}</span>
38 </th> 37 </th>
39 - </tr> 38 + </tr>-->
40 {{#each goods}} 39 {{#each goods}}
41 <tr> 40 <tr>
42 <td width="115"> 41 <td width="115">
@@ -44,18 +43,38 @@ @@ -44,18 +43,38 @@
44 </td> 43 </td>
45 <td> 44 <td>
46 <a href="{{href}}">{{name}}</a> 45 <a href="{{href}}">{{name}}</a>
  46 + <span>下单时间{{../orderTime}}</span>
47 </td> 47 </td>
48 - {{#if remark}}  
49 - <td class="remark-content">{{remark}}</td>  
50 - <td width="90"><span class="remarked">已评论!</span></td>  
51 - {{else}}  
52 - <td class="remark-content">您还没对这个商品进行评论!</td>  
53 - <td width="90">  
54 - <button class="remark-btn">我要评论</button>  
55 - <div data-orderid="{{../orderId}}" data-productskn="{{productSkn}}" data-productid="{{productId}}" data-goodsid="{{goodsId}}" data-erpskuid="{{erpSkuId}}"></div> 48 + <td>
  49 + <button class="remark-btn">评价商品</button>
  50 + </td>
  51 + </tr>
  52 + <tr>
  53 + <td colspan="3" class="comment-add">
  54 + <div>* 商品满意度:</div>
  55 + div.
56 </td> 56 </td>
57 - {{/if}}  
58 </tr> 57 </tr>
  58 + {{#each comments}}
  59 + <tr>
  60 + <td>购买评价:</td>
  61 + <td colspan="2">
  62 + <div class="comment-info">
  63 + <div class="comment-star">
  64 +
  65 + </div>
  66 + <span>合适</span>
  67 + <span>身高:175厘米</span>
  68 + <span>体重:70公斤</span>
  69 + </div>
  70 + <p>阿斯顿发送到发送到发生大幅度发生大水电费</p>
  71 + <div class="img">
  72 + <img src="{{img}}" alt="">
  73 + </div>
  74 + <p>评论时间:2016-10-10 21:21:21</p>
  75 + </td>
  76 + </tr>
  77 + {{/each}}
59 {{/each}} 78 {{/each}}
60 {{/each}} 79 {{/each}}
61 </table> 80 </table>