...
|
...
|
@@ -7,6 +7,7 @@ import utils from './utils'; |
|
|
import user from './user';
|
|
|
import cookies from './cookies';
|
|
|
import jsonp from './jsonp';
|
|
|
import captcha from './captcha';
|
|
|
|
|
|
const miniAppEntrance = '/pages/common/webback';
|
|
|
|
...
|
...
|
@@ -269,30 +270,56 @@ let _initCoupon = function(uid) { |
|
|
if (uid) {
|
|
|
let conpontoken = cookies.cookie('yoho-conpon-token');
|
|
|
let coupontype = cookies.cookie('yoho-conpon-type');
|
|
|
let couponCaptcha = Number(cookies.cookie('yoho-conpon-captcha'));
|
|
|
|
|
|
if (conpontoken) {
|
|
|
if (couponCaptcha || captcha.isOn()) {
|
|
|
let captchaInstance = captcha.getInstance((result) => {
|
|
|
if (result.ret === 0) {
|
|
|
_getCoupon({
|
|
|
token: conpontoken,
|
|
|
uid: uid,
|
|
|
coupontype
|
|
|
coupontype,
|
|
|
ticket: result.ticket,
|
|
|
randstr: result.randstr
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
captchaInstance.show();
|
|
|
}
|
|
|
|
|
|
cookies.setCookie('yoho-conpon-token', '');
|
|
|
cookies.setCookie('yoho-conpon-type', '');
|
|
|
cookies.setCookie('yoho-conpon-captcha', '');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$('body').on('click', '.yoho-conpon', function() {
|
|
|
let token = $(this).data('token');
|
|
|
let type = $(this).data('type');
|
|
|
let isCaptcha = $(this).hasClass('yoho-captcha') ? 1 : 0;
|
|
|
|
|
|
if (user.uid) {
|
|
|
if (isCaptcha || captcha.isOn()) {
|
|
|
let captchaInstance = captcha.getInstance((result) => {
|
|
|
if (result.ret === 0) {
|
|
|
_getCoupon({
|
|
|
token: token,
|
|
|
uid: user.uid,
|
|
|
coupontype: type
|
|
|
coupontype: type,
|
|
|
ticket: result.ticket,
|
|
|
randstr: result.randstr
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
captchaInstance.show();
|
|
|
}
|
|
|
} else {
|
|
|
cookies.setCookie('yoho-conpon-token', token);
|
|
|
cookies.setCookie('yoho-conpon-type', type);
|
|
|
cookies.setCookie('yoho-conpon-captcha', isCaptcha);
|
|
|
|
|
|
gotoLogin();
|
|
|
return;
|
...
|
...
|
|