Authored by yyq

consult

... ... @@ -4,19 +4,17 @@
*/
'use strict';
const path = require('path');
const Promise = require('bluebird');
const moment = require('moment');
const _ = require('lodash');
const imgUtils = require(path.join(global.utils, 'images'));
const api = global.yoho.API;
const searchApi = global.yoho.SearchAPI;
const helpers = global.yoho.helpers;
const co = Promise.coroutine;
// 分页 函数
const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler.js');
const pager = require(pagerPath).handlePagerData;
const pager = require(`${global.utils}/pager`).setPager;
const imgUtils = require(`${global.utils}/images`);
const NO_CONSULT = '您尚未咨询任何内容';
... ... @@ -27,12 +25,13 @@ const NO_CONSULT = '您尚未咨询任何内容';
* @return array
*/
function getProductGoodsInfo(skns) {
const query = skns.join(',');
const query = _.join(_.uniq(skns), ',');
return searchApi.get('/search.json', {
data: {
query: query
}
return api.get('', {
method: 'h5.product.batch',
limit: skns.length,
productSkn: query,
contain_all: 'Y'
}).then(result => {
let resData = {};
... ... @@ -84,20 +83,18 @@ exports.consultList = (uid, page, limit) => {
let goodInfos = yield getProductGoodsInfo(skns);
origin.consult_list.forEach(consult => {
let goodInfo = goodInfos[consult.skn];
if (!goodInfo) {
return;
}
let info = {
href: helpers.getUrlBySkc(goodInfo.productId, goodInfo.goodsId, goodInfo.cn_alphabet),
thumb: imgUtils.getImageUrl(goodInfo.images_url, 60, 60, 1),
href: helpers.getUrlBySkc(consult.productId),
name: consult.productName,
question: consult.ask || '',
consultTime: moment(consult.askTime).format('YYYY-MM-DD H:m:s')
consultTime: moment(consult.askTime * 1000).format('YYYY-MM-DD HH:mm:ss')
};
let goodInfo = goodInfos[consult.skn];
if (goodInfo) {
info.thumb = imgUtils.getImageUrl(goodInfo.images_url, 60, 60, 1);
}
if (consult.answer) {
info.reply = consult.answer;
... ... @@ -106,11 +103,11 @@ exports.consultList = (uid, page, limit) => {
result.consults.push(info);
});
result.pager = pager(origin.total, {
page: origin.page,
limit: limit
});
result.pager = Object.assign({
count: origin.total,
curPage: page,
totalPages: origin.page_total
}, pager(origin.page_total, {page: page}));
}
if (!result.consults.length) {
result.empty = NO_CONSULT;
... ... @@ -119,6 +116,5 @@ exports.consultList = (uid, page, limit) => {
return result;
});
return fetchConsults(data).then(processData);
};
... ...
... ... @@ -13,7 +13,7 @@ const tabsMiddleware = require(`${cRoot}/general-tabs`);
const indexController = require(`${cRoot}/index`);
const commentController = require(`${cRoot}/comment`);
// const consultController = require(`${cRoot}/consult`);
const consultController = require(`${cRoot}/consult`);
// const complaintsController = require(`${cRoot}/complaints`);
const messageController = require(`${cRoot}/message`);
... ... @@ -53,7 +53,7 @@ router.post('/comment/saveComment', commentController.saveComment);
router.get('/comment/order', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], commentController.commentList4Order);
// 我的咨询
// router.get('/consult', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], consultController.index);
router.get('/consult', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], consultController.index);
// 我的投诉
// router.get('/complaints', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], complaintsController.index);
... ...
... ... @@ -31,12 +31,12 @@
</tr>
{{/each}}
</table>
{{> common/foot-pager footPager=pager}}
</div>
{{else}}
{{> empty }}
{{/if}}
</div>
{{> pager}}
</div>
{{> help-us}}
</div>
... ...
... ... @@ -92,7 +92,7 @@
{{> pager}}
{{^}}
{{#with unUseCoupons}}
{{> home/orders/empty}}
{{> empty}}
{{/with}}
{{/unless}}
{{/if}}
... ... @@ -102,7 +102,7 @@
{{> pager}}
{{^}}
{{#with usedCoupons}}
{{> home/orders/empty}}
{{> empty}}
{{/with}}
{{/unless}}
{{/if}}
... ... @@ -112,7 +112,7 @@
{{> pager}}
{{^}}
{{#with noValidCoupons}}
{{> home/orders/empty}}
{{> empty}}
{{/with}}
{{/unless}}
{{/if}}
... ...
... ... @@ -2,7 +2,7 @@
<div class="favorite-articles">
{{#if articles.empty}}
{{#with articles}}
{{> home/orders/empty}}
{{> empty}}
{{/with}}
{{^}}
<ul>
... ...
... ... @@ -9,7 +9,7 @@
{{#if brands.empty}}
{{#with brands}}
{{> home/orders/empty}}
{{> empty}}
{{/with}}
{{^}}
<ul>
... ...
... ... @@ -60,7 +60,7 @@
{{#if goods.empty}}
{{#with goods}}
{{> home/orders/empty}}
{{> empty}}
{{/with}}
{{^}}
{{> favorite/product-table}}
... ...
... ... @@ -10,7 +10,7 @@
{{#if orders.empty}}
{{#with orders}}
{{> home/orders/empty}}
{{> empty}}
{{/with}}
{{^}}
{{# orders.list}}
... ...

608 Bytes | W: | H:

42.6 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

13.9 KB | W: | H:

11.4 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin