Authored by htoooth

refactor hotarea

1 -'use strict';  
2 -  
3 -  
4 -const library = '../../../library';  
5 -const API = require(`${library}/api`).API;  
6 -const sign = require(`${library}/sign`);  
7 -const log = require(`${library}/logger`);  
8 -  
9 -const api = new API();  
10 -  
11 -module.exports.getProductBannerAsync = function(pid) {  
12 - return api.get('', sign.apiSign({  
13 - method: 'web.productBanner.data',  
14 - product_id: pid  
15 - })).catch(log.error);  
16 -};  
17 -  
18 -module.exports.sizeInfoAsync = function(skn) {  
19 - return api.get('', sign.apiSign({  
20 - method: 'h5.product.intro',  
21 - productskn: skn  
22 - })).catch(log.error);  
23 -};  
24 -  
25 -module.exports.getProductComfortAsync = function(pid) {  
26 - return api.get('', sign.apiSign({  
27 - method: 'web.productComfort.data',  
28 - product_id: pid  
29 - })).catch(log.error);  
30 -};  
31 -  
32 -module.exports.getProductModelCardAsync = function(pid) {  
33 - return api.get('', sign.apiSign({  
34 - method: 'web.productModelcard.list',  
35 - product_id: pid  
36 - })).catch(log.error);  
37 -};  
38 -  
39 -module.exports.getProductModelTryAsync = function(skn) {  
40 - return api.get('', sign.apiSign({  
41 - method: 'web.productModelTry.data',  
42 - product_skn: skn  
43 - })).catch(log.error);  
44 -};  
45 -  
46 -/**  
47 - * 获得产品信息  
48 - * @param pid  
49 - * @returns {Promise.<type>}  
50 - */  
51 -module.exports.getProductInfo = function(pid) {  
52 - return api.get('', sign.apiSign({  
53 - method: 'h5.product.data',  
54 - productId: pid  
55 - })).catch(console.log);  
56 -};  
57 -  
58 -  
59 -  
60 -  
61 - 1 +'use strict';
  2 +
  3 +
  4 +const library = '../../../library';
  5 +const API = require(`${library}/api`).API;
  6 +const sign = require(`${library}/sign`);
  7 +const log = require(`${library}/logger`);
  8 +
  9 +const api = new API();
  10 +
  11 +module.exports.getProductBannerAsync = function(pid) {
  12 + return api.get('', sign.apiSign({
  13 + method: 'web.productBanner.data',
  14 + product_id: pid
  15 + })).catch(log.error);
  16 +};
  17 +
  18 +module.exports.sizeInfoAsync = function(skn) {
  19 + return api.get('', sign.apiSign({
  20 + method: 'h5.product.intro',
  21 + productskn: skn
  22 + })).catch(log.error);
  23 +};
  24 +
  25 +module.exports.getProductComfortAsync = function(pid) {
  26 + return api.get('', sign.apiSign({
  27 + method: 'web.productComfort.data',
  28 + product_id: pid
  29 + })).catch(log.error);
  30 +};
  31 +
  32 +module.exports.getProductModelCardAsync = function(pid) {
  33 + return api.get('', sign.apiSign({
  34 + method: 'web.productModelcard.list',
  35 + product_id: pid
  36 + })).catch(log.error);
  37 +};
  38 +
  39 +module.exports.getProductModelTryAsync = function(skn) {
  40 + return api.get('', sign.apiSign({
  41 + method: 'web.productModelTry.data',
  42 + product_skn: skn
  43 + })).catch(log.error);
  44 +};
  45 +
  46 +/**
  47 + * 获得产品信息
  48 + * @param pid
  49 + * @returns {Promise.<type>}
  50 + */
  51 +module.exports.getProductInfo = function(pid) {
  52 + return api.get('', sign.apiSign({
  53 + method: 'h5.product.data',
  54 + productId: pid
  55 + })).catch(console.log);
  56 +};
  57 +
  58 +
  59 +
  60 +
  61 +
@@ -14,11 +14,11 @@ const _ = require('lodash'); @@ -14,11 +14,11 @@ const _ = require('lodash');
14 const library = '../../../library'; 14 const library = '../../../library';
15 const helpers = require(`${library}/helpers`); 15 const helpers = require(`${library}/helpers`);
16 16
17 -const detailAPI = require('./detail-main-api'); 17 +const productAPI = require('./detail-product-api');
18 const commentAPI = require('./detail-comment-api'); 18 const commentAPI = require('./detail-comment-api');
19 const consultAPI = require('./detail-consult-api'); 19 const consultAPI = require('./detail-consult-api');
20 20
21 -const hotAreaService = require('./detail-hotarea-api'); 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');
24 const favoriteProductService = require('./favorite-product-service'); 24 const favoriteProductService = require('./favorite-product-service');
@@ -48,11 +48,11 @@ const setMultiResourceByProductBaseInfo = (data) => { @@ -48,11 +48,11 @@ const setMultiResourceByProductBaseInfo = (data) => {
48 // 获取相关url 48 // 获取相关url
49 49
50 let result = yield Promise.all([ 50 let result = yield Promise.all([
51 - detailAPI.getProductBannerAsync(productId, 'web', isOnlyUrl),  
52 - detailAPI.sizeInfoAsync(skn, isOnlyUrl),  
53 - detailAPI.getProductComfortAsync(productId, isOnlyUrl),  
54 - detailAPI.getProductModelCardAsync(productId, isOnlyUrl),  
55 - detailAPI.getProductModelTryAsync(skn, isOnlyUrl), 51 + productAPI.getProductBannerAsync(productId, 'web', isOnlyUrl),
  52 + productAPI.sizeInfoAsync(skn, isOnlyUrl),
  53 + productAPI.getProductComfortAsync(productId, isOnlyUrl),
  54 + productAPI.getProductModelCardAsync(productId, isOnlyUrl),
  55 + productAPI.getProductModelTryAsync(skn, isOnlyUrl),
56 brandService.getBannerInfoAsync(brandId, isOnlyUrl) 56 brandService.getBannerInfoAsync(brandId, isOnlyUrl)
57 ]); 57 ]);
58 58
@@ -192,7 +192,7 @@ function getProductActivityBannerAsync(pid) { @@ -192,7 +192,7 @@ function getProductActivityBannerAsync(pid) {
192 let data = getMultiDataByResourceName('ItemData::getProductBanner'); 192 let data = getMultiDataByResourceName('ItemData::getProductBanner');
193 193
194 if (!data) { 194 if (!data) {
195 - data = yield detailAPI.getProductBannerAsync(pid); 195 + data = yield productAPI.getProductBannerAsync(pid);
196 } 196 }
197 197
198 if (data.code && data.code === 200 && data.data) { 198 if (data.code && data.code === 200 && data.data) {
@@ -1026,7 +1026,7 @@ function getProductModelCardAsync(productId) { @@ -1026,7 +1026,7 @@ function getProductModelCardAsync(productId) {
1026 let data = getMultiDataByResourceName('ItemData::getProductModelCard'); 1026 let data = getMultiDataByResourceName('ItemData::getProductModelCard');
1027 1027
1028 if (!data) { 1028 if (!data) {
1029 - data = yield detailAPI.getProductModelCardAsync(productId); 1029 + data = yield productAPI.getProductModelCardAsync(productId);
1030 } 1030 }
1031 1031
1032 if (data.code && data.code === 200) { 1032 if (data.code && data.code === 200) {
@@ -1168,7 +1168,7 @@ function getProductModelTryAsync(productSkn) { @@ -1168,7 +1168,7 @@ function getProductModelTryAsync(productSkn) {
1168 let result = getMultiDataByResourceName('ItemData::getProductModelTry'); 1168 let result = getMultiDataByResourceName('ItemData::getProductModelTry');
1169 1169
1170 if (!result) { 1170 if (!result) {
1171 - result = yield detailAPI.getProductModelTryAsync(productSkn); 1171 + result = yield productAPI.getProductModelTryAsync(productSkn);
1172 } 1172 }
1173 1173
1174 if (result.code && result.code === 200 && result.data) { 1174 if (result.code && result.code === 200 && result.data) {
@@ -1287,7 +1287,7 @@ const getSizeInfoAsync = (productSkn, maxSortId)=> { @@ -1287,7 +1287,7 @@ const getSizeInfoAsync = (productSkn, maxSortId)=> {
1287 1287
1288 if (!sizeInfo) { 1288 if (!sizeInfo) {
1289 // 获取尺码 1289 // 获取尺码
1290 - sizeInfo = yield detailAPI.sizeInfoAsync(productSkn); 1290 + sizeInfo = yield productAPI.sizeInfoAsync(productSkn);
1291 } 1291 }
1292 1292
1293 if (!sizeInfo) { 1293 if (!sizeInfo) {
@@ -1407,7 +1407,7 @@ module.exports.showMainAsync = (data) => { @@ -1407,7 +1407,7 @@ module.exports.showMainAsync = (data) => {
1407 return co(function * () { 1407 return co(function * () {
1408 1408
1409 // 获取商品信息 1409 // 获取商品信息
1410 - let productInfo = yield detailAPI.getProductInfo(data.id); 1410 + let productInfo = yield productAPI.getProductInfo(data.id);
1411 1411
1412 productInfo = yield detailDataPkg(productInfo, data.uid, data.vipLevel); 1412 productInfo = yield detailDataPkg(productInfo, data.uid, data.vipLevel);
1413 1413