Authored by yyq

consult

@@ -4,19 +4,17 @@ @@ -4,19 +4,17 @@
4 */ 4 */
5 'use strict'; 5 'use strict';
6 6
7 -const path = require('path');  
8 const Promise = require('bluebird'); 7 const Promise = require('bluebird');
9 const moment = require('moment'); 8 const moment = require('moment');
10 const _ = require('lodash'); 9 const _ = require('lodash');
11 -const imgUtils = require(path.join(global.utils, 'images')); 10 +
12 const api = global.yoho.API; 11 const api = global.yoho.API;
13 -const searchApi = global.yoho.SearchAPI;  
14 const helpers = global.yoho.helpers; 12 const helpers = global.yoho.helpers;
15 const co = Promise.coroutine; 13 const co = Promise.coroutine;
16 14
17 // 分页 函数 15 // 分页 函数
18 -const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler.js');  
19 -const pager = require(pagerPath).handlePagerData; 16 +const pager = require(`${global.utils}/pager`).setPager;
  17 +const imgUtils = require(`${global.utils}/images`);
20 18
21 19
22 const NO_CONSULT = '您尚未咨询任何内容'; 20 const NO_CONSULT = '您尚未咨询任何内容';
@@ -27,12 +25,13 @@ const NO_CONSULT = '您尚未咨询任何内容'; @@ -27,12 +25,13 @@ const NO_CONSULT = '您尚未咨询任何内容';
27 * @return array 25 * @return array
28 */ 26 */
29 function getProductGoodsInfo(skns) { 27 function getProductGoodsInfo(skns) {
30 - const query = skns.join(','); 28 + const query = _.join(_.uniq(skns), ',');
31 29
32 - return searchApi.get('/search.json', {  
33 - data: {  
34 - query: query  
35 - } 30 + return api.get('', {
  31 + method: 'h5.product.batch',
  32 + limit: skns.length,
  33 + productSkn: query,
  34 + contain_all: 'Y'
36 }).then(result => { 35 }).then(result => {
37 let resData = {}; 36 let resData = {};
38 37
@@ -84,20 +83,18 @@ exports.consultList = (uid, page, limit) => { @@ -84,20 +83,18 @@ exports.consultList = (uid, page, limit) => {
84 let goodInfos = yield getProductGoodsInfo(skns); 83 let goodInfos = yield getProductGoodsInfo(skns);
85 84
86 origin.consult_list.forEach(consult => { 85 origin.consult_list.forEach(consult => {
87 - let goodInfo = goodInfos[consult.skn];  
88 -  
89 - if (!goodInfo) {  
90 - return;  
91 - }  
92 -  
93 let info = { 86 let info = {
94 - href: helpers.getUrlBySkc(goodInfo.productId, goodInfo.goodsId, goodInfo.cn_alphabet),  
95 - thumb: imgUtils.getImageUrl(goodInfo.images_url, 60, 60, 1), 87 + href: helpers.getUrlBySkc(consult.productId),
96 name: consult.productName, 88 name: consult.productName,
97 question: consult.ask || '', 89 question: consult.ask || '',
98 - consultTime: moment(consult.askTime).format('YYYY-MM-DD H:m:s') 90 + consultTime: moment(consult.askTime * 1000).format('YYYY-MM-DD HH:mm:ss')
99 }; 91 };
100 92
  93 + let goodInfo = goodInfos[consult.skn];
  94 +
  95 + if (goodInfo) {
  96 + info.thumb = imgUtils.getImageUrl(goodInfo.images_url, 60, 60, 1);
  97 + }
101 98
102 if (consult.answer) { 99 if (consult.answer) {
103 info.reply = consult.answer; 100 info.reply = consult.answer;
@@ -106,11 +103,11 @@ exports.consultList = (uid, page, limit) => { @@ -106,11 +103,11 @@ exports.consultList = (uid, page, limit) => {
106 result.consults.push(info); 103 result.consults.push(info);
107 }); 104 });
108 105
109 - result.pager = pager(origin.total, {  
110 - page: origin.page,  
111 - limit: limit  
112 - });  
113 - 106 + result.pager = Object.assign({
  107 + count: origin.total,
  108 + curPage: page,
  109 + totalPages: origin.page_total
  110 + }, pager(origin.page_total, {page: page}));
114 } 111 }
115 if (!result.consults.length) { 112 if (!result.consults.length) {
116 result.empty = NO_CONSULT; 113 result.empty = NO_CONSULT;
@@ -119,6 +116,5 @@ exports.consultList = (uid, page, limit) => { @@ -119,6 +116,5 @@ exports.consultList = (uid, page, limit) => {
119 return result; 116 return result;
120 }); 117 });
121 118
122 -  
123 return fetchConsults(data).then(processData); 119 return fetchConsults(data).then(processData);
124 }; 120 };
@@ -13,7 +13,7 @@ const tabsMiddleware = require(`${cRoot}/general-tabs`); @@ -13,7 +13,7 @@ const tabsMiddleware = require(`${cRoot}/general-tabs`);
13 const indexController = require(`${cRoot}/index`); 13 const indexController = require(`${cRoot}/index`);
14 const commentController = require(`${cRoot}/comment`); 14 const commentController = require(`${cRoot}/comment`);
15 15
16 -// const consultController = require(`${cRoot}/consult`); 16 +const consultController = require(`${cRoot}/consult`);
17 // const complaintsController = require(`${cRoot}/complaints`); 17 // const complaintsController = require(`${cRoot}/complaints`);
18 const messageController = require(`${cRoot}/message`); 18 const messageController = require(`${cRoot}/message`);
19 19
@@ -53,7 +53,7 @@ router.post('/comment/saveComment', commentController.saveComment); @@ -53,7 +53,7 @@ router.post('/comment/saveComment', commentController.saveComment);
53 router.get('/comment/order', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], commentController.commentList4Order); 53 router.get('/comment/order', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], commentController.commentList4Order);
54 54
55 // 我的咨询 55 // 我的咨询
56 -// router.get('/consult', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], consultController.index); 56 +router.get('/consult', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], consultController.index);
57 57
58 // 我的投诉 58 // 我的投诉
59 // router.get('/complaints', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], complaintsController.index); 59 // router.get('/complaints', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], complaintsController.index);
@@ -31,12 +31,12 @@ @@ -31,12 +31,12 @@
31 </tr> 31 </tr>
32 {{/each}} 32 {{/each}}
33 </table> 33 </table>
34 - {{> common/foot-pager footPager=pager}}  
35 </div> 34 </div>
36 {{else}} 35 {{else}}
37 {{> empty }} 36 {{> empty }}
38 {{/if}} 37 {{/if}}
39 </div> 38 </div>
  39 + {{> pager}}
40 </div> 40 </div>
41 {{> help-us}} 41 {{> help-us}}
42 </div> 42 </div>
@@ -92,7 +92,7 @@ @@ -92,7 +92,7 @@
92 {{> pager}} 92 {{> pager}}
93 {{^}} 93 {{^}}
94 {{#with unUseCoupons}} 94 {{#with unUseCoupons}}
95 - {{> home/orders/empty}} 95 + {{> empty}}
96 {{/with}} 96 {{/with}}
97 {{/unless}} 97 {{/unless}}
98 {{/if}} 98 {{/if}}
@@ -102,7 +102,7 @@ @@ -102,7 +102,7 @@
102 {{> pager}} 102 {{> pager}}
103 {{^}} 103 {{^}}
104 {{#with usedCoupons}} 104 {{#with usedCoupons}}
105 - {{> home/orders/empty}} 105 + {{> empty}}
106 {{/with}} 106 {{/with}}
107 {{/unless}} 107 {{/unless}}
108 {{/if}} 108 {{/if}}
@@ -112,7 +112,7 @@ @@ -112,7 +112,7 @@
112 {{> pager}} 112 {{> pager}}
113 {{^}} 113 {{^}}
114 {{#with noValidCoupons}} 114 {{#with noValidCoupons}}
115 - {{> home/orders/empty}} 115 + {{> empty}}
116 {{/with}} 116 {{/with}}
117 {{/unless}} 117 {{/unless}}
118 {{/if}} 118 {{/if}}
1 -<p class="empty-tip">{{empty}}</p>  
  1 +<p class="empty-tip">{{empty}}</p>
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <div class="favorite-articles"> 2 <div class="favorite-articles">
3 {{#if articles.empty}} 3 {{#if articles.empty}}
4 {{#with articles}} 4 {{#with articles}}
5 - {{> home/orders/empty}} 5 + {{> empty}}
6 {{/with}} 6 {{/with}}
7 {{^}} 7 {{^}}
8 <ul> 8 <ul>
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 9
10 {{#if brands.empty}} 10 {{#if brands.empty}}
11 {{#with brands}} 11 {{#with brands}}
12 - {{> home/orders/empty}} 12 + {{> empty}}
13 {{/with}} 13 {{/with}}
14 {{^}} 14 {{^}}
15 <ul> 15 <ul>
@@ -60,7 +60,7 @@ @@ -60,7 +60,7 @@
60 60
61 {{#if goods.empty}} 61 {{#if goods.empty}}
62 {{#with goods}} 62 {{#with goods}}
63 - {{> home/orders/empty}} 63 + {{> empty}}
64 {{/with}} 64 {{/with}}
65 {{^}} 65 {{^}}
66 {{> favorite/product-table}} 66 {{> favorite/product-table}}
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 10
11 {{#if orders.empty}} 11 {{#if orders.empty}}
12 {{#with orders}} 12 {{#with orders}}
13 - {{> home/orders/empty}} 13 + {{> empty}}
14 {{/with}} 14 {{/with}}
15 {{^}} 15 {{^}}
16 {{# orders.list}} 16 {{# 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