outlets-api.js
3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* @Author: Targaryen
* @Date: 2016-06-01 14:37:03
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-07 15:40:29
*/
'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const ServiceAPI = require(`${global.library}/api`).ServiceAPI;
const serviceApi = new ServiceAPI();
const api = new API();
const sign = require(`${library}/sign`);
const _ = require('lodash');
const yhChannel = {
boys: {
channel: '1'
},
girls: {
channel: '2'
},
kids: {
channel: '3'
},
lifestyle: {
channel: '4'
}
};
/**
* 获取奥莱活动列表接口
* @param {[int]} id 活动id 为空表示查询全部活动
* @param {[int ]} platform 活动平台 1--WEB,2--APP,3--WAP,4--IPAD
* @param {[int]} size 查询数量,默认查询全部
* @param {[int]} channel 频道: 1 || 2 || 3 || 4
* @param {[int]} type
* @return {[type]} 0 活动列表,1 限时嗨购 2 即将结束 3.即将上线
*/
exports.getOutletsActivityOrigin = (params) => {
let tempChannel = _.isEmpty(params.channel) ? 'boys' : params.channel;
return api.get('', sign.apiSign({
method: 'app.outlets.activityGet',
id: params.id || null,
platform: params.platform || 1,
size: params.size || 0,
yh_channel: yhChannel[tempChannel].channel,
type: params.type || 0
}));
};
/**
* 获取奥莱频道资源位数据
* @param {[object]} params
* @return {[type]}
*/
exports.getChannelResouceData = (params) => {
return serviceApi.get('operations/api/v5/resource/home', sign.apiSign(params));
};
/**
* 获取奥莱潮品速递商品数据
* @param {[type]} params [description]
* @return {[type]} [description]
*/
exports.getOutletsTrendData = (params) => {
return api.get('', sign.apiSign({
method: 'app.search.trend',
yh_channel: params.yh_channel || '1',
order: params.order || 's_s_desc,s_n_desc',
gender: params.gender || '1,3',
stocknumber: 1, // 过滤出库存 > 1的商品
limit: params.limit || 5,
outlets: params.outlets || 1 // 默认取奥莱商品
}));
};
/**
* 获取奥莱商品列表 promise 对象
* @return {[type]} [description]
*/
exports.getOutletsGoodsList = (params) => {
let tempChannel = _.isEmpty(params.channel) ? 'boys' : params.channel;
let tempParams = {
method: 'app.search.li',
query: _.isEmpty(params.query) ? null : params.query,
p_d: _.isEmpty(params.p_d) ? null : params.p_d,
limit: _.isEmpty(params.limit) ? '60' : params.limit,
order: _.isEmpty(params.order) ? 's_t_desc' : params.order,
page: _.isEmpty(params.page) ? 1 : params.page,
gender: _.isEmpty(params.gender) ? null : params.gender,
sort: _.isEmpty(params.sort) ? null : params.sort,
msort: _.isEmpty(params.msort) ? null : params.msort,
misort: _.isEmpty(params.misort) ? null : params.misort,
brand: _.isEmpty(params.brand) ? null : params.brand,
color: _.isEmpty(params.color) ? null : params.color,
size: _.isEmpty(params.size) ? null : params.size,
saleType: _.isEmpty(params.saleType) ? null : params.saleType,
breakSize: _.isEmpty(params.breakSize) ? null : params.breakSize,
breakSort: _.isEmpty(params.breakSort) ? null : params.breakSort,
productPool: _.isEmpty(params.productPool) ? null : params.productPool,
price: _.isEmpty(params.price) ? null : params.price,
outlets: _.isEmpty(params.outlets) ? 1 : params.outlets,
yh_channel: yhChannel[tempChannel].channel
};
let finalParams = {};
_.forEach(tempParams, function(value, key) {
if (!_.isEmpty(value)) {
finalParams[key] = value;
}
});
return api.get('', sign.apiSign(finalParams));
};