Showing
1 changed file
with
27 additions
and
16 deletions
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,9 +14,12 @@ module.exports = class extends global.yoho.BaseModel { | @@ -16,9 +14,12 @@ 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 | 17 | + return this.get({ |
18 | + data: { | ||
19 | + method: 'app.blk.getAllChannels', | ||
20 | + app_type: params.app_type | ||
21 | + }, | ||
22 | + api: global.yoho.API | ||
22 | }, { | 23 | }, { |
23 | cache: true | 24 | cache: true |
24 | }).then(result => { | 25 | }).then(result => { |
@@ -54,12 +55,15 @@ module.exports = class extends global.yoho.BaseModel { | @@ -54,12 +55,15 @@ module.exports = class extends global.yoho.BaseModel { | ||
54 | */ | 55 | */ |
55 | getProductBatch(param, options) { | 56 | getProductBatch(param, options) { |
56 | param.productSkn = _.isArray(param.productSkn) ? param.productSkn : [param.productSkn]; | 57 | 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 | 58 | + return this.get({ |
59 | + data: { | ||
60 | + method: 'h5.product.batch', | ||
61 | + productSkn: param.productSkn.join(','), | ||
62 | + yh_channel: param.yh_channel, | ||
63 | + page: param.page, | ||
64 | + limit: param.limit | ||
65 | + }, | ||
66 | + api: global.yoho.API | ||
63 | }, { | 67 | }, { |
64 | cache: true | 68 | cache: true |
65 | }).then(result => { | 69 | }).then(result => { |
@@ -82,9 +86,12 @@ module.exports = class extends global.yoho.BaseModel { | @@ -82,9 +86,12 @@ module.exports = class extends global.yoho.BaseModel { | ||
82 | * @return {[array]} | 86 | * @return {[array]} |
83 | */ | 87 | */ |
84 | getFashionPrefer(params) { | 88 | getFashionPrefer(params) { |
85 | - return api.get('', Object.assign({ | ||
86 | - method: 'h5.product.fashionPrefer' | ||
87 | - }, params)); | 89 | + return this.get({ |
90 | + data: Object.assign({ | ||
91 | + method: 'h5.product.fashionPrefer' | ||
92 | + }, params), | ||
93 | + api: global.yoho.API | ||
94 | + }); | ||
88 | } | 95 | } |
89 | 96 | ||
90 | /** | 97 | /** |
@@ -98,7 +105,11 @@ module.exports = class extends global.yoho.BaseModel { | @@ -98,7 +105,11 @@ module.exports = class extends global.yoho.BaseModel { | ||
98 | if (options.isApp) { | 105 | if (options.isApp) { |
99 | params.platform = 'iphone'; | 106 | params.platform = 'iphone'; |
100 | } | 107 | } |
101 | - return serviceAPI.get('operations/api/v5/resource/get', params, { | 108 | + return this.get({ |
109 | + url: 'operations/api/v5/resource/get', | ||
110 | + data: params, | ||
111 | + api: global.yoho.ServiceAPI | ||
112 | + }, { | ||
102 | cache: true | 113 | cache: true |
103 | }).then(result => { | 114 | }).then(result => { |
104 | let data = { | 115 | let data = { |
@@ -180,7 +191,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -180,7 +191,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
180 | } | 191 | } |
181 | 192 | ||
182 | getResourcesData(params, options) { | 193 | getResourcesData(params, options) { |
183 | - return api.all([ | 194 | + return Promise.all([ |
184 | this.getResources(params, options), | 195 | this.getResources(params, options), |
185 | this.getFashionPrefer(params) | 196 | this.getFashionPrefer(params) |
186 | ]).then(result => { | 197 | ]).then(result => { |
-
Please register or login to post a comment