Authored by htoooth

refactor hotarea

'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const log = require(`${library}/logger`);
const api = new API();
module.exports.getProductBannerAsync = function(pid) {
return api.get('', sign.apiSign({
method: 'web.productBanner.data',
product_id: pid
})).catch(log.error);
};
module.exports.sizeInfoAsync = function(skn) {
return api.get('', sign.apiSign({
method: 'h5.product.intro',
productskn: skn
})).catch(log.error);
};
module.exports.getProductComfortAsync = function(pid) {
return api.get('', sign.apiSign({
method: 'web.productComfort.data',
product_id: pid
})).catch(log.error);
};
module.exports.getProductModelCardAsync = function(pid) {
return api.get('', sign.apiSign({
method: 'web.productModelcard.list',
product_id: pid
})).catch(log.error);
};
module.exports.getProductModelTryAsync = function(skn) {
return api.get('', sign.apiSign({
method: 'web.productModelTry.data',
product_skn: skn
})).catch(log.error);
};
/**
* 获得产品信息
* @param pid
* @returns {Promise.<type>}
*/
module.exports.getProductInfo = function(pid) {
return api.get('', sign.apiSign({
method: 'h5.product.data',
productId: pid
})).catch(console.log);
};
'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const log = require(`${library}/logger`);
const api = new API();
module.exports.getProductBannerAsync = function(pid) {
return api.get('', sign.apiSign({
method: 'web.productBanner.data',
product_id: pid
})).catch(log.error);
};
module.exports.sizeInfoAsync = function(skn) {
return api.get('', sign.apiSign({
method: 'h5.product.intro',
productskn: skn
})).catch(log.error);
};
module.exports.getProductComfortAsync = function(pid) {
return api.get('', sign.apiSign({
method: 'web.productComfort.data',
product_id: pid
})).catch(log.error);
};
module.exports.getProductModelCardAsync = function(pid) {
return api.get('', sign.apiSign({
method: 'web.productModelcard.list',
product_id: pid
})).catch(log.error);
};
module.exports.getProductModelTryAsync = function(skn) {
return api.get('', sign.apiSign({
method: 'web.productModelTry.data',
product_skn: skn
})).catch(log.error);
};
/**
* 获得产品信息
* @param pid
* @returns {Promise.<type>}
*/
module.exports.getProductInfo = function(pid) {
return api.get('', sign.apiSign({
method: 'h5.product.data',
productId: pid
})).catch(console.log);
};
... ...
... ... @@ -14,11 +14,11 @@ const _ = require('lodash');
const library = '../../../library';
const helpers = require(`${library}/helpers`);
const detailAPI = require('./detail-main-api');
const productAPI = require('./detail-product-api');
const commentAPI = require('./detail-comment-api');
const consultAPI = require('./detail-consult-api');
const hotAreaService = require('./detail-hotarea-api');
const hotAreaService = require('./detail-hotarea-service');
const brandService = require('./brand-service');
const favoriteBrandService = require('./favorite-brand-service');
const favoriteProductService = require('./favorite-product-service');
... ... @@ -48,11 +48,11 @@ const setMultiResourceByProductBaseInfo = (data) => {
// 获取相关url
let result = yield Promise.all([
detailAPI.getProductBannerAsync(productId, 'web', isOnlyUrl),
detailAPI.sizeInfoAsync(skn, isOnlyUrl),
detailAPI.getProductComfortAsync(productId, isOnlyUrl),
detailAPI.getProductModelCardAsync(productId, isOnlyUrl),
detailAPI.getProductModelTryAsync(skn, isOnlyUrl),
productAPI.getProductBannerAsync(productId, 'web', isOnlyUrl),
productAPI.sizeInfoAsync(skn, isOnlyUrl),
productAPI.getProductComfortAsync(productId, isOnlyUrl),
productAPI.getProductModelCardAsync(productId, isOnlyUrl),
productAPI.getProductModelTryAsync(skn, isOnlyUrl),
brandService.getBannerInfoAsync(brandId, isOnlyUrl)
]);
... ... @@ -192,7 +192,7 @@ function getProductActivityBannerAsync(pid) {
let data = getMultiDataByResourceName('ItemData::getProductBanner');
if (!data) {
data = yield detailAPI.getProductBannerAsync(pid);
data = yield productAPI.getProductBannerAsync(pid);
}
if (data.code && data.code === 200 && data.data) {
... ... @@ -1026,7 +1026,7 @@ function getProductModelCardAsync(productId) {
let data = getMultiDataByResourceName('ItemData::getProductModelCard');
if (!data) {
data = yield detailAPI.getProductModelCardAsync(productId);
data = yield productAPI.getProductModelCardAsync(productId);
}
if (data.code && data.code === 200) {
... ... @@ -1168,7 +1168,7 @@ function getProductModelTryAsync(productSkn) {
let result = getMultiDataByResourceName('ItemData::getProductModelTry');
if (!result) {
result = yield detailAPI.getProductModelTryAsync(productSkn);
result = yield productAPI.getProductModelTryAsync(productSkn);
}
if (result.code && result.code === 200 && result.data) {
... ... @@ -1287,7 +1287,7 @@ const getSizeInfoAsync = (productSkn, maxSortId)=> {
if (!sizeInfo) {
// 获取尺码
sizeInfo = yield detailAPI.sizeInfoAsync(productSkn);
sizeInfo = yield productAPI.sizeInfoAsync(productSkn);
}
if (!sizeInfo) {
... ... @@ -1407,7 +1407,7 @@ module.exports.showMainAsync = (data) => {
return co(function * () {
// 获取商品信息
let productInfo = yield detailAPI.getProductInfo(data.id);
let productInfo = yield productAPI.getProductInfo(data.id);
productInfo = yield detailDataPkg(productInfo, data.uid, data.vipLevel);
... ...