...
|
...
|
@@ -21,6 +21,9 @@ const aMinute = 60000; |
|
|
const anHour = 3600000;
|
|
|
const aDay = anHour * 24;
|
|
|
|
|
|
/**
|
|
|
* 需要格式化的时间格式
|
|
|
*/
|
|
|
const timeFormat = {
|
|
|
d: '剩{d}天',
|
|
|
h: '剩{h}小时',
|
...
|
...
|
@@ -32,6 +35,9 @@ const timeFormat = { |
|
|
ms: '剩{m}分钟{s}秒'
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 排序转换
|
|
|
*/
|
|
|
const typeCont = {
|
|
|
price: ['s_p_desc', 's_p_asc'],
|
|
|
discount: ['p_d_desc', 'p_d_asc'],
|
...
|
...
|
@@ -42,6 +48,8 @@ const typeCont = { |
|
|
|
|
|
/**
|
|
|
* 折扣专场专题列表过期时间处理
|
|
|
* @param {[string]} time
|
|
|
* @return {[object]}
|
|
|
*/
|
|
|
const processTime = (time) => {
|
|
|
let data = {};
|
...
|
...
|
@@ -65,6 +73,8 @@ const processTime = (time) => { |
|
|
|
|
|
/**
|
|
|
* 折扣专场专题详情过期时间处理
|
|
|
* @param {[string]} time
|
|
|
* @return {[boject]}
|
|
|
*/
|
|
|
const processTimes = (time) => {
|
|
|
let data = {};
|
...
|
...
|
@@ -91,6 +101,8 @@ const processTimes = (time) => { |
|
|
|
|
|
/**
|
|
|
* 折扣专场列表数据处理
|
|
|
* @param {[array]} list
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const processSpecial = (list) => {
|
|
|
const formatData = [];
|
...
|
...
|
@@ -119,6 +131,8 @@ const processSpecial = (list) => { |
|
|
|
|
|
/**
|
|
|
* 折扣专场接口调用
|
|
|
* @param {[object]} params
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const special = (params) => {
|
|
|
params = params || {};
|
...
|
...
|
@@ -132,6 +146,8 @@ const special = (params) => { |
|
|
|
|
|
/**
|
|
|
* 断码区分类数据处理
|
|
|
* @param {[array]} list
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const processBreakingSort = (list) => {
|
|
|
const formatData = {};
|
...
|
...
|
@@ -157,8 +173,18 @@ const processBreakingSort = (list) => { |
|
|
|
|
|
/**
|
|
|
* 商品搜索接口请求
|
|
|
* @param {[object]} params
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const searchSales = (params) => {
|
|
|
|
|
|
// 排除基本筛选项默认值为0的对象
|
|
|
for(let str in params){
|
|
|
if (str !== 'order' && params[str] === '0' || params[str] === null) {
|
|
|
delete params[str];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
params = Object.assign({
|
|
|
limit: '50'
|
|
|
}, params);
|
...
|
...
|
@@ -173,22 +199,10 @@ const searchSales = (params) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取筛选数据
|
|
|
* 获取用户数据信息
|
|
|
* @param {[string]} uid
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
exports.getFilterData = (params) => {
|
|
|
return searchSales(params).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return productProcess.processFilter(result.data.filter || [], {
|
|
|
hideSize: params.saleType === '1',
|
|
|
hideSort: params.saleType === '1'
|
|
|
});
|
|
|
} else {
|
|
|
logger.error('SALE 商品搜索返回 code 不是 200');
|
|
|
return [];
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const getUserProfile = (uid) => {
|
|
|
return api.get('', sign.apiSign({
|
|
|
method: 'app.passport.profile',
|
...
|
...
|
@@ -197,31 +211,9 @@ const getUserProfile = (uid) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取商品数据
|
|
|
*/
|
|
|
exports.getSearchData = (params, uid) => {
|
|
|
return Promise.all([
|
|
|
searchSales(params).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return productProcess.processProductList(result.data.product_list || []);
|
|
|
} else {
|
|
|
logger.error('SALE 商品搜索返回 code 不是 200');
|
|
|
return [];
|
|
|
}
|
|
|
}),
|
|
|
getUserProfile(uid).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return camelCase(result.data.vip_info);
|
|
|
} else {
|
|
|
logger.error('获取用户信息返回 code 不是 200');
|
|
|
return {};
|
|
|
}
|
|
|
})
|
|
|
]);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取资源位数据
|
|
|
* @param {[string]} page
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const getResources = (page) => {
|
|
|
const contentCode = {
|
...
|
...
|
@@ -244,6 +236,8 @@ const getResources = (page) => { |
|
|
|
|
|
/**
|
|
|
* 获取断码区分类数据
|
|
|
* @param {[string]} yhChannel
|
|
|
* @return {[object]}
|
|
|
*/
|
|
|
const getBreakingSort = (yhChannel) => {
|
|
|
return api.get('', sign.apiSign({
|
...
|
...
|
@@ -260,7 +254,54 @@ const getBreakingSort = (yhChannel) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取筛选数据
|
|
|
* @param {[object]} params
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
exports.getFilterData = (params) => {
|
|
|
return searchSales(params).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return productProcess.processFilter(result.data.filter || [], {
|
|
|
hideSize: params.saleType === '1',
|
|
|
hideSort: params.saleType === '1'
|
|
|
});
|
|
|
} else {
|
|
|
logger.error('SALE 商品搜索返回 code 不是 200');
|
|
|
return [];
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取商品数据
|
|
|
* @param {[object]} params
|
|
|
* @param {[string]} uid
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
exports.getSearchData = (params, uid) => {
|
|
|
return Promise.all([
|
|
|
searchSales(params).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return productProcess.processProductList(result.data.product_list || []);
|
|
|
} else {
|
|
|
logger.error('SALE 商品搜索返回 code 不是 200');
|
|
|
return [];
|
|
|
}
|
|
|
}),
|
|
|
getUserProfile(uid).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return camelCase(result.data.vip_info);
|
|
|
} else {
|
|
|
logger.error('获取用户信息返回 code 不是 200');
|
|
|
return {};
|
|
|
}
|
|
|
})
|
|
|
]);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取sale首页数据
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
exports.getSaleData = () => {
|
|
|
return getResources('sale');
|
...
|
...
|
@@ -268,8 +309,7 @@ exports.getSaleData = () => { |
|
|
|
|
|
/**
|
|
|
* 获取会员享数据
|
|
|
* @param {[object]} params
|
|
|
* @return {[object]}
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
exports.getVipData = () => {
|
|
|
return getResources('vip');
|
...
|
...
|
@@ -312,7 +352,7 @@ exports.getSpecialData = (params) => { |
|
|
|
|
|
/**
|
|
|
* 获取折扣专场专题详情数据
|
|
|
* @param {[object]} params
|
|
|
* @param {[string]} id
|
|
|
* @return {[object]}
|
|
|
*/
|
|
|
exports.getSpecialDetailData = (id) => {
|
...
|
...
|
@@ -324,6 +364,7 @@ exports.getSpecialDetailData = (id) => { |
|
|
return special(param).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
res = processSpecial(result.data);
|
|
|
console.log(res)
|
|
|
return {
|
|
|
title: res[0].title,
|
|
|
activity: {
|
...
|
...
|
|