Showing
5 changed files
with
63 additions
and
65 deletions
@@ -17,13 +17,7 @@ exports.sendCoin = (req, res, next) => { | @@ -17,13 +17,7 @@ exports.sendCoin = (req, res, next) => { | ||
17 | uid = req.query.app.uid; | 17 | uid = req.query.app.uid; |
18 | } | 18 | } |
19 | 19 | ||
20 | - // if (!uid) { | ||
21 | - // data.code = 401; | ||
22 | - // data.message = "未登录"; | ||
23 | - // return res.jsonp(data); | ||
24 | - // } | ||
25 | - | ||
26 | - coinModel.sendCoin({ | 20 | + req.ctx(coinModel).sendCoin({ |
27 | token: req.query.token, | 21 | token: req.query.token, |
28 | uid: uid | 22 | uid: uid |
29 | }).then((result) => { | 23 | }).then((result) => { |
@@ -17,9 +17,7 @@ exports.index = (req, res, next) => { | @@ -17,9 +17,7 @@ exports.index = (req, res, next) => { | ||
17 | renderData.mobile = mobile; | 17 | renderData.mobile = mobile; |
18 | renderData.ordercode = ordercode; | 18 | renderData.ordercode = ordercode; |
19 | 19 | ||
20 | - // 测试假数据 | ||
21 | - // res.render('coupon', renderData); // 渲染页面 | ||
22 | - couponModel.getPageInfo({ | 20 | + req.ctx(couponModel).getPageInfo({ |
23 | ordercode: ordercode, | 21 | ordercode: ordercode, |
24 | uid: uid | 22 | uid: uid |
25 | }).then((couponData) => { | 23 | }).then((couponData) => { |
@@ -49,9 +47,7 @@ exports.getCoupon = (req, res, next) => { | @@ -49,9 +47,7 @@ exports.getCoupon = (req, res, next) => { | ||
49 | renderData.mobile = mobile; | 47 | renderData.mobile = mobile; |
50 | renderData.ordercode = ordercode; | 48 | renderData.ordercode = ordercode; |
51 | 49 | ||
52 | - // //测试假数据 | ||
53 | - // res.render('coupon', renderData); // 渲染页面 | ||
54 | - couponModel.getCoupon({ | 50 | + req.ctx(couponModel).getCoupon({ |
55 | ordercode: ordercode, | 51 | ordercode: ordercode, |
56 | mobile: mobile | 52 | mobile: mobile |
57 | }).then((couponData) => { | 53 | }).then((couponData) => { |
@@ -59,8 +55,6 @@ exports.getCoupon = (req, res, next) => { | @@ -59,8 +55,6 @@ exports.getCoupon = (req, res, next) => { | ||
59 | // 获取信息成功 | 55 | // 获取信息成功 |
60 | couponData.ordercode = ordercode; | 56 | couponData.ordercode = ordercode; |
61 | } | 57 | } |
62 | - | ||
63 | - // console.log(couponData); | ||
64 | res.json({ | 58 | res.json({ |
65 | result: couponData | 59 | result: couponData |
66 | }); | 60 | }); |
@@ -72,8 +66,6 @@ exports.verify = (req, res, next) => { | @@ -72,8 +66,6 @@ exports.verify = (req, res, next) => { | ||
72 | module: 'activity', | 66 | module: 'activity', |
73 | page: 'coupon' | 67 | page: 'coupon' |
74 | }; | 68 | }; |
75 | - | ||
76 | - | ||
77 | var ordercode = req.query.ordercode, | 69 | var ordercode = req.query.ordercode, |
78 | mobile = req.query.mobile, | 70 | mobile = req.query.mobile, |
79 | identifycode = req.query.identifycode; | 71 | identifycode = req.query.identifycode; |
@@ -82,9 +74,7 @@ exports.verify = (req, res, next) => { | @@ -82,9 +74,7 @@ exports.verify = (req, res, next) => { | ||
82 | renderData.ordercode = ordercode; | 74 | renderData.ordercode = ordercode; |
83 | renderData.identifycode = identifycode; | 75 | renderData.identifycode = identifycode; |
84 | 76 | ||
85 | - // //测试假数据 | ||
86 | - // res.render('coupon', renderData); // 渲染页面 | ||
87 | - couponModel.registerAndSendCoupon({ | 77 | + req.ctx(couponModel).registerAndSendCoupon({ |
88 | ordercode: ordercode, | 78 | ordercode: ordercode, |
89 | mobile: mobile, | 79 | mobile: mobile, |
90 | identifycode: identifycode | 80 | identifycode: identifycode |
@@ -93,8 +83,6 @@ exports.verify = (req, res, next) => { | @@ -93,8 +83,6 @@ exports.verify = (req, res, next) => { | ||
93 | // 获取信息成功 | 83 | // 获取信息成功 |
94 | couponData.ordercode = ordercode; | 84 | couponData.ordercode = ordercode; |
95 | } | 85 | } |
96 | - | ||
97 | - // console.log(couponData); | ||
98 | res.json({ | 86 | res.json({ |
99 | result: couponData | 87 | result: couponData |
100 | }); | 88 | }); |
@@ -2,12 +2,19 @@ | @@ -2,12 +2,19 @@ | ||
2 | * 领取有货币 | 2 | * 领取有货币 |
3 | */ | 3 | */ |
4 | 4 | ||
5 | -const api = global.yoho.API; | 5 | +module.exports = class extends global.yoho.BaseModel { |
6 | + constructor(ctx) { | ||
7 | + super(ctx); | ||
8 | + } | ||
6 | 9 | ||
7 | -module.exports = { | ||
8 | - sendCoin: function(params) { | ||
9 | - return api.get('', Object.assign({ | ||
10 | - method: 'app.activity.receviceYohoCoin' | ||
11 | - }, params)); | 10 | + sendCoin(params) { |
11 | + return this.get({ | ||
12 | + data: Object.assign({ | ||
13 | + method: 'app.activity.receviceYohoCoin' | ||
14 | + }, params), | ||
15 | + param: { | ||
16 | + cache: true | ||
17 | + } | ||
18 | + }); | ||
12 | } | 19 | } |
13 | }; | 20 | }; |
1 | -var api = global.yoho.API; | ||
2 | - | ||
3 | /** | 1 | /** |
4 | * 分享页面基础参数 | 2 | * 分享页面基础参数 |
5 | * @param {object} sizeInfo [接口原始数据] | 3 | * @param {object} sizeInfo [接口原始数据] |
@@ -72,50 +70,62 @@ const getUserStatus = (param) => { | @@ -72,50 +70,62 @@ const getUserStatus = (param) => { | ||
72 | return dest; | 70 | return dest; |
73 | }; | 71 | }; |
74 | 72 | ||
73 | +module.exports = class extends global.yoho.BaseModel { | ||
74 | + constructor(ctx) { | ||
75 | + super(ctx); | ||
76 | + } | ||
75 | 77 | ||
76 | -/** | ||
77 | - * 获取分享页面数据 | ||
78 | - */ | ||
79 | -exports.getPageInfo = (data) => { | ||
80 | - var defaultParam = { | 78 | + /** |
79 | + * 获取分享页面数据 | ||
80 | + */ | ||
81 | + getPageInfo(data) { | ||
82 | + let defaultParam = { | ||
81 | method: 'app.activity.getInfoOfOrderShare' | 83 | method: 'app.activity.getInfoOfOrderShare' |
82 | - }, | ||
83 | - infoData = Object.assign(defaultParam, data); // 处理完成后,发给后端 | ||
84 | - | ||
85 | - return api.get('', infoData).then(result => { | ||
86 | - return getPageInfo(result); | ||
87 | - }); // 所有数据返回一个 Promise,方便 Promise.all 调用 | ||
88 | -}; | 84 | + }; |
85 | + let infoData = Object.assign(defaultParam, data); // 处理完成后,发给后端 | ||
86 | + | ||
87 | + return this.get({ | ||
88 | + data: infoData | ||
89 | + }).then(result => { | ||
90 | + return getPageInfo(result); | ||
91 | + }); // 所有数据返回一个 Promise,方便 Promise.all 调用 | ||
92 | + } | ||
89 | 93 | ||
90 | -/** | ||
91 | - * 输入手机号领券,新用户返回验证码 | ||
92 | - */ | ||
93 | -exports.getCoupon = (data) => { | ||
94 | - var defaultParam = { | 94 | + /** |
95 | + * 输入手机号领券,新用户返回验证码 | ||
96 | + */ | ||
97 | + getCoupon(data) { | ||
98 | + let defaultParam = { | ||
95 | method: 'wap.order.drawOrderShareCoupon' | 99 | method: 'wap.order.drawOrderShareCoupon' |
96 | - }, | 100 | + }; |
97 | 101 | ||
98 | // 处理完成后,发给后端 | 102 | // 处理完成后,发给后端 |
99 | - phoneData = Object.assign(defaultParam, data); | 103 | + let phoneData = Object.assign(defaultParam, data); |
100 | 104 | ||
101 | - return api.get('', phoneData).then(result => { | ||
102 | - return getUserStatus(result); | ||
103 | - }); // 所有数据返回一个 Promise,方便 Promise.all 调用 | ||
104 | -}; | 105 | + return this.get({ |
106 | + data: phoneData | ||
107 | + }).then(result => { | ||
108 | + return getUserStatus(result); | ||
109 | + }); // 所有数据返回一个 Promise,方便 Promise.all 调用 | ||
110 | + } | ||
105 | 111 | ||
106 | 112 | ||
107 | -/** | ||
108 | - * 验证注册码进行注册并发券 | ||
109 | - */ | ||
110 | -exports.registerAndSendCoupon = (data) => { | ||
111 | - var defaultParam = { | 113 | + /** |
114 | + * 验证注册码进行注册并发券 | ||
115 | + */ | ||
116 | + registerAndSendCoupon(data) { | ||
117 | + let defaultParam = { | ||
112 | method: 'wap.order.registerAndSendCoupon' | 118 | method: 'wap.order.registerAndSendCoupon' |
113 | - }, | 119 | + }; |
114 | 120 | ||
115 | // 处理完成后,发给后端 | 121 | // 处理完成后,发给后端 |
116 | - verifyData = Object.assign(defaultParam, data); | 122 | + let verifyData = Object.assign(defaultParam, data); |
117 | 123 | ||
118 | - return api.get('', verifyData).then(result => { | ||
119 | - return getUserStatus(result); | ||
120 | - }); // 所有数据返回一个 Promise,方便 Promise.all 调用 | 124 | + return this.get({ |
125 | + data: verifyData | ||
126 | + }).then(result => { | ||
127 | + return getUserStatus(result); | ||
128 | + }); // 所有数据返回一个 Promise,方便 Promise.all 调用 | ||
129 | + } | ||
121 | }; | 130 | }; |
131 | + |
@@ -9,7 +9,6 @@ const utils = '../../../utils'; | @@ -9,7 +9,6 @@ const utils = '../../../utils'; | ||
9 | const _ = require('lodash'); | 9 | const _ = require('lodash'); |
10 | const comment = require('./consult-comment'); | 10 | const comment = require('./consult-comment'); |
11 | const bundle = require('./bundle'); | 11 | const bundle = require('./bundle'); |
12 | -const api = global.yoho.API; | ||
13 | const helpers = global.yoho.helpers; | 12 | const helpers = global.yoho.helpers; |
14 | const productProcess = require(`${utils}/product-process`); | 13 | const productProcess = require(`${utils}/product-process`); |
15 | 14 | ||
@@ -149,7 +148,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -149,7 +148,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
149 | if (!brandId) { | 148 | if (!brandId) { |
150 | return Promise.resolve([]); | 149 | return Promise.resolve([]); |
151 | } | 150 | } |
152 | - return api.get({ | 151 | + return this.get({ |
153 | data: { | 152 | data: { |
154 | method: 'app.shop.queryShopsByBrandId', | 153 | method: 'app.shop.queryShopsByBrandId', |
155 | brand_id: _.toString(brandId) | 154 | brand_id: _.toString(brandId) |
-
Please register or login to post a comment