Showing
4 changed files
with
56 additions
and
34 deletions
@@ -2,6 +2,8 @@ | @@ -2,6 +2,8 @@ | ||
2 | * Created by TaoHuang on 2016/6/13. | 2 | * Created by TaoHuang on 2016/6/13. |
3 | */ | 3 | */ |
4 | 4 | ||
5 | +'use strict'; | ||
6 | + | ||
5 | const library = '../../../library'; | 7 | const library = '../../../library'; |
6 | const API = require(`${library}/api`).API; | 8 | const API = require(`${library}/api`).API; |
7 | const sign = require(`${library}/sign`); | 9 | const sign = require(`${library}/sign`); |
1 | +/** | ||
2 | + * Created by TaoHuang on 2016/6/14. | ||
3 | + */ | ||
4 | + | ||
5 | +'use strict'; | ||
6 | + | ||
7 | +const Promise = require('bluebird'); | ||
8 | +const co = Promise.coroutine; | ||
9 | +const _ = require('lodash'); | ||
10 | + | ||
11 | +const library = '../../../library'; | ||
12 | +const helpers = require(`${library}/helpers`); | ||
13 | + | ||
14 | +const api = require('./detail-comment-api'); | ||
15 | + | ||
16 | +const detailHelper = require('./detail-helper'); | ||
17 | + | ||
18 | +module.exports.indexAsync = (pid, page, size) => { | ||
19 | + return co(function *() { | ||
20 | + let commentList = yield api.indexAsync(pid, page, size); | ||
21 | + | ||
22 | + if (commentList.code && commentList.code === 200) { | ||
23 | + return commentList.data.map(value => { | ||
24 | + let item = {}; | ||
25 | + | ||
26 | + let avatar = detailHelper.DEFAULT_AVATAR_ICO; | ||
27 | + | ||
28 | + if (value.head_ico) { | ||
29 | + avatar = `${detailHelper.IMAGE_SERVICE_URL}${_.last(value.head_ico.split('headimg'))}`; | ||
30 | + avatar = helpers.image(avatar, 30, 30); | ||
31 | + } | ||
32 | + | ||
33 | + item.avatar = avatar; | ||
34 | + item.userName = value.nickname; | ||
35 | + item.color = value.color_name; | ||
36 | + item.size = value.size_name; | ||
37 | + item.comment = value.content || ''; | ||
38 | + item.date = value.create_time; | ||
39 | + item.total = value.total; | ||
40 | + | ||
41 | + return item; | ||
42 | + }); | ||
43 | + } | ||
44 | + | ||
45 | + return []; | ||
46 | + })(); | ||
47 | +}; |
@@ -10,6 +10,11 @@ const moment = require('moment'); | @@ -10,6 +10,11 @@ const moment = require('moment'); | ||
10 | const COOKIE_NAME_BOYS = module.exports.COOKIE_NAME_BOYS = 'boys'; | 10 | const COOKIE_NAME_BOYS = module.exports.COOKIE_NAME_BOYS = 'boys'; |
11 | const COOKIE_DOMAIN = module.exports.COOKIE_DOMAIN = '.yohobuy.com'; | 11 | const COOKIE_DOMAIN = module.exports.COOKIE_DOMAIN = '.yohobuy.com'; |
12 | 12 | ||
13 | +// 商品详情页的默认头像 | ||
14 | +module.exports.DEFAULT_AVATAR_ICO = 'http://static.yohobuy.com/images/v3/boy.jpg'; | ||
15 | + | ||
16 | +module.exports.IMAGE_SERVICE_URL = 'http://head.static.yhbimg.com/yhb-head/'; | ||
17 | + | ||
13 | module.exports.setSwitchToCookie = (res) => { | 18 | module.exports.setSwitchToCookie = (res) => { |
14 | res.cookie('_Channel', COOKIE_NAME_BOYS, { | 19 | res.cookie('_Channel', COOKIE_NAME_BOYS, { |
15 | domain: COOKIE_DOMAIN, | 20 | domain: COOKIE_DOMAIN, |
@@ -15,9 +15,9 @@ const library = '../../../library'; | @@ -15,9 +15,9 @@ const library = '../../../library'; | ||
15 | const helpers = require(`${library}/helpers`); | 15 | const helpers = require(`${library}/helpers`); |
16 | 16 | ||
17 | const productAPI = require('./detail-product-api'); | 17 | const productAPI = require('./detail-product-api'); |
18 | -const commentAPI = require('./detail-comment-api'); | ||
19 | const consultAPI = require('./detail-consult-api'); | 18 | const consultAPI = require('./detail-consult-api'); |
20 | 19 | ||
20 | +const commentService = require('./detail-comment-service'); | ||
21 | const hotAreaService = require('./detail-hotarea-service'); | 21 | const hotAreaService = require('./detail-hotarea-service'); |
22 | const brandService = require('./brand-service'); | 22 | const brandService = require('./brand-service'); |
23 | const favoriteBrandService = require('./favorite-brand-service'); | 23 | const favoriteBrandService = require('./favorite-brand-service'); |
@@ -33,9 +33,6 @@ const BLANK_STR = ' '; | @@ -33,9 +33,6 @@ const BLANK_STR = ' '; | ||
33 | // 商品详情页的默认头像 | 33 | // 商品详情页的默认头像 |
34 | const DEFAULT_AVATAR_ICO = 'http://static.yohobuy.com/images/v3/boy.jpg'; | 34 | const DEFAULT_AVATAR_ICO = 'http://static.yohobuy.com/images/v3/boy.jpg'; |
35 | 35 | ||
36 | -const IMAGE_SERVICE_URL = 'http://head.static.yhbimg.com/yhb-head/'; | ||
37 | - | ||
38 | - | ||
39 | const multiResourcesUrl = {}; | 36 | const multiResourcesUrl = {}; |
40 | const setMultiResourceByProductBaseInfo = (data) => { | 37 | const setMultiResourceByProductBaseInfo = (data) => { |
41 | return co(function * () { | 38 | return co(function * () { |
@@ -1333,36 +1330,7 @@ const getSizeInfoAsync = (productSkn, maxSortId)=> { | @@ -1333,36 +1330,7 @@ const getSizeInfoAsync = (productSkn, maxSortId)=> { | ||
1333 | /** | 1330 | /** |
1334 | * 获取评论 | 1331 | * 获取评论 |
1335 | */ | 1332 | */ |
1336 | -module.exports.indexCommentAsync = (pid, page, size) => { | ||
1337 | - return co(function *() { | ||
1338 | - let commentList = yield commentAPI.indexAsync(pid, page, size); | ||
1339 | - | ||
1340 | - if (commentList.code && commentList.code === 200) { | ||
1341 | - return commentList.data.map(value => { | ||
1342 | - let item = {}; | ||
1343 | - | ||
1344 | - let avatar = DEFAULT_AVATAR_ICO; | ||
1345 | - | ||
1346 | - if (value.head_ico) { | ||
1347 | - avatar = `${IMAGE_SERVICE_URL}${_.last(value.head_ico.split('headimg'))}`; | ||
1348 | - avatar = helpers.image(avatar, 30, 30); | ||
1349 | - } | ||
1350 | - | ||
1351 | - item.avatar = avatar; | ||
1352 | - item.userName = value.nickname; | ||
1353 | - item.color = value.color_name; | ||
1354 | - item.size = value.size_name; | ||
1355 | - item.comment = value.content || ''; | ||
1356 | - item.date = value.create_time; | ||
1357 | - item.total = value.total; | ||
1358 | - | ||
1359 | - return item; | ||
1360 | - }); | ||
1361 | - } | ||
1362 | - | ||
1363 | - return []; | ||
1364 | - })(); | ||
1365 | -}; | 1333 | +module.exports.indexCommentAsync = commentService.indexAsync; |
1366 | 1334 | ||
1367 | /** | 1335 | /** |
1368 | * 获取咨询列表 | 1336 | * 获取咨询列表 |
-
Please register or login to post a comment