Showing
3 changed files
with
33 additions
and
28 deletions
@@ -273,9 +273,9 @@ class BuyNowController { | @@ -273,9 +273,9 @@ class BuyNowController { | ||
273 | } | 273 | } |
274 | 274 | ||
275 | co(function* () { | 275 | co(function* () { |
276 | - let userData = yield userModel.queryProfile(uid); | 276 | + let userData = yield req.ctx(userModel).queryProfile(uid); |
277 | let mobile = _.get(userData, 'data.mobile', ''); | 277 | let mobile = _.get(userData, 'data.mobile', ''); |
278 | - let addresslist = yield userModel.addressTextData(uid); | 278 | + let addresslist = yield req.ctx(userModel).addressTextData(uid); |
279 | let returnData = orderModel.processInvoiceData(orderInfo, mobile, addresslist); | 279 | let returnData = orderModel.processInvoiceData(orderInfo, mobile, addresslist); |
280 | let headerData = headerModel.setNav({ | 280 | let headerData = headerModel.setNav({ |
281 | invoiceNotice: '发票须知', | 281 | invoiceNotice: '发票须知', |
@@ -77,7 +77,7 @@ exports.orderEnsure = (req, res, next) => { | @@ -77,7 +77,7 @@ exports.orderEnsure = (req, res, next) => { | ||
77 | 77 | ||
78 | let allPromise = [ | 78 | let allPromise = [ |
79 | orderPromise, | 79 | orderPromise, |
80 | - userModel.queryProfile(uid), | 80 | + req.ctx(userModel).queryProfile(uid), |
81 | addressModel.addressData(uid) | 81 | addressModel.addressData(uid) |
82 | ]; | 82 | ]; |
83 | 83 | ||
@@ -424,9 +424,9 @@ exports.invoiceInfo = (req, res, next) => { | @@ -424,9 +424,9 @@ exports.invoiceInfo = (req, res, next) => { | ||
424 | } | 424 | } |
425 | 425 | ||
426 | co(function* () { | 426 | co(function* () { |
427 | - let userData = yield userModel.queryProfile(uid); | 427 | + let userData = yield req.ctx(userModel).queryProfile(uid); |
428 | let mobile = _.get(userData, 'data.mobile', ''); | 428 | let mobile = _.get(userData, 'data.mobile', ''); |
429 | - let addresslist = yield userModel.addressTextData(uid); | 429 | + let addresslist = yield req.ctx(userModel).addressTextData(uid); |
430 | let returnData = orderModel.processInvoiceData(orderInfo, mobile, addresslist); | 430 | let returnData = orderModel.processInvoiceData(orderInfo, mobile, addresslist); |
431 | let headerData = headerModel.setNav({ | 431 | let headerData = headerModel.setNav({ |
432 | invoiceNotice: '发票须知', | 432 | invoiceNotice: '发票须知', |
1 | 'use strict'; | 1 | 'use strict'; |
2 | -const api = global.yoho.API; | ||
3 | 2 | ||
3 | +class userModel extends global.yoho.BaseModel { | ||
4 | + constructor(ctx) { | ||
5 | + super(ctx); | ||
6 | + } | ||
4 | 7 | ||
8 | + /** | ||
9 | + * 获取用户信息 | ||
10 | + * doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/addUserprofile.md | ||
11 | + * @param uid 用户id | ||
12 | + * @return | ||
13 | + */ | ||
14 | + queryProfile(uid) { | ||
15 | + let params = { | ||
16 | + method: 'app.passport.profile', | ||
17 | + uid | ||
18 | + }; | ||
5 | 19 | ||
6 | -/** | ||
7 | - * 获取用户信息 | ||
8 | - * doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/addUserprofile.md | ||
9 | - * @param uid 用户id | ||
10 | - * @return | ||
11 | - */ | ||
12 | -exports.queryProfile = (uid) => { | ||
13 | - let params = { | ||
14 | - method: 'app.passport.profile', | ||
15 | - uid | ||
16 | - }; | 20 | + let options = { |
21 | + cache: true | ||
22 | + }; | ||
17 | 23 | ||
18 | - let options = { | ||
19 | - cache: true | ||
20 | - }; | 24 | + return this.get({data: params, param: options}); |
25 | + } | ||
21 | 26 | ||
22 | - return api.get('', params, options); | ||
23 | -}; | 27 | + addressTextData(uid) { |
28 | + return this.get({data: { | ||
29 | + method: 'app.address.get', | ||
30 | + uid: uid | ||
31 | + }}); | ||
32 | + } | ||
33 | +} | ||
24 | 34 | ||
25 | -exports.addressTextData = (uid) => { | ||
26 | - return api.get('', { | ||
27 | - method: 'app.address.get', | ||
28 | - uid: uid | ||
29 | - }); | ||
30 | -}; | 35 | +module.exports = userModel; |
-
Please register or login to post a comment