Authored by 刘传洋

comment

... ... @@ -27,10 +27,29 @@ exports.index = (req, res, next) => {
});
res.render('comment', localData);
// res.render('comment', {
//
// });
})
.catch(next);
};
exports.commentList4Order = (req, res, next) => {
let uid = req.user.uid;
let orderId = req.query.orderId;
commentModel.getCommentList4Order(uid, orderId)
.then(data => {
let result = _.merge({
module: 'home',
page: 'comment'
}, data);
res.render('comment', result);
})
.catch(next);
};
exports.saveComment = (req, res, next) => {
// only ajax
... ...
... ... @@ -99,6 +99,86 @@ exports.getCommentList = (uid, isComment, page, limit) => {
return co(process)();
};
exports.getCommentList4Order = (uid, orderId) => {
// limit = limit || 10;
const process = function*() {
let result = yield api.post('', {
method: 'web.show.queryOrderProductCommentList',
uid: uid,
orderId: orderId
});
let isComment = true;
let commentList = {
isComment: isComment,
goodsNum: 0,
orders: []
};
//let pagerObj = {};
// 接口返回成功, 处理数据
if (result.code === 200 && !_.isEmpty(result.data)) {
_.forEach(result.data, (value) => {
let order = {
orderNum: value.orderCode,
orderTime: value.createTime,
orderId: value.orderId,
goods: []
};
_.forEach(value.orderGoods, (v) => {
let cnAlphabet = v.cnAlphabet || '';
let good = {
href: helpers.getUrlBySkc(v.productId, v.goodsId, cnAlphabet),
thumb: imgUtils.getImageUrl(v.imageUrl, 100, 100),
name: v.productName || '',
productSkn: v.productSkn,
productId: v.productId,
goodsId: v.goodsId,
erpSkuId: v.erpSkuId
};
if (isComment === v.hasOwnProperty('comment')) {
if (isComment) {
good.remark = v.comment;
}
order.goods.push(good);
commentList.goodsNum++;
}
});
order.goods.length && commentList.orders.push(order);
});
//let total = commentList.orders.length;
// let totalPage = Math.ceil(total / limit);
// let begin = (page - 1) * limit;
// commentList.orders = commentList.orders.slice(begin, begin + limit); // [begin, begin+limit)
// pagerObj = pager(total, {
// isComment: isComment ? 'Y' : 'N'//,
// //page: page
// });
} else {
commentList.empty = isComment ? NO_COMMENTED_GOODS : NO_UNCOMMENT_GOODS; // 空数据 提示文字
}
return {
comment: commentList// ,
// pager: pagerObj
};
};
return co(process)();
};
exports.saveShareOrder = data => {
let process = function*() {
... ...
... ... @@ -126,6 +126,7 @@ router.get('/QRcode', [getCommonHeader, getHomeNav], personalController.QRcode);
// 我的评论
router.get('/comment', [getCommonHeader, getHomeNav], commentController.index);
router.post('/comment/saveComment', commentController.saveComment);
router.get('/comment/');
// 我的咨询
router.get('/consult', [getCommonHeader, getHomeNav], consultController.index);
... ...
... ... @@ -24,19 +24,18 @@
</div>
<p class="comment-table-header table-header clearfix">
<span class="info">商品信息</span>
<span class="time">评论</span>
<span class="type">状态/操作</span>
<span class="type">操作</span>
</p>
{{#if orders.length }}
<table class="comment-table">
{{#each orders}}
<tr>
<!--<tr>
<th colspan="4">
订单编号:{{orderNum}}
<span class="right">下单时间:{{orderTime}}</span>
</th>
</tr>
</tr>-->
{{#each goods}}
<tr>
<td width="115">
... ... @@ -44,22 +43,42 @@
</td>
<td>
<a href="{{href}}">{{name}}</a>
<span>下单时间{{../orderTime}}</span>
</td>
<td>
<button class="remark-btn">评价商品</button>
</td>
</tr>
<tr>
<td colspan="3" class="comment-add">
<div>* 商品满意度:</div>
div.
</td>
{{#if remark}}
<td class="remark-content">{{remark}}</td>
<td width="90"><span class="remarked">已评论!</span></td>
{{else}}
<td class="remark-content">您还没对这个商品进行评论!</td>
<td width="90">
<button class="remark-btn">我要评论</button>
<div data-orderid="{{../orderId}}" data-productskn="{{productSkn}}" data-productid="{{productId}}" data-goodsid="{{goodsId}}" data-erpskuid="{{erpSkuId}}"></div>
</td>
{{/if}}
</tr>
{{#each comments}}
<tr>
<td>购买评价:</td>
<td colspan="2">
<div class="comment-info">
<div class="comment-star">
</div>
<span>合适</span>
<span>身高:175厘米</span>
<span>体重:70公斤</span>
</div>
<p>阿斯顿发送到发送到发生大幅度发生大水电费</p>
<div class="img">
<img src="{{img}}" alt="">
</div>
<p>评论时间:2016-10-10 21:21:21</p>
</td>
</tr>
{{/each}}
{{/each}}
{{/each}}
</table>
{{#with ../pager}}
{{#with ../pager}}
{{> common/foot-pager footPager=this}}
{{/with}}
{{else}}
... ...