Showing
15 changed files
with
156 additions
and
101 deletions
@@ -20,7 +20,7 @@ const detailHelper = require('../models/detail-helper'); | @@ -20,7 +20,7 @@ const detailHelper = require('../models/detail-helper'); | ||
20 | module.exports.showMain = (req, res, next) => { | 20 | module.exports.showMain = (req, res, next) => { |
21 | // TODO: vipLevel = 0; // 用户等级 | 21 | // TODO: vipLevel = 0; // 用户等级 |
22 | 22 | ||
23 | - let pid = 217011; | 23 | + let pid = 204503; |
24 | 24 | ||
25 | let uid = req.user.uid || ''; | 25 | let uid = req.user.uid || ''; |
26 | 26 |
@@ -6,18 +6,24 @@ const sign = require(`${library}/sign`); | @@ -6,18 +6,24 @@ const sign = require(`${library}/sign`); | ||
6 | 6 | ||
7 | const api = new API(); | 7 | const api = new API(); |
8 | 8 | ||
9 | +const fake = require('./fake'); | ||
10 | + | ||
9 | module.exports.getBannerInfoAsync = (bid) => { | 11 | module.exports.getBannerInfoAsync = (bid) => { |
10 | - return api.get('', sign.apiSign({ | ||
11 | - method: 'web.brand.banner', | ||
12 | - brand_id: bid | ||
13 | - })); | 12 | + //return api.get('', sign.apiSign({ |
13 | + // method: 'web.brand.banner', | ||
14 | + // brand_id: bid | ||
15 | + //})); | ||
16 | + | ||
17 | + return Promise.resolve(fake.fakeBrandBanner); | ||
14 | }; | 18 | }; |
15 | 19 | ||
16 | module.exports.getBrandLogoByDomainAsync = (domain) => { | 20 | module.exports.getBrandLogoByDomainAsync = (domain) => { |
17 | - return api.get('', sign.apiSign({ | ||
18 | - domain: domain, | ||
19 | - method: 'web.brand.byDomain' | ||
20 | - })); | 21 | + //return api.get('', sign.apiSign({ |
22 | + // domain: domain, | ||
23 | + // method: 'web.brand.byDomain' | ||
24 | + //})); | ||
25 | + | ||
26 | + return Promise.resolve(fake.fakeBrandDomain); | ||
21 | }; | 27 | }; |
22 | 28 | ||
23 | 29 |
@@ -12,9 +12,12 @@ module.exports.getBrandByDomainAsync = (domain) => { | @@ -12,9 +12,12 @@ module.exports.getBrandByDomainAsync = (domain) => { | ||
12 | return co(function*() { | 12 | return co(function*() { |
13 | let brandInfo = yield api.getBrandLogoByDomainAsync(domain); | 13 | let brandInfo = yield api.getBrandLogoByDomainAsync(domain); |
14 | 14 | ||
15 | + if (!brandInfo.data || brandInfo.code !== 200) { | ||
16 | + return {}; | ||
17 | + } | ||
18 | + | ||
15 | let result = {}; | 19 | let result = {}; |
16 | 20 | ||
17 | - if (brandInfo.data && brandInfo.code === 200) { | ||
18 | result.brandId = brandInfo.data.id || ''; | 21 | result.brandId = brandInfo.data.id || ''; |
19 | result.node = brandInfo.data.static_content_code || false; | 22 | result.node = brandInfo.data.static_content_code || false; |
20 | result.brandBanner = brandInfo.data.brand_banner || ''; | 23 | result.brandBanner = brandInfo.data.brand_banner || ''; |
@@ -26,7 +29,6 @@ module.exports.getBrandByDomainAsync = (domain) => { | @@ -26,7 +29,6 @@ module.exports.getBrandByDomainAsync = (domain) => { | ||
26 | result.type = brandInfo.data.type ? +brandInfo.data.type : 0; | 29 | result.type = brandInfo.data.type ? +brandInfo.data.type : 0; |
27 | result.shopId = brandInfo.data.shop_id || ''; | 30 | result.shopId = brandInfo.data.shop_id || ''; |
28 | 31 | ||
29 | - } | ||
30 | return result; | 32 | return result; |
31 | })(); | 33 | })(); |
32 | }; | 34 | }; |
@@ -15,33 +15,38 @@ const api = require('./detail-comment-api'); | @@ -15,33 +15,38 @@ const api = require('./detail-comment-api'); | ||
15 | 15 | ||
16 | const detailHelper = require('./detail-helper'); | 16 | const detailHelper = require('./detail-helper'); |
17 | 17 | ||
18 | +const fake = require('./fake'); | ||
19 | + | ||
18 | module.exports.indexAsync = (pid, page, size) => { | 20 | module.exports.indexAsync = (pid, page, size) => { |
19 | return co(function *() { | 21 | 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 | - } | 22 | + return fake.fakeComments; |
23 | + //let commentList = yield api.indexAsync(pid, page, size); | ||
24 | + // | ||
25 | + //if (!commentList.code || !commentList.code !== 200) { | ||
26 | + // return []; | ||
27 | + //} | ||
28 | + | ||
29 | + | ||
30 | + //return commentList.data.map(value => { | ||
31 | + // let item = {}; | ||
32 | + // | ||
33 | + // let avatar = detailHelper.DEFAULT_AVATAR_ICO; | ||
34 | + // | ||
35 | + // if (value.head_ico) { | ||
36 | + // avatar = `${detailHelper.IMAGE_SERVICE_URL}${_.last(value.head_ico.split('headimg'))}`; | ||
37 | + // avatar = helpers.image(avatar, 30, 30); | ||
38 | + // } | ||
39 | + // | ||
40 | + // item.avatar = avatar; | ||
41 | + // item.userName = value.nickname; | ||
42 | + // item.color = value.color_name; | ||
43 | + // item.size = value.size_name; | ||
44 | + // item.comment = value.content || ''; | ||
45 | + // item.date = value.create_time; | ||
46 | + // item.total = value.total; | ||
47 | + // | ||
48 | + // return item; | ||
49 | + //}); | ||
44 | 50 | ||
45 | - return []; | ||
46 | })(); | 51 | })(); |
47 | }; | 52 | }; |
@@ -15,7 +15,7 @@ const api = new API(); | @@ -15,7 +15,7 @@ const api = new API(); | ||
15 | /** | 15 | /** |
16 | * 咨询内容列表 | 16 | * 咨询内容列表 |
17 | */ | 17 | */ |
18 | -module.exports.indexAsync = function(uid, pid, page, size) { | 18 | +module.exports.indexAsync = function (uid, pid, page, size) { |
19 | let param = {}; | 19 | let param = {}; |
20 | 20 | ||
21 | param.method = 'app.consult.li'; | 21 | param.method = 'app.consult.li'; |
@@ -34,7 +34,7 @@ module.exports.indexAsync = function(uid, pid, page, size) { | @@ -34,7 +34,7 @@ module.exports.indexAsync = function(uid, pid, page, size) { | ||
34 | /** | 34 | /** |
35 | * 添加咨询操作 | 35 | * 添加咨询操作 |
36 | */ | 36 | */ |
37 | -module.exports.createAsync = function(uid, pid, content) { | 37 | +module.exports.createAsync = function (uid, pid, content) { |
38 | return api.post('', sign.apiSign({ | 38 | return api.post('', sign.apiSign({ |
39 | method: 'h5.consult.add', | 39 | method: 'h5.consult.add', |
40 | product_id: pid, | 40 | product_id: pid, |
@@ -10,28 +10,34 @@ const co = Promise.coroutine; | @@ -10,28 +10,34 @@ const co = Promise.coroutine; | ||
10 | const api = require('./detail-consult-api'); | 10 | const api = require('./detail-consult-api'); |
11 | const detailHelper = require('./detail-helper'); | 11 | const detailHelper = require('./detail-helper'); |
12 | 12 | ||
13 | +const fake = require('./fake'); | ||
14 | + | ||
13 | module.exports.indexAsync = (uid, pid, page, size) => { | 15 | module.exports.indexAsync = (uid, pid, page, size) => { |
14 | return co(function *() { | 16 | return co(function *() { |
15 | - let consultList = yield api.indexAsync(uid, pid, page, size); | ||
16 | - | ||
17 | - if (consultList.code && consultList.code === 200) { | ||
18 | - return consultList.data.list.map(value => { | ||
19 | - return { | ||
20 | - avatar: detailHelper.DEFAULT_AVATAR_ICO, | ||
21 | - question: value.ask, | ||
22 | - date: value.ask_time, | ||
23 | - answer: value.answer, | ||
24 | - id: value.id, | ||
25 | - isLike: value.is_like === 'Y', | ||
26 | - like: parseInt(value.like, 10), | ||
27 | - isUseful: value.is_useful === 'Y', | ||
28 | - useful: parseInt(value.useful, 10), | ||
29 | - total: value.total | ||
30 | - }; | ||
31 | - }); | ||
32 | - } | ||
33 | - | ||
34 | - return []; | 17 | + return fake.fakeConsule; |
18 | + | ||
19 | + | ||
20 | + //let consultList = yield api.indexAsync(uid, pid, page, size); | ||
21 | + // | ||
22 | + //if (!consultList.code || consultList.code !== 200) { | ||
23 | + // return []; | ||
24 | + //} | ||
25 | + // | ||
26 | + //return consultList.data.list.map(value => { | ||
27 | + // return { | ||
28 | + // avatar: detailHelper.DEFAULT_AVATAR_ICO, | ||
29 | + // question: value.ask, | ||
30 | + // date: value.ask_time, | ||
31 | + // answer: value.answer, | ||
32 | + // id: value.id, | ||
33 | + // isLike: value.is_like === 'Y', | ||
34 | + // like: parseInt(value.like, 10), | ||
35 | + // isUseful: value.is_useful === 'Y', | ||
36 | + // useful: parseInt(value.useful, 10), | ||
37 | + // total: value.total | ||
38 | + // }; | ||
39 | + //}); | ||
40 | + | ||
35 | })(); | 41 | })(); |
36 | }; | 42 | }; |
37 | 43 |
@@ -9,12 +9,15 @@ const log = require(`${library}/logger`); | @@ -9,12 +9,15 @@ const log = require(`${library}/logger`); | ||
9 | 9 | ||
10 | const api = new API(); | 10 | const api = new API(); |
11 | 11 | ||
12 | +const fake = require('./fake'); | ||
12 | /** | 13 | /** |
13 | * 获取商品的热区 | 14 | * 获取商品的热区 |
14 | */ | 15 | */ |
15 | module.exports.indexAsync = (pid) => { | 16 | module.exports.indexAsync = (pid) => { |
16 | - return api.get('', sign.apiSign({ | ||
17 | - method: 'web.productCollocation.list', | ||
18 | - product_id: pid | ||
19 | - })).catch(log.error); | 17 | + //return api.get('', sign.apiSign({ |
18 | + // method: 'web.productCollocation.list', | ||
19 | + // product_id: pid | ||
20 | + //})).catch(log.error); | ||
21 | + | ||
22 | + return Promise.resolve(fake.fakeProductCollent); | ||
20 | }; | 23 | }; |
@@ -20,21 +20,21 @@ module.exports.indexAsync = (pid) => { | @@ -20,21 +20,21 @@ module.exports.indexAsync = (pid) => { | ||
20 | return co(function *() { | 20 | return co(function *() { |
21 | let data = yield api.indexAsync(pid); | 21 | let data = yield api.indexAsync(pid); |
22 | 22 | ||
23 | - if (!data.code && !(data.code === 200) && !data.data) { | 23 | + if (!data.code || data.code !== 200) { |
24 | return []; | 24 | return []; |
25 | } | 25 | } |
26 | 26 | ||
27 | return data.data.reduce((result, area) => { | 27 | return data.data.reduce((result, area) => { |
28 | + if (!area.infos) { | ||
29 | + return result; | ||
30 | + } | ||
31 | + | ||
28 | let item = {}; | 32 | let item = {}; |
29 | 33 | ||
30 | if (area.imageUrl) { | 34 | if (area.imageUrl) { |
31 | item.img = helpers.getForceSourceUrl(area.imageUrl); | 35 | item.img = helpers.getForceSourceUrl(area.imageUrl); |
32 | } | 36 | } |
33 | 37 | ||
34 | - if (!area.infos) { | ||
35 | - return result; | ||
36 | - } | ||
37 | - | ||
38 | item.list = area.infos.reduce((acc, cur, index) => { | 38 | item.list = area.infos.reduce((acc, cur, index) => { |
39 | if (!cur.product || !cur.product.goodsList) { | 39 | if (!cur.product || !cur.product.goodsList) { |
40 | return acc; | 40 | return acc; |
@@ -8,41 +8,53 @@ const log = require(`${library}/logger`); | @@ -8,41 +8,53 @@ const log = require(`${library}/logger`); | ||
8 | 8 | ||
9 | const api = new API(); | 9 | const api = new API(); |
10 | 10 | ||
11 | +const fake = require('./fake'); | ||
12 | + | ||
11 | module.exports.getProductBannerAsync = function(pid, clientType) { | 13 | module.exports.getProductBannerAsync = function(pid, clientType) { |
12 | - clientType = clientType || 'web'; | ||
13 | - return api.get('', sign.apiSign({ | ||
14 | - method: 'web.productBanner.data', | ||
15 | - product_id: pid, | ||
16 | - client_type: clientType | ||
17 | - })).catch(log.error); | 14 | + //clientType = clientType || 'web'; |
15 | + //return api.get('', sign.apiSign({ | ||
16 | + // method: 'web.productBanner.data', | ||
17 | + // product_id: pid, | ||
18 | + // client_type: clientType | ||
19 | + //})).catch(log.error); | ||
20 | + | ||
21 | + return Promise.resolve(fake.fakeProductBanner); | ||
18 | }; | 22 | }; |
19 | 23 | ||
20 | module.exports.sizeInfoAsync = function(skn) { | 24 | module.exports.sizeInfoAsync = function(skn) { |
21 | - return api.get('', sign.apiSign({ | ||
22 | - method: 'h5.product.intro', | ||
23 | - productskn: skn | ||
24 | - })).catch(log.error); | 25 | + //return api.get('', sign.apiSign({ |
26 | + // method: 'h5.product.intro', | ||
27 | + // productskn: skn | ||
28 | + //})).catch(log.error); | ||
29 | + | ||
30 | + return Promise.resolve(fake.fakeProductIntro); | ||
25 | }; | 31 | }; |
26 | 32 | ||
27 | module.exports.getProductComfortAsync = function(pid) { | 33 | module.exports.getProductComfortAsync = function(pid) { |
28 | - return api.get('', sign.apiSign({ | ||
29 | - method: 'web.productComfort.data', | ||
30 | - product_id: pid | ||
31 | - })).catch(log.error); | 34 | + //return api.get('', sign.apiSign({ |
35 | + // method: 'web.productComfort.data', | ||
36 | + // product_id: pid | ||
37 | + //})).catch(log.error); | ||
38 | + | ||
39 | + return Promise.resolve(fake.fakeComfort); | ||
32 | }; | 40 | }; |
33 | 41 | ||
34 | module.exports.getProductModelCardAsync = function(pid) { | 42 | module.exports.getProductModelCardAsync = function(pid) { |
35 | - return api.get('', sign.apiSign({ | ||
36 | - method: 'web.productModelcard.list', | ||
37 | - product_id: pid | ||
38 | - })).catch(log.error); | 43 | + //return api.get('', sign.apiSign({ |
44 | + // method: 'web.productModelcard.list', | ||
45 | + // product_id: pid | ||
46 | + //})).catch(log.error); | ||
47 | + | ||
48 | + return Promise.resolve(fake.fakeModelCard); | ||
39 | }; | 49 | }; |
40 | 50 | ||
41 | module.exports.getProductModelTryAsync = function(skn) { | 51 | module.exports.getProductModelTryAsync = function(skn) { |
42 | - return api.get('', sign.apiSign({ | ||
43 | - method: 'web.productModelTry.data', | ||
44 | - product_skn: skn | ||
45 | - })).catch(log.error); | 52 | + //return api.get('', sign.apiSign({ |
53 | + // method: 'web.productModelTry.data', | ||
54 | + // product_skn: skn | ||
55 | + //})).catch(log.error); | ||
56 | + | ||
57 | + return Promise.resolve(fake.fakeModelTry); | ||
46 | }; | 58 | }; |
47 | 59 | ||
48 | /** | 60 | /** |
@@ -51,10 +63,12 @@ module.exports.getProductModelTryAsync = function(skn) { | @@ -51,10 +63,12 @@ module.exports.getProductModelTryAsync = function(skn) { | ||
51 | * @returns {Promise.<type>} | 63 | * @returns {Promise.<type>} |
52 | */ | 64 | */ |
53 | module.exports.getProductInfo = function(pid) { | 65 | module.exports.getProductInfo = function(pid) { |
54 | - return api.get('', sign.apiSign({ | ||
55 | - method: 'h5.product.data', | ||
56 | - productId: pid | ||
57 | - })).catch(console.log); | 66 | + //return api.get('', sign.apiSign({ |
67 | + // method: 'h5.product.data', | ||
68 | + // productId: pid | ||
69 | + //})).catch(console.log); | ||
70 | + | ||
71 | + return Promise.resolve(fake.fakeProduct); | ||
58 | }; | 72 | }; |
59 | 73 | ||
60 | 74 |
@@ -27,6 +27,7 @@ const shopAPI = require('./shop-api'); | @@ -27,6 +27,7 @@ const shopAPI = require('./shop-api'); | ||
27 | const searchAPI = require('./search-api'); | 27 | const searchAPI = require('./search-api'); |
28 | const homeService = require('./home-service'); | 28 | const homeService = require('./home-service'); |
29 | const HeaderModel = require('../../../doraemon/models/header'); | 29 | const HeaderModel = require('../../../doraemon/models/header'); |
30 | +const fake = require('./fake'); | ||
30 | 31 | ||
31 | const BLANK_STR = ' '; | 32 | const BLANK_STR = ' '; |
32 | 33 | ||
@@ -857,7 +858,7 @@ function getDescriptionDataBySizeInfo(sizeInfo) { | @@ -857,7 +858,7 @@ function getDescriptionDataBySizeInfo(sizeInfo) { | ||
857 | }); | 858 | }); |
858 | } | 859 | } |
859 | 860 | ||
860 | - description.confort = getProductComfort(); | 861 | + description.comfort = getProductComfort(); |
861 | } | 862 | } |
862 | 863 | ||
863 | return description; | 864 | return description; |
@@ -1279,7 +1280,10 @@ const getSizeInfo = (productSkn, maxSortId)=> { | @@ -1279,7 +1280,10 @@ const getSizeInfo = (productSkn, maxSortId)=> { | ||
1279 | result.size = getSizeData(sizeInfo); | 1280 | result.size = getSizeData(sizeInfo); |
1280 | 1281 | ||
1281 | // 模特数据 | 1282 | // 模特数据 |
1282 | - result.reference = getReferenceDataBySizeInfo(sizeInfo); | 1283 | + let reference = getReferenceDataBySizeInfo(sizeInfo); |
1284 | + if(_.isEmpty(reference)){ | ||
1285 | + result.reference = reference; | ||
1286 | + } | ||
1283 | 1287 | ||
1284 | // 洗涤材质 | 1288 | // 洗涤材质 |
1285 | result.material = getMaterialDataBySizeInfo(sizeInfo); | 1289 | result.material = getMaterialDataBySizeInfo(sizeInfo); |
apps/product/models/fake.js
0 → 100644
This diff could not be displayed because it is too large.
@@ -6,7 +6,11 @@ const log = require(`${library}/logger`); | @@ -6,7 +6,11 @@ const log = require(`${library}/logger`); | ||
6 | 6 | ||
7 | const api = new API(); | 7 | const api = new API(); |
8 | 8 | ||
9 | +const fake = require('./fake'); | ||
10 | + | ||
9 | module.exports.getSortByConditionAsync = function(condition) { | 11 | module.exports.getSortByConditionAsync = function(condition) { |
10 | - return api.get('sortgroup.json', condition).catch(log.error); | 12 | + //return api.get('sortgroup.json', condition).catch(log.error); |
13 | + | ||
14 | + return Promise.resolve(fake.fakeNav); | ||
11 | }; | 15 | }; |
12 | 16 |
@@ -15,6 +15,9 @@ const serviceApi = new ServiceAPI(); | @@ -15,6 +15,9 @@ const serviceApi = new ServiceAPI(); | ||
15 | 15 | ||
16 | const log = require(`${global.library}/logger`); | 16 | const log = require(`${global.library}/logger`); |
17 | 17 | ||
18 | +const Promise = require('bluebird'); | ||
19 | +const fake = require('../../apps/product/models/fake'); | ||
20 | + | ||
18 | /** | 21 | /** |
19 | * 获取菜单 | 22 | * 获取菜单 |
20 | * @param undefined | 23 | * @param undefined |
@@ -131,7 +134,6 @@ const getThirdNav = (data) => { | @@ -131,7 +134,6 @@ const getThirdNav = (data) => { | ||
131 | }); | 134 | }); |
132 | 135 | ||
133 | 136 | ||
134 | - | ||
135 | return thirdNav; | 137 | return thirdNav; |
136 | }; | 138 | }; |
137 | 139 | ||
@@ -168,8 +170,6 @@ const getSubNav = (data, type) => { | @@ -168,8 +170,6 @@ const getSubNav = (data, type) => { | ||
168 | }; | 170 | }; |
169 | 171 | ||
170 | 172 | ||
171 | - | ||
172 | - | ||
173 | /** | 173 | /** |
174 | * 处理接口返回的数据 | 174 | * 处理接口返回的数据 |
175 | * @param {object} 接口返回的对象 | 175 | * @param {object} 接口返回的对象 |
@@ -191,7 +191,6 @@ const setHeaderData = (resData, type) => { | @@ -191,7 +191,6 @@ const setHeaderData = (resData, type) => { | ||
191 | }; | 191 | }; |
192 | 192 | ||
193 | 193 | ||
194 | - | ||
195 | /** | 194 | /** |
196 | * 请求头部数据 | 195 | * 请求头部数据 |
197 | * @param {String} 频道类型 | 196 | * @param {String} 频道类型 |
@@ -205,7 +204,17 @@ exports.requestHeaderData = (type, parentId) => { | @@ -205,7 +204,17 @@ exports.requestHeaderData = (type, parentId) => { | ||
205 | 204 | ||
206 | type = type || 'boys'; | 205 | type = type || 'boys'; |
207 | 206 | ||
208 | - return serviceApi.get('operations/api/v6/category/getCategory', data, true).then(res => { | 207 | + //return serviceApi.get('operations/api/v6/category/getCategory', data, true).then(res => { |
208 | + // if (res && res.code === 200) { | ||
209 | + // return setHeaderData(res.data, type); | ||
210 | + // } else { | ||
211 | + // log.error('获取头部信息的接口返回状态码 不是 200'); | ||
212 | + // return {}; | ||
213 | + // } | ||
214 | + //}); | ||
215 | + | ||
216 | + return Promise.resolve(fake.fakeHeader).then(res => { | ||
217 | + console.log(res); | ||
209 | if (res && res.code === 200) { | 218 | if (res && res.code === 200) { |
210 | return setHeaderData(res.data, type); | 219 | return setHeaderData(res.data, type); |
211 | } else { | 220 | } else { |
-
Please register or login to post a comment