|
@@ -31,7 +31,7 @@ const dateFormate = (str) =>{ |
|
@@ -31,7 +31,7 @@ const dateFormate = (str) =>{ |
31
|
};
|
31
|
};
|
32
|
|
32
|
|
33
|
// 为了活动卡片特殊样式,将折扣信息拆分开来
|
33
|
// 为了活动卡片特殊样式,将折扣信息拆分开来
|
34
|
-const transDiscountToArr = (discount) => {
|
34
|
+const _transDiscountToArr = (discount) => {
|
35
|
return discount.replace(/(?:\d+[.\d]?)([\u4e00-\u9fa5]{1})/g, function(fullMatch, capture) {
|
35
|
return discount.replace(/(?:\d+[.\d]?)([\u4e00-\u9fa5]{1})/g, function(fullMatch, capture) {
|
36
|
if (capture) {
|
36
|
if (capture) {
|
37
|
const arr = [];
|
37
|
const arr = [];
|
|
@@ -52,7 +52,7 @@ const transDiscountToArr = (discount) => { |
|
@@ -52,7 +52,7 @@ const transDiscountToArr = (discount) => { |
52
|
* @param {String} contentcode 内容码
|
52
|
* @param {String} contentcode 内容码
|
53
|
* @return {Promise}
|
53
|
* @return {Promise}
|
54
|
*/
|
54
|
*/
|
55
|
-const getOutletResource = (channel, contentcode) => {
|
55
|
+const _getOutletResource = (channel, contentcode) => {
|
56
|
const params = {
|
56
|
const params = {
|
57
|
content_code: contentcode || 'c19ffa03f053f4cac3690b22c8da26b7',
|
57
|
content_code: contentcode || 'c19ffa03f053f4cac3690b22c8da26b7',
|
58
|
limit: 25,
|
58
|
limit: 25,
|
|
@@ -63,7 +63,7 @@ const getOutletResource = (channel, contentcode) => { |
|
@@ -63,7 +63,7 @@ const getOutletResource = (channel, contentcode) => { |
63
|
if (result && result.code === 200) {
|
63
|
if (result && result.code === 200) {
|
64
|
return resourcesProcess(result.data.list);
|
64
|
return resourcesProcess(result.data.list);
|
65
|
} else {
|
65
|
} else {
|
66
|
- log.error('奥莱资源位接口返回状态码 不是 200');
|
66
|
+ log.error('the response code of outlet "operations/api/v5/resource/home" is NOT 200', result);
|
67
|
return [];
|
67
|
return [];
|
68
|
}
|
68
|
}
|
69
|
});
|
69
|
});
|
|
@@ -74,7 +74,7 @@ const getOutletResource = (channel, contentcode) => { |
|
@@ -74,7 +74,7 @@ const getOutletResource = (channel, contentcode) => { |
74
|
* @param {[Object]} 原始导航数据
|
74
|
* @param {[Object]} 原始导航数据
|
75
|
* @return {Object} 转换后的数据
|
75
|
* @return {Object} 转换后的数据
|
76
|
*/
|
76
|
*/
|
77
|
-const convertNavData = (list) => {
|
77
|
+const _convertNavData = (list) => {
|
78
|
const formatData = [];
|
78
|
const formatData = [];
|
79
|
|
79
|
|
80
|
list = list || [];
|
80
|
list = list || [];
|
|
@@ -95,20 +95,19 @@ const convertNavData = (list) => { |
|
@@ -95,20 +95,19 @@ const convertNavData = (list) => { |
95
|
* @param {String} 导航类型id
|
95
|
* @param {String} 导航类型id
|
96
|
* @return {Promise}
|
96
|
* @return {Promise}
|
97
|
*/
|
97
|
*/
|
98
|
-const getNavData = (categoryId) => {
|
98
|
+const _getNavData = (categoryId) => {
|
99
|
const params = {
|
99
|
const params = {
|
100
|
- v: 7,
|
|
|
101
|
parent_id: categoryId
|
100
|
parent_id: categoryId
|
102
|
};
|
101
|
};
|
103
|
|
102
|
|
104
|
return serviceApi.get('operations/api/v6/category/getCategory', sign.apiSign(params)).then(result => {
|
103
|
return serviceApi.get('operations/api/v6/category/getCategory', sign.apiSign(params)).then(result => {
|
105
|
if (result && result.code === 200) {
|
104
|
if (result && result.code === 200) {
|
106
|
- let data = convertNavData(result.data);
|
105
|
+ let data = _convertNavData(result.data);
|
107
|
|
106
|
|
108
|
data.category = categoryId;
|
107
|
data.category = categoryId;
|
109
|
return data;
|
108
|
return data;
|
110
|
} else {
|
109
|
} else {
|
111
|
- log.error('奥莱导航接口返回状态码 不是 200', result);
|
110
|
+ log.error('the response code of "operations/api/v6/category/getCategory" is NOT 200', result);
|
112
|
return [];
|
111
|
return [];
|
113
|
}
|
112
|
}
|
114
|
});
|
113
|
});
|
|
@@ -119,7 +118,7 @@ const getNavData = (categoryId) => { |
|
@@ -119,7 +118,7 @@ const getNavData = (categoryId) => { |
119
|
* @param {Object} data 原始数据
|
118
|
* @param {Object} data 原始数据
|
120
|
* @return {Object} 转换后的数据
|
119
|
* @return {Object} 转换后的数据
|
121
|
*/
|
120
|
*/
|
122
|
-const convertActicityData = (data) => {
|
121
|
+const _convertActicityData = (data) => {
|
123
|
const formatData = [];
|
122
|
const formatData = [];
|
124
|
|
123
|
|
125
|
let discountArr = [],
|
124
|
let discountArr = [],
|
|
@@ -130,11 +129,11 @@ const convertActicityData = (data) => { |
|
@@ -130,11 +129,11 @@ const convertActicityData = (data) => { |
130
|
_.forEach(data, (item) => {
|
129
|
_.forEach(data, (item) => {
|
131
|
discountArr = item.promotionName.split('~');
|
130
|
discountArr = item.promotionName.split('~');
|
132
|
if (discountArr.length === 1) {
|
131
|
if (discountArr.length === 1) {
|
133
|
- discountNum = transDiscountToArr(discountArr[0])[0];
|
|
|
134
|
- discountText = transDiscountToArr(discountArr[0])[1];
|
132
|
+ discountNum = _transDiscountToArr(discountArr[0])[0];
|
|
|
133
|
+ discountText = _transDiscountToArr(discountArr[0])[1];
|
135
|
} else {
|
134
|
} else {
|
136
|
- discountNum = discountArr[0] + '~' + transDiscountToArr(discountArr[1])[0];
|
|
|
137
|
- discountText = transDiscountToArr(discountArr[1])[1];
|
135
|
+ discountNum = discountArr[0] + '~' + _transDiscountToArr(discountArr[1])[0];
|
|
|
136
|
+ discountText = _transDiscountToArr(discountArr[1])[1];
|
138
|
}
|
137
|
}
|
139
|
|
138
|
|
140
|
|
139
|
|
|
@@ -159,21 +158,21 @@ const convertActicityData = (data) => { |
|
@@ -159,21 +158,21 @@ const convertActicityData = (data) => { |
159
|
* @param {String} id 活动id
|
158
|
* @param {String} id 活动id
|
160
|
* @return {Promise} 调用接口的Promise
|
159
|
* @return {Promise} 调用接口的Promise
|
161
|
*/
|
160
|
*/
|
162
|
-const getActivityDetail = (id) => {
|
161
|
+const _getActivityDetail = (id) => {
|
163
|
var params = {
|
162
|
var params = {
|
164
|
method: 'app.outlets.activityGet',
|
163
|
method: 'app.outlets.activityGet',
|
165
|
- sort: 1,
|
|
|
166
|
- platform: 3,
|
164
|
+ sort: 1, // 接口规定传1
|
|
|
165
|
+ platform: 3, // h5平台代号
|
167
|
id: id,
|
166
|
id: id,
|
168
|
- type: 0
|
167
|
+ type: 0 // 接口规定传0
|
169
|
};
|
168
|
};
|
170
|
|
169
|
|
171
|
|
170
|
|
172
|
return api.get('', sign.apiSign(params)).then(res => {
|
171
|
return api.get('', sign.apiSign(params)).then(res => {
|
173
|
if (res.code === 200) {
|
172
|
if (res.code === 200) {
|
174
|
- return convertActicityData(res.data);
|
173
|
+ return _convertActicityData(res.data);
|
175
|
} else {
|
174
|
} else {
|
176
|
- log.error('获取奥莱活动详情页接口返回状态码 不是 200', res);
|
175
|
+ log.error('the response code of "app.outlets.activityGet" is NOT 200', res);
|
177
|
return {};
|
176
|
return {};
|
178
|
}
|
177
|
}
|
179
|
});
|
178
|
});
|
|
@@ -184,14 +183,14 @@ const getActivityDetail = (id) => { |
|
@@ -184,14 +183,14 @@ const getActivityDetail = (id) => { |
184
|
* @param {Object} data 请求接口所需的参数
|
183
|
* @param {Object} data 请求接口所需的参数
|
185
|
* @return {Promise} 调用接口的Promise
|
184
|
* @return {Promise} 调用接口的Promise
|
186
|
*/
|
185
|
*/
|
187
|
-const getHomeActivity = (data) => {
|
186
|
+const _getHomeActivity = (data) => {
|
188
|
var params = {
|
187
|
var params = {
|
189
|
method: 'app.outlets.activityGet',
|
188
|
method: 'app.outlets.activityGet',
|
190
|
- platform: 3
|
189
|
+ platform: 3 // h5平台代号
|
191
|
};
|
190
|
};
|
192
|
|
191
|
|
193
|
return api.get('', sign.apiSign(_.assign(params, data))).then(res => {
|
192
|
return api.get('', sign.apiSign(_.assign(params, data))).then(res => {
|
194
|
- return convertActicityData(res.data);
|
193
|
+ return _convertActicityData(res.data);
|
195
|
});
|
194
|
});
|
196
|
};
|
195
|
};
|
197
|
|
196
|
|
|
@@ -202,13 +201,13 @@ const getHomeActivity = (data) => { |
|
@@ -202,13 +201,13 @@ const getHomeActivity = (data) => { |
202
|
* @param {Strting} code 内容码
|
201
|
* @param {Strting} code 内容码
|
203
|
* @return {Promise} 调用接口的Promise
|
202
|
* @return {Promise} 调用接口的Promise
|
204
|
*/
|
203
|
*/
|
205
|
-exports.getContent = (categoryId, channel, code) => {
|
204
|
+const getContent = (categoryId, channel, code) => {
|
206
|
let params = {
|
205
|
let params = {
|
207
|
- type: 0,
|
206
|
+ type: 0, // 获取全部奥莱活动列表, 不区分是否将开始或结束
|
208
|
yh_channel: channel
|
207
|
yh_channel: channel
|
209
|
};
|
208
|
};
|
210
|
|
209
|
|
211
|
- const p = [getNavData(categoryId), getOutletResource(channel, code), getHomeActivity(params)];
|
210
|
+ const p = [_getNavData(categoryId), _getOutletResource(channel, code), _getHomeActivity(params)];
|
212
|
|
211
|
|
213
|
return Promise.all(p).then(data => {
|
212
|
return Promise.all(p).then(data => {
|
214
|
|
213
|
|
|
@@ -225,13 +224,13 @@ exports.getContent = (categoryId, channel, code) => { |
|
@@ -225,13 +224,13 @@ exports.getContent = (categoryId, channel, code) => { |
225
|
* @param {String} id 活动id
|
224
|
* @param {String} id 活动id
|
226
|
* @return {Promise} 调用接口的Promise
|
225
|
* @return {Promise} 调用接口的Promise
|
227
|
*/
|
226
|
*/
|
228
|
-exports.getActivity = (id) => {
|
|
|
229
|
- return getActivityDetail(id).then(res => {
|
227
|
+const getActivity = (id) => {
|
|
|
228
|
+ return _getActivityDetail(id).then(res => {
|
230
|
return {
|
229
|
return {
|
231
|
activity: res,
|
230
|
activity: res,
|
232
|
productPool: res[0] && res[0].productPoolId || '',
|
231
|
productPool: res[0] && res[0].productPoolId || '',
|
233
|
activityTitle: res[0] && res[0].title || 'OUTLET',
|
232
|
activityTitle: res[0] && res[0].title || 'OUTLET',
|
234
|
- saleType: 4
|
233
|
+ saleType: 4 // 促销类型, 奥莱为4
|
235
|
};
|
234
|
};
|
236
|
});
|
235
|
});
|
237
|
};
|
236
|
};
|
|
@@ -242,12 +241,12 @@ exports.getActivity = (id) => { |
|
@@ -242,12 +241,12 @@ exports.getActivity = (id) => { |
242
|
* @param {String} categoryId 父级菜单id,用于标明当前页面是奥莱页面
|
241
|
* @param {String} categoryId 父级菜单id,用于标明当前页面是奥莱页面
|
243
|
* @return {Object} 活动列表数据
|
242
|
* @return {Object} 活动列表数据
|
244
|
*/
|
243
|
*/
|
245
|
-exports.getRecentActivity = (type, categoryId) => {
|
244
|
+const getRecentActivity = (type, categoryId) => {
|
246
|
var params = {
|
245
|
var params = {
|
247
|
type: type
|
246
|
type: type
|
248
|
};
|
247
|
};
|
249
|
|
248
|
|
250
|
- return Promise.all([getNavData(categoryId), getHomeActivity(params)]).then(res => {
|
249
|
+ return Promise.all([_getNavData(categoryId), _getHomeActivity(params)]).then(res => {
|
251
|
|
250
|
|
252
|
return {
|
251
|
return {
|
253
|
nav: res[0] || [],
|
252
|
nav: res[0] || [],
|
|
@@ -255,3 +254,9 @@ exports.getRecentActivity = (type, categoryId) => { |
|
@@ -255,3 +254,9 @@ exports.getRecentActivity = (type, categoryId) => { |
255
|
};
|
254
|
};
|
256
|
});
|
255
|
});
|
257
|
};
|
256
|
};
|
|
|
257
|
+
|
|
|
258
|
+module.exports = {
|
|
|
259
|
+ getContent: getContent,
|
|
|
260
|
+ getActivity: getActivity,
|
|
|
261
|
+ getRecentActivity: getRecentActivity
|
|
|
262
|
+}; |