sale-api.js
2.7 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
124
125
126
127
128
129
/*
* @Author: Targaryen
* @Date: 2016-05-25 18:03:34
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-07 13:58:53
*/
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const _ = require('lodash');
const config = global.yoho.config;
const yhChannel = {
boys: {
channel: '1'
},
girls: {
channel: '2'
},
kids: {
channel: '3'
},
lifestyle: {
channel: '4'
}
};
/**
* 获取商品列表 promise 对象
* @return {[type]} [description]
*/
exports.getSaleGoodsList = (params) => {
let finalParams = {
method: 'app.search.sales',
limit: 60,
order: 's_t_desc',
productSize: '384x511'
};
if (params.channel) {
finalParams.yh_channel = yhChannel[params.channel].channel;
}
return api.get('', Object.assign(finalParams, params), config.apiCache);
};
/**
* 断码区分类信息数据 promise 对象
* @return {[type]} [description]
*/
exports.getSalebreakingYardsSortList = (params) => {
let tempChannel = _.isEmpty(params.channel) ? 'boys' : params.channel;
return api.get('', {
method: 'app.sale.getBreakingSort',
yh_channel: yhChannel[tempChannel].channel
}, config.apiCache);
};
/**
* 获取折扣专区活动列表 promise 对象
* @return {[type]} [description]
*/
exports.getSaleActivityList = (params, channel) => {
let tempChannel = yhChannel[channel] || yhChannel.boys;
return api.get('', {
id: params.id || null,
method: 'app.activity.get',
sort: '2',
plateform: '1',
yh_channel: tempChannel.channel
}, config.apiCache);
};
/**
* 获取Sale首页顶部 banner promise 对象
* @return {[type]} [description]
*/
exports.getSaleBannerList = (cCode) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: cCode
}, config.apiCache);
};
/**
* 获取左侧类目列表
* @return {[type]} [description]
*/
exports.getLeftContentList = () => {
return api.get('', {
method: 'app.sort.get'
}, config.apiCache);
};
/**
* 获取用户数据信息
* @param {[string]} uid
* @return {[array]}
*/
exports.getUserProfile = (uid) => {
if (!uid) {
return Promise.resolve({
code: 200,
data: {}
});
}
return api.get('', {
method: 'app.passport.profile',
uid: uid
}, true);
};
/**
* 获取用户数据信息
* @param {[string]} uid
* @return {[array]}
*/
exports.getSaleSpecialAsync = (specialId) => {
return api.get('', {
method: 'app.resources.getOneSpecial',
special_id: specialId
}, {
code: 200,
cache: true
});
};