Authored by 郭成尧

addressModel-ctx

@@ -228,7 +228,7 @@ class BuyNowController { @@ -228,7 +228,7 @@ class BuyNowController {
228 let buy_number = req.query.buy_number; 228 let buy_number = req.query.buy_number;
229 229
230 co(function * () { 230 co(function * () {
231 - let address = yield addressModel.addressData(uid); 231 + let address = yield req.ctx(addressModel).addressData(uid);
232 let moreUrl = helpers.urlFormat('/cart/index/buynow/orderensure', { 232 let moreUrl = helpers.urlFormat('/cart/index/buynow/orderensure', {
233 product_sku: product_sku, 233 product_sku: product_sku,
234 buy_number: buy_number 234 buy_number: buy_number
@@ -78,7 +78,7 @@ exports.orderEnsure = (req, res, next) => { @@ -78,7 +78,7 @@ exports.orderEnsure = (req, res, next) => {
78 let allPromise = [ 78 let allPromise = [
79 orderPromise, 79 orderPromise,
80 req.ctx(userModel).queryProfile(uid), 80 req.ctx(userModel).queryProfile(uid),
81 - addressModel.addressData(uid) 81 + req.ctx(addressModel).addressData(uid)
82 ]; 82 ];
83 83
84 if (_.isUndefined(req.cookies._isNewUser)) { 84 if (_.isUndefined(req.cookies._isNewUser)) {
@@ -372,7 +372,7 @@ exports.useCouponCode = (req, res, next) => { @@ -372,7 +372,7 @@ exports.useCouponCode = (req, res, next) => {
372 exports.selectAddress = (req, res, next) => { 372 exports.selectAddress = (req, res, next) => {
373 let uid = req.user.uid; 373 let uid = req.user.uid;
374 374
375 - return addressModel.addressData(uid).then(address => { 375 + return req.ctx(addressModel).addressData(uid).then(address => {
376 376
377 let moreUrl = (req.get('Referer') && !/\/home\/addressAct/.test(req.get('Referer')) && 377 let moreUrl = (req.get('Referer') && !/\/home\/addressAct/.test(req.get('Referer')) &&
378 !/selectAddress/.test(req.get('Referer'))) ? 378 !/selectAddress/.test(req.get('Referer'))) ?
@@ -5,12 +5,17 @@ @@ -5,12 +5,17 @@
5 const api = global.yoho.API; 5 const api = global.yoho.API;
6 const crypto = global.yoho.crypto; 6 const crypto = global.yoho.crypto;
7 7
8 -/** 8 +class AddressModel extends global.yoho.BaseModel {
  9 + constructor(ctx) {
  10 + super(ctx);
  11 + }
  12 +
  13 + /**
9 * 地址数据 14 * 地址数据
10 * @param uid 15 * @param uid
11 * @return 16 * @return
12 */ 17 */
13 -exports.addressData = (uid) => { 18 + addressData(uid) {
14 let params = { 19 let params = {
15 method: 'app.address.gethidden', 20 method: 'app.address.gethidden',
16 uid 21 uid
@@ -37,4 +42,7 @@ exports.addressData = (uid) => { @@ -37,4 +42,7 @@ exports.addressData = (uid) => {
37 return {code: 500, data: [], message: '地址获取失败'}; 42 return {code: 500, data: [], message: '地址获取失败'};
38 } 43 }
39 ); 44 );
40 -}; 45 + }
  46 +}
  47 +
  48 +module.exports = AddressModel;