...
|
...
|
@@ -69,14 +69,12 @@ const contentCode = { |
|
|
}
|
|
|
};
|
|
|
|
|
|
class Sale {
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 折扣专场列表数据处理
|
|
|
* @param {[array]} list
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
static processDiscount(list, channel) {
|
|
|
const _processDiscount = (list, channel) => {
|
|
|
const formatData = [];
|
|
|
let flag = true;
|
|
|
|
...
|
...
|
@@ -97,14 +95,14 @@ class Sale { |
|
|
});
|
|
|
|
|
|
return formatData;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 折扣专场接口调用
|
|
|
* @param {[object]} params
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
static discount(params) {
|
|
|
const _discount = (params) => {
|
|
|
params = params || {};
|
|
|
|
|
|
return api.get('', sign.apiSign(Object.assign({
|
...
|
...
|
@@ -112,14 +110,14 @@ class Sale { |
|
|
sort: 2,
|
|
|
plateform: 2
|
|
|
}, params)));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 断码区分类数据处理
|
|
|
* @param {[array]} list
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
static processBreakingSort(list) {
|
|
|
const _processBreakingSort = (list) => {
|
|
|
const formatData = {};
|
|
|
const sort = [];
|
|
|
const sub = [];
|
...
|
...
|
@@ -148,14 +146,14 @@ class Sale { |
|
|
formatData.sub = sub;
|
|
|
|
|
|
return formatData;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 商品搜索接口请求
|
|
|
* @param {[object]} params
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
static searchSales(params) {
|
|
|
const _searchSales = (params) => {
|
|
|
|
|
|
let method = 'app.search.sales';
|
|
|
|
...
|
...
|
@@ -183,14 +181,14 @@ class Sale { |
|
|
return api.get('', sign.apiSign(Object.assign({
|
|
|
method: method
|
|
|
}, params)), true);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取用户数据信息
|
|
|
* @param {[string]} uid
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
static getUserProfile(uid) {
|
|
|
const _getUserProfile = (uid) => {
|
|
|
if (!uid) {
|
|
|
return Promise.resolve({
|
|
|
code: 200,
|
...
|
...
|
@@ -201,14 +199,14 @@ class Sale { |
|
|
method: 'app.passport.profile',
|
|
|
uid: uid
|
|
|
}), true);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取资源位数据
|
|
|
* @param {[string]} page
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
static getResources(page, channel) {
|
|
|
const _getResources = (page, channel) => {
|
|
|
return serviceAPI.get('operations/api/v5/resource/get', sign.apiSign({
|
|
|
content_code: contentCode[channel][page]
|
|
|
})).then((result) => {
|
...
|
...
|
@@ -219,33 +217,33 @@ class Sale { |
|
|
return [];
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取断码区分类数据
|
|
|
* @param {[string]} yhChannel
|
|
|
* @return {[object]}
|
|
|
*/
|
|
|
static getBreakingSort(yhChannel) {
|
|
|
const _getBreakingSort = (yhChannel) => {
|
|
|
return api.get('', sign.apiSign({
|
|
|
method: 'app.sale.getBreakingSort',
|
|
|
yh_channel: channelType[yhChannel] || '1'
|
|
|
})).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return Sale.processBreakingSort(result.data);
|
|
|
return _processBreakingSort(result.data);
|
|
|
} else {
|
|
|
logger.error('断码区分类接口返回 code 不是 200');
|
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取商品数据
|
|
|
*/
|
|
|
static getSearchData(params, uid) {
|
|
|
const getSearchData = (params, uid) => {
|
|
|
return Promise.all([
|
|
|
Sale.searchSales(params).then((result) => {
|
|
|
_searchSales(params).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return productProcess.processProductList(result.data.product_list || [], {
|
|
|
yh_channel: params.yh_channel,
|
...
|
...
|
@@ -256,7 +254,7 @@ class Sale { |
|
|
return [];
|
|
|
}
|
|
|
}),
|
|
|
Sale.getUserProfile(uid).then((result) => {
|
|
|
_getUserProfile(uid).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return result.data.vip_info ? camelCase(result.data.vip_info) : {};
|
|
|
} else {
|
...
|
...
|
@@ -265,15 +263,15 @@ class Sale { |
|
|
}
|
|
|
})
|
|
|
]);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取筛选数据
|
|
|
* @param {[object]} params
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
static getFilterData(params) {
|
|
|
return Sale.searchSales(params).then((result) => {
|
|
|
const getFilterData = (params) => {
|
|
|
return _searchSales(params).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return productProcess.processFilter(result.data.filter || [], {
|
|
|
hideSize: params.saleType === '1',
|
...
|
...
|
@@ -284,78 +282,78 @@ class Sale { |
|
|
return [];
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取sale首页数据
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
static getSaleData(channel) {
|
|
|
return Sale.getResources('sale', channel);
|
|
|
}
|
|
|
const getSaleData = (channel) => {
|
|
|
return _getResources('sale', channel);
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取会员享数据
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
static getVipData(channel) {
|
|
|
return Sale.getResources('vip', channel);
|
|
|
}
|
|
|
const getVipData = (channel) => {
|
|
|
return _getResources('vip', channel);
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取断码区数据
|
|
|
* @param {[object]} params
|
|
|
* @return {[object]}
|
|
|
*/
|
|
|
static getBreakCodeData(params) {
|
|
|
const getBreakCodeData = (params) => {
|
|
|
params = params || {};
|
|
|
return Promise.all([Sale.getResources('breakCode', params.yhChannel), Sale.getBreakingSort(params.yhChannel)])
|
|
|
return Promise.all([_getResources('breakCode', params.yhChannel), _getBreakingSort(params.yhChannel)])
|
|
|
.then((result) => {
|
|
|
return {
|
|
|
content: result[0],
|
|
|
nav: result[1]
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取折扣专场专题列表数据
|
|
|
* @param {[object]} params
|
|
|
* @return {[object]}
|
|
|
*/
|
|
|
static getDiscountData(yhChannel) {
|
|
|
const getDiscountData = (yhChannel) => {
|
|
|
const discountData = {};
|
|
|
|
|
|
return Sale.discount({
|
|
|
return _discount({
|
|
|
yh_channel: channelType[yhChannel] || '1'
|
|
|
}).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
discountData.data = Sale.processDiscount(result.data, yhChannel);
|
|
|
discountData.data = _processDiscount(result.data, yhChannel);
|
|
|
return discountData;
|
|
|
} else {
|
|
|
logger.error('折扣专场专题列表返回 code 不是 200');
|
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取折扣专场专题详情数据
|
|
|
* @param {[string]} id
|
|
|
* @return {[object]}
|
|
|
*/
|
|
|
static getDiscountDetailData(id, yhChannel) {
|
|
|
const getDiscountDetailData = (id, yhChannel) => {
|
|
|
let res = {};
|
|
|
let param = {
|
|
|
id: id,
|
|
|
yh_channel: channelType[yhChannel] || '1'
|
|
|
};
|
|
|
|
|
|
return Sale.discount(param).then((result) => {
|
|
|
return _discount(param).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
res = Sale.processDiscount(result.data);
|
|
|
res = _processDiscount(result.data);
|
|
|
|
|
|
return {
|
|
|
title: res[0].title,
|
...
|
...
|
@@ -370,7 +368,14 @@ class Sale { |
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports = Sale; |
|
|
module.exports = {
|
|
|
getSaleData: getSaleData,
|
|
|
getBreakCodeData: getBreakCodeData,
|
|
|
getDiscountData: getDiscountData,
|
|
|
getDiscountDetailData: getDiscountDetailData,
|
|
|
getVipData: getVipData,
|
|
|
getFilterData: getFilterData,
|
|
|
getSearchData: getSearchData
|
|
|
}; |
...
|
...
|
|