Showing
5 changed files
with
63 additions
and
12 deletions
1 | 'use strict'; | 1 | 'use strict'; |
2 | const _ = require('lodash'); | 2 | const _ = require('lodash'); |
3 | const helpers = global.yoho.helpers; | 3 | const helpers = global.yoho.helpers; |
4 | -const co = require('bluebird').coroutine; | 4 | +const co = Promise.coroutine; |
5 | const cartModel = require('../models/cart'); | 5 | const cartModel = require('../models/cart'); |
6 | const headerModel = require('../../../doraemon/models/header'); | 6 | const headerModel = require('../../../doraemon/models/header'); |
7 | const userModel = require('../models/user'); | 7 | const userModel = require('../models/user'); |
@@ -211,6 +211,7 @@ exports.orderSub = (req, res, next) => { | @@ -211,6 +211,7 @@ exports.orderSub = (req, res, next) => { | ||
211 | let msg = req.body.msg || null; | 211 | let msg = req.body.msg || null; |
212 | let couponCode = req.body.couponCode || null; | 212 | let couponCode = req.body.couponCode || null; |
213 | let gift_card_code = req.body.gift_card_code || null; | 213 | let gift_card_code = req.body.gift_card_code || null; |
214 | + let verifyCode = req.body.verifyCode || null; | ||
214 | let yohoCoin = req.body.yohoCoin || 0; | 215 | let yohoCoin = req.body.yohoCoin || 0; |
215 | let skuList = req.body.skuList || ''; | 216 | let skuList = req.body.skuList || ''; |
216 | let isPrintPrice = req.body.isPrintPrice || 'Y'; | 217 | let isPrintPrice = req.body.isPrintPrice || 'Y'; |
@@ -258,6 +259,23 @@ exports.orderSub = (req, res, next) => { | @@ -258,6 +259,23 @@ exports.orderSub = (req, res, next) => { | ||
258 | } | 259 | } |
259 | 260 | ||
260 | return co(function* () { | 261 | return co(function* () { |
262 | + // 使用礼品卡,发送验证码 | ||
263 | + if (gift_card_code) { | ||
264 | + if (!verifyCode) { | ||
265 | + yield orderModel.giftCardSendSms(uid); | ||
266 | + | ||
267 | + return res.json({ | ||
268 | + code: 411 | ||
269 | + }); | ||
270 | + } else { | ||
271 | + let verifyResult = yield orderModel.validRegCode(uid, verifyCode); | ||
272 | + | ||
273 | + if (verifyResult.code !== 200) { | ||
274 | + return res.json(verifyResult); | ||
275 | + } | ||
276 | + } | ||
277 | + } | ||
278 | + | ||
261 | let result; | 279 | let result; |
262 | let params = { | 280 | let params = { |
263 | uid: uid, | 281 | uid: uid, |
@@ -536,3 +554,14 @@ exports.jitDetail = (req, res, next) => { | @@ -536,3 +554,14 @@ exports.jitDetail = (req, res, next) => { | ||
536 | })); | 554 | })); |
537 | })().catch(next); | 555 | })().catch(next); |
538 | }; | 556 | }; |
557 | + | ||
558 | +/** | ||
559 | + * 重发验证码 | ||
560 | + */ | ||
561 | +exports.giftCardSendSms = (req, res, next) => { | ||
562 | + let uid = req.user.uid; | ||
563 | + | ||
564 | + orderModel.giftCardSendSms(uid).then(result => { | ||
565 | + res.json(result); | ||
566 | + }).catch(next); | ||
567 | +}; |
@@ -91,8 +91,20 @@ const giftCardSendSms = (uid) => { | @@ -91,8 +91,20 @@ const giftCardSendSms = (uid) => { | ||
91 | }); | 91 | }); |
92 | }; | 92 | }; |
93 | 93 | ||
94 | +/** | ||
95 | + * 礼品卡支付时验证短信验证码 | ||
96 | + */ | ||
97 | +const validRegCode = (uid, verifyCode) => { | ||
98 | + return api.get('', { | ||
99 | + method: 'app.giftcard.validRegCode', | ||
100 | + uid: uid, | ||
101 | + code: verifyCode | ||
102 | + }); | ||
103 | +}; | ||
104 | + | ||
94 | module.exports = { | 105 | module.exports = { |
95 | processInvoiceData, | 106 | processInvoiceData, |
96 | isNewUser, | 107 | isNewUser, |
97 | - giftCardSendSms | 108 | + giftCardSendSms, |
109 | + validRegCode | ||
98 | }; | 110 | }; |
@@ -59,8 +59,10 @@ class OrderEnsure extends Page { | @@ -59,8 +59,10 @@ class OrderEnsure extends Page { | ||
59 | 59 | ||
60 | /** | 60 | /** |
61 | * 验证码弹窗 | 61 | * 验证码弹窗 |
62 | + * @param {手机号} mobile | ||
63 | + * @param {弹窗确定事件的回调} sureCallback | ||
62 | */ | 64 | */ |
63 | - showSafeCheckDialog(mobile) { | 65 | + showSafeCheckDialog(mobile, sureCallback) { |
64 | dialog.showDialog({ | 66 | dialog.showDialog({ |
65 | hasHeader: '安全验证', | 67 | hasHeader: '安全验证', |
66 | dialogText: safeCheckBoxHbs({ mobile: mobile }), | 68 | dialogText: safeCheckBoxHbs({ mobile: mobile }), |
@@ -69,7 +71,10 @@ class OrderEnsure extends Page { | @@ -69,7 +71,10 @@ class OrderEnsure extends Page { | ||
69 | rightBtnText: '确定' | 71 | rightBtnText: '确定' |
70 | } | 72 | } |
71 | }); | 73 | }); |
72 | - dialog.removeClickEvent(this.sckDialogClickHandle(this.sureCallback)); | 74 | + |
75 | + dialog.rewriteEvents().then(() => { | ||
76 | + this.sckDialogClickHandle(sureCallback); | ||
77 | + }); | ||
73 | } | 78 | } |
74 | 79 | ||
75 | /** | 80 | /** |
@@ -105,7 +110,7 @@ class OrderEnsure extends Page { | @@ -105,7 +110,7 @@ class OrderEnsure extends Page { | ||
105 | 110 | ||
106 | $sureBtn.on('click', () => { | 111 | $sureBtn.on('click', () => { |
107 | if ($(event.target).hasClass('active')) { | 112 | if ($(event.target).hasClass('active')) { |
108 | - return sureCallback(); | 113 | + sureCallback($verifyCodeInput.val()); |
109 | } | 114 | } |
110 | }); | 115 | }); |
111 | } | 116 | } |
@@ -171,7 +171,11 @@ function orderCompute() { | @@ -171,7 +171,11 @@ function orderCompute() { | ||
171 | }); | 171 | }); |
172 | } | 172 | } |
173 | 173 | ||
174 | -function submitOrder() { | 174 | +/** |
175 | + * 提交订单 | ||
176 | + * @param {短信验证码} verifyCode | ||
177 | + */ | ||
178 | +function submitOrder(verifyCode) { | ||
175 | let msg = $('#msg').find('input').val() || orderInfo('msg'); | 179 | let msg = $('#msg').find('input').val() || orderInfo('msg'); |
176 | 180 | ||
177 | if (isSubmiting) { | 181 | if (isSubmiting) { |
@@ -198,6 +202,7 @@ function submitOrder() { | @@ -198,6 +202,7 @@ function submitOrder() { | ||
198 | paymentType: orderInfo('paymentType'), // 支付方式 | 202 | paymentType: orderInfo('paymentType'), // 支付方式 |
199 | couponCode: orderInfo('couponCode'), | 203 | couponCode: orderInfo('couponCode'), |
200 | gift_card_code: orderInfo('gift_card_code'), | 204 | gift_card_code: orderInfo('gift_card_code'), |
205 | + verifyCode: verifyCode || null, | ||
201 | yohoCoin: orderInfo('yohoCoin'), | 206 | yohoCoin: orderInfo('yohoCoin'), |
202 | skuList: isLimitGood() ? orderInfo('skuList') : void 0 | 207 | skuList: isLimitGood() ? orderInfo('skuList') : void 0 |
203 | }; | 208 | }; |
@@ -265,7 +270,7 @@ function submitOrder() { | @@ -265,7 +270,7 @@ function submitOrder() { | ||
265 | } else if (res.code === 409) { | 270 | } else if (res.code === 409) { |
266 | richTip.show(res.message, res.buttons); | 271 | richTip.show(res.message, res.buttons); |
267 | } else if (res.code === 411) { | 272 | } else if (res.code === 411) { |
268 | - orderEnsure.showSafeCheckDialog(); | 273 | + orderEnsure.showSafeCheckDialog('123456789', submitOrder); |
269 | } else if (res.message) { | 274 | } else if (res.message) { |
270 | tip.show(res.message); | 275 | tip.show(res.message); |
271 | } | 276 | } |
@@ -90,12 +90,12 @@ exports.hideDialog = function() { | @@ -90,12 +90,12 @@ exports.hideDialog = function() { | ||
90 | $('.dialog-wrapper').remove(); | 90 | $('.dialog-wrapper').remove(); |
91 | }; | 91 | }; |
92 | 92 | ||
93 | -exports.removeClickEvent = (callback) => { | 93 | +/** |
94 | + * 重写事件绑定 | ||
95 | + */ | ||
96 | +exports.rewriteEvents = () => { | ||
94 | setTimeout(() => { | 97 | setTimeout(() => { |
95 | $('.dialog-wrapper').off(); | 98 | $('.dialog-wrapper').off(); |
96 | - | ||
97 | - if (callback) { | ||
98 | - return callback(); | ||
99 | - } | ||
100 | }, 600); | 99 | }, 600); |
100 | + return Promise.resolve(); | ||
101 | }; | 101 | }; |
-
Please register or login to post a comment