/** * Created by TaoHuang on 2016/6/14. */ 'use strict'; const Promise = require('bluebird'); const co = Promise.coroutine; const _ = require('lodash'); const helpers = global.yoho.helpers; const api = require('./detail-comment-api'); const detailHelper = require('./detail-helper'); const indexAsync = (pid, page, size) => { return co(function *() { let commentList = yield api.indexAsync(pid, page, size); if (!(commentList.code && commentList.code === 200)) { return []; } return commentList.data.map(value => { let item = {}; let avatar = detailHelper.DEFAULT_AVATAR_ICO; if (value.head_ico) { avatar = `${_.last(value.head_ico.split('headimg'))}`; avatar = helpers.image(avatar, 30, 30); } item.avatar = avatar; item.userName = value.nickname; item.color = value.color_name; item.size = value.size_name; item.comment = value.content || ''; item.date = value.create_time; item.total = value.total; return item; }); })(); }; /** * 获取订单评论 * * @param pid * @param page * @param size */ const getShareOrderListAsync = (pid, page, size) => { return api.getShareOrderListAsync(pid, page, size); }; module.exports = { indexAsync, getShareOrderListAsync };