Showing
5 changed files
with
82 additions
and
9 deletions
@@ -48,7 +48,7 @@ function getGenderByCookie(req) { | @@ -48,7 +48,7 @@ function getGenderByCookie(req) { | ||
48 | return gender; | 48 | return gender; |
49 | } | 49 | } |
50 | 50 | ||
51 | -module.exports.show= (req, res, next) => { | 51 | +module.exports.show = (req, res, next) => { |
52 | // TODO: 需要修改为正式取 UID 的方式 | 52 | // TODO: 需要修改为正式取 UID 的方式 |
53 | // TODO: vipLevel = 0; // 用户等级 | 53 | // TODO: vipLevel = 0; // 用户等级 |
54 | 54 | ||
@@ -69,7 +69,7 @@ module.exports.show= (req, res, next) => { | @@ -69,7 +69,7 @@ module.exports.show= (req, res, next) => { | ||
69 | ua: req.get('user-agent') || '', | 69 | ua: req.get('user-agent') || '', |
70 | channel: channel, | 70 | channel: channel, |
71 | gender: gender, | 71 | gender: gender, |
72 | - uid: 0, | 72 | + uid: '', |
73 | vipLevel: 0 | 73 | vipLevel: 0 |
74 | }).then((result) => { | 74 | }).then((result) => { |
75 | res.render('detail', Object.assign({ | 75 | res.render('detail', Object.assign({ |
@@ -78,6 +78,7 @@ module.exports.show= (req, res, next) => { | @@ -78,6 +78,7 @@ module.exports.show= (req, res, next) => { | ||
78 | }, result)); | 78 | }, result)); |
79 | }).catch(next); | 79 | }).catch(next); |
80 | }; | 80 | }; |
81 | +/**/ | ||
81 | 82 | ||
82 | /** | 83 | /** |
83 | * 获得评论 | 84 | * 获得评论 |
@@ -94,3 +95,15 @@ module.exports.comments = (req, res, next) => { | @@ -94,3 +95,15 @@ module.exports.comments = (req, res, next) => { | ||
94 | res.json(result) | 95 | res.json(result) |
95 | }).catch(next); | 96 | }).catch(next); |
96 | } | 97 | } |
98 | + | ||
99 | +module.exports.consults = (req, res, next) => { | ||
100 | + // TODO: uid | ||
101 | + let uid = ''; | ||
102 | + let pid = req.params.productId || 0; | ||
103 | + let page = req.params.page || 1; | ||
104 | + let size = req.params.size || 10; | ||
105 | + | ||
106 | + detail.getConsultsAsync(uid, pid, page, size).then(result => { | ||
107 | + res.json(result); | ||
108 | + }).catch(next); | ||
109 | +} |
@@ -43,6 +43,18 @@ module.exports.getProductModelTryAsync = function (skn) { | @@ -43,6 +43,18 @@ module.exports.getProductModelTryAsync = function (skn) { | ||
43 | }; | 43 | }; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | + * 获得产品信息 | ||
47 | + * @param pid | ||
48 | + * @returns {Promise.<type>} | ||
49 | + */ | ||
50 | +module.exports.getProductInfo = function (pid) { | ||
51 | + return api.get('', sign.api.Sign({ | ||
52 | + method: 'h5.product.data', | ||
53 | + productId: data.id | ||
54 | + })).catch(console.log); | ||
55 | +}; | ||
56 | + | ||
57 | +/** | ||
46 | * 获取评论 | 58 | * 获取评论 |
47 | */ | 59 | */ |
48 | module.exports.getCommentsAsync = function (pid, page, size) { | 60 | module.exports.getCommentsAsync = function (pid, page, size) { |
@@ -52,5 +64,28 @@ module.exports.getCommentsAsync = function (pid, page, size) { | @@ -52,5 +64,28 @@ module.exports.getCommentsAsync = function (pid, page, size) { | ||
52 | page: page, | 64 | page: page, |
53 | limit: size | 65 | limit: size |
54 | })).catch(console.log); | 66 | })).catch(console.log); |
55 | -} | 67 | +}; |
68 | + | ||
69 | +/** | ||
70 | + * 咨询内容列表 | ||
71 | + * @param uid | ||
72 | + * @param pid | ||
73 | + * @param page | ||
74 | + * @param size | ||
75 | + * @returns {Promise.<type>} | ||
76 | + */ | ||
77 | +module.exports.getConsultsAsync = function (uid, pid, page, size) { | ||
78 | + let param = {}; | ||
79 | + param.method = 'app.consult.li'; | ||
80 | + param.product_id = pid; | ||
81 | + | ||
82 | + if (!uid) { | ||
83 | + param.uid = uid; | ||
84 | + } | ||
85 | + | ||
86 | + param.page = page; | ||
87 | + param.limit = size; | ||
88 | + | ||
89 | + return api.get('', sign.apiSign(param)).catch(console.log); | ||
90 | +}; | ||
56 | 91 |
@@ -1370,17 +1370,41 @@ module.exports.getCommentsAsync = (pid, page, size) => { | @@ -1370,17 +1370,41 @@ module.exports.getCommentsAsync = (pid, page, size) => { | ||
1370 | 1370 | ||
1371 | return []; | 1371 | return []; |
1372 | })(); | 1372 | })(); |
1373 | -} | 1373 | +}; |
1374 | + | ||
1375 | +/** | ||
1376 | + * 获取咨询列表 | ||
1377 | + */ | ||
1378 | +module.exports.getConsultsAsync = (uid, pid, page, size) => { | ||
1379 | + return co(function *() { | ||
1380 | + let consultList = yield detailAPI.getConsultsAsync(uid, pdi, page, size); | ||
1381 | + if (consultList.code && consultList.code === 200) { | ||
1382 | + return consultList.data.list.map(value => { | ||
1383 | + return { | ||
1384 | + avatar: DEFAULT_AVATAR_ICO, | ||
1385 | + question: value.ask, | ||
1386 | + date: value.ask_time, | ||
1387 | + answer: value.answer, | ||
1388 | + id: value.id, | ||
1389 | + isLike: value.is_like === 'Y', | ||
1390 | + like: parseInt(value.like, 10), | ||
1391 | + isUseful: value.is_useful === 'Y', | ||
1392 | + useful: parseInt(value.useful, 10), | ||
1393 | + total: value.total | ||
1394 | + } | ||
1395 | + }); | ||
1396 | + } | ||
1397 | + | ||
1398 | + return [] | ||
1399 | + })(); | ||
1400 | +}; | ||
1374 | 1401 | ||
1375 | module.exports.showAsync = (data) => { | 1402 | module.exports.showAsync = (data) => { |
1376 | 1403 | ||
1377 | return co(function * () { | 1404 | return co(function * () { |
1378 | 1405 | ||
1379 | // 获取商品信息 | 1406 | // 获取商品信息 |
1380 | - let productInfo = yield api.get('', sign.apiSign({ | ||
1381 | - productId: data.id, | ||
1382 | - method: 'h5.product.data' | ||
1383 | - })); | 1407 | + let productInfo = yield detailAPI.getProductInfo(data.id); |
1384 | 1408 | ||
1385 | productInfo = yield detailDataPkg(productInfo, data.uid, data.vipLevel, data.ua); | 1409 | productInfo = yield detailDataPkg(productInfo, data.uid, data.vipLevel, data.ua); |
1386 | 1410 |
@@ -34,5 +34,6 @@ router.get('/outlets/:channel', outlets.channel); | @@ -34,5 +34,6 @@ router.get('/outlets/:channel', outlets.channel); | ||
34 | // 商品详情routers | 34 | // 商品详情routers |
35 | router.get('/detail/:id/:gid', detail.show); | 35 | router.get('/detail/:id/:gid', detail.show); |
36 | router.get('/detail/comments', detail.comments); | 36 | router.get('/detail/comments', detail.comments); |
37 | +router.get('/detail/consults', detail.consults); | ||
37 | 38 | ||
38 | module.exports = router; | 39 | module.exports = router; |
@@ -575,7 +575,7 @@ lazyLoad($('#details-html img')); | @@ -575,7 +575,7 @@ lazyLoad($('#details-html img')); | ||
575 | 575 | ||
576 | $.ajax({ | 576 | $.ajax({ |
577 | type: 'GET', | 577 | type: 'GET', |
578 | - url: '/product/item/consults', | 578 | + url: '/product/detail/consults', |
579 | data: { | 579 | data: { |
580 | productId: id, | 580 | productId: id, |
581 | page: consultPage | 581 | page: consultPage |
-
Please register or login to post a comment