|
|
var $ = require('yoho-jquery'),
|
|
|
Hbs = require('yoho-handlebars'),
|
|
|
dialog = require('../common/dialog'),
|
|
|
Captcha = require('../plugins/captcha');
|
|
|
dialog = require('../common/dialog');
|
|
|
var meGift;
|
|
|
|
|
|
require('yoho-jquery-placeholder');
|
...
|
...
|
@@ -38,7 +37,7 @@ meGift = { |
|
|
if (that.isBinMobile) {
|
|
|
that.activateGift();
|
|
|
} else {
|
|
|
that.verifyEmailCode();
|
|
|
that.getMobileCode();
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -89,13 +88,11 @@ meGift = { |
|
|
});
|
|
|
},
|
|
|
|
|
|
postAjax: function(url, data, verifyData, captcha) {
|
|
|
postAjax: function(url, data, verifyData) {
|
|
|
var deferred = $.Deferred(); // eslint-disable-line
|
|
|
var that = this;
|
|
|
var x;
|
|
|
|
|
|
captcha && captcha.hideTip();
|
|
|
|
|
|
if (that.isFlag) {
|
|
|
return deferred.resolve({
|
|
|
code: 401,
|
...
|
...
|
@@ -122,9 +119,7 @@ meGift = { |
|
|
type: 'post',
|
|
|
data: data
|
|
|
}).then(function(res) {
|
|
|
if (res.code === 405) {
|
|
|
captcha && captcha.showTip(res.message);
|
|
|
} else if (res.code !== 200) {
|
|
|
if (res.code !== 200) {
|
|
|
that.meAlert(res.message, false);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -153,13 +148,12 @@ meGift = { |
|
|
},
|
|
|
|
|
|
// 获取邮箱验证码
|
|
|
getEmailCode: function(captcha) {
|
|
|
getEmailCode: function() {
|
|
|
var that = this;
|
|
|
|
|
|
this.postAjax('/home/megift/sendEmailCode', {
|
|
|
email: this.userEmail,
|
|
|
verifyCode: captcha.getResults()
|
|
|
}, {}, captcha).then(function(res) {
|
|
|
email: this.userEmail
|
|
|
}, {}).then(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
that.intTimer($('.email-btn'));
|
|
|
}
|
...
|
...
|
@@ -169,7 +163,6 @@ meGift = { |
|
|
// 效验邮箱验证码
|
|
|
verifyEmailCode: function() {
|
|
|
var that = this;
|
|
|
var captcha;
|
|
|
var dg = new dialog.Dialog({
|
|
|
content: that.emailTpl({}),
|
|
|
className: 'me-gift-confirm',
|
...
|
...
|
@@ -197,12 +190,11 @@ meGift = { |
|
|
setTimeout(function() {
|
|
|
$('[placeholder]', dg.$el).placeholder(); // ie8 兼容 placeholder
|
|
|
}, 10);
|
|
|
captcha = new Captcha('#captcha').init();
|
|
|
|
|
|
// 发送邮箱验证码
|
|
|
$('.me-gift-confirm').find('.email-btn').unbind('click').bind('click', function() {
|
|
|
if (!$(this).hasClass('int-timer')) {
|
|
|
that.getEmailCode(captcha);
|
|
|
that.getEmailCode();
|
|
|
}
|
|
|
});
|
|
|
},
|
...
|
...
|
@@ -210,7 +202,6 @@ meGift = { |
|
|
// 获取手机验证码
|
|
|
getMobileCode: function() {
|
|
|
var that = this;
|
|
|
var captcha;
|
|
|
var dg = new dialog.Dialog({
|
|
|
content: that.mobileTpl({}),
|
|
|
className: 'me-gift-confirm',
|
...
|
...
|
@@ -236,7 +227,7 @@ meGift = { |
|
|
area: ($('.mobile-area').find('em').text() || '').replace(/^\+/, ''),
|
|
|
mobile: $('input.mobile').val(),
|
|
|
code: $('input.mobile-code').val()
|
|
|
}, verifyData, captcha).then(function(res) {
|
|
|
}, verifyData).then(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
that.isBinMobile = 1;
|
|
|
dg.close();
|
...
|
...
|
@@ -250,18 +241,17 @@ meGift = { |
|
|
setTimeout(function() {
|
|
|
$('[placeholder]', dg.$el).placeholder(); // ie8 兼容 placeholder
|
|
|
}, 10);
|
|
|
captcha = new Captcha('#captcha').init();
|
|
|
|
|
|
// 发送邮箱验证码
|
|
|
$('.me-gift-confirm').find('.mobile-btn').unbind('click').bind('click', function() {
|
|
|
if (!$(this).hasClass('int-timer')) {
|
|
|
that.smsBind(captcha);
|
|
|
that.smsBind();
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
// 发送手机验证码
|
|
|
smsBind: function(captcha) {
|
|
|
smsBind: function() {
|
|
|
var that = this;
|
|
|
var area = ($('.mobile-area').find('em').text() || '').replace(/^\+/, '');
|
|
|
var mobile = $('input.mobile').val();
|
...
|
...
|
@@ -272,9 +262,8 @@ meGift = { |
|
|
|
|
|
this.postAjax('/home/megift/smsBind', {
|
|
|
area: area,
|
|
|
mobile: mobile,
|
|
|
verifyCode: captcha.getResults()
|
|
|
}, verifyData, captcha).then(function(res) {
|
|
|
mobile: mobile
|
|
|
}, verifyData).then(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
that.intTimer($('.mobile-btn'));
|
|
|
}
|
...
|
...
|
@@ -284,7 +273,6 @@ meGift = { |
|
|
// 激活礼品卡
|
|
|
activateGift: function() {
|
|
|
var that = this;
|
|
|
var captcha;
|
|
|
var dg = new dialog.Dialog({
|
|
|
content: that.giftTpl({}),
|
|
|
className: 'me-gift-confirm',
|
...
|
...
|
@@ -308,9 +296,8 @@ meGift = { |
|
|
|
|
|
that.postAjax('/home/meGift/activateGift', {
|
|
|
cardCode: $confirm.find('.card-code').val(),
|
|
|
cardPwd: $confirm.find('.card-pwd').val(),
|
|
|
verifyCode: captcha.getResults()
|
|
|
}, verifyData, captcha).then(function(res) {
|
|
|
cardPwd: $confirm.find('.card-pwd').val()
|
|
|
}, verifyData).then(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
dg.close();
|
|
|
that.meAlert('<p>您的礼品卡激活成功</p>', false, function() {
|
...
|
...
|
@@ -325,7 +312,6 @@ meGift = { |
|
|
setTimeout(function() {
|
|
|
$('[placeholder]', dg.$el).placeholder(); // ie8 兼容 placeholder
|
|
|
}, 10);
|
|
|
captcha = new Captcha('#captcha').init();
|
|
|
},
|
|
|
|
|
|
// 消费明细
|
...
|
...
|
|