Merge branch 'master' into feature/detailchose
Showing
39 changed files
with
935 additions
and
599 deletions
@@ -93,6 +93,8 @@ let calcSignature = Promise.coroutine(function* (data) { | @@ -93,6 +93,8 @@ let calcSignature = Promise.coroutine(function* (data) { | ||
93 | const str = `jsapi_ticket=${data.ticket}&noncestr=${data.nonceStr}×tamp=${data.timestamp}&url=${data.url}`; | 93 | const str = `jsapi_ticket=${data.ticket}&noncestr=${data.nonceStr}×tamp=${data.timestamp}&url=${data.url}`; |
94 | 94 | ||
95 | data.signature = sha1(str); | 95 | data.signature = sha1(str); |
96 | + | ||
97 | + delete data.secret; // 一定要注意 密钥绝对不能返回到前端!!! | ||
96 | return data; | 98 | return data; |
97 | }); | 99 | }); |
98 | 100 |
@@ -6,8 +6,6 @@ | @@ -6,8 +6,6 @@ | ||
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | -var api = global.yoho.API; | ||
10 | -const service = global.yoho.ServiceAPI; | ||
11 | const helpers = global.yoho.helpers; | 9 | const helpers = global.yoho.helpers; |
12 | 10 | ||
13 | // const utils = '../../../utils'; | 11 | // const utils = '../../../utils'; |
@@ -34,23 +32,29 @@ module.exports = class extends global.yoho.BaseModel { | @@ -34,23 +32,29 @@ module.exports = class extends global.yoho.BaseModel { | ||
34 | * 获取频道接口 | 32 | * 获取频道接口 |
35 | */ | 33 | */ |
36 | _packageAd(params) { | 34 | _packageAd(params) { |
37 | - return service.get('/operations/api/v5/resource/get', { | ||
38 | - content_code: params.contentCode, | ||
39 | - gender: 1, | ||
40 | - limit: 1000, | ||
41 | - page: 1 | ||
42 | - }, { | ||
43 | - cache: true | 35 | + return this.get({ |
36 | + url: '/operations/api/v5/resource/get', | ||
37 | + data: { | ||
38 | + content_code: params.contentCode, | ||
39 | + gender: 1, | ||
40 | + limit: 1000, | ||
41 | + page: 1 | ||
42 | + }, | ||
43 | + api: global.yoho.ServiceAPI, | ||
44 | + param: { | ||
45 | + cache: true | ||
46 | + } | ||
44 | }); | 47 | }); |
45 | } | 48 | } |
46 | 49 | ||
47 | _packageList(channel) { | 50 | _packageList(channel) { |
48 | - return api.get('', { | ||
49 | - method: 'app.brand.allBrandList', | ||
50 | - yh_channel: channel | ||
51 | - }, { | ||
52 | - cache: true, | ||
53 | - code: 200 | 51 | + return this.get({ |
52 | + data: {method: 'app.brand.allBrandList', yh_channel: channel}, | ||
53 | + api: global.yoho.API, | ||
54 | + param: { | ||
55 | + cache: true, | ||
56 | + code: 200 | ||
57 | + } | ||
54 | }); | 58 | }); |
55 | } | 59 | } |
56 | 60 | ||
@@ -240,13 +244,16 @@ module.exports = class extends global.yoho.BaseModel { | @@ -240,13 +244,16 @@ module.exports = class extends global.yoho.BaseModel { | ||
240 | * @return array | 244 | * @return array |
241 | */ | 245 | */ |
242 | getBrandForSearch(channel) { | 246 | getBrandForSearch(channel) { |
243 | - return api.get('', { | ||
244 | - method: 'app.brand.allBrandList', | ||
245 | - yh_channel: channel || 1 | ||
246 | - | ||
247 | - }, { | ||
248 | - cache: true, | ||
249 | - code: 200 | 247 | + return this.get({ |
248 | + data: { | ||
249 | + method: 'app.brand.allBrandList', | ||
250 | + yh_channel: channel || 1 | ||
251 | + }, | ||
252 | + api: global.yoho.API, | ||
253 | + param: { | ||
254 | + cache: true, | ||
255 | + code: 200 | ||
256 | + } | ||
250 | }).then(result => { | 257 | }).then(result => { |
251 | 258 | ||
252 | return result; | 259 | return result; |
@@ -261,13 +268,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -261,13 +268,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
261 | * @return array | 268 | * @return array |
262 | */ | 269 | */ |
263 | branchSearchHistory(params) { | 270 | branchSearchHistory(params) { |
264 | - return api.get('', { | ||
265 | - method: 'app.search.hotBrandRecords', | ||
266 | - uid: params.uid, | ||
267 | - records: params.records || '' | ||
268 | - | ||
269 | - }, { | ||
270 | - code: 200 | 271 | + return this.get({ |
272 | + data: { | ||
273 | + method: 'app.search.hotBrandRecords', | ||
274 | + uid: params.uid, | ||
275 | + records: params.records || '' | ||
276 | + }, | ||
277 | + api: global.yoho.API, | ||
278 | + param: {code: 200} | ||
271 | }).then(result => { | 279 | }).then(result => { |
272 | 280 | ||
273 | return result; | 281 | return result; |
@@ -277,14 +285,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -277,14 +285,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
277 | 285 | ||
278 | addSearchHistory(param) { | 286 | addSearchHistory(param) { |
279 | 287 | ||
280 | - return api.get('', { | ||
281 | - | ||
282 | - method: 'app.search.hotBrandRecords', | ||
283 | - uid: param.uid, | ||
284 | - records: param.records | ||
285 | - | ||
286 | - }, { | ||
287 | - code: 200 | 288 | + return this.get({ |
289 | + data: { | ||
290 | + method: 'app.search.hotBrandRecords', | ||
291 | + uid: param.uid, | ||
292 | + records: param.records | ||
293 | + }, | ||
294 | + api: global.yoho.API, | ||
295 | + param: {code: 200} | ||
288 | }); | 296 | }); |
289 | } | 297 | } |
290 | 298 | ||
@@ -294,12 +302,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -294,12 +302,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
294 | * @return array | 302 | * @return array |
295 | */ | 303 | */ |
296 | branchSearchHot() { | 304 | branchSearchHot() { |
297 | - return api.get('', { | ||
298 | - method: 'app.search.hotBrands' | ||
299 | - | ||
300 | - }, { | ||
301 | - cache: true, | ||
302 | - code: 200 | 305 | + return this.get({ |
306 | + data: {method: 'app.search.hotBrands'}, | ||
307 | + api: global.yoho.API, | ||
308 | + param: { | ||
309 | + cache: true, | ||
310 | + code: 200 | ||
311 | + } | ||
303 | }).then(result => { | 312 | }).then(result => { |
304 | 313 | ||
305 | return result; | 314 | return result; |
@@ -314,7 +323,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -314,7 +323,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
314 | * @return array | 323 | * @return array |
315 | */ | 324 | */ |
316 | branchSearch(params) { | 325 | branchSearch(params) { |
317 | - return api.all([ | 326 | + return Promise.all([ |
318 | 327 | ||
319 | this.getBrandForSearch(params.channel), | 328 | this.getBrandForSearch(params.channel), |
320 | 329 | ||
@@ -410,12 +419,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -410,12 +419,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
410 | 419 | ||
411 | delBrandSearchHistory(param) { | 420 | delBrandSearchHistory(param) { |
412 | 421 | ||
413 | - return api.get('', { | ||
414 | - method: 'app.search.clearHotBrandRecords', | ||
415 | - uid: param.uid | ||
416 | - | ||
417 | - }, { | ||
418 | - code: 200 | 422 | + return this.get({ |
423 | + data: { | ||
424 | + method: 'app.search.clearHotBrandRecords', | ||
425 | + uid: param.uid | ||
426 | + }, | ||
427 | + api: global.yoho.API, | ||
428 | + param: {code: 200} | ||
419 | }).then(result => { | 429 | }).then(result => { |
420 | 430 | ||
421 | return result; | 431 | return result; |
@@ -5,7 +5,6 @@ | @@ -5,7 +5,6 @@ | ||
5 | */ | 5 | */ |
6 | 'use strict'; | 6 | 'use strict'; |
7 | const _ = require('lodash'); | 7 | const _ = require('lodash'); |
8 | -const api = global.yoho.API; | ||
9 | const helpers = global.yoho.helpers; | 8 | const helpers = global.yoho.helpers; |
10 | const utils = require('../../../utils'); | 9 | const utils = require('../../../utils'); |
11 | 10 | ||
@@ -71,10 +70,10 @@ module.exports = class extends global.yoho.BaseModel { | @@ -71,10 +70,10 @@ module.exports = class extends global.yoho.BaseModel { | ||
71 | } | 70 | } |
72 | 71 | ||
73 | getCateData(channel) { | 72 | getCateData(channel) { |
74 | - return api.get('', { | ||
75 | - method: 'app.sort.get' | ||
76 | - }, { | ||
77 | - cache: true | 73 | + return this.get({ |
74 | + data: {method: 'app.sort.get'}, | ||
75 | + api: global.yoho.API, | ||
76 | + param: {cache: true} | ||
78 | }).then((result) => { | 77 | }).then((result) => { |
79 | 78 | ||
80 | if (!result || !result.code || result.code !== 200 || !result.data) { | 79 | if (!result || !result.code || result.code !== 200 || !result.data) { |
@@ -7,12 +7,9 @@ | @@ -7,12 +7,9 @@ | ||
7 | const utils = '../../../utils'; | 7 | const utils = '../../../utils'; |
8 | const contentCodeConfig = require('../../../config/content-code'); | 8 | const contentCodeConfig = require('../../../config/content-code'); |
9 | const _ = require('lodash'); | 9 | const _ = require('lodash'); |
10 | -const api = global.yoho.ServiceAPI; | ||
11 | -const API = global.yoho.API; | ||
12 | const logger = global.yoho.logger; | 10 | const logger = global.yoho.logger; |
13 | const resourcesProcess = require(`${utils}/resources-process`); | 11 | const resourcesProcess = require(`${utils}/resources-process`); |
14 | 12 | ||
15 | - | ||
16 | /** | 13 | /** |
17 | * 性别数据 | 14 | * 性别数据 |
18 | * @type {Object} | 15 | * @type {Object} |
@@ -134,8 +131,11 @@ module.exports = class extends global.yoho.BaseModel { | @@ -134,8 +131,11 @@ module.exports = class extends global.yoho.BaseModel { | ||
134 | 131 | ||
135 | params.new_device = true; | 132 | params.new_device = true; |
136 | 133 | ||
137 | - return api.get('operations/api/v5/resource/home', params, { | ||
138 | - cache: true | 134 | + return this.get({ |
135 | + url: 'operations/api/v5/resource/home', | ||
136 | + data: params, | ||
137 | + api: global.yoho.ServiceAPI, | ||
138 | + param: {cache: true} | ||
139 | }).then(result => { | 139 | }).then(result => { |
140 | if (result && result.code === 200 && result.data && result.data.list) { | 140 | if (result && result.code === 200 && result.data && result.data.list) { |
141 | for (let item of result.data.list) { | 141 | for (let item of result.data.list) { |
@@ -159,8 +159,10 @@ module.exports = class extends global.yoho.BaseModel { | @@ -159,8 +159,10 @@ module.exports = class extends global.yoho.BaseModel { | ||
159 | _getLeftNav(choosed) { | 159 | _getLeftNav(choosed) { |
160 | choosed = choosed || 'all'; | 160 | choosed = choosed || 'all'; |
161 | 161 | ||
162 | - return api.get('operations/api/v6/category/getCategory', {}, { | ||
163 | - cache: true | 162 | + return this.get({ |
163 | + url: 'operations/api/v6/category/getCategory', | ||
164 | + api: global.yoho.ServiceAPI, | ||
165 | + param: {cache: true} | ||
164 | }).then(result => { | 166 | }).then(result => { |
165 | // console.log(result) | 167 | // console.log(result) |
166 | if (result && result.code === 200) { | 168 | if (result && result.code === 200) { |
@@ -188,10 +190,12 @@ module.exports = class extends global.yoho.BaseModel { | @@ -188,10 +190,12 @@ module.exports = class extends global.yoho.BaseModel { | ||
188 | delete params.gender; | 190 | delete params.gender; |
189 | } | 191 | } |
190 | 192 | ||
191 | - return API.get('', _.assign({ | ||
192 | - method: 'app.search.getTerms' | ||
193 | - }, params), { | ||
194 | - cache: true | 193 | + return this.get({ |
194 | + data: _.assign({ | ||
195 | + method: 'app.search.getTerms' | ||
196 | + }, params), | ||
197 | + api: global.yoho.API, | ||
198 | + param: {cache: true} | ||
195 | }).then((result) => { | 199 | }).then((result) => { |
196 | if (result && result.code === 200) { | 200 | if (result && result.code === 200) { |
197 | return result.data; | 201 | return result.data; |
@@ -207,8 +211,10 @@ module.exports = class extends global.yoho.BaseModel { | @@ -207,8 +211,10 @@ module.exports = class extends global.yoho.BaseModel { | ||
207 | * @return {[type]} | 211 | * @return {[type]} |
208 | */ | 212 | */ |
209 | _getChannelList() { | 213 | _getChannelList() { |
210 | - return api.get('operations/api/v5/entrance/getEntrance', {}, { | ||
211 | - cache: true | 214 | + return this.get({ |
215 | + url: 'operations/api/v5/entrance/getEntrance', | ||
216 | + api: global.yoho.ServiceAPI, | ||
217 | + param: {cache: true} | ||
212 | }).then((result) => { | 218 | }).then((result) => { |
213 | if (result && result.code === 200) { | 219 | if (result && result.code === 200) { |
214 | const list = {}; | 220 | const list = {}; |
@@ -253,10 +259,11 @@ module.exports = class extends global.yoho.BaseModel { | @@ -253,10 +259,11 @@ module.exports = class extends global.yoho.BaseModel { | ||
253 | * @return {[type]} | 259 | * @return {[type]} |
254 | */ | 260 | */ |
255 | _getChannelBg() { | 261 | _getChannelBg() { |
256 | - return api.get('operations/api/v5/resource/get', { | ||
257 | - content_code: contentCode.index | ||
258 | - }, { | ||
259 | - cache: true | 262 | + return this.get({ |
263 | + url: 'operations/api/v5/resource/get', | ||
264 | + data: {content_code: contentCode.index}, | ||
265 | + api: global.yoho.ServiceAPI, | ||
266 | + param: {cache: true} | ||
260 | }).then(result => { | 267 | }).then(result => { |
261 | if (result && result.code === 200) { | 268 | if (result && result.code === 200) { |
262 | return result.data.length && result.data[0] && result.data[0].data && result.data[0].data.list[0]; | 269 | return result.data.length && result.data[0] && result.data[0].data && result.data[0].data.list[0]; |
@@ -308,10 +315,11 @@ module.exports = class extends global.yoho.BaseModel { | @@ -308,10 +315,11 @@ module.exports = class extends global.yoho.BaseModel { | ||
308 | gender = gender || 'boys'; | 315 | gender = gender || 'boys'; |
309 | 316 | ||
310 | if (gender === 'boys' || gender === 'girls') { | 317 | if (gender === 'boys' || gender === 'girls') { |
311 | - return api.get('operations/api/v5/resource/get', { | ||
312 | - content_code: bottomBannerCode[gender] // eslint-disable-line | ||
313 | - }, { | ||
314 | - cache: true | 318 | + return this.get({ |
319 | + url: 'operations/api/v5/resource/get', | ||
320 | + data: {content_code: bottomBannerCode[gender]}, // eslint-disable-line | ||
321 | + api: global.yoho.ServiceAPI, | ||
322 | + param: {cache: true} | ||
315 | }); | 323 | }); |
316 | } | 324 | } |
317 | return Promise.resolve({ | 325 | return Promise.resolve({ |
@@ -325,10 +333,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -325,10 +333,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
325 | * 获取店铺推荐收藏和人数 | 333 | * 获取店铺推荐收藏和人数 |
326 | */ | 334 | */ |
327 | shopRecom(params) { | 335 | shopRecom(params) { |
328 | - return API.get('', { | ||
329 | - method: 'app.shops.floorNewInfo', | ||
330 | - shop_ids: params.shopIds, | ||
331 | - uid: params.uid, | 336 | + return this.get({ |
337 | + data: { | ||
338 | + method: 'app.shops.floorNewInfo', | ||
339 | + shop_ids: params.shopIds, | ||
340 | + uid: params.uid, | ||
341 | + }, | ||
342 | + api: global.yoho.API | ||
332 | }); | 343 | }); |
333 | } | 344 | } |
334 | }; | 345 | }; |
@@ -7,7 +7,6 @@ | @@ -7,7 +7,6 @@ | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | const utils = '../../../utils'; | 8 | const utils = '../../../utils'; |
9 | const resourcesProcess = require(`${utils}/resources-process`); | 9 | const resourcesProcess = require(`${utils}/resources-process`); |
10 | -const service = global.yoho.ServiceAPI; | ||
11 | 10 | ||
12 | module.exports = class extends global.yoho.BaseModel { | 11 | module.exports = class extends global.yoho.BaseModel { |
13 | constructor(ctx) { | 12 | constructor(ctx) { |
@@ -15,8 +14,9 @@ module.exports = class extends global.yoho.BaseModel { | @@ -15,8 +14,9 @@ module.exports = class extends global.yoho.BaseModel { | ||
15 | } | 14 | } |
16 | 15 | ||
17 | getResourceData(code) { | 16 | getResourceData(code) { |
18 | - return service.get('operations/api/v5/resource/get', { | ||
19 | - content_code: code | 17 | + return this.get({ |
18 | + url: 'operations/api/v5/resource/get', | ||
19 | + data: {content_code: code}, | ||
20 | }, { | 20 | }, { |
21 | cache: true, | 21 | cache: true, |
22 | code: 200 | 22 | code: 200 |
1 | 'use strict'; | 1 | 'use strict'; |
2 | -const api = global.yoho.API; | ||
3 | -const serviceAPI = global.yoho.ServiceAPI; | ||
4 | const _ = require('lodash'); | 2 | const _ = require('lodash'); |
5 | const helpers = global.yoho.helpers; | 3 | const helpers = global.yoho.helpers; |
6 | 4 | ||
@@ -104,11 +102,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -104,11 +102,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
104 | _getChannelData(params) { | 102 | _getChannelData(params) { |
105 | let gender = params - 1 || 0; | 103 | let gender = params - 1 || 0; |
106 | 104 | ||
107 | - return api.get('', { | ||
108 | - method: 'app.blk.getAllChannels' | ||
109 | - }, { | ||
110 | - cache: true, | ||
111 | - code: 200 | 105 | + return this.get({ |
106 | + data: {method: 'app.blk.getAllChannels'}, | ||
107 | + api: global.yoho.API, | ||
108 | + param: { | ||
109 | + cache: true, | ||
110 | + code: 200 | ||
111 | + } | ||
112 | }).then(result => { | 112 | }).then(result => { |
113 | let channel = []; | 113 | let channel = []; |
114 | 114 | ||
@@ -135,11 +135,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -135,11 +135,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
135 | if (!contentCode) { | 135 | if (!contentCode) { |
136 | return []; | 136 | return []; |
137 | } | 137 | } |
138 | - return serviceAPI.get('operations/api/v5/resource/get', { | ||
139 | - content_code: contentCode | ||
140 | - }, { | ||
141 | - cache: true, | ||
142 | - code: 200 | 138 | + return this.get({ |
139 | + url: 'operations/api/v5/resource/get', | ||
140 | + data: {content_code: contentCode}, | ||
141 | + api: global.yoho.ServiceAPI, | ||
142 | + param: { | ||
143 | + cache: true, | ||
144 | + code: 200 | ||
145 | + } | ||
143 | }).then(result => { | 146 | }).then(result => { |
144 | return result && result.data ? result.data : []; | 147 | return result && result.data ? result.data : []; |
145 | }); | 148 | }); |
@@ -148,13 +151,16 @@ module.exports = class extends global.yoho.BaseModel { | @@ -148,13 +151,16 @@ module.exports = class extends global.yoho.BaseModel { | ||
148 | _getBrandListOriginData(channel) { | 151 | _getBrandListOriginData(channel) { |
149 | let finalResult = {}; | 152 | let finalResult = {}; |
150 | 153 | ||
151 | - return api.get('', { | ||
152 | - method: 'app.brand.newBrandList', | ||
153 | - yh_channel: yhChannel[channel].channel, | ||
154 | - app_type: 1 | ||
155 | - }, { | ||
156 | - code: 200, | ||
157 | - cache: true | 154 | + return this.get({ |
155 | + data: { | ||
156 | + method: 'app.brand.newBrandList', | ||
157 | + yh_channel: yhChannel[channel].channel, | ||
158 | + app_type: 1 | ||
159 | + }, | ||
160 | + params: { | ||
161 | + code: 200, | ||
162 | + cache: true | ||
163 | + } | ||
158 | }).then(result => { | 164 | }).then(result => { |
159 | if (result.data && result.data.all_list) { | 165 | if (result.data && result.data.all_list) { |
160 | return Object.assign(finalResult, this.handleBrandList(result.data.all_list)); | 166 | return Object.assign(finalResult, this.handleBrandList(result.data.all_list)); |
@@ -218,11 +224,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -218,11 +224,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
218 | } | 224 | } |
219 | 225 | ||
220 | _getCateData(channel, appType) { | 226 | _getCateData(channel, appType) { |
221 | - return api.get('', { | ||
222 | - method: 'app.sort.get', | ||
223 | - app_type: 1 | ||
224 | - }, { | ||
225 | - cache: true | 227 | + return this.get({ |
228 | + data: { | ||
229 | + method: 'app.sort.get', | ||
230 | + app_type: 1 | ||
231 | + }, | ||
232 | + param: { | ||
233 | + cache: true | ||
234 | + } | ||
226 | }).then((result) => { | 235 | }).then((result) => { |
227 | if (!result.code || result.code !== 200 || !result.data) { | 236 | if (!result.code || result.code !== 200 || !result.data) { |
228 | return []; | 237 | return []; |
@@ -4,7 +4,6 @@ | @@ -4,7 +4,6 @@ | ||
4 | * @date: 2016/09/07 | 4 | * @date: 2016/09/07 |
5 | */ | 5 | */ |
6 | 'use strict'; | 6 | 'use strict'; |
7 | -const api = global.yoho.API; | ||
8 | 7 | ||
9 | 8 | ||
10 | module.exports = class extends global.yoho.BaseModel { | 9 | module.exports = class extends global.yoho.BaseModel { |
@@ -33,6 +32,9 @@ module.exports = class extends global.yoho.BaseModel { | @@ -33,6 +32,9 @@ module.exports = class extends global.yoho.BaseModel { | ||
33 | param.fav_id = id; | 32 | param.fav_id = id; |
34 | param.method = 'app.favorite.cancel'; | 33 | param.method = 'app.favorite.cancel'; |
35 | } | 34 | } |
36 | - return api.post('', param); | 35 | + return this.post({ |
36 | + data: param, | ||
37 | + api: global.yoho.API | ||
38 | + }); | ||
37 | } | 39 | } |
38 | }; | 40 | }; |
@@ -5,7 +5,6 @@ | @@ -5,7 +5,6 @@ | ||
5 | */ | 5 | */ |
6 | 'use strict'; | 6 | 'use strict'; |
7 | const serviceAPI = global.yoho.ServiceAPI; | 7 | const serviceAPI = global.yoho.ServiceAPI; |
8 | -const api = global.yoho.API; | ||
9 | const _ = require('lodash'); | 8 | const _ = require('lodash'); |
10 | const helpers = global.yoho.helpers; | 9 | const helpers = global.yoho.helpers; |
11 | 10 | ||
@@ -74,9 +73,12 @@ class DetailModel extends global.yoho.BaseModel { | @@ -74,9 +73,12 @@ class DetailModel extends global.yoho.BaseModel { | ||
74 | 73 | ||
75 | _getLeftNav(choosed) { | 74 | _getLeftNav(choosed) { |
76 | choosed = choosed || 'all'; | 75 | choosed = choosed || 'all'; |
77 | - | ||
78 | - return serviceAPI.get('operations/api/v6/category/getCategory', {}, { | ||
79 | - cache: true | 76 | + return this.get({ |
77 | + api: serviceAPI, | ||
78 | + url: 'operations/api/v6/category/getCategory', | ||
79 | + param: { | ||
80 | + cache: true | ||
81 | + } | ||
80 | }).then(result => { | 82 | }).then(result => { |
81 | if (result && result.code === 200) { | 83 | if (result && result.code === 200) { |
82 | 84 | ||
@@ -86,8 +88,12 @@ class DetailModel extends global.yoho.BaseModel { | @@ -86,8 +88,12 @@ class DetailModel extends global.yoho.BaseModel { | ||
86 | } | 88 | } |
87 | 89 | ||
88 | _getShareData(id) { | 90 | _getShareData(id) { |
89 | - return serviceAPI.get('guang/api/v6/share/guang', { | ||
90 | - id: id | 91 | + return this.get({ |
92 | + api: serviceAPI, | ||
93 | + url: 'guang/api/v6/share/guang', | ||
94 | + data: { | ||
95 | + id: id | ||
96 | + } | ||
91 | }).then(result => { | 97 | }).then(result => { |
92 | if (result && result.code === 200) { | 98 | if (result && result.code === 200) { |
93 | 99 | ||
@@ -101,10 +107,15 @@ class DetailModel extends global.yoho.BaseModel { | @@ -101,10 +107,15 @@ class DetailModel extends global.yoho.BaseModel { | ||
101 | * @param {*} articleId | 107 | * @param {*} articleId |
102 | */ | 108 | */ |
103 | _getArticle(articleId) { | 109 | _getArticle(articleId) { |
104 | - return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticle`, { | ||
105 | - article_id: articleId | ||
106 | - }, { | ||
107 | - cache: true | 110 | + return this.get({ |
111 | + api: serviceAPI, | ||
112 | + url: `${URI_PACKAGE_ARTICLE}getArticle`, | ||
113 | + data: { | ||
114 | + article_id: articleId | ||
115 | + }, | ||
116 | + param: { | ||
117 | + cache: true | ||
118 | + } | ||
108 | }); | 119 | }); |
109 | } | 120 | } |
110 | 121 | ||
@@ -113,10 +124,15 @@ class DetailModel extends global.yoho.BaseModel { | @@ -113,10 +124,15 @@ class DetailModel extends global.yoho.BaseModel { | ||
113 | * @param {*} authorId | 124 | * @param {*} authorId |
114 | */ | 125 | */ |
115 | _getAuthor(authorId) { | 126 | _getAuthor(authorId) { |
116 | - return serviceAPI.get(`${URI_PACKAGE_AUTHOR}getAuthor`, { | ||
117 | - author_id: authorId | ||
118 | - }, { | ||
119 | - cache: true | 127 | + return this.get({ |
128 | + api: serviceAPI, | ||
129 | + url: `${URI_PACKAGE_AUTHOR}getAuthor`, | ||
130 | + data: { | ||
131 | + author_id: authorId | ||
132 | + }, | ||
133 | + param: { | ||
134 | + cache: true | ||
135 | + } | ||
120 | }); | 136 | }); |
121 | } | 137 | } |
122 | 138 | ||
@@ -125,10 +141,15 @@ class DetailModel extends global.yoho.BaseModel { | @@ -125,10 +141,15 @@ class DetailModel extends global.yoho.BaseModel { | ||
125 | * @param {*} articleId | 141 | * @param {*} articleId |
126 | */ | 142 | */ |
127 | _getArticleContent(articleId) { | 143 | _getArticleContent(articleId) { |
128 | - return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, { | ||
129 | - article_id: articleId | ||
130 | - }, { | ||
131 | - cache: true | 144 | + return this.get({ |
145 | + api: serviceAPI, | ||
146 | + url: `${URI_PACKAGE_ARTICLE}getArticleContent`, | ||
147 | + data: { | ||
148 | + article_id: articleId | ||
149 | + }, | ||
150 | + param: { | ||
151 | + cache: true | ||
152 | + } | ||
132 | }); | 153 | }); |
133 | } | 154 | } |
134 | 155 | ||
@@ -137,10 +158,15 @@ class DetailModel extends global.yoho.BaseModel { | @@ -137,10 +158,15 @@ class DetailModel extends global.yoho.BaseModel { | ||
137 | * @param {*} articleId | 158 | * @param {*} articleId |
138 | */ | 159 | */ |
139 | _getBrand(articleId) { | 160 | _getBrand(articleId) { |
140 | - return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getBrand`, { | ||
141 | - article_id: articleId | ||
142 | - }, { | ||
143 | - cache: true | 161 | + return this.get({ |
162 | + api: serviceAPI, | ||
163 | + url: `${URI_PACKAGE_ARTICLE}getBrand`, | ||
164 | + data: { | ||
165 | + article_id: articleId | ||
166 | + }, | ||
167 | + param: { | ||
168 | + cache: true | ||
169 | + } | ||
144 | }); | 170 | }); |
145 | } | 171 | } |
146 | 172 | ||
@@ -150,13 +176,18 @@ class DetailModel extends global.yoho.BaseModel { | @@ -150,13 +176,18 @@ class DetailModel extends global.yoho.BaseModel { | ||
150 | * @param {*} tag | 176 | * @param {*} tag |
151 | */ | 177 | */ |
152 | _getOtherArticle(articleId, tag) { | 178 | _getOtherArticle(articleId, tag) { |
153 | - return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getOtherArticle`, { | ||
154 | - article_id: articleId, | ||
155 | - tags: tag, | ||
156 | - offset: 0, | ||
157 | - limit: 3 | ||
158 | - }, { | ||
159 | - cache: true | 179 | + return this.get({ |
180 | + api: serviceAPI, | ||
181 | + url: `${URI_PACKAGE_ARTICLE}getOtherArticle`, | ||
182 | + data: { | ||
183 | + article_id: articleId, | ||
184 | + tags: tag, | ||
185 | + offset: 0, | ||
186 | + limit: 3 | ||
187 | + }, | ||
188 | + param: { | ||
189 | + cache: true | ||
190 | + } | ||
160 | }); | 191 | }); |
161 | } | 192 | } |
162 | 193 | ||
@@ -164,10 +195,12 @@ class DetailModel extends global.yoho.BaseModel { | @@ -164,10 +195,12 @@ class DetailModel extends global.yoho.BaseModel { | ||
164 | * APP 获取微信模块 | 195 | * APP 获取微信模块 |
165 | */ | 196 | */ |
166 | _getSingleTemplateWechat() { | 197 | _getSingleTemplateWechat() { |
167 | - return api.get('', { | ||
168 | - method: 'app.resources.getSingleTemplate', | ||
169 | - module: 'wechat', | ||
170 | - key: 'guang_detail_wechat' | 198 | + return this.get({ |
199 | + data: { | ||
200 | + method: 'app.resources.getSingleTemplate', | ||
201 | + module: 'wechat', | ||
202 | + key: 'guang_detail_wechat' | ||
203 | + } | ||
171 | }); | 204 | }); |
172 | } | 205 | } |
173 | 206 | ||
@@ -320,13 +353,16 @@ class DetailModel extends global.yoho.BaseModel { | @@ -320,13 +353,16 @@ class DetailModel extends global.yoho.BaseModel { | ||
320 | * @return {[object]} | 353 | * @return {[object]} |
321 | */ | 354 | */ |
322 | intro(id) { | 355 | intro(id) { |
323 | - let param = { | ||
324 | - article_id: id, | ||
325 | - client_type: 'h5' | ||
326 | - }; | ||
327 | - | ||
328 | - return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, param, { | ||
329 | - cache: true | 356 | + return this.get({ |
357 | + api: serviceAPI, | ||
358 | + url: `${URI_PACKAGE_ARTICLE}getArticleContent`, | ||
359 | + data: { | ||
360 | + article_id: id, | ||
361 | + client_type: 'h5' | ||
362 | + }, | ||
363 | + param: { | ||
364 | + cache: true | ||
365 | + } | ||
330 | }); | 366 | }); |
331 | } | 367 | } |
332 | 368 | ||
@@ -338,16 +374,16 @@ class DetailModel extends global.yoho.BaseModel { | @@ -338,16 +374,16 @@ class DetailModel extends global.yoho.BaseModel { | ||
338 | productInfoBySkns(sknString) { | 374 | productInfoBySkns(sknString) { |
339 | let limit = sknString && sknString.split(',').length; | 375 | let limit = sknString && sknString.split(',').length; |
340 | 376 | ||
341 | - // 调用搜索接口 | ||
342 | - let param = { | ||
343 | - method: 'app.search.recomandLi', | ||
344 | - query: sknString, | ||
345 | - order: 's_t_desc', | ||
346 | - limit: limit || 1 | ||
347 | - }; | ||
348 | - | ||
349 | - return api.get('', param, { | ||
350 | - cache: true | 377 | + return this.get({ |
378 | + data: { | ||
379 | + method: 'app.search.recomandLi', | ||
380 | + query: sknString, | ||
381 | + order: 's_t_desc', | ||
382 | + limit: limit || 1 | ||
383 | + }, | ||
384 | + param: { | ||
385 | + cache: true | ||
386 | + } | ||
351 | }).then(result => { | 387 | }).then(result => { |
352 | return _.get(result, 'data.product_list', []); | 388 | return _.get(result, 'data.product_list', []); |
353 | }); | 389 | }); |
@@ -357,11 +393,15 @@ class DetailModel extends global.yoho.BaseModel { | @@ -357,11 +393,15 @@ class DetailModel extends global.yoho.BaseModel { | ||
357 | * 获取文章评论列表 | 393 | * 获取文章评论列表 |
358 | */ | 394 | */ |
359 | comments(params) { | 395 | comments(params) { |
360 | - return serviceAPI.get(`${URI_PACKAGE_COMMENTS}getList`, { | ||
361 | - article_id: params.article_id, | ||
362 | - page: params.page, | ||
363 | - limit: params.limit || 20, | ||
364 | - udid: params.udid | 396 | + return this.get({ |
397 | + api: serviceAPI, | ||
398 | + url: `${URI_PACKAGE_COMMENTS}getList`, | ||
399 | + data: { | ||
400 | + article_id: params.article_id, | ||
401 | + page: params.page, | ||
402 | + limit: params.limit || 20, | ||
403 | + udid: params.udid | ||
404 | + } | ||
365 | }).then(result => { | 405 | }).then(result => { |
366 | return _.get(result, 'data.list', []); | 406 | return _.get(result, 'data.list', []); |
367 | }); | 407 | }); |
@@ -372,11 +412,15 @@ class DetailModel extends global.yoho.BaseModel { | @@ -372,11 +412,15 @@ class DetailModel extends global.yoho.BaseModel { | ||
372 | * @param {*} params | 412 | * @param {*} params |
373 | */ | 413 | */ |
374 | commentsTotal(params) { | 414 | commentsTotal(params) { |
375 | - return serviceAPI.get(`${URI_PACKAGE_COMMENTS}getList`, { | ||
376 | - article_id: params.article_id, | ||
377 | - page: 1, | ||
378 | - limit: 1, | ||
379 | - udid: params.udid | 415 | + return this.get({ |
416 | + api: serviceAPI, | ||
417 | + url: `${URI_PACKAGE_COMMENTS}getList`, | ||
418 | + data: { | ||
419 | + article_id: params.article_id, | ||
420 | + page: 1, | ||
421 | + limit: 1, | ||
422 | + udid: params.udid | ||
423 | + } | ||
380 | }).then(result => { | 424 | }).then(result => { |
381 | return _.get(result, 'data.total', 0); | 425 | return _.get(result, 'data.total', 0); |
382 | }); | 426 | }); |
@@ -387,10 +431,14 @@ class DetailModel extends global.yoho.BaseModel { | @@ -387,10 +431,14 @@ class DetailModel extends global.yoho.BaseModel { | ||
387 | * @param {*} params | 431 | * @param {*} params |
388 | */ | 432 | */ |
389 | getArticlePraiseAndFavor(params) { | 433 | getArticlePraiseAndFavor(params) { |
390 | - return serviceAPI.get(`${URI_PACKAGE_PRAISE}getArticlePraiseAndFavor`, { | ||
391 | - uid: params.uid, | ||
392 | - id: params.id, | ||
393 | - udid: params.udid | 434 | + return this.get({ |
435 | + api: serviceAPI, | ||
436 | + url: `${URI_PACKAGE_PRAISE}getArticlePraiseAndFavor`, | ||
437 | + data: { | ||
438 | + uid: params.uid, | ||
439 | + id: params.id, | ||
440 | + udid: params.udid | ||
441 | + } | ||
394 | }).then(result => { | 442 | }).then(result => { |
395 | return _.get(result, 'data', {}); | 443 | return _.get(result, 'data', {}); |
396 | }); | 444 | }); |
@@ -22,10 +22,15 @@ class IndexModel extends global.yoho.BaseModel { | @@ -22,10 +22,15 @@ class IndexModel extends global.yoho.BaseModel { | ||
22 | * @return {[object]} | 22 | * @return {[object]} |
23 | */ | 23 | */ |
24 | getAuthor(id) { | 24 | getAuthor(id) { |
25 | - return serviceAPI.get('guang/service/v1/author/getAuthor', { | ||
26 | - author_id: id | ||
27 | - }, { | ||
28 | - cache: true | 25 | + return this.get({ |
26 | + api: serviceAPI, | ||
27 | + url: 'guang/service/v1/author/getAuthor', | ||
28 | + data: { | ||
29 | + author_id: id | ||
30 | + }, | ||
31 | + param: { | ||
32 | + cache: true | ||
33 | + } | ||
29 | }).then((result) => { | 34 | }).then((result) => { |
30 | if (result && result.code === 200) { | 35 | if (result && result.code === 200) { |
31 | return result; | 36 | return result; |
@@ -50,19 +55,22 @@ class IndexModel extends global.yoho.BaseModel { | @@ -50,19 +55,22 @@ class IndexModel extends global.yoho.BaseModel { | ||
50 | * @return {[array]} | 55 | * @return {[array]} |
51 | */ | 56 | */ |
52 | getArticleList(gender, sortId, uid, udid, page, tag, authorId, limit, useCache) { | 57 | getArticleList(gender, sortId, uid, udid, page, tag, authorId, limit, useCache) { |
53 | - let param = { | ||
54 | - page: page || 1, | ||
55 | - uid: uid || 0, | ||
56 | - udid: udid || '', | ||
57 | - gender: gender || '', | ||
58 | - sort_id: sortId, | ||
59 | - tag: tag, | ||
60 | - author_id: authorId, | ||
61 | - limit: 4 | ||
62 | - }; | ||
63 | - | ||
64 | - return serviceAPI.get('guang/api/v2/article/getList', param, { | ||
65 | - cache: useCache | 58 | + return this.get({ |
59 | + api: serviceAPI, | ||
60 | + url: 'guang/api/v2/article/getList', | ||
61 | + data: { | ||
62 | + page: page || 1, | ||
63 | + uid: uid || 0, | ||
64 | + udid: udid || '', | ||
65 | + gender: gender || '', | ||
66 | + sort_id: sortId, | ||
67 | + tag: tag, | ||
68 | + author_id: authorId, | ||
69 | + limit: 4 | ||
70 | + }, | ||
71 | + param: { | ||
72 | + cache: useCache | ||
73 | + } | ||
66 | }).then((result) => { | 74 | }).then((result) => { |
67 | if (result && result.code === 200) { | 75 | if (result && result.code === 200) { |
68 | return result; | 76 | return result; |
@@ -305,7 +313,11 @@ class IndexModel extends global.yoho.BaseModel { | @@ -305,7 +313,11 @@ class IndexModel extends global.yoho.BaseModel { | ||
305 | }); | 313 | }); |
306 | } | 314 | } |
307 | 315 | ||
308 | - return serviceAPI.get('guang/api/v6/article/getSimpleArticleList', params); | 316 | + return this.get({ |
317 | + api: serviceAPI, | ||
318 | + url: 'guang/api/v6/article/getSimpleArticleList', | ||
319 | + data: params | ||
320 | + }); | ||
309 | } | 321 | } |
310 | 322 | ||
311 | /** | 323 | /** |
@@ -315,10 +327,14 @@ class IndexModel extends global.yoho.BaseModel { | @@ -315,10 +327,14 @@ class IndexModel extends global.yoho.BaseModel { | ||
315 | */ | 327 | */ |
316 | 328 | ||
317 | getDynamicDataById(id, uid, udid) { | 329 | getDynamicDataById(id, uid, udid) { |
318 | - return serviceAPI.get('guang/api/v6/article/getArticlePraiseAndFavor', { | ||
319 | - id: id, | ||
320 | - uid: uid, | ||
321 | - udid: udid | 330 | + return this.get({ |
331 | + api: serviceAPI, | ||
332 | + url: 'guang/api/v6/article/getArticlePraiseAndFavor', | ||
333 | + data: { | ||
334 | + id: id, | ||
335 | + uid: uid, | ||
336 | + udid: udid | ||
337 | + } | ||
322 | }); | 338 | }); |
323 | } | 339 | } |
324 | 340 | ||
@@ -327,8 +343,12 @@ class IndexModel extends global.yoho.BaseModel { | @@ -327,8 +343,12 @@ class IndexModel extends global.yoho.BaseModel { | ||
327 | * @param {*} params | 343 | * @param {*} params |
328 | */ | 344 | */ |
329 | _getTopArticles(params) { | 345 | _getTopArticles(params) { |
330 | - return serviceAPI.get('guang/api/v6/article/getTopList', { | ||
331 | - gender: params.gender | 346 | + return this.get({ |
347 | + api: serviceAPI, | ||
348 | + url: 'guang/api/v6/article/getTopList', | ||
349 | + data: { | ||
350 | + gender: params.gender | ||
351 | + } | ||
332 | }); | 352 | }); |
333 | } | 353 | } |
334 | 354 | ||
@@ -336,11 +356,13 @@ class IndexModel extends global.yoho.BaseModel { | @@ -336,11 +356,13 @@ class IndexModel extends global.yoho.BaseModel { | ||
336 | * 逛分类 | 356 | * 逛分类 |
337 | */ | 357 | */ |
338 | _category() { | 358 | _category() { |
339 | - return serviceAPI.get('/guang/api/v1/category/get', { | ||
340 | - | ||
341 | - }, { | ||
342 | - cache: true, | ||
343 | - code: 200 | 359 | + return this.get({ |
360 | + api: serviceAPI, | ||
361 | + url: '/guang/api/v1/category/get', | ||
362 | + param: { | ||
363 | + cache: true, | ||
364 | + code: 200 | ||
365 | + } | ||
344 | }); | 366 | }); |
345 | } | 367 | } |
346 | 368 | ||
@@ -348,24 +370,23 @@ class IndexModel extends global.yoho.BaseModel { | @@ -348,24 +370,23 @@ class IndexModel extends global.yoho.BaseModel { | ||
348 | * 逛内容列表 | 370 | * 逛内容列表 |
349 | */ | 371 | */ |
350 | _article(param) { | 372 | _article(param) { |
351 | - return serviceAPI.get('/guang/api/v2/article/getList', { | ||
352 | - gender: param.gender, | ||
353 | - page: param.page || 1, | ||
354 | - uid: param.uid, | ||
355 | - udid: param.udid, | ||
356 | - sort_id: param.type || 0, | ||
357 | - tag: param.tag ? param.tag : null, | ||
358 | - limit: 4 | ||
359 | - | ||
360 | - // author_id: param.authorId ? param.authorId : null, | ||
361 | - // limit: param.limit ? param.limit : null | ||
362 | - }, { | ||
363 | - cache: true, | ||
364 | - code: 200 | 373 | + return this.get({ |
374 | + api: serviceAPI, | ||
375 | + url: '/guang/api/v2/article/getList', | ||
376 | + data: { | ||
377 | + gender: param.gender, | ||
378 | + page: param.page || 1, | ||
379 | + uid: param.uid, | ||
380 | + udid: param.udid, | ||
381 | + sort_id: param.type || 0, | ||
382 | + tag: param.tag ? param.tag : null, | ||
383 | + limit: 4 | ||
384 | + }, param: { | ||
385 | + cache: true, | ||
386 | + code: 200 | ||
387 | + } | ||
365 | }).then(result => { | 388 | }).then(result => { |
366 | - | ||
367 | return result; | 389 | return result; |
368 | - | ||
369 | }); | 390 | }); |
370 | } | 391 | } |
371 | } | 392 | } |
@@ -4,8 +4,6 @@ | @@ -4,8 +4,6 @@ | ||
4 | * @date: 2016/09/07 | 4 | * @date: 2016/09/07 |
5 | */ | 5 | */ |
6 | 'use strict'; | 6 | 'use strict'; |
7 | -const serviceAPI = global.yoho.ServiceAPI; | ||
8 | -const api = global.yoho.API; | ||
9 | 7 | ||
10 | module.exports = class extends global.yoho.BaseModel { | 8 | module.exports = class extends global.yoho.BaseModel { |
11 | constructor(ctx) { | 9 | constructor(ctx) { |
@@ -26,9 +24,17 @@ module.exports = class extends global.yoho.BaseModel { | @@ -26,9 +24,17 @@ module.exports = class extends global.yoho.BaseModel { | ||
26 | }; | 24 | }; |
27 | 25 | ||
28 | if (opt === 'cancel') { | 26 | if (opt === 'cancel') { |
29 | - return serviceAPI.get('guang/api/v2/praise/cancel', param); | 27 | + return this.get({ |
28 | + url: 'guang/api/v2/praise/cancel', | ||
29 | + data: param, | ||
30 | + api: global.yoho.ServiceAPI | ||
31 | + }); | ||
30 | } else { | 32 | } else { |
31 | - return serviceAPI.get('guang/api/v2/praise/setPraise', param); | 33 | + return this.get({ |
34 | + url: 'guang/api/v2/praise/setPraise', | ||
35 | + data: param, | ||
36 | + api: global.yoho.ServiceAPI | ||
37 | + }); | ||
32 | } | 38 | } |
33 | } | 39 | } |
34 | 40 | ||
@@ -46,9 +52,17 @@ module.exports = class extends global.yoho.BaseModel { | @@ -46,9 +52,17 @@ module.exports = class extends global.yoho.BaseModel { | ||
46 | }; | 52 | }; |
47 | 53 | ||
48 | if (opt === 'cancel') { | 54 | if (opt === 'cancel') { |
49 | - return serviceAPI.get('guang/api/v1/favorite/cancelFavorite', param); | 55 | + return this.get({ |
56 | + url: 'guang/api/v1/favorite/cancelFavorite', | ||
57 | + data: param, | ||
58 | + api: global.yoho.ServiceAPI | ||
59 | + }); | ||
50 | } else { | 60 | } else { |
51 | - return serviceAPI.get('guang/api/v1/favorite/setFavorite', param); | 61 | + return this.get({ |
62 | + url: 'guang/api/v1/favorite/setFavorite', | ||
63 | + data: param, | ||
64 | + api: global.yoho.ServiceAPI | ||
65 | + }); | ||
52 | } | 66 | } |
53 | } | 67 | } |
54 | 68 | ||
@@ -73,9 +87,17 @@ module.exports = class extends global.yoho.BaseModel { | @@ -73,9 +87,17 @@ module.exports = class extends global.yoho.BaseModel { | ||
73 | 87 | ||
74 | 88 | ||
75 | if (opt === 'ok') { | 89 | if (opt === 'ok') { |
76 | - return api.get('app.favorite.add', param); | 90 | + return this.get({ |
91 | + url: 'app.favorite.add', | ||
92 | + data: param, | ||
93 | + api: global.yoho.API | ||
94 | + }); | ||
77 | } else { | 95 | } else { |
78 | - return api.get('app.favorite.cancel', param); | 96 | + return this.get({ |
97 | + url: 'app.favorite.cancel', | ||
98 | + data: param, | ||
99 | + api: global.yoho.API | ||
100 | + }); | ||
79 | } | 101 | } |
80 | } | 102 | } |
81 | }; | 103 | }; |
1 | 'use strict'; | 1 | 'use strict'; |
2 | -const api = global.yoho.API; | ||
3 | -const serviceAPI = global.yoho.ServiceAPI; | ||
4 | const _ = require('lodash'); | 2 | const _ = require('lodash'); |
5 | const productProcess = require('../../../utils/product-process'); | 3 | const productProcess = require('../../../utils/product-process'); |
6 | 4 | ||
@@ -16,11 +14,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -16,11 +14,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
16 | getAllChannels(params) { | 14 | getAllChannels(params) { |
17 | let gender = params.gender - 1 || 0; | 15 | let gender = params.gender - 1 || 0; |
18 | 16 | ||
19 | - return api.get('', { | ||
20 | - method: 'app.blk.getAllChannels', | ||
21 | - app_type: params.app_type | ||
22 | - }, { | ||
23 | - cache: true | 17 | + return this.get({ |
18 | + data: { | ||
19 | + method: 'app.blk.getAllChannels', | ||
20 | + app_type: params.app_type | ||
21 | + }, | ||
22 | + api: global.yoho.API, | ||
23 | + param: {cache: true} | ||
24 | }).then(result => { | 24 | }).then(result => { |
25 | let data = {channel: []}; | 25 | let data = {channel: []}; |
26 | 26 | ||
@@ -54,14 +54,16 @@ module.exports = class extends global.yoho.BaseModel { | @@ -54,14 +54,16 @@ module.exports = class extends global.yoho.BaseModel { | ||
54 | */ | 54 | */ |
55 | getProductBatch(param, options) { | 55 | getProductBatch(param, options) { |
56 | param.productSkn = _.isArray(param.productSkn) ? param.productSkn : [param.productSkn]; | 56 | param.productSkn = _.isArray(param.productSkn) ? param.productSkn : [param.productSkn]; |
57 | - return api.get('', { | ||
58 | - method: 'h5.product.batch', | ||
59 | - productSkn: param.productSkn.join(','), | ||
60 | - yh_channel: param.yh_channel, | ||
61 | - page: param.page, | ||
62 | - limit: param.limit | ||
63 | - }, { | ||
64 | - cache: true | 57 | + return this.get({ |
58 | + data: { | ||
59 | + method: 'h5.product.batch', | ||
60 | + productSkn: param.productSkn.join(','), | ||
61 | + yh_channel: param.yh_channel, | ||
62 | + page: param.page, | ||
63 | + limit: param.limit | ||
64 | + }, | ||
65 | + api: global.yoho.API, | ||
66 | + param: {cache: true} | ||
65 | }).then(result => { | 67 | }).then(result => { |
66 | let data = {}; | 68 | let data = {}; |
67 | 69 | ||
@@ -82,9 +84,12 @@ module.exports = class extends global.yoho.BaseModel { | @@ -82,9 +84,12 @@ module.exports = class extends global.yoho.BaseModel { | ||
82 | * @return {[array]} | 84 | * @return {[array]} |
83 | */ | 85 | */ |
84 | getFashionPrefer(params) { | 86 | getFashionPrefer(params) { |
85 | - return api.get('', Object.assign({ | ||
86 | - method: 'h5.product.fashionPrefer' | ||
87 | - }, params)); | 87 | + return this.get({ |
88 | + data: Object.assign({ | ||
89 | + method: 'h5.product.fashionPrefer' | ||
90 | + }, params), | ||
91 | + api: global.yoho.API | ||
92 | + }); | ||
88 | } | 93 | } |
89 | 94 | ||
90 | /** | 95 | /** |
@@ -98,8 +103,11 @@ module.exports = class extends global.yoho.BaseModel { | @@ -98,8 +103,11 @@ module.exports = class extends global.yoho.BaseModel { | ||
98 | if (options.isApp) { | 103 | if (options.isApp) { |
99 | params.platform = 'iphone'; | 104 | params.platform = 'iphone'; |
100 | } | 105 | } |
101 | - return serviceAPI.get('operations/api/v5/resource/get', params, { | ||
102 | - cache: true | 106 | + return this.get({ |
107 | + url: 'operations/api/v5/resource/get', | ||
108 | + data: params, | ||
109 | + api: global.yoho.ServiceAPI, | ||
110 | + param: {cache: true} | ||
103 | }).then(result => { | 111 | }).then(result => { |
104 | let data = { | 112 | let data = { |
105 | goods: {}, | 113 | goods: {}, |
@@ -180,7 +188,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -180,7 +188,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
180 | } | 188 | } |
181 | 189 | ||
182 | getResourcesData(params, options) { | 190 | getResourcesData(params, options) { |
183 | - return api.all([ | 191 | + return Promise.all([ |
184 | this.getResources(params, options), | 192 | this.getResources(params, options), |
185 | this.getFashionPrefer(params) | 193 | this.getFashionPrefer(params) |
186 | ]).then(result => { | 194 | ]).then(result => { |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | const productNameProcess = require(`${global.utils}/product-name-process`); | 3 | const productNameProcess = require(`${global.utils}/product-name-process`); |
4 | -const api = global.yoho.API; | ||
5 | -const serviceAPI = global.yoho.ServiceAPI; | ||
6 | const _ = require('lodash'); | 4 | const _ = require('lodash'); |
7 | const logger = global.yoho.logger; | 5 | const logger = global.yoho.logger; |
8 | const helpers = global.yoho.helpers; | 6 | const helpers = global.yoho.helpers; |
@@ -65,7 +63,12 @@ module.exports = class extends global.yoho.BaseModel { | @@ -65,7 +63,12 @@ module.exports = class extends global.yoho.BaseModel { | ||
65 | param.is_recommend = isRecommend; | 63 | param.is_recommend = isRecommend; |
66 | } | 64 | } |
67 | 65 | ||
68 | - return serviceAPI.get('guang/api/v3/plustar/getlist', param, {cache: true}).then((result) => { | 66 | + return this.get({ |
67 | + url: 'guang/api/v3/plustar/getlist', | ||
68 | + data: param, | ||
69 | + api: global.yoho.ServiceAPI, | ||
70 | + param: {cache: true} | ||
71 | + }).then((result) => { | ||
69 | if (result && result.code === 200) { | 72 | if (result && result.code === 200) { |
70 | return this.formaData(result.data.data.list[0].data, gender); | 73 | return this.formaData(result.data.data.list[0].data, gender); |
71 | } else { | 74 | } else { |
@@ -125,14 +128,18 @@ module.exports = class extends global.yoho.BaseModel { | @@ -125,14 +128,18 @@ module.exports = class extends global.yoho.BaseModel { | ||
125 | // 新品到着 | 128 | // 新品到着 |
126 | getNewProduct(brandId, gender, url, isApp) { | 129 | getNewProduct(brandId, gender, url, isApp) { |
127 | 130 | ||
128 | - return api.get('', { | ||
129 | - method: 'app.search.li', | ||
130 | - brand: brandId, | ||
131 | - gender: gender, | ||
132 | - limit: 6, | ||
133 | - order: 's_t_desc', | ||
134 | - page: 1 | ||
135 | - }, {cache: true}).then((result) => { | 131 | + return this.get({ |
132 | + data: { | ||
133 | + method: 'app.search.li', | ||
134 | + brand: brandId, | ||
135 | + gender: gender, | ||
136 | + limit: 6, | ||
137 | + order: 's_t_desc', | ||
138 | + page: 1 | ||
139 | + }, | ||
140 | + api: global.yoho.API, | ||
141 | + param: {cache: true} | ||
142 | + }).then((result) => { | ||
136 | 143 | ||
137 | if (result && result.code === 200) { | 144 | if (result && result.code === 200) { |
138 | 145 | ||
@@ -235,11 +242,15 @@ module.exports = class extends global.yoho.BaseModel { | @@ -235,11 +242,15 @@ module.exports = class extends global.yoho.BaseModel { | ||
235 | // 相关资讯--不能加cache,否则点赞有缓存. | 242 | // 相关资讯--不能加cache,否则点赞有缓存. |
236 | getRelatedEditorial(brandId, uid, udid, isApp) { | 243 | getRelatedEditorial(brandId, uid, udid, isApp) { |
237 | 244 | ||
238 | - return serviceAPI.get('guang/service/v1/article/getArticleByBrand', { | ||
239 | - brand_id: brandId, | ||
240 | - uid: uid, | ||
241 | - udid: udid, | ||
242 | - limit: 3 | 245 | + return this.get({ |
246 | + url: 'guang/service/v1/article/getArticleByBrand', | ||
247 | + data: { | ||
248 | + brand_id: brandId, | ||
249 | + uid: uid, | ||
250 | + udid: udid, | ||
251 | + limit: 3 | ||
252 | + }, | ||
253 | + api: global.yoho.ServiceAPI | ||
243 | }).then((result) => { | 254 | }).then((result) => { |
244 | if (result && result.code === 200) { | 255 | if (result && result.code === 200) { |
245 | 256 | ||
@@ -280,7 +291,11 @@ module.exports = class extends global.yoho.BaseModel { | @@ -280,7 +291,11 @@ module.exports = class extends global.yoho.BaseModel { | ||
280 | param.uid = uid; | 291 | param.uid = uid; |
281 | } | 292 | } |
282 | 293 | ||
283 | - return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', param).then((result) => { | 294 | + return this.get({ |
295 | + url: 'shops/service/v1/favorite/getUidBrandFav', | ||
296 | + data: param, | ||
297 | + api: global.yoho.ServiceAPI | ||
298 | + }).then((result) => { | ||
284 | 299 | ||
285 | if (result && result.code === 200) { | 300 | if (result && result.code === 200) { |
286 | 301 | ||
@@ -298,9 +313,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -298,9 +313,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
298 | // 品牌详情 | 313 | // 品牌详情 |
299 | getDetailData(id, uid, udid, gender, isApp) { | 314 | getDetailData(id, uid, udid, gender, isApp) { |
300 | 315 | ||
301 | - return serviceAPI.get('guang/api/v1/plustar/getbrandinfo', { | ||
302 | - id: id | ||
303 | - }, {cache: true}).then((result) => { | 316 | + return this.get({ |
317 | + url: 'guang/api/v1/plustar/getbrandinfo', | ||
318 | + data: { | ||
319 | + id: id | ||
320 | + }, | ||
321 | + api: global.yoho.ServiceAPI, | ||
322 | + param: {cache: true} | ||
323 | + }).then((result) => { | ||
304 | if (result && result.code === 200) { | 324 | if (result && result.code === 200) { |
305 | let list = result.data || []; | 325 | let list = result.data || []; |
306 | let jumpToApp; | 326 | let jumpToApp; |
@@ -10,8 +10,6 @@ const resourcesProcess = require(`${utils}/resources-process`); | @@ -10,8 +10,6 @@ const resourcesProcess = require(`${utils}/resources-process`); | ||
10 | const logger = global.yoho.logger; | 10 | const logger = global.yoho.logger; |
11 | const helpers = global.yoho.helpers; | 11 | const helpers = global.yoho.helpers; |
12 | const _ = require('lodash'); | 12 | const _ = require('lodash'); |
13 | -const serviceAPI = global.yoho.ServiceAPI; | ||
14 | -const api = global.yoho.API; | ||
15 | 13 | ||
16 | const contentCode = contentCodeConfig.guang; | 14 | const contentCode = contentCodeConfig.guang; |
17 | 15 | ||
@@ -26,11 +24,16 @@ module.exports = class extends global.yoho.BaseModel { | @@ -26,11 +24,16 @@ module.exports = class extends global.yoho.BaseModel { | ||
26 | * @return {[array]} | 24 | * @return {[array]} |
27 | */ | 25 | */ |
28 | _getResources(page) { | 26 | _getResources(page) { |
29 | - return serviceAPI.get('operations/api/v5/resource/get', { | ||
30 | - content_code: contentCode[page], | ||
31 | - platform: 'iphone' | ||
32 | - }, { | ||
33 | - cache: true | 27 | + return this.get({ |
28 | + url: 'operations/api/v5/resource/get', | ||
29 | + data: { | ||
30 | + content_code: contentCode[page], | ||
31 | + platform: 'iphone' | ||
32 | + }, | ||
33 | + api: global.yoho.ServiceAPI, | ||
34 | + param: { | ||
35 | + cache: true | ||
36 | + } | ||
34 | }).then((result) => { | 37 | }).then((result) => { |
35 | if (result && result.code === 200) { | 38 | if (result && result.code === 200) { |
36 | return resourcesProcess(result.data); | 39 | return resourcesProcess(result.data); |
@@ -165,11 +168,15 @@ module.exports = class extends global.yoho.BaseModel { | @@ -165,11 +168,15 @@ module.exports = class extends global.yoho.BaseModel { | ||
165 | * 星潮首页 | 168 | * 星潮首页 |
166 | */ | 169 | */ |
167 | getIndexData() { | 170 | getIndexData() { |
168 | - return api.get('', { | ||
169 | - method: 'app.starClass.index', | ||
170 | - code: '8adc27fcf5676f356602889afcfd2a8e' | ||
171 | - }, { | ||
172 | - cache: true | 171 | + return this.get({ |
172 | + data: { | ||
173 | + method: 'app.starClass.index', | ||
174 | + code: '8adc27fcf5676f356602889afcfd2a8e' | ||
175 | + }, | ||
176 | + api: global.yoho.API, | ||
177 | + param: { | ||
178 | + cache: true | ||
179 | + } | ||
173 | }).then((result) => { | 180 | }).then((result) => { |
174 | if (result && result.code === 200) { | 181 | if (result && result.code === 200) { |
175 | return this._processIndexData(result); | 182 | return this._processIndexData(result); |
@@ -184,14 +191,18 @@ module.exports = class extends global.yoho.BaseModel { | @@ -184,14 +191,18 @@ module.exports = class extends global.yoho.BaseModel { | ||
184 | * 明星专题 | 191 | * 明星专题 |
185 | */ | 192 | */ |
186 | getDetailData(params, uid) { | 193 | getDetailData(params, uid) { |
187 | - return api.get('', { | ||
188 | - method: 'app.starClass.lastTagArticle', | ||
189 | - tag: params.tag, | ||
190 | - page: params.page || 1, | ||
191 | - size: 10, | ||
192 | - uid: uid | ||
193 | - }, { | ||
194 | - cache: true | 194 | + return this.get({ |
195 | + data: { | ||
196 | + method: 'app.starClass.lastTagArticle', | ||
197 | + tag: params.tag, | ||
198 | + page: params.page || 1, | ||
199 | + size: 10, | ||
200 | + uid: uid | ||
201 | + }, | ||
202 | + api: global.yoho.API, | ||
203 | + param: { | ||
204 | + cache: true | ||
205 | + } | ||
195 | }).then((result) => { | 206 | }).then((result) => { |
196 | if (result && result.code === 200) { | 207 | if (result && result.code === 200) { |
197 | if (params.page > result.data.totalPage) { | 208 | if (params.page > result.data.totalPage) { |
@@ -237,11 +248,16 @@ module.exports = class extends global.yoho.BaseModel { | @@ -237,11 +248,16 @@ module.exports = class extends global.yoho.BaseModel { | ||
237 | * 星搭配 | 248 | * 星搭配 |
238 | */ | 249 | */ |
239 | getCollocationListData(params, uid) { | 250 | getCollocationListData(params, uid) { |
240 | - return serviceAPI.get('guang/api/v5/article/getStarClassroomArticleList', Object.assign({ | ||
241 | - limit: '20', | ||
242 | - uid: uid | ||
243 | - }, params), { | ||
244 | - cache: true | 251 | + return this.get({ |
252 | + url: 'guang/api/v5/article/getStarClassroomArticleList', | ||
253 | + data: Object.assign({ | ||
254 | + limit: '20', | ||
255 | + uid: uid | ||
256 | + }, params), | ||
257 | + api: global.yoho.ServiceAPI, | ||
258 | + param: { | ||
259 | + cache: true | ||
260 | + } | ||
245 | }).then((result) => { | 261 | }).then((result) => { |
246 | if (result && result.code === 200) { | 262 | if (result && result.code === 200) { |
247 | return this._processGuangData(result.data.list.artList); | 263 | return this._processGuangData(result.data.list.artList); |
@@ -260,11 +276,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -260,11 +276,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
260 | }); | 276 | }); |
261 | } | 277 | } |
262 | 278 | ||
263 | - return api.get('', { | ||
264 | - method: params.type === 'del' ? 'app.sns.cancelFavorBackCount' : 'app.sns.setFavorBackCount', | ||
265 | - client_type: 'h5', | ||
266 | - article_id: params.articleId, | ||
267 | - uid: uid | 279 | + return this.get({ |
280 | + data: { | ||
281 | + method: params.type === 'del' ? 'app.sns.cancelFavorBackCount' : 'app.sns.setFavorBackCount', | ||
282 | + client_type: 'h5', | ||
283 | + article_id: params.articleId, | ||
284 | + uid: uid | ||
285 | + }, | ||
286 | + api: global.yoho.API | ||
268 | }); | 287 | }); |
269 | } | 288 | } |
270 | }; | 289 | }; |
@@ -21,10 +21,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -21,10 +21,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
21 | * @param params | 21 | * @param params |
22 | */ | 22 | */ |
23 | _getAddressData(params) { | 23 | _getAddressData(params) { |
24 | - return api.get('', { | ||
25 | - method: 'app.address.gethidden', | ||
26 | - uid: params.uid | ||
27 | - }, {code: 200}); | 24 | + return this.get({ |
25 | + data: { | ||
26 | + method: 'app.address.gethidden', | ||
27 | + uid: params.uid | ||
28 | + }, | ||
29 | + api: global.yoho.API, | ||
30 | + param: {code: 200} | ||
31 | + }); | ||
28 | } | 32 | } |
29 | 33 | ||
30 | /** | 34 | /** |
@@ -34,10 +38,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -34,10 +38,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
34 | * @private | 38 | * @private |
35 | */ | 39 | */ |
36 | _getThrAddressData(params) { | 40 | _getThrAddressData(params) { |
37 | - return api.get('', { | ||
38 | - method: 'app.address.getlist', | ||
39 | - uid: params.uid | ||
40 | - }, {code: 200, cache: true}); | 41 | + return this.get({ |
42 | + data: { | ||
43 | + method: 'app.address.getlist', | ||
44 | + uid: params.uid | ||
45 | + }, | ||
46 | + api: global.yoho.API, | ||
47 | + param: {code: 200, cache: true} | ||
48 | + }); | ||
41 | } | 49 | } |
42 | 50 | ||
43 | /** | 51 | /** |
@@ -46,16 +54,19 @@ module.exports = class extends global.yoho.BaseModel { | @@ -46,16 +54,19 @@ module.exports = class extends global.yoho.BaseModel { | ||
46 | * @private | 54 | * @private |
47 | */ | 55 | */ |
48 | _saveAddressData(params) { | 56 | _saveAddressData(params) { |
49 | - return api.get('', { | ||
50 | - method: params.id ? 'app.address.update' : 'app.address.add', | ||
51 | - id: params.id, | ||
52 | - address: params.address, | ||
53 | - area_code: params.area_code, | ||
54 | - consignee: params.consignee, | ||
55 | - email: params.email, | ||
56 | - mobile: params.mobile, | ||
57 | - zip_code: params.zip_code, | ||
58 | - uid: params.uid | 57 | + return this.get({ |
58 | + data: { | ||
59 | + method: params.id ? 'app.address.update' : 'app.address.add', | ||
60 | + id: params.id, | ||
61 | + address: params.address, | ||
62 | + area_code: params.area_code, | ||
63 | + consignee: params.consignee, | ||
64 | + email: params.email, | ||
65 | + mobile: params.mobile, | ||
66 | + zip_code: params.zip_code, | ||
67 | + uid: params.uid | ||
68 | + }, | ||
69 | + api: global.yoho.API | ||
59 | }); | 70 | }); |
60 | } | 71 | } |
61 | 72 | ||
@@ -65,10 +76,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -65,10 +76,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
65 | * @private | 76 | * @private |
66 | */ | 77 | */ |
67 | _setDefaultAddress(params) { | 78 | _setDefaultAddress(params) { |
68 | - return api.get('', { | ||
69 | - method: 'app.address.setdefault', | ||
70 | - uid: params.id, | ||
71 | - id: params.id | 79 | + return this.get({ |
80 | + data: { | ||
81 | + method: 'app.address.setdefault', | ||
82 | + uid: params.id, | ||
83 | + id: params.id | ||
84 | + }, | ||
85 | + api: global.yoho.API | ||
72 | }); | 86 | }); |
73 | } | 87 | } |
74 | 88 | ||
@@ -78,10 +92,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -78,10 +92,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
78 | * @private | 92 | * @private |
79 | */ | 93 | */ |
80 | _delAddressData(params) { | 94 | _delAddressData(params) { |
81 | - return api.get('', { | ||
82 | - method: 'app.address.del', | ||
83 | - id: params.id, | ||
84 | - uid: params.uid | 95 | + return this.get({ |
96 | + data: { | ||
97 | + method: 'app.address.del', | ||
98 | + id: params.id, | ||
99 | + uid: params.uid | ||
100 | + }, | ||
101 | + api: global.yoho.API | ||
85 | }); | 102 | }); |
86 | } | 103 | } |
87 | 104 | ||
@@ -201,10 +218,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -201,10 +218,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
201 | * 新版地址选择获取地址 | 218 | * 新版地址选择获取地址 |
202 | */ | 219 | */ |
203 | newGetAddress(params) { | 220 | newGetAddress(params) { |
204 | - return api.get('', { | ||
205 | - method: 'app.address.provinces', | ||
206 | - id: params.id || '0' | ||
207 | - }, {code: 200, cache: true}).then(result => { | 221 | + return this.get({ |
222 | + data: { | ||
223 | + method: 'app.address.provinces', | ||
224 | + id: params.id || '0' | ||
225 | + }, | ||
226 | + api: global.yoho.API, | ||
227 | + param: {code: 200, cache: true} | ||
228 | + }).then(result => { | ||
208 | return result && result.data; | 229 | return result && result.data; |
209 | }); | 230 | }); |
210 | } | 231 | } |
@@ -214,11 +235,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -214,11 +235,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
214 | * @param params | 235 | * @param params |
215 | */ | 236 | */ |
216 | chooseAddress(orderCode, addressId, uid) { | 237 | chooseAddress(orderCode, addressId, uid) { |
217 | - return api.get('', { | ||
218 | - method: 'app.SpaceOrders.updateDeliveryAddress', | ||
219 | - uid: uid, | ||
220 | - order_code: orderCode, | ||
221 | - address_id: crypto.decrypt(null, addressId) | 238 | + return this.get({ |
239 | + data: { | ||
240 | + method: 'app.SpaceOrders.updateDeliveryAddress', | ||
241 | + uid: uid, | ||
242 | + order_code: orderCode, | ||
243 | + address_id: crypto.decrypt(null, addressId) | ||
244 | + }, | ||
245 | + api: global.yoho.API | ||
222 | }).then((result) => { | 246 | }).then((result) => { |
223 | return result; | 247 | return result; |
224 | }); | 248 | }); |
1 | // 优惠券 by acgpiano | 1 | // 优惠券 by acgpiano |
2 | 'use strict'; | 2 | 'use strict'; |
3 | 3 | ||
4 | -const api = global.yoho.API; | ||
5 | const helpers = global.yoho.helpers; | 4 | const helpers = global.yoho.helpers; |
6 | 5 | ||
7 | class couponsModel extends global.yoho.BaseModel { | 6 | class couponsModel extends global.yoho.BaseModel { |
@@ -10,7 +9,7 @@ class couponsModel extends global.yoho.BaseModel { | @@ -10,7 +9,7 @@ class couponsModel extends global.yoho.BaseModel { | ||
10 | } | 9 | } |
11 | 10 | ||
12 | couponData(params) { | 11 | couponData(params) { |
13 | - return api.get('', params).then(result => { | 12 | + return this.get({data: params}).then(result => { |
14 | 13 | ||
15 | if (result && result.data && result.data.couponList) { | 14 | if (result && result.data && result.data.couponList) { |
16 | let status0 = params.status === 0; | 15 | let status0 = params.status === 0; |
@@ -7,9 +7,6 @@ | @@ -7,9 +7,6 @@ | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | const logger = global.yoho.logger; | 9 | const logger = global.yoho.logger; |
10 | -const api = global.yoho.API; | ||
11 | - | ||
12 | -// const serviceAPI = global.yoho.ServiceAPI; | ||
13 | const camelCase = global.yoho.camelCase; | 10 | const camelCase = global.yoho.camelCase; |
14 | const _ = require('lodash'); | 11 | const _ = require('lodash'); |
15 | const config = global.yoho.config; | 12 | const config = global.yoho.config; |
@@ -22,12 +19,12 @@ class favoriteIndexModel extends global.yoho.BaseModel { | @@ -22,12 +19,12 @@ class favoriteIndexModel extends global.yoho.BaseModel { | ||
22 | 19 | ||
23 | favProduct(uid, page, limit) { | 20 | favProduct(uid, page, limit) { |
24 | 21 | ||
25 | - return api.get('', { | 22 | + return this.get({data: { |
26 | method: 'app.favorite.product', | 23 | method: 'app.favorite.product', |
27 | uid: uid, | 24 | uid: uid, |
28 | page: page, | 25 | page: page, |
29 | limit: limit | 26 | limit: limit |
30 | - }).then((result) => { | 27 | + }}).then((result) => { |
31 | 28 | ||
32 | let resu = { | 29 | let resu = { |
33 | hasFavProduct: [] | 30 | hasFavProduct: [] |
@@ -123,12 +120,12 @@ class favoriteIndexModel extends global.yoho.BaseModel { | @@ -123,12 +120,12 @@ class favoriteIndexModel extends global.yoho.BaseModel { | ||
123 | } | 120 | } |
124 | 121 | ||
125 | favfavBrand(uid, page, limit) { | 122 | favfavBrand(uid, page, limit) { |
126 | - return api.get('', { | 123 | + return this.get({data: { |
127 | method: 'app.favorite.brand', | 124 | method: 'app.favorite.brand', |
128 | uid: uid, | 125 | uid: uid, |
129 | page: page, | 126 | page: page, |
130 | limit: limit | 127 | limit: limit |
131 | - }).then((result) => { | 128 | + }}).then((result) => { |
132 | 129 | ||
133 | let resu = { | 130 | let resu = { |
134 | hasFavBrand: [] | 131 | hasFavBrand: [] |
@@ -203,12 +200,12 @@ class favoriteIndexModel extends global.yoho.BaseModel { | @@ -203,12 +200,12 @@ class favoriteIndexModel extends global.yoho.BaseModel { | ||
203 | 200 | ||
204 | favoriteDelete(uid, type, favId) { | 201 | favoriteDelete(uid, type, favId) { |
205 | 202 | ||
206 | - return api.get('', { | 203 | + return this.get({data: { |
207 | method: 'app.favorite.cancel', | 204 | method: 'app.favorite.cancel', |
208 | uid: uid, | 205 | uid: uid, |
209 | type: type, | 206 | type: type, |
210 | fav_id: favId | 207 | fav_id: favId |
211 | - }); | 208 | + }}); |
212 | } | 209 | } |
213 | 210 | ||
214 | index(uid, page, limit, isbrand) { | 211 | index(uid, page, limit, isbrand) { |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | -const api = global.yoho.API; | ||
4 | const helpers = global.yoho.helpers; | 3 | const helpers = global.yoho.helpers; |
5 | const _ = require('lodash'); | 4 | const _ = require('lodash'); |
6 | const moment = require('moment'); | 5 | const moment = require('moment'); |
@@ -90,7 +89,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -90,7 +89,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
90 | 89 | ||
91 | index(param) { | 90 | index(param) { |
92 | if (param.uid) { | 91 | if (param.uid) { |
93 | - return api.all([ | 92 | + return Promise.all([ |
94 | this.getGradeGrade(param.uid, param.channel), | 93 | this.getGradeGrade(param.uid, param.channel), |
95 | this.getGradeUser(param.uid, param.channel), | 94 | this.getGradeUser(param.uid, param.channel), |
96 | this.getGrowthVip(param.uid) | 95 | this.getGrowthVip(param.uid) |
@@ -200,7 +199,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -200,7 +199,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
200 | } | 199 | } |
201 | 200 | ||
202 | grow(param) { | 201 | grow(param) { |
203 | - return api.all([ | 202 | + return Promise.all([ |
204 | this.getGrowthVip(param.uid), | 203 | this.getGrowthVip(param.uid), |
205 | this.getHis(param) | 204 | this.getHis(param) |
206 | ]).then((result) => { | 205 | ]).then((result) => { |
@@ -258,7 +257,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -258,7 +257,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
258 | } | 257 | } |
259 | 258 | ||
260 | getHisAjax(param) { | 259 | getHisAjax(param) { |
261 | - return api.all([ | 260 | + return Promise.all([ |
262 | this.getHis(param) | 261 | this.getHis(param) |
263 | ]).then((result) => { | 262 | ]).then((result) => { |
264 | let resu = { | 263 | let resu = { |
@@ -8,11 +8,9 @@ | @@ -8,11 +8,9 @@ | ||
8 | 'use strict'; | 8 | 'use strict'; |
9 | 9 | ||
10 | const api = global.yoho.API; | 10 | const api = global.yoho.API; |
11 | -const singleAPI = global.yoho.SingleAPI; | ||
12 | const helpers = global.yoho.helpers; | 11 | const helpers = global.yoho.helpers; |
13 | const _ = require('lodash'); | 12 | const _ = require('lodash'); |
14 | const crypto = global.yoho.crypto; | 13 | const crypto = global.yoho.crypto; |
15 | -const service = global.yoho.ServiceAPI; | ||
16 | const utils = '../../../utils'; | 14 | const utils = '../../../utils'; |
17 | const resourcesProcess = require(`${utils}/resources-process`); | 15 | const resourcesProcess = require(`${utils}/resources-process`); |
18 | 16 | ||
@@ -26,11 +24,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -26,11 +24,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
26 | */ | 24 | */ |
27 | _userData(params) { | 25 | _userData(params) { |
28 | if (params.uid) { | 26 | if (params.uid) { |
29 | - return api.get('', { | ||
30 | - method: 'app.passport.profile', | ||
31 | - uid: params.uid | ||
32 | - }, { | ||
33 | - code: 200 | 27 | + return this.get({ |
28 | + data: { | ||
29 | + method: 'app.passport.profile', | ||
30 | + uid: params.uid | ||
31 | + }, | ||
32 | + api: global.yoho.API, | ||
33 | + param: {code: 200} | ||
34 | }); | 34 | }); |
35 | } else { | 35 | } else { |
36 | return Promise.resolve({}); | 36 | return Promise.resolve({}); |
@@ -41,10 +41,10 @@ module.exports = class extends global.yoho.BaseModel { | @@ -41,10 +41,10 @@ module.exports = class extends global.yoho.BaseModel { | ||
41 | * 获取个人中心公告有关数据 | 41 | * 获取个人中心公告有关数据 |
42 | */ | 42 | */ |
43 | _noticeData() { | 43 | _noticeData() { |
44 | - return api.get('', { | ||
45 | - method: 'app.resources.getNotices' | ||
46 | - }, { | ||
47 | - code: 200 | 44 | + return this.get({ |
45 | + data: {method: 'app.resources.getNotices'}, | ||
46 | + api: global.yoho.API, | ||
47 | + param: {code: 200} | ||
48 | }); | 48 | }); |
49 | } | 49 | } |
50 | 50 | ||
@@ -55,11 +55,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -55,11 +55,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
55 | */ | 55 | */ |
56 | _favoriteData(params) { | 56 | _favoriteData(params) { |
57 | if (params.uid) { | 57 | if (params.uid) { |
58 | - return singleAPI.get('favorite', { | ||
59 | - method: 'app.favorite.getFavoriteCount', | ||
60 | - uid: params.uid | ||
61 | - }, { | ||
62 | - code: 200 | 58 | + return this.get({ |
59 | + url: 'favorite', | ||
60 | + data: { | ||
61 | + method: 'app.favorite.getFavoriteCount', | ||
62 | + uid: params.uid | ||
63 | + }, | ||
64 | + api: global.yoho.SingleAPI, | ||
65 | + param: {code: 200} | ||
63 | }); | 66 | }); |
64 | } else { | 67 | } else { |
65 | return false; | 68 | return false; |
@@ -71,12 +74,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -71,12 +74,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
71 | */ | 74 | */ |
72 | _infoNum(params) { | 75 | _infoNum(params) { |
73 | if (params.uid) { | 76 | if (params.uid) { |
74 | - return api.get('', { | ||
75 | - method: 'app.home.getInfoNum', | ||
76 | - uid: params.uid, | ||
77 | - udid: params.udid | ||
78 | - }, { | ||
79 | - code: 200 | 77 | + return this.get({ |
78 | + data: { | ||
79 | + method: 'app.home.getInfoNum', | ||
80 | + uid: params.uid, | ||
81 | + udid: params.udid | ||
82 | + }, | ||
83 | + api: global.yoho.API, | ||
84 | + param: {code: 200} | ||
80 | }); | 85 | }); |
81 | } else { | 86 | } else { |
82 | return false; | 87 | return false; |
@@ -89,11 +94,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -89,11 +94,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
89 | */ | 94 | */ |
90 | _getAddressData(params) { | 95 | _getAddressData(params) { |
91 | if (params.uid) { | 96 | if (params.uid) { |
92 | - return api.get('', { | ||
93 | - method: 'app.address.gethidden', | ||
94 | - uid: params.uid | ||
95 | - }, { | ||
96 | - code: 200 | 97 | + return this.get({ |
98 | + data: { | ||
99 | + method: 'app.address.gethidden', | ||
100 | + uid: params.uid | ||
101 | + }, | ||
102 | + api: global.yoho.API, | ||
103 | + param: {code: 200} | ||
97 | }); | 104 | }); |
98 | } else { | 105 | } else { |
99 | return false; | 106 | return false; |
@@ -102,8 +109,12 @@ module.exports = class extends global.yoho.BaseModel { | @@ -102,8 +109,12 @@ module.exports = class extends global.yoho.BaseModel { | ||
102 | 109 | ||
103 | // 资源位 | 110 | // 资源位 |
104 | _getRes() { | 111 | _getRes() { |
105 | - return service.get('/operations/api/v5/resource/home', { | ||
106 | - content_code: '5d05d443a557783b1489d328c127e9bf', | 112 | + return this.get({ |
113 | + url: '/operations/api/v5/resource/home', | ||
114 | + data: { | ||
115 | + content_code: '5d05d443a557783b1489d328c127e9bf', | ||
116 | + }, | ||
117 | + api: global.yoho.ServiceAPI | ||
107 | }).then(result => { | 118 | }).then(result => { |
108 | if (result && result.code === 200 && result.data && result.data.list) { | 119 | if (result && result.code === 200 && result.data && result.data.list) { |
109 | for (let item of result.data.list) { | 120 | for (let item of result.data.list) { |
@@ -121,11 +132,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -121,11 +132,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
121 | // 潮流口令 | 132 | // 潮流口令 |
122 | _getCode(uid) { | 133 | _getCode(uid) { |
123 | if (uid) { | 134 | if (uid) { |
124 | - return api.get('', { | ||
125 | - method: 'app.invitecode.my', | ||
126 | - uid: uid | ||
127 | - }, { | ||
128 | - code: 200 | 135 | + return this.get({ |
136 | + data: { | ||
137 | + method: 'app.invitecode.my', | ||
138 | + uid: uid | ||
139 | + }, | ||
140 | + api: global.yoho.API, | ||
141 | + param: {code: 200} | ||
129 | }); | 142 | }); |
130 | } else { | 143 | } else { |
131 | return Promise.resolve({}); | 144 | return Promise.resolve({}); |
@@ -133,8 +146,12 @@ module.exports = class extends global.yoho.BaseModel { | @@ -133,8 +146,12 @@ module.exports = class extends global.yoho.BaseModel { | ||
133 | } | 146 | } |
134 | 147 | ||
135 | _getTrendPop(contentCode) { | 148 | _getTrendPop(contentCode) { |
136 | - return service.get('operations/api/v5/resource/get', { | ||
137 | - content_code: contentCode, | 149 | + return this.get({ |
150 | + url: 'operations/api/v5/resource/get', | ||
151 | + data: { | ||
152 | + content_code: contentCode, | ||
153 | + }, | ||
154 | + api: global.yoho.ServiceAPI | ||
138 | }).then(result => { | 155 | }).then(result => { |
139 | if (result && result.code === 200 && result.data) { | 156 | if (result && result.code === 200 && result.data) { |
140 | return result.data[0]; | 157 | return result.data[0]; |
@@ -237,11 +254,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -237,11 +254,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
237 | } | 254 | } |
238 | 255 | ||
239 | _detailInfo(uid) { | 256 | _detailInfo(uid) { |
240 | - return api.get('', { | ||
241 | - method: 'app.passport.profile', | ||
242 | - uid: uid | ||
243 | - }, { | ||
244 | - code: 200 | 257 | + return this.get({ |
258 | + data: { | ||
259 | + method: 'app.passport.profile', | ||
260 | + uid: uid | ||
261 | + }, | ||
262 | + api: global.yoho.API, | ||
263 | + param: {code: 200} | ||
245 | }); | 264 | }); |
246 | } | 265 | } |
247 | 266 | ||
@@ -278,13 +297,15 @@ module.exports = class extends global.yoho.BaseModel { | @@ -278,13 +297,15 @@ module.exports = class extends global.yoho.BaseModel { | ||
278 | */ | 297 | */ |
279 | recordContent(uid, udid, page, limit) { | 298 | recordContent(uid, udid, page, limit) { |
280 | if (uid) { | 299 | if (uid) { |
281 | - return api.get('', { | ||
282 | - method: 'app.browse.product', | ||
283 | - uid: uid, | ||
284 | - limit: limit, | ||
285 | - page: page | ||
286 | - }, { | ||
287 | - code: 200 | 300 | + return this.get({ |
301 | + data: { | ||
302 | + method: 'app.browse.product', | ||
303 | + uid: uid, | ||
304 | + limit: limit, | ||
305 | + page: page | ||
306 | + }, | ||
307 | + api: global.yoho.API, | ||
308 | + param: {code: 200} | ||
288 | }).then((result) => { | 309 | }).then((result) => { |
289 | 310 | ||
290 | let resu = {}; | 311 | let resu = {}; |
@@ -338,10 +359,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -338,10 +359,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
338 | * @param params | 359 | * @param params |
339 | */ | 360 | */ |
340 | delRecord(uid, skn) { | 361 | delRecord(uid, skn) { |
341 | - return api.get('', { | ||
342 | - method: 'app.browse.delete', | ||
343 | - uid: uid, | ||
344 | - skn: skn | 362 | + return this.get({ |
363 | + data: { | ||
364 | + method: 'app.browse.delete', | ||
365 | + uid: uid, | ||
366 | + skn: skn | ||
367 | + }, | ||
368 | + api: global.yoho.API | ||
345 | }); | 369 | }); |
346 | } | 370 | } |
347 | 371 | ||
@@ -350,22 +374,30 @@ module.exports = class extends global.yoho.BaseModel { | @@ -350,22 +374,30 @@ module.exports = class extends global.yoho.BaseModel { | ||
350 | * @param params | 374 | * @param params |
351 | */ | 375 | */ |
352 | getGradeGrade(uid, channel) { | 376 | getGradeGrade(uid, channel) { |
353 | - return api.get('', { | ||
354 | - method: 'app.passport.vip', | ||
355 | - uid: uid, | ||
356 | - channel: channel || 1 | ||
357 | - }, { | ||
358 | - code: 200 | 377 | + return this.get({ |
378 | + data: { | ||
379 | + method: 'app.passport.vip', | ||
380 | + uid: uid, | ||
381 | + channel: channel || 1 | ||
382 | + }, | ||
383 | + api: global.yoho.API, | ||
384 | + param: { | ||
385 | + code: 200 | ||
386 | + } | ||
359 | }); | 387 | }); |
360 | } | 388 | } |
361 | 389 | ||
362 | getGradeUser(uid, channel) { | 390 | getGradeUser(uid, channel) { |
363 | - return api.get('', { | ||
364 | - method: 'app.passport.profile', | ||
365 | - uid: uid, | ||
366 | - channel: channel || 1 | ||
367 | - }, { | ||
368 | - code: 200 | 391 | + return this.get({ |
392 | + data: { | ||
393 | + method: 'app.passport.profile', | ||
394 | + uid: uid, | ||
395 | + channel: channel || 1 | ||
396 | + }, | ||
397 | + api: global.yoho.API, | ||
398 | + param: { | ||
399 | + code: 200 | ||
400 | + } | ||
369 | }); | 401 | }); |
370 | } | 402 | } |
371 | 403 | ||
@@ -474,12 +506,16 @@ module.exports = class extends global.yoho.BaseModel { | @@ -474,12 +506,16 @@ module.exports = class extends global.yoho.BaseModel { | ||
474 | */ | 506 | */ |
475 | getPreferential(params) { | 507 | getPreferential(params) { |
476 | 508 | ||
477 | - return api.get('', { | ||
478 | - method: 'app.passport.getPrivilege', | ||
479 | - uid: params.uid, | ||
480 | - channel: params.channel || 1 | ||
481 | - }, { | ||
482 | - code: 200 | 509 | + return this.get({ |
510 | + data: { | ||
511 | + method: 'app.passport.getPrivilege', | ||
512 | + uid: params.uid, | ||
513 | + channel: params.channel || 1 | ||
514 | + }, | ||
515 | + api: global.yoho.API, | ||
516 | + param: { | ||
517 | + code: 200 | ||
518 | + } | ||
483 | }).then((result) => { | 519 | }).then((result) => { |
484 | 520 | ||
485 | let obj = {}; | 521 | let obj = {}; |
@@ -2,7 +2,6 @@ | @@ -2,7 +2,6 @@ | ||
2 | 'use strict'; | 2 | 'use strict'; |
3 | 3 | ||
4 | const moment = require('moment'); | 4 | const moment = require('moment'); |
5 | -const api = global.yoho.API; | ||
6 | const helpers = global.yoho.helpers; | 5 | const helpers = global.yoho.helpers; |
7 | 6 | ||
8 | // 格式化时间 | 7 | // 格式化时间 |
@@ -55,11 +54,11 @@ class messageModel extends global.yoho.BaseModel { | @@ -55,11 +54,11 @@ class messageModel extends global.yoho.BaseModel { | ||
55 | 54 | ||
56 | // 获取生日信息 | 55 | // 获取生日信息 |
57 | _getBirthCouponById(uid) { | 56 | _getBirthCouponById(uid) { |
58 | - return api.get('', { | 57 | + return this.get({data: { |
59 | method: 'app.promotion.queryBirthCoupon', | 58 | method: 'app.promotion.queryBirthCoupon', |
60 | uid: uid, | 59 | uid: uid, |
61 | couponType: 4, | 60 | couponType: 4, |
62 | - }).then(result => { | 61 | + }}).then(result => { |
63 | if (result && result.data) { | 62 | if (result && result.data) { |
64 | let final = { | 63 | let final = { |
65 | ticket: [] | 64 | ticket: [] |
@@ -155,14 +154,13 @@ class messageModel extends global.yoho.BaseModel { | @@ -155,14 +154,13 @@ class messageModel extends global.yoho.BaseModel { | ||
155 | 154 | ||
156 | // 获取列表或详情 | 155 | // 获取列表或详情 |
157 | getList(params) { | 156 | getList(params) { |
158 | - return api.get('', { | 157 | + return this.get({data: { |
159 | method: 'app.inbox.getlist', | 158 | method: 'app.inbox.getlist', |
160 | page: params.page || 1, | 159 | page: params.page || 1, |
161 | size: params.size || 10, | 160 | size: params.size || 10, |
162 | uid: params.uid, | 161 | uid: params.uid, |
163 | - }).then(result => { | 162 | + }}).then(result => { |
164 | if (params.msgid) { | 163 | if (params.msgid) { |
165 | - // 绕的一比 | ||
166 | return this._detail(result, params.msgid); | 164 | return this._detail(result, params.msgid); |
167 | } else { | 165 | } else { |
168 | return this._list(result); | 166 | return this._list(result); |
@@ -172,11 +170,11 @@ class messageModel extends global.yoho.BaseModel { | @@ -172,11 +170,11 @@ class messageModel extends global.yoho.BaseModel { | ||
172 | 170 | ||
173 | // 删除消息 | 171 | // 删除消息 |
174 | delMsg(params) { | 172 | delMsg(params) { |
175 | - return api.get('', { | 173 | + return this.get({data: { |
176 | method: 'app.inbox.delmessage', | 174 | method: 'app.inbox.delmessage', |
177 | uid: params.uid, | 175 | uid: params.uid, |
178 | id: params.msgid, | 176 | id: params.msgid, |
179 | - }).then(result => { | 177 | + }}).then(result => { |
180 | if (result && result.code === 200) { | 178 | if (result && result.code === 200) { |
181 | return { | 179 | return { |
182 | code: 200 | 180 | code: 200 |
@@ -192,11 +190,11 @@ class messageModel extends global.yoho.BaseModel { | @@ -192,11 +190,11 @@ class messageModel extends global.yoho.BaseModel { | ||
192 | 190 | ||
193 | // 领取优惠券 | 191 | // 领取优惠券 |
194 | pickCoupon(params) { | 192 | pickCoupon(params) { |
195 | - return api.get('', { | 193 | + return this.get({data: { |
196 | method: 'app.promotion.getCoupon', | 194 | method: 'app.promotion.getCoupon', |
197 | uid: params.uid, | 195 | uid: params.uid, |
198 | couponId: params.couponId, | 196 | couponId: params.couponId, |
199 | - }).then(result => { | 197 | + }}).then(result => { |
200 | if (result && result.code === 200) { | 198 | if (result && result.code === 200) { |
201 | return { | 199 | return { |
202 | code: 200 | 200 | code: 200 |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | -const serviceAPI = global.yoho.ServiceAPI; | ||
4 | -const api = global.yoho.API; | ||
5 | const _ = require('lodash'); | 3 | const _ = require('lodash'); |
6 | const logger = global.yoho.logger; | 4 | const logger = global.yoho.logger; |
7 | 5 | ||
@@ -11,10 +9,10 @@ class myCurrencyModel extends global.yoho.BaseModel { | @@ -11,10 +9,10 @@ class myCurrencyModel extends global.yoho.BaseModel { | ||
11 | } | 9 | } |
12 | 10 | ||
13 | _yohoCoin(uid) { | 11 | _yohoCoin(uid) { |
14 | - return api.get('', { | 12 | + return this.get({data: { |
15 | method: 'app.yoho.yohocoin', | 13 | method: 'app.yoho.yohocoin', |
16 | uid: uid | 14 | uid: uid |
17 | - }).then((result) => { | 15 | + }}).then((result) => { |
18 | let data = []; | 16 | let data = []; |
19 | 17 | ||
20 | if (result && result.code === 200) { | 18 | if (result && result.code === 200) { |
@@ -28,12 +26,18 @@ class myCurrencyModel extends global.yoho.BaseModel { | @@ -28,12 +26,18 @@ class myCurrencyModel extends global.yoho.BaseModel { | ||
28 | } | 26 | } |
29 | 27 | ||
30 | bannerData(contentCode) { | 28 | bannerData(contentCode) { |
31 | - | ||
32 | - return serviceAPI.get('operations/api/v5/resource/get', { | ||
33 | - content_code: contentCode | ||
34 | - }, { | ||
35 | - cache: true | ||
36 | - }).then((result) => { | 29 | + let options = { |
30 | + url: 'operations/api/v5/resource/get', | ||
31 | + data: { | ||
32 | + content_code: contentCode | ||
33 | + }, | ||
34 | + param: { | ||
35 | + cache: true | ||
36 | + }, | ||
37 | + api: global.yoho.ServiceAPI | ||
38 | + }; | ||
39 | + | ||
40 | + return this.get(options).then((result) => { | ||
37 | 41 | ||
38 | if (result && result.code === 200) { | 42 | if (result && result.code === 200) { |
39 | 43 | ||
@@ -60,12 +64,12 @@ class myCurrencyModel extends global.yoho.BaseModel { | @@ -60,12 +64,12 @@ class myCurrencyModel extends global.yoho.BaseModel { | ||
60 | } | 64 | } |
61 | 65 | ||
62 | currencyDetail(uid, page, limit) { | 66 | currencyDetail(uid, page, limit) { |
63 | - return api.get('', { | 67 | + return this.get({data: { |
64 | method: 'app.yohocoin.lists', | 68 | method: 'app.yohocoin.lists', |
65 | uid: uid, | 69 | uid: uid, |
66 | page: page, | 70 | page: page, |
67 | limit: limit | 71 | limit: limit |
68 | - }).then((result) => { | 72 | + }}).then((result) => { |
69 | let data = []; | 73 | let data = []; |
70 | 74 | ||
71 | if (result && result.code === 200) { | 75 | if (result && result.code === 200) { |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | -const api = global.yoho.API; | ||
4 | const crypto = global.yoho.crypto; | 3 | const crypto = global.yoho.crypto; |
5 | const PASSWORD = 'yoho9646yoho9646'; | 4 | const PASSWORD = 'yoho9646yoho9646'; |
6 | 5 | ||
@@ -19,10 +18,10 @@ class qrcodeModel extends global.yoho.BaseModel { | @@ -19,10 +18,10 @@ class qrcodeModel extends global.yoho.BaseModel { | ||
19 | uid = params.token; | 18 | uid = params.token; |
20 | } | 19 | } |
21 | 20 | ||
22 | - return api.get('', { | 21 | + return this.get({data: { |
23 | method: 'app.twoDimen.getCode', | 22 | method: 'app.twoDimen.getCode', |
24 | - uid: uid, | ||
25 | - }).then(result => { | 23 | + uid: uid |
24 | + }}).then(result => { | ||
26 | return (result && result.data && result.data.code) || ''; | 25 | return (result && result.data && result.data.code) || ''; |
27 | }); | 26 | }); |
28 | } | 27 | } |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | -const api = global.yoho.API; | ||
4 | const helpers = global.yoho.helpers; | 3 | const helpers = global.yoho.helpers; |
5 | const _ = require('lodash'); | 4 | const _ = require('lodash'); |
6 | 5 | ||
@@ -99,15 +98,19 @@ module.exports = class extends global.yoho.BaseModel { | @@ -99,15 +98,19 @@ module.exports = class extends global.yoho.BaseModel { | ||
99 | * @param params | 98 | * @param params |
100 | */ | 99 | */ |
101 | _getOrderData(params) { | 100 | _getOrderData(params) { |
102 | - return api.get('', { | ||
103 | - method: 'app.SpaceOrders.get', | ||
104 | - type: params.type, | ||
105 | - page: params.page, | ||
106 | - limit: params.limit, | ||
107 | - gender: params.gender, | ||
108 | - yh_channel: params.yh_channel, | ||
109 | - uid: params.uid | ||
110 | - }, {code: 200}); | 101 | + return this.get({ |
102 | + data: { | ||
103 | + method: 'app.SpaceOrders.get', | ||
104 | + type: params.type, | ||
105 | + page: params.page, | ||
106 | + limit: params.limit, | ||
107 | + gender: params.gender, | ||
108 | + yh_channel: params.yh_channel, | ||
109 | + uid: params.uid | ||
110 | + }, | ||
111 | + api: global.yoho.API, | ||
112 | + param: {code: 200} | ||
113 | + }); | ||
111 | } | 114 | } |
112 | 115 | ||
113 | /** | 116 | /** |
@@ -248,11 +251,12 @@ module.exports = class extends global.yoho.BaseModel { | @@ -248,11 +251,12 @@ module.exports = class extends global.yoho.BaseModel { | ||
248 | navs: this._getNavs(params.type) | 251 | navs: this._getNavs(params.type) |
249 | }; | 252 | }; |
250 | 253 | ||
251 | - return api.get('', _.assign({ | ||
252 | - method: 'app.SpaceOrders.closeReasons' | ||
253 | - }, params), { | ||
254 | - cache: true, | ||
255 | - code: 200 | 254 | + return this.get({ |
255 | + data: _.assign({ | ||
256 | + method: 'app.SpaceOrders.closeReasons' | ||
257 | + }, params), | ||
258 | + api: global.yoho.API, | ||
259 | + param: {cache: true, code: 200} | ||
256 | }).then(result => { | 260 | }).then(result => { |
257 | 261 | ||
258 | if (result && result.data) { | 262 | if (result && result.data) { |
@@ -267,9 +271,11 @@ module.exports = class extends global.yoho.BaseModel { | @@ -267,9 +271,11 @@ module.exports = class extends global.yoho.BaseModel { | ||
267 | * 申请退款原因 | 271 | * 申请退款原因 |
268 | */ | 272 | */ |
269 | refundReason() { | 273 | refundReason() { |
270 | - return api.get('', { | ||
271 | - method: 'app.SpaceOrders.refundApplyReasons' | ||
272 | - }, {code: 200, cache: true}).then(result => { | 274 | + return this.get({ |
275 | + data: {method: 'app.SpaceOrders.refundApplyReasons'}, | ||
276 | + api: global.yoho.API, | ||
277 | + param: {code: 200, cache: true} | ||
278 | + }).then(result => { | ||
273 | return _.get(result, 'data', []); | 279 | return _.get(result, 'data', []); |
274 | }); | 280 | }); |
275 | } | 281 | } |
@@ -324,10 +330,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -324,10 +330,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
324 | * 确认收货确认订单接口 | 330 | * 确认收货确认订单接口 |
325 | */ | 331 | */ |
326 | sure(params) { | 332 | sure(params) { |
327 | - return api.get('', { | ||
328 | - method: 'app.SpaceOrders.confirm', | ||
329 | - order_code: params.order_code, | ||
330 | - uid: params.uid | 333 | + return this.get({ |
334 | + data: { | ||
335 | + method: 'app.SpaceOrders.confirm', | ||
336 | + order_code: params.order_code, | ||
337 | + uid: params.uid | ||
338 | + }, | ||
339 | + api: global.yoho.API | ||
331 | }); | 340 | }); |
332 | } | 341 | } |
333 | }; | 342 | }; |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | - | ||
4 | -const api = global.yoho.API; | ||
5 | -const serviceApi = global.yoho.ServiceAPI; | ||
6 | - | ||
7 | const _ = require('lodash'); | 3 | const _ = require('lodash'); |
8 | 4 | ||
9 | // const config = global.yoho.config; | 5 | // const config = global.yoho.config; |
@@ -20,10 +16,10 @@ module.exports = class extends global.yoho.BaseModel { | @@ -20,10 +16,10 @@ module.exports = class extends global.yoho.BaseModel { | ||
20 | } | 16 | } |
21 | 17 | ||
22 | closeReasons() { | 18 | closeReasons() { |
23 | - return api.get('', { | ||
24 | - method: 'app.SpaceOrders.closeReasons' | ||
25 | - }, { | ||
26 | - cache: true | 19 | + return this.get({ |
20 | + data: {method: 'app.SpaceOrders.closeReasons'}, | ||
21 | + api: global.yoho.API, | ||
22 | + param: {cache: true} | ||
27 | }).then((result) => { | 23 | }).then((result) => { |
28 | if (result && result.code === 200) { | 24 | if (result && result.code === 200) { |
29 | return result.data; | 25 | return result.data; |
@@ -157,10 +153,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -157,10 +153,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
157 | return Promise.resolve({}); | 153 | return Promise.resolve({}); |
158 | } | 154 | } |
159 | 155 | ||
160 | - return api.get('', { | ||
161 | - method: 'app.SpaceOrders.detail', | ||
162 | - uid: uid, | ||
163 | - order_code: orderCode | 156 | + return this.get({ |
157 | + data: { | ||
158 | + method: 'app.SpaceOrders.detail', | ||
159 | + uid: uid, | ||
160 | + order_code: orderCode | ||
161 | + }, | ||
162 | + api: global.yoho.API | ||
164 | }).then(result => { | 163 | }).then(result => { |
165 | if (result && result.code === 200) { | 164 | if (result && result.code === 200) { |
166 | let orderDetail = camelCase(result.data); | 165 | let orderDetail = camelCase(result.data); |
@@ -297,19 +296,25 @@ module.exports = class extends global.yoho.BaseModel { | @@ -297,19 +296,25 @@ module.exports = class extends global.yoho.BaseModel { | ||
297 | 296 | ||
298 | // 删除订单 | 297 | // 删除订单 |
299 | delOrder(orderCode, uid) { | 298 | delOrder(orderCode, uid) { |
300 | - return api.get('', { | ||
301 | - method: 'app.SpaceOrders.delOrderByCode', | ||
302 | - uid: uid, | ||
303 | - order_code: orderCode | 299 | + return this.get({ |
300 | + data: { | ||
301 | + method: 'app.SpaceOrders.delOrderByCode', | ||
302 | + uid: uid, | ||
303 | + order_code: orderCode | ||
304 | + }, | ||
305 | + api: global.yoho.API | ||
304 | }); | 306 | }); |
305 | } | 307 | } |
306 | 308 | ||
307 | // 再次购买 | 309 | // 再次购买 |
308 | readdData(orderCode, uid) { | 310 | readdData(orderCode, uid) { |
309 | - return api.get('', { | ||
310 | - method: 'app.Shopping.readd', | ||
311 | - uid: uid, | ||
312 | - order_code: orderCode | 311 | + return this.get({ |
312 | + data: { | ||
313 | + method: 'app.Shopping.readd', | ||
314 | + uid: uid, | ||
315 | + order_code: orderCode | ||
316 | + }, | ||
317 | + api: global.yoho.API | ||
313 | }).then((result) => { | 318 | }).then((result) => { |
314 | if (result && result.code === 200) { | 319 | if (result && result.code === 200) { |
315 | result.message = '商品已重新加入购物车'; | 320 | result.message = '商品已重新加入购物车'; |
@@ -327,14 +332,17 @@ module.exports = class extends global.yoho.BaseModel { | @@ -327,14 +332,17 @@ module.exports = class extends global.yoho.BaseModel { | ||
327 | // 取消订单 | 332 | // 取消订单 |
328 | cancelOrder(orderCode, uid, reasonId, gender, channel, reason) { | 333 | cancelOrder(orderCode, uid, reasonId, gender, channel, reason) { |
329 | 334 | ||
330 | - return api.get('', { | ||
331 | - method: 'app.SpaceOrders.close', | ||
332 | - uid: uid, | ||
333 | - order_code: orderCode, | ||
334 | - reasonId: reasonId, | ||
335 | - reasons: reason, | ||
336 | - gender: gender, | ||
337 | - yh_channel: channel | 335 | + return this.get({ |
336 | + data: { | ||
337 | + method: 'app.SpaceOrders.close', | ||
338 | + uid: uid, | ||
339 | + order_code: orderCode, | ||
340 | + reasonId: reasonId, | ||
341 | + reasons: reason, | ||
342 | + gender: gender, | ||
343 | + yh_channel: channel | ||
344 | + }, | ||
345 | + api: global.yoho.API | ||
338 | }); | 346 | }); |
339 | } | 347 | } |
340 | 348 | ||
@@ -342,12 +350,15 @@ module.exports = class extends global.yoho.BaseModel { | @@ -342,12 +350,15 @@ module.exports = class extends global.yoho.BaseModel { | ||
342 | * 申请退款 | 350 | * 申请退款 |
343 | */ | 351 | */ |
344 | refundApply(params) { | 352 | refundApply(params) { |
345 | - return api.get('', { | ||
346 | - method: 'app.SpaceOrders.refundApply', | ||
347 | - uid: params.uid, | ||
348 | - order_code: params.orderCode, | ||
349 | - reason_id: params.reasonId, | ||
350 | - reason: params.reason | 353 | + return this.get({ |
354 | + data: { | ||
355 | + method: 'app.SpaceOrders.refundApply', | ||
356 | + uid: params.uid, | ||
357 | + order_code: params.orderCode, | ||
358 | + reason_id: params.reasonId, | ||
359 | + reason: params.reason | ||
360 | + }, | ||
361 | + api: global.yoho.API | ||
351 | }); | 362 | }); |
352 | } | 363 | } |
353 | 364 | ||
@@ -378,16 +389,22 @@ module.exports = class extends global.yoho.BaseModel { | @@ -378,16 +389,22 @@ module.exports = class extends global.yoho.BaseModel { | ||
378 | }); | 389 | }); |
379 | } | 390 | } |
380 | 391 | ||
381 | - return api.get('', finalParams); | 392 | + return this.get({ |
393 | + data: finalParams, | ||
394 | + api: global.yoho.API | ||
395 | + }); | ||
382 | } | 396 | } |
383 | 397 | ||
384 | /** | 398 | /** |
385 | * 获取物流详情页banner | 399 | * 获取物流详情页banner |
386 | */ | 400 | */ |
387 | _getLogisterBanner() { | 401 | _getLogisterBanner() { |
388 | - return serviceApi.get('operations/api/v5/resource/get', { | ||
389 | - content_code: CODE_LOGISTIC_BANNER | ||
390 | - }, {code: 200}); | 402 | + return this.get({ |
403 | + url: 'operations/api/v5/resource/get', | ||
404 | + data: {content_code: CODE_LOGISTIC_BANNER}, | ||
405 | + params: {code: 200}, | ||
406 | + api: global.yoho.ServiceAPI | ||
407 | + }); | ||
391 | } | 408 | } |
392 | 409 | ||
393 | /** | 410 | /** |
@@ -468,6 +485,9 @@ module.exports = class extends global.yoho.BaseModel { | @@ -468,6 +485,9 @@ module.exports = class extends global.yoho.BaseModel { | ||
468 | }); | 485 | }); |
469 | } | 486 | } |
470 | 487 | ||
471 | - return api.post('', apiParams); | 488 | + return this.post({ |
489 | + data: apiParams, | ||
490 | + api: global.yoho.API | ||
491 | + }); | ||
472 | } | 492 | } |
473 | }; | 493 | }; |
@@ -6,7 +6,6 @@ | @@ -6,7 +6,6 @@ | ||
6 | 'use strict'; | 6 | 'use strict'; |
7 | 7 | ||
8 | const logger = global.yoho.logger; | 8 | const logger = global.yoho.logger; |
9 | -var api = global.yoho.API; | ||
10 | 9 | ||
11 | class qrcodeModel extends global.yoho.BaseModel { | 10 | class qrcodeModel extends global.yoho.BaseModel { |
12 | constructor(ctx) { | 11 | constructor(ctx) { |
@@ -14,11 +13,12 @@ class qrcodeModel extends global.yoho.BaseModel { | @@ -14,11 +13,12 @@ class qrcodeModel extends global.yoho.BaseModel { | ||
14 | } | 13 | } |
15 | 14 | ||
16 | getQRcodeData(id, uid) { | 15 | getQRcodeData(id, uid) { |
17 | - return api.get('', { | 16 | + return this.get({data: { |
18 | method: 'app.SpaceOrders.getQrByOrderCode', | 17 | method: 'app.SpaceOrders.getQrByOrderCode', |
19 | order_code: id, | 18 | order_code: id, |
20 | uid: uid | 19 | uid: uid |
21 | - }).then(result => { | 20 | + }}).then(result => { |
21 | + console.log(result); | ||
22 | if (result && result.code === 200) { | 22 | if (result && result.code === 200) { |
23 | return result.data; | 23 | return result.data; |
24 | } else { | 24 | } else { |
@@ -7,7 +7,6 @@ | @@ -7,7 +7,6 @@ | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | const logger = global.yoho.logger; | 9 | const logger = global.yoho.logger; |
10 | -const serviceAPI = global.yoho.ServiceAPI; | ||
11 | const camelCase = global.yoho.camelCase; | 10 | const camelCase = global.yoho.camelCase; |
12 | const _ = require('lodash'); | 11 | const _ = require('lodash'); |
13 | 12 | ||
@@ -18,10 +17,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -18,10 +17,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
18 | 17 | ||
19 | suggestData(uid, udid, page, limit) { | 18 | suggestData(uid, udid, page, limit) { |
20 | 19 | ||
21 | - return serviceAPI.get('suggest/api/v1/suggest/getList', { | ||
22 | - udid: udid, | ||
23 | - page: page, | ||
24 | - limit: limit | 20 | + return this.get({ |
21 | + url: 'suggest/api/v1/suggest/getList', | ||
22 | + data: { | ||
23 | + udid: udid, | ||
24 | + page: page, | ||
25 | + limit: limit | ||
26 | + }, | ||
27 | + api: global.yoho.ServiceAPI | ||
25 | }).then((result) => { | 28 | }).then((result) => { |
26 | if (result && result.code === 200 && result.data) { | 29 | if (result && result.code === 200 && result.data) { |
27 | _.forEach(result.data.list, function(data) { | 30 | _.forEach(result.data.list, function(data) { |
@@ -40,11 +43,15 @@ module.exports = class extends global.yoho.BaseModel { | @@ -40,11 +43,15 @@ module.exports = class extends global.yoho.BaseModel { | ||
40 | } | 43 | } |
41 | 44 | ||
42 | upAndDown(uid, udid, reliable, suggestId) { | 45 | upAndDown(uid, udid, reliable, suggestId) { |
43 | - return serviceAPI.get('suggest/api/v1/suggest/is_reliable', { | ||
44 | - uid: uid, | ||
45 | - udid: udid, | ||
46 | - is_reliable: reliable, | ||
47 | - suggest_id: suggestId | 46 | + return this.get({ |
47 | + url: 'suggest/api/v1/suggest/is_reliable', | ||
48 | + data: { | ||
49 | + uid: uid, | ||
50 | + udid: udid, | ||
51 | + is_reliable: reliable, | ||
52 | + suggest_id: suggestId | ||
53 | + }, | ||
54 | + api: global.yoho.ServiceAPI | ||
48 | }); | 55 | }); |
49 | } | 56 | } |
50 | 57 | ||
@@ -61,6 +68,10 @@ module.exports = class extends global.yoho.BaseModel { | @@ -61,6 +68,10 @@ module.exports = class extends global.yoho.BaseModel { | ||
61 | per.image = image; | 68 | per.image = image; |
62 | } | 69 | } |
63 | 70 | ||
64 | - return serviceAPI.get('suggest/api/v1/suggest/saveSuggest', per); | 71 | + return this.get({ |
72 | + url: 'suggest/api/v1/suggest/saveSuggest', | ||
73 | + data: per, | ||
74 | + api: global.yoho.ServiceAPI | ||
75 | + }); | ||
65 | } | 76 | } |
66 | }; | 77 | }; |
1 | -const api = global.yoho.API; | ||
2 | -const service = global.yoho.ServiceAPI; | ||
3 | const _ = require('lodash'); | 1 | const _ = require('lodash'); |
4 | 2 | ||
5 | module.exports = class extends global.yoho.BaseModel { | 3 | module.exports = class extends global.yoho.BaseModel { |
@@ -9,11 +7,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -9,11 +7,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
9 | 7 | ||
10 | // 文字说明 | 8 | // 文字说明 |
11 | invitionText(uid) { | 9 | invitionText(uid) { |
12 | - return api.get('', { | ||
13 | - method: 'app.invitecode.my', | ||
14 | - uid: uid | ||
15 | - }, { | ||
16 | - code: 200 | 10 | + return this.get({ |
11 | + data: { | ||
12 | + method: 'app.invitecode.my', | ||
13 | + uid: uid | ||
14 | + }, | ||
15 | + api: global.yoho.API, | ||
16 | + param: {code: 200} | ||
17 | }).then((result) => { | 17 | }).then((result) => { |
18 | 18 | ||
19 | if (result && result.code === 200 && result.data) { | 19 | if (result && result.code === 200 && result.data) { |
@@ -27,10 +27,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -27,10 +27,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
27 | 27 | ||
28 | // 资源位图 | 28 | // 资源位图 |
29 | resources(contentCode) { | 29 | resources(contentCode) { |
30 | - return service.get('operations/api/v5/resource/get', { | ||
31 | - content_code: contentCode | ||
32 | - }, { | ||
33 | - code: 200 | 30 | + return this.get({ |
31 | + url: 'operations/api/v5/resource/get', | ||
32 | + data: { | ||
33 | + content_code: contentCode | ||
34 | + }, | ||
35 | + api: global.yoho.ServiceAPI, | ||
36 | + param: {code: 200} | ||
34 | }).then((result) => { | 37 | }).then((result) => { |
35 | if (result && result.data) { | 38 | if (result && result.data) { |
36 | 39 | ||
@@ -40,7 +43,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -40,7 +43,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
40 | } | 43 | } |
41 | 44 | ||
42 | invitionData(uid, contentCode) { | 45 | invitionData(uid, contentCode) { |
43 | - return api.all([this.invitionText(uid), this.resources(contentCode)]).then((result) => { | 46 | + return Promise.all([this.invitionText(uid), this.resources(contentCode)]).then((result) => { |
44 | let finaData = {}; | 47 | let finaData = {}; |
45 | 48 | ||
46 | finaData = Object.assign(finaData, result[0]); | 49 | finaData = Object.assign(finaData, result[0]); |
@@ -550,19 +550,29 @@ exports.loginShowCaptchaByIp = function(req, res, next) { | @@ -550,19 +550,29 @@ exports.loginShowCaptchaByIp = function(req, res, next) { | ||
550 | req.yoho.captchaShow = false; | 550 | req.yoho.captchaShow = false; |
551 | } | 551 | } |
552 | 552 | ||
553 | - co(function*() { | ||
554 | - let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`); | 553 | + // 第一次登录要不要展示验证码:后台开关勾选,首次登录不需要展示 |
554 | + let firstLoginShowCaptcha = !_.get(req.app.locals.wap, 'close.firstLoginShowCaptcha', false); | ||
555 | 555 | ||
556 | - log.info(`Pagerender clientip ${req.yoho.clientIp} status is ` + hasErrorLog); | 556 | + log.info(`firstLoginShowCaptcha status is ${firstLoginShowCaptcha}`); |
557 | 557 | ||
558 | - if (hasErrorLog) { | ||
559 | - req.yoho.captchaShow = true; | ||
560 | - } | ||
561 | - next(); | ||
562 | - })().catch(function(e) { | 558 | + if (firstLoginShowCaptcha) { |
563 | req.yoho.captchaShow = true; | 559 | req.yoho.captchaShow = true; |
564 | - next(); | ||
565 | - }); | 560 | + return next(); |
561 | + } else { | ||
562 | + co(function* () { | ||
563 | + let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`); | ||
564 | + | ||
565 | + log.info(`Pagerender clientip ${req.yoho.clientIp} status is ` + hasErrorLog); | ||
566 | + | ||
567 | + if (hasErrorLog) { | ||
568 | + req.yoho.captchaShow = true; | ||
569 | + } | ||
570 | + next(); | ||
571 | + })().catch(function(e) { | ||
572 | + req.yoho.captchaShow = true; | ||
573 | + next(); | ||
574 | + }); | ||
575 | + } | ||
566 | }; | 576 | }; |
567 | 577 | ||
568 | exports.common = common; | 578 | exports.common = common; |
@@ -15,6 +15,9 @@ class SmsNew { | @@ -15,6 +15,9 @@ class SmsNew { | ||
15 | let bannerData = yield req.ctx(LoginNewModel).getTopBanner(); | 15 | let bannerData = yield req.ctx(LoginNewModel).getTopBanner(); |
16 | let banner = _.get(bannerData, 'data[0].data[0].src', ''); | 16 | let banner = _.get(bannerData, 'data[0].data[0].src', ''); |
17 | 17 | ||
18 | + // 是否打开账号登录 | ||
19 | + let openPassword = !_.get(req.app.locals.wap, 'close.passwordLogin', false); | ||
20 | + | ||
18 | res.render('sms/sms-login-new', { | 21 | res.render('sms/sms-login-new', { |
19 | module: 'passport', | 22 | module: 'passport', |
20 | page: 'sms-login-new', | 23 | page: 'sms-login-new', |
@@ -32,7 +35,8 @@ class SmsNew { | @@ -32,7 +35,8 @@ class SmsNew { | ||
32 | internationalUrl: '/passport/international', // 国际号登录的URL链接 | 35 | internationalUrl: '/passport/international', // 国际号登录的URL链接 |
33 | phoneRetriveUrl: '/passport/back/mobile', // 通过手机号找回密码的URL链接 | 36 | phoneRetriveUrl: '/passport/back/mobile', // 通过手机号找回密码的URL链接 |
34 | emailRetriveUrl: '/passport/back/email', // 通过邮箱找回密码的URL链接 | 37 | emailRetriveUrl: '/passport/back/email', // 通过邮箱找回密码的URL链接 |
35 | - isWechat: req.yoho.isWechat | 38 | + isWechat: req.yoho.isWechat, |
39 | + openPassword | ||
36 | }); | 40 | }); |
37 | })().catch(next); | 41 | })().catch(next); |
38 | } | 42 | } |
@@ -29,14 +29,23 @@ const check = (req, res, next) => { | @@ -29,14 +29,23 @@ const check = (req, res, next) => { | ||
29 | co(function* () { | 29 | co(function* () { |
30 | // 如果是账号密码登录,那么需要检查是否登录失败过,登录失败过展示验证码 | 30 | // 如果是账号密码登录,那么需要检查是否登录失败过,登录失败过展示验证码 |
31 | if (req.path === '/passport/login/auth') { | 31 | if (req.path === '/passport/login/auth') { |
32 | - let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`); | 32 | + // 第一次登录要不要展示验证码:后台开关勾选,首次登录不需要展示 |
33 | + let firstLoginShowCaptcha = !_.get(req.app.locals.wap, 'close.firstLoginShowCaptcha', false); | ||
33 | 34 | ||
34 | - log.info(`Check clientip ${req.yoho.clientIp} status is ` + hasErrorLog); | 35 | + log.info(`firstLoginShowCaptcha status is ${firstLoginShowCaptcha}`); |
35 | 36 | ||
36 | - if (hasErrorLog) { | 37 | + if (firstLoginShowCaptcha) { |
37 | req.yoho.captchaShow = true; | 38 | req.yoho.captchaShow = true; |
38 | } else { | 39 | } else { |
39 | - req.yoho.captchaShow = false; | 40 | + let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`); |
41 | + | ||
42 | + log.info(`Check clientip ${req.yoho.clientIp} status is ` + hasErrorLog); | ||
43 | + | ||
44 | + if (hasErrorLog) { | ||
45 | + req.yoho.captchaShow = true; | ||
46 | + } else { | ||
47 | + req.yoho.captchaShow = false; | ||
48 | + } | ||
40 | } | 49 | } |
41 | } | 50 | } |
42 | 51 |
@@ -28,8 +28,10 @@ | @@ -28,8 +28,10 @@ | ||
28 | <div data-geetest="{{useGeetest}}" id="js-img-check" {{#unless useGeetest}} class="full-img-verify" {{/unless}}></div> | 28 | <div data-geetest="{{useGeetest}}" id="js-img-check" {{#unless useGeetest}} class="full-img-verify" {{/unless}}></div> |
29 | <button id="smsLoginBtn" class="sms-login-btn">登录</button> | 29 | <button id="smsLoginBtn" class="sms-login-btn">登录</button> |
30 | <div class="other-info"> | 30 | <div class="other-info"> |
31 | + {{#if openPassword}} | ||
31 | <a href="{{internationalUrl}}">海外账号登录</a> | 32 | <a href="{{internationalUrl}}">海外账号登录</a> |
32 | <a href="{{loginUrl}}">账号密码登录</a> | 33 | <a href="{{loginUrl}}">账号密码登录</a> |
34 | + {{/if}} | ||
33 | <a id="getPswrdBtn" href="javascript:void(0);">忘记密码?</a> | 35 | <a id="getPswrdBtn" href="javascript:void(0);">忘记密码?</a> |
34 | </div> | 36 | </div> |
35 | </div> | 37 | </div> |
@@ -54,4 +56,4 @@ | @@ -54,4 +56,4 @@ | ||
54 | <a class="by-mobile" onclick="location.href='{{phoneRetriveUrl}}'">手机找回</a> | 56 | <a class="by-mobile" onclick="location.href='{{phoneRetriveUrl}}'">手机找回</a> |
55 | </div> | 57 | </div> |
56 | </div> | 58 | </div> |
57 | -</div> | ||
59 | +</div> |
@@ -4,8 +4,6 @@ | @@ -4,8 +4,6 @@ | ||
4 | 'use strict'; | 4 | 'use strict'; |
5 | const _ = require('lodash'); | 5 | const _ = require('lodash'); |
6 | const helpers = global.yoho.helpers; | 6 | const helpers = global.yoho.helpers; |
7 | -const api = global.yoho.API; | ||
8 | -const singleAPI = global.yoho.SingleAPI; | ||
9 | const stringProcess = require(`${global.utils}/string-process`); | 7 | const stringProcess = require(`${global.utils}/string-process`); |
10 | 8 | ||
11 | /** | 9 | /** |
@@ -28,10 +26,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -28,10 +26,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
28 | * 店铺品牌列表 | 26 | * 店铺品牌列表 |
29 | */ | 27 | */ |
30 | getShopBrands(shopId) { | 28 | getShopBrands(shopId) { |
31 | - return api.get('', { | ||
32 | - method: 'app.shops.getShopsBrands', | ||
33 | - shop_id: shopId | ||
34 | - }, {code: 200}).then(result => { | 29 | + return this.get({ |
30 | + data: { | ||
31 | + method: 'app.shops.getShopsBrands', | ||
32 | + shop_id: shopId | ||
33 | + }, | ||
34 | + api: global.yoho.API, | ||
35 | + param: {code: 200} | ||
36 | + }).then(result => { | ||
35 | if (result && result.data) { | 37 | if (result && result.data) { |
36 | _.forEach(result.data, value => { | 38 | _.forEach(result.data, value => { |
37 | value.url = helpers.urlFormat('', { | 39 | value.url = helpers.urlFormat('', { |
@@ -70,7 +72,10 @@ module.exports = class extends global.yoho.BaseModel { | @@ -70,7 +72,10 @@ module.exports = class extends global.yoho.BaseModel { | ||
70 | }); | 72 | }); |
71 | } | 73 | } |
72 | 74 | ||
73 | - return api.get('', finalParams); | 75 | + return this.get({ |
76 | + data: finalParams, | ||
77 | + api: global.yoho.API | ||
78 | + }); | ||
74 | } | 79 | } |
75 | 80 | ||
76 | /** | 81 | /** |
@@ -79,11 +84,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -79,11 +84,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
79 | * @return array | false | 84 | * @return array | false |
80 | */ | 85 | */ |
81 | getBrandLogoByDomain(domain) { | 86 | getBrandLogoByDomain(domain) { |
82 | - return api.get('', { | ||
83 | - method: 'web.brand.byDomain', | ||
84 | - domain: domain | ||
85 | - }, { | ||
86 | - cache: true | 87 | + return this.get({ |
88 | + data: { | ||
89 | + method: 'web.brand.byDomain', | ||
90 | + domain: domain | ||
91 | + }, | ||
92 | + api: global.yoho.API, | ||
93 | + param: {cache: true} | ||
87 | }).then(result => { | 94 | }).then(result => { |
88 | if (result && result.data) { | 95 | if (result && result.data) { |
89 | let formatData = result.data; | 96 | let formatData = result.data; |
@@ -117,11 +124,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -117,11 +124,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
117 | return Promise.resolve({}); | 124 | return Promise.resolve({}); |
118 | } | 125 | } |
119 | 126 | ||
120 | - return api.get('', _.assign({ | ||
121 | - method: 'app.brand.getBrandIntro', | ||
122 | - brand_id: brandId | ||
123 | - }, param), { | ||
124 | - code: 200 | 127 | + return this.get({ |
128 | + data: _.assign({ | ||
129 | + method: 'app.brand.getBrandIntro', | ||
130 | + brand_id: brandId | ||
131 | + }, param), | ||
132 | + api: global.yoho.API, | ||
133 | + param: {code: 200} | ||
125 | }).then(result => { | 134 | }).then(result => { |
126 | if (result && result.data) { | 135 | if (result && result.data) { |
127 | let list = result.data; | 136 | let list = result.data; |
@@ -144,11 +153,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -144,11 +153,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
144 | * @return array banner数据 | 153 | * @return array banner数据 |
145 | */ | 154 | */ |
146 | getBrandBanner(brandId) { | 155 | getBrandBanner(brandId) { |
147 | - return api.get('', { | ||
148 | - method: 'app.brand.banner', | ||
149 | - brand_id: brandId | ||
150 | - }, { | ||
151 | - cache: true | 156 | + return this.get({ |
157 | + data: { | ||
158 | + method: 'app.brand.banner', | ||
159 | + brand_id: brandId | ||
160 | + }, | ||
161 | + api: global.yoho.API, | ||
162 | + param: {cache: true} | ||
152 | }).then((result) => { | 163 | }).then((result) => { |
153 | if (result && result.code === 200 && result.data) { | 164 | if (result && result.code === 200 && result.data) { |
154 | if (result.data.banner) { | 165 | if (result.data.banner) { |
@@ -173,7 +184,11 @@ module.exports = class extends global.yoho.BaseModel { | @@ -173,7 +184,11 @@ module.exports = class extends global.yoho.BaseModel { | ||
173 | shop_id: shopId | 184 | shop_id: shopId |
174 | }; | 185 | }; |
175 | 186 | ||
176 | - return api.get('', params, {cache: true, code: 200}); | 187 | + return this.get({ |
188 | + data: params, | ||
189 | + api: global.yoho.API, | ||
190 | + param: {cache: true, code: 200} | ||
191 | + }); | ||
177 | } | 192 | } |
178 | 193 | ||
179 | 194 | ||
@@ -188,7 +203,10 @@ module.exports = class extends global.yoho.BaseModel { | @@ -188,7 +203,10 @@ module.exports = class extends global.yoho.BaseModel { | ||
188 | shop_id: shopId | 203 | shop_id: shopId |
189 | }; | 204 | }; |
190 | 205 | ||
191 | - return api.get('', params, {cache: true, code: 200}); | 206 | + return this.get({ |
207 | + data: params, | ||
208 | + param: {cache: true, code: 200} | ||
209 | + }); | ||
192 | } | 210 | } |
193 | 211 | ||
194 | /** | 212 | /** |
@@ -198,10 +216,13 @@ module.exports = class extends global.yoho.BaseModel { | @@ -198,10 +216,13 @@ module.exports = class extends global.yoho.BaseModel { | ||
198 | * @return array | 216 | * @return array |
199 | */ | 217 | */ |
200 | getShopCategory(shopId, channel) { | 218 | getShopCategory(shopId, channel) { |
201 | - return api.get('', { | ||
202 | - method: 'app.shop.getSortInfo', | ||
203 | - yh_channel: yhChannel[channel], | ||
204 | - shop_id: shopId | 219 | + return this.get({ |
220 | + data: { | ||
221 | + method: 'app.shop.getSortInfo', | ||
222 | + yh_channel: yhChannel[channel], | ||
223 | + shop_id: shopId | ||
224 | + }, | ||
225 | + api: global.yoho.API | ||
205 | }); | 226 | }); |
206 | } | 227 | } |
207 | 228 | ||
@@ -223,7 +244,11 @@ module.exports = class extends global.yoho.BaseModel { | @@ -223,7 +244,11 @@ module.exports = class extends global.yoho.BaseModel { | ||
223 | }); | 244 | }); |
224 | } | 245 | } |
225 | 246 | ||
226 | - return singleAPI.get('favorite', finalParams); | 247 | + return this.get({ |
248 | + url: 'favorite', | ||
249 | + data: finalParams, | ||
250 | + api: global.yoho.SingleAPI | ||
251 | + }); | ||
227 | } | 252 | } |
228 | 253 | ||
229 | /** | 254 | /** |
@@ -232,12 +257,15 @@ module.exports = class extends global.yoho.BaseModel { | @@ -232,12 +257,15 @@ module.exports = class extends global.yoho.BaseModel { | ||
232 | * @return array | 257 | * @return array |
233 | */ | 258 | */ |
234 | getShopDecorator(shopId) { | 259 | getShopDecorator(shopId) { |
235 | - return api.get('', { | ||
236 | - method: 'app.shopsdecorator.getList', | ||
237 | - shop_id: shopId | ||
238 | - }, { | ||
239 | - cache: true, | ||
240 | - code: 200 | 260 | + return this.get({ |
261 | + data: { | ||
262 | + method: 'app.shopsdecorator.getList', | ||
263 | + shop_id: shopId | ||
264 | + }, | ||
265 | + param: { | ||
266 | + cache: true, | ||
267 | + code: 200 | ||
268 | + } | ||
241 | }).then((result) => { | 269 | }).then((result) => { |
242 | return (result && result.data) || {}; | 270 | return (result && result.data) || {}; |
243 | }); | 271 | }); |
@@ -60,6 +60,13 @@ | @@ -60,6 +60,13 @@ | ||
60 | } | 60 | } |
61 | 61 | ||
62 | setTimeout(function() { | 62 | setTimeout(function() { |
63 | + {{#if @root.isLogin}} | ||
64 | + {{#if @root.isApp}} | ||
65 | + _hmt.push(['_setCustomVar', 3, 'login', 'APP', 2]); | ||
66 | + {{^}} | ||
67 | + _hmt.push(['_setCustomVar', 3, 'login', 'H5', 2]); | ||
68 | + {{/if}} | ||
69 | + {{/if}} | ||
63 | (function() { | 70 | (function() { |
64 | var hm = document.createElement("script"); | 71 | var hm = document.createElement("script"); |
65 | hm.src = "https://hm.baidu.com/hm.js?65dd99e0435a55177ffda862198ce841"; | 72 | hm.src = "https://hm.baidu.com/hm.js?65dd99e0435a55177ffda862198ce841"; |
@@ -72,14 +79,6 @@ | @@ -72,14 +79,6 @@ | ||
72 | var s = document.getElementsByTagName("script")[0]; | 79 | var s = document.getElementsByTagName("script")[0]; |
73 | s.parentNode.insertBefore(hm, s); | 80 | s.parentNode.insertBefore(hm, s); |
74 | })(); --}} | 81 | })(); --}} |
75 | - | ||
76 | - {{#if @root.isLogin}} | ||
77 | - {{#if @root.isApp}} | ||
78 | - _hmt.push(['_setCustomVar', 1, 'login', 'APP', 2]); | ||
79 | - {{^}} | ||
80 | - _hmt.push(['_setCustomVar', 1, 'login', 'H5', 2]); | ||
81 | - {{/if}} | ||
82 | - {{/if}} | ||
83 | }, 1000); | 82 | }, 1000); |
84 | }()); | 83 | }()); |
85 | 84 |
1 | { | 1 | { |
2 | "name": "m-yohobuy-node", | 2 | "name": "m-yohobuy-node", |
3 | - "version": "6.0.20", | 3 | + "version": "6.0.22", |
4 | "private": true, | 4 | "private": true, |
5 | "description": "A New Yohobuy Project With Express", | 5 | "description": "A New Yohobuy Project With Express", |
6 | "repository": { | 6 | "repository": { |
@@ -41,7 +41,7 @@ | @@ -41,7 +41,7 @@ | ||
41 | "license": "MIT", | 41 | "license": "MIT", |
42 | "dependencies": { | 42 | "dependencies": { |
43 | "bluebird": "^3.4.7", | 43 | "bluebird": "^3.4.7", |
44 | - "body-parser": "^1.17.2", | 44 | + "body-parser": "^1.18.0", |
45 | "captchapng": "0.0.1", | 45 | "captchapng": "0.0.1", |
46 | "cheerio": "^0.22.0", | 46 | "cheerio": "^0.22.0", |
47 | "client-sessions": "^0.8.0", | 47 | "client-sessions": "^0.8.0", |
@@ -77,7 +77,7 @@ | @@ -77,7 +77,7 @@ | ||
77 | "yoho-zookeeper": "^1.0.8" | 77 | "yoho-zookeeper": "^1.0.8" |
78 | }, | 78 | }, |
79 | "devDependencies": { | 79 | "devDependencies": { |
80 | - "autoprefixer": "^7.1.2", | 80 | + "autoprefixer": "^7.1.4", |
81 | "babel-core": "^6.26.0", | 81 | "babel-core": "^6.26.0", |
82 | "babel-loader": "^7.1.2", | 82 | "babel-loader": "^7.1.2", |
83 | "babel-polyfill": "^6.26.0", | 83 | "babel-polyfill": "^6.26.0", |
@@ -93,7 +93,7 @@ | @@ -93,7 +93,7 @@ | ||
93 | "happypack": "^3.1.0", | 93 | "happypack": "^3.1.0", |
94 | "husky": "^0.14.3", | 94 | "husky": "^0.14.3", |
95 | "ignore-file-loader": "^1.0.0", | 95 | "ignore-file-loader": "^1.0.0", |
96 | - "nodemon": "^1.11.0", | 96 | + "nodemon": "^1.12.0", |
97 | "opn": "^5.1.0", | 97 | "opn": "^5.1.0", |
98 | "postcss-assets": "^4.2.0", | 98 | "postcss-assets": "^4.2.0", |
99 | "postcss-calc": "^6.0.0", | 99 | "postcss-calc": "^6.0.0", |
@@ -112,7 +112,7 @@ | @@ -112,7 +112,7 @@ | ||
112 | "shelljs": "^0.7.8", | 112 | "shelljs": "^0.7.8", |
113 | "store": "^2.0.12", | 113 | "store": "^2.0.12", |
114 | "style-loader": "^0.18.2", | 114 | "style-loader": "^0.18.2", |
115 | - "stylelint": "^8.0.0", | 115 | + "stylelint": "^8.1.1", |
116 | "stylelint-config-yoho": "^1.2.10", | 116 | "stylelint-config-yoho": "^1.2.10", |
117 | "stylelint-formatter-table": "^1.0.2", | 117 | "stylelint-formatter-table": "^1.0.2", |
118 | "stylelint-processor-html": "^1.0.0", | 118 | "stylelint-processor-html": "^1.0.0", |
@@ -122,11 +122,11 @@ | @@ -122,11 +122,11 @@ | ||
122 | "vue-lazyload": "^1.0.6", | 122 | "vue-lazyload": "^1.0.6", |
123 | "vue-loader": "^13.0.4", | 123 | "vue-loader": "^13.0.4", |
124 | "vue-template-compiler": "^2.4.2", | 124 | "vue-template-compiler": "^2.4.2", |
125 | - "webpack": "^3.5.5", | 125 | + "webpack": "^3.5.6", |
126 | "webpack-bundle-analyzer": "^2.9.0", | 126 | "webpack-bundle-analyzer": "^2.9.0", |
127 | "webpack-dev-middleware": "^1.12.0", | 127 | "webpack-dev-middleware": "^1.12.0", |
128 | "webpack-dev-server": "^2.7.1", | 128 | "webpack-dev-server": "^2.7.1", |
129 | - "webpack-hot-middleware": "^2.18.2", | 129 | + "webpack-hot-middleware": "^2.19.1", |
130 | "webpack-merge": "^4.1.0", | 130 | "webpack-merge": "^4.1.0", |
131 | "webpack-uglify-parallel": "^0.1.3", | 131 | "webpack-uglify-parallel": "^0.1.3", |
132 | "yoho-cookie": "^1.2.0", | 132 | "yoho-cookie": "^1.2.0", |
@@ -7,6 +7,8 @@ | @@ -7,6 +7,8 @@ | ||
7 | require('cart/order-ensure.page.css'); | 7 | require('cart/order-ensure.page.css'); |
8 | require('common.js'); | 8 | require('common.js'); |
9 | 9 | ||
10 | +const dialog = require('plugin/dialog'); | ||
11 | + | ||
10 | let lazyLoad = require('yoho-jquery-lazyload'), | 12 | let lazyLoad = require('yoho-jquery-lazyload'), |
11 | tip = require('plugin/tip'), | 13 | tip = require('plugin/tip'), |
12 | cookie = require('yoho-cookie'); | 14 | cookie = require('yoho-cookie'); |
@@ -262,6 +264,13 @@ function submitOrder() { | @@ -262,6 +264,13 @@ function submitOrder() { | ||
262 | } | 264 | } |
263 | cookie.set('order-info', '', actCkOpthn); | 265 | cookie.set('order-info', '', actCkOpthn); |
264 | window.location.href = url; | 266 | window.location.href = url; |
267 | + } else if (res.code === 440) { | ||
268 | + dialog.showDialog({ | ||
269 | + dialogText: res.message, | ||
270 | + hasFooter: { | ||
271 | + centerBtnText: '我知道了' | ||
272 | + } | ||
273 | + }); | ||
265 | } else if (res.message) { | 274 | } else if (res.message) { |
266 | tip.show(res.message); | 275 | tip.show(res.message); |
267 | } | 276 | } |
@@ -88,21 +88,24 @@ | @@ -88,21 +88,24 @@ | ||
88 | .footer { | 88 | .footer { |
89 | height: 90px; | 89 | height: 90px; |
90 | line-height: 90px; | 90 | line-height: 90px; |
91 | - font-size: 30px; | ||
92 | padding: 0 30px; | 91 | padding: 0 30px; |
93 | } | 92 | } |
94 | 93 | ||
95 | .header { | 94 | .header { |
96 | border-bottom: 1px solid #e0e0e0; | 95 | border-bottom: 1px solid #e0e0e0; |
96 | + font-size: 28px; | ||
97 | } | 97 | } |
98 | 98 | ||
99 | .order-status { | 99 | .order-status { |
100 | - float: right; | 100 | + position: absolute; |
101 | + right: 24px; | ||
102 | + top: 0; | ||
101 | } | 103 | } |
102 | 104 | ||
103 | .footer { | 105 | .footer { |
104 | text-align: right; | 106 | text-align: right; |
105 | border-top: 1px solid #e0e0e0; | 107 | border-top: 1px solid #e0e0e0; |
108 | + font-size: 30px; | ||
106 | } | 109 | } |
107 | 110 | ||
108 | .sum-cost { | 111 | .sum-cost { |
-
Please register or login to post a comment