|
@@ -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,7 +95,7 @@ const convertNavData = (list) => { |
|
@@ -95,7 +95,7 @@ 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,
|
100
|
v: 7,
|
101
|
parent_id: categoryId
|
101
|
parent_id: categoryId
|
|
@@ -103,12 +103,12 @@ const getNavData = (categoryId) => { |
|
@@ -103,12 +103,12 @@ const getNavData = (categoryId) => { |
103
|
|
103
|
|
104
|
return serviceApi.get('operations/api/v6/category/getCategory', sign.apiSign(params)).then(result => {
|
104
|
return serviceApi.get('operations/api/v6/category/getCategory', sign.apiSign(params)).then(result => {
|
105
|
if (result && result.code === 200) {
|
105
|
if (result && result.code === 200) {
|
106
|
- let data = convertNavData(result.data);
|
106
|
+ let data = _convertNavData(result.data);
|
107
|
|
107
|
|
108
|
data.category = categoryId;
|
108
|
data.category = categoryId;
|
109
|
return data;
|
109
|
return data;
|
110
|
} else {
|
110
|
} else {
|
111
|
- log.error('奥莱导航接口返回状态码 不是 200', result);
|
111
|
+ log.error('the response code of "operations/api/v6/category/getCategory" is NOT 200', result);
|
112
|
return [];
|
112
|
return [];
|
113
|
}
|
113
|
}
|
114
|
});
|
114
|
});
|
|
@@ -119,7 +119,7 @@ const getNavData = (categoryId) => { |
|
@@ -119,7 +119,7 @@ const getNavData = (categoryId) => { |
119
|
* @param {Object} data 原始数据
|
119
|
* @param {Object} data 原始数据
|
120
|
* @return {Object} 转换后的数据
|
120
|
* @return {Object} 转换后的数据
|
121
|
*/
|
121
|
*/
|
122
|
-const convertActicityData = (data) => {
|
122
|
+const _convertActicityData = (data) => {
|
123
|
const formatData = [];
|
123
|
const formatData = [];
|
124
|
|
124
|
|
125
|
let discountArr = [],
|
125
|
let discountArr = [],
|
|
@@ -130,11 +130,11 @@ const convertActicityData = (data) => { |
|
@@ -130,11 +130,11 @@ const convertActicityData = (data) => { |
130
|
_.forEach(data, (item) => {
|
130
|
_.forEach(data, (item) => {
|
131
|
discountArr = item.promotionName.split('~');
|
131
|
discountArr = item.promotionName.split('~');
|
132
|
if (discountArr.length === 1) {
|
132
|
if (discountArr.length === 1) {
|
133
|
- discountNum = transDiscountToArr(discountArr[0])[0];
|
|
|
134
|
- discountText = transDiscountToArr(discountArr[0])[1];
|
133
|
+ discountNum = _transDiscountToArr(discountArr[0])[0];
|
|
|
134
|
+ discountText = _transDiscountToArr(discountArr[0])[1];
|
135
|
} else {
|
135
|
} else {
|
136
|
- discountNum = discountArr[0] + '~' + transDiscountToArr(discountArr[1])[0];
|
|
|
137
|
- discountText = transDiscountToArr(discountArr[1])[1];
|
136
|
+ discountNum = discountArr[0] + '~' + _transDiscountToArr(discountArr[1])[0];
|
|
|
137
|
+ discountText = _transDiscountToArr(discountArr[1])[1];
|
138
|
}
|
138
|
}
|
139
|
|
139
|
|
140
|
|
140
|
|
|
@@ -159,7 +159,7 @@ const convertActicityData = (data) => { |
|
@@ -159,7 +159,7 @@ const convertActicityData = (data) => { |
159
|
* @param {String} id 活动id
|
159
|
* @param {String} id 活动id
|
160
|
* @return {Promise} 调用接口的Promise
|
160
|
* @return {Promise} 调用接口的Promise
|
161
|
*/
|
161
|
*/
|
162
|
-const getActivityDetail = (id) => {
|
162
|
+const _getActivityDetail = (id) => {
|
163
|
var params = {
|
163
|
var params = {
|
164
|
method: 'app.outlets.activityGet',
|
164
|
method: 'app.outlets.activityGet',
|
165
|
sort: 1,
|
165
|
sort: 1,
|
|
@@ -171,9 +171,9 @@ const getActivityDetail = (id) => { |
|
@@ -171,9 +171,9 @@ const getActivityDetail = (id) => { |
171
|
|
171
|
|
172
|
return api.get('', sign.apiSign(params)).then(res => {
|
172
|
return api.get('', sign.apiSign(params)).then(res => {
|
173
|
if (res.code === 200) {
|
173
|
if (res.code === 200) {
|
174
|
- return convertActicityData(res.data);
|
174
|
+ return _convertActicityData(res.data);
|
175
|
} else {
|
175
|
} else {
|
176
|
- log.error('获取奥莱活动详情页接口返回状态码 不是 200', res);
|
176
|
+ log.error('the response code of "app.outlets.activityGet" is NOT 200', res);
|
177
|
return {};
|
177
|
return {};
|
178
|
}
|
178
|
}
|
179
|
});
|
179
|
});
|
|
@@ -184,14 +184,14 @@ const getActivityDetail = (id) => { |
|
@@ -184,14 +184,14 @@ const getActivityDetail = (id) => { |
184
|
* @param {Object} data 请求接口所需的参数
|
184
|
* @param {Object} data 请求接口所需的参数
|
185
|
* @return {Promise} 调用接口的Promise
|
185
|
* @return {Promise} 调用接口的Promise
|
186
|
*/
|
186
|
*/
|
187
|
-const getHomeActivity = (data) => {
|
187
|
+const _getHomeActivity = (data) => {
|
188
|
var params = {
|
188
|
var params = {
|
189
|
method: 'app.outlets.activityGet',
|
189
|
method: 'app.outlets.activityGet',
|
190
|
platform: 3
|
190
|
platform: 3
|
191
|
};
|
191
|
};
|
192
|
|
192
|
|
193
|
return api.get('', sign.apiSign(_.assign(params, data))).then(res => {
|
193
|
return api.get('', sign.apiSign(_.assign(params, data))).then(res => {
|
194
|
- return convertActicityData(res.data);
|
194
|
+ return _convertActicityData(res.data);
|
195
|
});
|
195
|
});
|
196
|
};
|
196
|
};
|
197
|
|
197
|
|
|
@@ -202,13 +202,13 @@ const getHomeActivity = (data) => { |
|
@@ -202,13 +202,13 @@ const getHomeActivity = (data) => { |
202
|
* @param {Strting} code 内容码
|
202
|
* @param {Strting} code 内容码
|
203
|
* @return {Promise} 调用接口的Promise
|
203
|
* @return {Promise} 调用接口的Promise
|
204
|
*/
|
204
|
*/
|
205
|
-exports.getContent = (categoryId, channel, code) => {
|
205
|
+const getContent = (categoryId, channel, code) => {
|
206
|
let params = {
|
206
|
let params = {
|
207
|
type: 0,
|
207
|
type: 0,
|
208
|
yh_channel: channel
|
208
|
yh_channel: channel
|
209
|
};
|
209
|
};
|
210
|
|
210
|
|
211
|
- const p = [getNavData(categoryId), getOutletResource(channel, code), getHomeActivity(params)];
|
211
|
+ const p = [_getNavData(categoryId), _getOutletResource(channel, code), _getHomeActivity(params)];
|
212
|
|
212
|
|
213
|
return Promise.all(p).then(data => {
|
213
|
return Promise.all(p).then(data => {
|
214
|
|
214
|
|
|
@@ -225,8 +225,8 @@ exports.getContent = (categoryId, channel, code) => { |
|
@@ -225,8 +225,8 @@ exports.getContent = (categoryId, channel, code) => { |
225
|
* @param {String} id 活动id
|
225
|
* @param {String} id 活动id
|
226
|
* @return {Promise} 调用接口的Promise
|
226
|
* @return {Promise} 调用接口的Promise
|
227
|
*/
|
227
|
*/
|
228
|
-exports.getActivity = (id) => {
|
|
|
229
|
- return getActivityDetail(id).then(res => {
|
228
|
+const getActivity = (id) => {
|
|
|
229
|
+ return _getActivityDetail(id).then(res => {
|
230
|
return {
|
230
|
return {
|
231
|
activity: res,
|
231
|
activity: res,
|
232
|
productPool: res[0] && res[0].productPoolId || '',
|
232
|
productPool: res[0] && res[0].productPoolId || '',
|
|
@@ -242,12 +242,12 @@ exports.getActivity = (id) => { |
|
@@ -242,12 +242,12 @@ exports.getActivity = (id) => { |
242
|
* @param {String} categoryId 父级菜单id,用于标明当前页面是奥莱页面
|
242
|
* @param {String} categoryId 父级菜单id,用于标明当前页面是奥莱页面
|
243
|
* @return {Object} 活动列表数据
|
243
|
* @return {Object} 活动列表数据
|
244
|
*/
|
244
|
*/
|
245
|
-exports.getRecentActivity = (type, categoryId) => {
|
245
|
+const getRecentActivity = (type, categoryId) => {
|
246
|
var params = {
|
246
|
var params = {
|
247
|
type: type
|
247
|
type: type
|
248
|
};
|
248
|
};
|
249
|
|
249
|
|
250
|
- return Promise.all([getNavData(categoryId), getHomeActivity(params)]).then(res => {
|
250
|
+ return Promise.all([_getNavData(categoryId), _getHomeActivity(params)]).then(res => {
|
251
|
|
251
|
|
252
|
return {
|
252
|
return {
|
253
|
nav: res[0] || [],
|
253
|
nav: res[0] || [],
|
|
@@ -255,3 +255,9 @@ exports.getRecentActivity = (type, categoryId) => { |
|
@@ -255,3 +255,9 @@ exports.getRecentActivity = (type, categoryId) => { |
255
|
};
|
255
|
};
|
256
|
});
|
256
|
});
|
257
|
};
|
257
|
};
|
|
|
258
|
+
|
|
|
259
|
+module.exports = {
|
|
|
260
|
+ getContent: getContent,
|
|
|
261
|
+ getActivity: getActivity,
|
|
|
262
|
+ getRecentActivity: getRecentActivity
|
|
|
263
|
+} |