Showing
6 changed files
with
44 additions
and
39 deletions
@@ -6,22 +6,23 @@ | @@ -6,22 +6,23 @@ | ||
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | -const moment = require('moment'); | ||
10 | 9 | ||
10 | +const library = '../../../library'; | ||
11 | const helpers = require(`${library}/helpers`); | 11 | const helpers = require(`${library}/helpers`); |
12 | 12 | ||
13 | const mRoot = '../models'; | 13 | const mRoot = '../models'; |
14 | const service = require(`${mRoot}/detail-service`); | 14 | const service = require(`${mRoot}/detail-service`); |
15 | -const detailHelper = require(`${mRoot}/detail-helper`); | 15 | +const detailHelper = require('../models/detail-helper'); |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * 单个商品详情 | 18 | * 单个商品详情 |
19 | */ | 19 | */ |
20 | module.exports.showMain = (req, res, next) => { | 20 | module.exports.showMain = (req, res, next) => { |
21 | - // TODO: 需要修改为正式取 UID 的方式 | ||
22 | // TODO: vipLevel = 0; // 用户等级 | 21 | // TODO: vipLevel = 0; // 用户等级 |
23 | 22 | ||
24 | - let pid = 204503; | 23 | + let pid = 373057; |
24 | + | ||
25 | + let uid = req.user.uid || ''; | ||
25 | 26 | ||
26 | let channel = detailHelper.COOKIE_NAME_BOYS; | 27 | let channel = detailHelper.COOKIE_NAME_BOYS; |
27 | 28 | ||
@@ -38,10 +39,10 @@ module.exports.showMain = (req, res, next) => { | @@ -38,10 +39,10 @@ module.exports.showMain = (req, res, next) => { | ||
38 | ua: req.get('user-agent') || '', | 39 | ua: req.get('user-agent') || '', |
39 | channel: channel, | 40 | channel: channel, |
40 | gender: gender, | 41 | gender: gender, |
41 | - uid: '', | 42 | + uid: uid, |
42 | vipLevel: 0 | 43 | vipLevel: 0 |
43 | }).then((result) => { | 44 | }).then((result) => { |
44 | - res.render('detail', Object.assign({ | 45 | + res.render('product/detail', Object.assign({ |
45 | module: 'product', | 46 | module: 'product', |
46 | page: 'detail' | 47 | page: 'detail' |
47 | }, result)); | 48 | }, result)); |
@@ -55,9 +56,9 @@ module.exports.indexHotArea = (req, res, next) => { | @@ -55,9 +56,9 @@ module.exports.indexHotArea = (req, res, next) => { | ||
55 | let pid = req.params.productId || 0; | 56 | let pid = req.params.productId || 0; |
56 | 57 | ||
57 | service.indexHotAreaAsync(pid).then(result => { | 58 | service.indexHotAreaAsync(pid).then(result => { |
58 | - res.render('hotarea', { | 59 | + res.render('product/hotarea', { |
59 | hotArea: result, | 60 | hotArea: result, |
60 | - layout:false | 61 | + layout: false |
61 | }); | 62 | }); |
62 | }).catch(next); | 63 | }).catch(next); |
63 | }; | 64 | }; |
@@ -68,11 +69,13 @@ module.exports.indexHotArea = (req, res, next) => { | @@ -68,11 +69,13 @@ module.exports.indexHotArea = (req, res, next) => { | ||
68 | */ | 69 | */ |
69 | module.exports.indexComment = (req, res, next) => { | 70 | module.exports.indexComment = (req, res, next) => { |
70 | let pid = req.params.productId || 0; | 71 | let pid = req.params.productId || 0; |
72 | + | ||
71 | let page = req.params.page || 1; | 73 | let page = req.params.page || 1; |
74 | + | ||
72 | let size = req.params.size || 10; | 75 | let size = req.params.size || 10; |
73 | 76 | ||
74 | service.indexCommentAsync(pid, page, size).then(result => { | 77 | service.indexCommentAsync(pid, page, size).then(result => { |
75 | - res.json(result) | 78 | + res.json(result); |
76 | }).catch(next); | 79 | }).catch(next); |
77 | }; | 80 | }; |
78 | 81 | ||
@@ -81,10 +84,12 @@ module.exports.indexComment = (req, res, next) => { | @@ -81,10 +84,12 @@ module.exports.indexComment = (req, res, next) => { | ||
81 | * json | 84 | * json |
82 | */ | 85 | */ |
83 | module.exports.indexConsult = (req, res, next) => { | 86 | module.exports.indexConsult = (req, res, next) => { |
84 | - // TODO: uid | ||
85 | - let uid = ''; | 87 | + let uid = req.user.uid || ''; |
88 | + | ||
86 | let pid = req.params.productId || 0; | 89 | let pid = req.params.productId || 0; |
90 | + | ||
87 | let page = req.params.page || 1; | 91 | let page = req.params.page || 1; |
92 | + | ||
88 | let size = req.params.size || 10; | 93 | let size = req.params.size || 10; |
89 | 94 | ||
90 | service.indexConsultAsync(uid, pid, page, size).then(result => { | 95 | service.indexConsultAsync(uid, pid, page, size).then(result => { |
@@ -97,10 +102,10 @@ module.exports.indexConsult = (req, res, next) => { | @@ -97,10 +102,10 @@ module.exports.indexConsult = (req, res, next) => { | ||
97 | * json | 102 | * json |
98 | */ | 103 | */ |
99 | module.exports.createConsult = (req, res, next) => { | 104 | module.exports.createConsult = (req, res, next) => { |
105 | + let uid = req.user.uid || ''; | ||
100 | 106 | ||
101 | - //TODO: uid | ||
102 | - let uid = ''; | ||
103 | let pid = req.body.productId || 0; | 107 | let pid = req.body.productId || 0; |
108 | + | ||
104 | let content = req.body.content; | 109 | let content = req.body.content; |
105 | 110 | ||
106 | if (content && uid) { | 111 | if (content && uid) { |
@@ -117,9 +122,9 @@ module.exports.createConsult = (req, res, next) => { | @@ -117,9 +122,9 @@ module.exports.createConsult = (req, res, next) => { | ||
117 | } else if (!uid) { | 122 | } else if (!uid) { |
118 | res.json({ | 123 | res.json({ |
119 | code: 403, | 124 | code: 403, |
120 | - message: "用户没有登录", | 125 | + message: '用户没有登录', |
121 | data: { | 126 | data: { |
122 | - url: helpers.urlFormat('/signin.html') | 127 | + url: helpers.urlFormat('signin.html') |
123 | } | 128 | } |
124 | }); | 129 | }); |
125 | 130 |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | */ | 3 | */ |
4 | 'use strict'; | 4 | 'use strict'; |
5 | 5 | ||
6 | +const library = '../../../library'; | ||
6 | const helpers = require(`${library}/helpers`); | 7 | const helpers = require(`${library}/helpers`); |
7 | 8 | ||
8 | const brandService = require('../models/favorite-brand-service'); | 9 | const brandService = require('../models/favorite-brand-service'); |
@@ -12,21 +13,20 @@ const productService = require('../models/favorite-product-service'); | @@ -12,21 +13,20 @@ const productService = require('../models/favorite-product-service'); | ||
12 | * 收藏品牌ajax请求 | 13 | * 收藏品牌ajax请求 |
13 | */ | 14 | */ |
14 | module.exports.changeFavoriteBrand = (req, res, next) => { | 15 | module.exports.changeFavoriteBrand = (req, res, next) => { |
15 | - // TODO: uid get | ||
16 | - let uid = ''; | 16 | + let uid = req.user.uid || ''; |
17 | 17 | ||
18 | let brandId = req.body.brandId; | 18 | let brandId = req.body.brandId; |
19 | 19 | ||
20 | if (uid && brandId) { | 20 | if (uid && brandId) { |
21 | brandService.changeAsync(uid, brandId).then(result => { | 21 | brandService.changeAsync(uid, brandId).then(result => { |
22 | - res.json(result) | 22 | + res.json(result); |
23 | }).catch(next); | 23 | }).catch(next); |
24 | } else if (!uid) { | 24 | } else if (!uid) { |
25 | res.json({ | 25 | res.json({ |
26 | code: 403, | 26 | code: 403, |
27 | message: '用户ID不存在', | 27 | message: '用户ID不存在', |
28 | data: { | 28 | data: { |
29 | - url: helpers.urlFormat('/signin.html') | 29 | + url: helpers.urlFormat('signin.html') |
30 | } | 30 | } |
31 | }); | 31 | }); |
32 | } else { | 32 | } else { |
@@ -38,8 +38,7 @@ module.exports.changeFavoriteBrand = (req, res, next) => { | @@ -38,8 +38,7 @@ module.exports.changeFavoriteBrand = (req, res, next) => { | ||
38 | }; | 38 | }; |
39 | 39 | ||
40 | module.exports.collectProduct = (req, res, next) => { | 40 | module.exports.collectProduct = (req, res, next) => { |
41 | - // TODO: uid get | ||
42 | - let uid = ''; | 41 | + let uid = req.user.uid || ''; |
43 | 42 | ||
44 | let pid = req.body.productId; | 43 | let pid = req.body.productId; |
45 | 44 | ||
@@ -78,13 +77,13 @@ module.exports.collectProduct = (req, res, next) => { | @@ -78,13 +77,13 @@ module.exports.collectProduct = (req, res, next) => { | ||
78 | code: 403, | 77 | code: 403, |
79 | message: '用户没有登录', | 78 | message: '用户没有登录', |
80 | data: { | 79 | data: { |
81 | - url: helpers.urlFormat('/signin.html') | 80 | + url: helpers.urlFormat('signin.html') |
82 | } | 81 | } |
83 | - }) | 82 | + }); |
84 | } else { | 83 | } else { |
85 | res.json({ | 84 | res.json({ |
86 | code: 400, | 85 | code: 400, |
87 | message: '收藏失败' | 86 | message: '收藏失败' |
88 | - }) | 87 | + }); |
89 | } | 88 | } |
90 | }; | 89 | }; |
@@ -4,9 +4,11 @@ | @@ -4,9 +4,11 @@ | ||
4 | 4 | ||
5 | 'use strict'; | 5 | 'use strict'; |
6 | 6 | ||
7 | +const moment = require('moment'); | ||
8 | + | ||
7 | /* COOKIE标识访问的是男生频道 */ | 9 | /* COOKIE标识访问的是男生频道 */ |
8 | -const COOKIE_NAME_BOYS = 'boys'; | ||
9 | -module.exports.COOKIE_DOMAIN = '.yohobuy.com'; | 10 | +const COOKIE_NAME_BOYS = module.exports.COOKIE_NAME_BOYS = 'boys'; |
11 | +const COOKIE_DOMAIN = module.exports.COOKIE_DOMAIN = '.yohobuy.com'; | ||
10 | 12 | ||
11 | module.exports.setSwitchToCookie = (res) => { | 13 | module.exports.setSwitchToCookie = (res) => { |
12 | res.cookie('_Channel', COOKIE_NAME_BOYS, { | 14 | res.cookie('_Channel', COOKIE_NAME_BOYS, { |
@@ -5,7 +5,6 @@ | @@ -5,7 +5,6 @@ | ||
5 | const library = '../../../library'; | 5 | const library = '../../../library'; |
6 | const API = require(`${library}/api`).API; | 6 | const API = require(`${library}/api`).API; |
7 | const sign = require(`${library}/sign`); | 7 | const sign = require(`${library}/sign`); |
8 | -const Promise = require('bluebird'); | ||
9 | 8 | ||
10 | const api = new API(); | 9 | const api = new API(); |
11 | 10 | ||
@@ -13,7 +12,7 @@ const api = new API(); | @@ -13,7 +12,7 @@ const api = new API(); | ||
13 | * 获取商品的热区 | 12 | * 获取商品的热区 |
14 | */ | 13 | */ |
15 | module.exports.indexAsync = (pid) => { | 14 | module.exports.indexAsync = (pid) => { |
16 | - return api.get('', api.apiSign({ | 15 | + return api.get('', sign.apiSign({ |
17 | method: 'web.productCollocation.list', | 16 | method: 'web.productCollocation.list', |
18 | product_id: pid | 17 | product_id: pid |
19 | })).catch(console.log); | 18 | })).catch(console.log); |
@@ -12,8 +12,6 @@ const moment = require('moment'); | @@ -12,8 +12,6 @@ const moment = require('moment'); | ||
12 | const _ = require('lodash'); | 12 | const _ = require('lodash'); |
13 | 13 | ||
14 | const library = '../../../library'; | 14 | const library = '../../../library'; |
15 | -const API = require(`${library}/api`).API; | ||
16 | -const sign = require(`${library}/sign`); | ||
17 | const helpers = require(`${library}/helpers`); | 15 | const helpers = require(`${library}/helpers`); |
18 | 16 | ||
19 | const detailAPI = require('./detail-main-api'); | 17 | const detailAPI = require('./detail-main-api'); |
@@ -27,17 +25,16 @@ const favoriteProductService = require('./favorite-product-service'); | @@ -27,17 +25,16 @@ const favoriteProductService = require('./favorite-product-service'); | ||
27 | 25 | ||
28 | const shopAPI = require('./shop-api'); | 26 | const shopAPI = require('./shop-api'); |
29 | const searchAPI = require('./search-api'); | 27 | const searchAPI = require('./search-api'); |
30 | -const homeHandle = require('./home-handle'); | 28 | +const homeService = require('./home-service'); |
31 | const HeaderModel = require('../../../doraemon/models/header'); | 29 | const HeaderModel = require('../../../doraemon/models/header'); |
32 | 30 | ||
33 | const BLANK_STR = ' '; | 31 | const BLANK_STR = ' '; |
34 | 32 | ||
35 | -//商品详情页的默认头像 | 33 | +// 商品详情页的默认头像 |
36 | 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'; |
37 | 35 | ||
38 | -const IMAGE_SERVICE_URL = "http://head.static.yhbimg.com/yhb-head/"; | 36 | +const IMAGE_SERVICE_URL = 'http://head.static.yhbimg.com/yhb-head/'; |
39 | 37 | ||
40 | -var api = new API(); | ||
41 | 38 | ||
42 | const multiResourcesUrl = {}; | 39 | const multiResourcesUrl = {}; |
43 | const setMultiResourceByProductBaseInfo = (data) => { | 40 | const setMultiResourceByProductBaseInfo = (data) => { |
@@ -1373,6 +1370,7 @@ module.exports.indexCommentAsync = (pid, page, size) => { | @@ -1373,6 +1370,7 @@ module.exports.indexCommentAsync = (pid, page, size) => { | ||
1373 | module.exports.indexConsultAsync = (uid, pid, page, size) => { | 1370 | module.exports.indexConsultAsync = (uid, pid, page, size) => { |
1374 | return co(function *() { | 1371 | return co(function *() { |
1375 | let consultList = yield consultAPI.indexAsync(uid, pid, page, size); | 1372 | let consultList = yield consultAPI.indexAsync(uid, pid, page, size); |
1373 | + | ||
1376 | if (consultList.code && consultList.code === 200) { | 1374 | if (consultList.code && consultList.code === 200) { |
1377 | return consultList.data.list.map(value => { | 1375 | return consultList.data.list.map(value => { |
1378 | return { | 1376 | return { |
@@ -1386,11 +1384,11 @@ module.exports.indexConsultAsync = (uid, pid, page, size) => { | @@ -1386,11 +1384,11 @@ module.exports.indexConsultAsync = (uid, pid, page, size) => { | ||
1386 | isUseful: value.is_useful === 'Y', | 1384 | isUseful: value.is_useful === 'Y', |
1387 | useful: parseInt(value.useful, 10), | 1385 | useful: parseInt(value.useful, 10), |
1388 | total: value.total | 1386 | total: value.total |
1389 | - } | 1387 | + }; |
1390 | }); | 1388 | }); |
1391 | } | 1389 | } |
1392 | 1390 | ||
1393 | - return [] | 1391 | + return []; |
1394 | })(); | 1392 | })(); |
1395 | }; | 1393 | }; |
1396 | 1394 | ||
@@ -1399,7 +1397,7 @@ module.exports.indexConsultAsync = (uid, pid, page, size) => { | @@ -1399,7 +1397,7 @@ module.exports.indexConsultAsync = (uid, pid, page, size) => { | ||
1399 | */ | 1397 | */ |
1400 | module.exports.createConsultAsync = (uid, pid, content) => { | 1398 | module.exports.createConsultAsync = (uid, pid, content) => { |
1401 | return consultAPI.createAsync(uid, pid, content); | 1399 | return consultAPI.createAsync(uid, pid, content); |
1402 | -} | 1400 | +}; |
1403 | 1401 | ||
1404 | /** | 1402 | /** |
1405 | * 获取某一个商品详情主页面 | 1403 | * 获取某一个商品详情主页面 |
@@ -1425,7 +1423,7 @@ module.exports.showMainAsync = (data) => { | @@ -1425,7 +1423,7 @@ module.exports.showMainAsync = (data) => { | ||
1425 | }; | 1423 | }; |
1426 | 1424 | ||
1427 | // 导航 | 1425 | // 导航 |
1428 | - result.detail.pathNav = _.concat(homeHandle.getHomeChannelNav(data.channel), | 1426 | + result.detail.pathNav = _.concat(homeService.getHomeChannelNav(data.channel), |
1429 | navs, | 1427 | navs, |
1430 | [{name: productInfo.goodsInfo.name}]); | 1428 | [{name: productInfo.goodsInfo.name}]); |
1431 | result.detail.lastWalk = 5; | 1429 | result.detail.lastWalk = 5; |
@@ -1479,6 +1477,8 @@ module.exports.indexHotAreaAsync = (pid) => { | @@ -1479,6 +1477,8 @@ module.exports.indexHotAreaAsync = (pid) => { | ||
1479 | cur.product.cnAlphabet) | 1477 | cur.product.cnAlphabet) |
1480 | }; | 1478 | }; |
1481 | acc.push(point); | 1479 | acc.push(point); |
1480 | + | ||
1481 | + return acc; | ||
1482 | }, []); | 1482 | }, []); |
1483 | 1483 | ||
1484 | if (_.isEmpty(item)) { | 1484 | if (_.isEmpty(item)) { |
@@ -1493,4 +1493,4 @@ module.exports.indexHotAreaAsync = (pid) => { | @@ -1493,4 +1493,4 @@ module.exports.indexHotAreaAsync = (pid) => { | ||
1493 | 1493 | ||
1494 | return []; | 1494 | return []; |
1495 | })(); | 1495 | })(); |
1496 | -} | 1496 | +}; |
-
Please register or login to post a comment