Authored by htoooth

refactor consult

/**
* Created by TaoHuang on 2016/6/14.
*/
'use strict';
const Promise = require('bluebird');
const co = Promise.coroutine;
const api = require('./detail-consult-api');
const detailHelper = require('./detail-helper');
module.exports.indexAsync = (uid, pid, page, size) => {
return co(function *() {
let consultList = yield api.indexAsync(uid, pid, page, size);
if (consultList.code && consultList.code === 200) {
return consultList.data.list.map(value => {
return {
avatar: detailHelper.DEFAULT_AVATAR_ICO,
question: value.ask,
date: value.ask_time,
answer: value.answer,
id: value.id,
isLike: value.is_like === 'Y',
like: parseInt(value.like, 10),
isUseful: value.is_useful === 'Y',
useful: parseInt(value.useful, 10),
total: value.total
};
});
}
return [];
})();
};
module.exports.createAsync = api.createAsync;
... ...
... ... @@ -15,8 +15,8 @@ const library = '../../../library';
const helpers = require(`${library}/helpers`);
const productAPI = require('./detail-product-api');
const consultAPI = require('./detail-consult-api');
const consultService = require('./detail-consult-service');
const commentService = require('./detail-comment-service');
const hotAreaService = require('./detail-hotarea-service');
const brandService = require('./brand-service');
... ... @@ -30,9 +30,6 @@ const HeaderModel = require('../../../doraemon/models/header');
const BLANK_STR = ' ';
// 商品详情页的默认头像
const DEFAULT_AVATAR_ICO = 'http://static.yohobuy.com/images/v3/boy.jpg';
const multiResourcesUrl = {};
const setMultiResourceByProductBaseInfo = (data) => {
return co(function * () {
... ... @@ -1335,35 +1332,12 @@ module.exports.indexCommentAsync = commentService.indexAsync;
/**
* 获取咨询列表
*/
module.exports.indexConsultAsync = (uid, pid, page, size) => {
return co(function *() {
let consultList = yield consultAPI.indexAsync(uid, pid, page, size);
if (consultList.code && consultList.code === 200) {
return consultList.data.list.map(value => {
return {
avatar: DEFAULT_AVATAR_ICO,
question: value.ask,
date: value.ask_time,
answer: value.answer,
id: value.id,
isLike: value.is_like === 'Y',
like: parseInt(value.like, 10),
isUseful: value.is_useful === 'Y',
useful: parseInt(value.useful, 10),
total: value.total
};
});
}
return [];
})();
};
module.exports.indexConsultAsync = consultService.indexAsync;
/**
* 添加咨询
*/
module.exports.createConsultAsync = consultAPI.createAsync;
module.exports.createConsultAsync = consultService.createAsync;
/**
* 获取某一个商品详情主页面
... ...