Authored by 郝肖肖

'礼品卡去掉验证码'

... ... @@ -71,7 +71,7 @@ module.exports = class extends global.yoho.BaseModel {
'/home/account/modifymobile'
]},
{name: '地址管理', href: '/home/address'},
{name: '兑换礼品卡', href: '/home/gift'}
// {name: '兑换礼品卡', href: '/home/gift'} // @韩施超-产品让注释的
]
}
];
... ...
... ... @@ -103,27 +103,14 @@ module.exports = class extends global.yoho.BaseModel {
}
// 验证手机是否绑定
verifyBinMobile(uid) {
verifyBinMobile() {
let userInfo = {
isBinMobile: Number(!!_.get(this.ctx, 'req.user.mobile', false))
};
if (userInfo.isBinMobile) {
return Promise.resolve(userInfo);
}
return this.meGiftAPi.getProfile(uid).then(lres => {
lres = _.get(lres, 'data', {});
let isBinMobile = Number(!!lres.verify_mobile);
return Object.assign({}, userInfo, {
isBinMobile: isBinMobile,
email: lres.verify_email
});
});
}
// 发送邮箱验证码
sendEmailCode(params, uid) {
return this.meGiftAPi.sendEmailCode(params.email, uid);
... ...
... ... @@ -275,12 +275,12 @@ router.get('/newuser', newUserController.check);
// 我的礼品卡
router.get('/megift', tabsMiddleware.getCommonHeader, meGiftController.index);
router.post('/megift/sendEmailCode', captcha.requiredAPI, meGiftController.sendEmailCode);// 发送邮箱验证码
router.post('/megift/sendEmailCode', meGiftController.sendEmailCode);// 发送邮箱验证码
router.post('/megift/verifyEmail', meGiftController.verifyEmail);// 验证邮箱验证码
// 图形验证码、检查是否绑定手机号、发验证码
router.post('/megift/smsBind', captcha.requiredAPI, meGiftController.smsBind);
// 检查是否绑定手机号、发验证码
router.post('/megift/smsBind', meGiftController.smsBind);
router.post('/megift/changeMobile', meGiftController.changeMobile);// 修改绑定手机
router.post('/megift/activateGift', captcha.requiredAPI, meGiftController.activateGift);// 激活礼品卡
router.post('/megift/activateGift', meGiftController.activateGift);// 激活礼品卡
router.get('/megift/detail', meGiftController.detail);// 消费明细
module.exports = router;
... ...
... ... @@ -51,9 +51,6 @@
<input type="text" placeholder="短信验证码" class="left email-code" />
<span class="left email-btn">获取短信验证码</span>
</div>
<div class="gift-group">
<div id="captcha" style="display: inline-block; position: relative;"></div>
</div>
</script>
{{!-- 绑定手机模板 --}}
... ... @@ -81,12 +78,9 @@
</span>
<input type="text" placeholder="请输入手机号" class="right mobile" />
</div>
<div class="gift-group">
<div class="gift-group bind-mobile-input">
<input type="text" placeholder="短信验证码" class="left mobile-code" />
<span class="left mobile-btn">获取短信验证码</span>
</div>
<div class="gift-group">
<div id="captcha" style="display: inline-block; position: relative;"></div>
<span class="right mobile-btn">获取短信验证码</span>
</div>
</div>
</script>
... ... @@ -94,12 +88,9 @@
{{!-- 激活礼品卡模板 --}}
<script id="activate-gift-tpl" type="text/html">
<div class="title">激活礼品卡</div>
<div class="verify-input">
<div class="verify-input activate-center">
<div class="gift-group"><input type="text" placeholder="请输入礼品卡号" class="card-code" /></div>
<div class="gift-group"><input type="text" placeholder="请输入礼品卡密" class="card-pwd" /></div>
<div class="gift-group">
<div id="captcha" style="display: inline-block; position: relative;"></div>
</div>
<div class="gift-group activate-input-last"><input type="text" placeholder="请输入礼品卡密" class="card-pwd" /></div>
</div>
</script>
... ...
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();
},
// 消费明细
... ...
... ... @@ -150,7 +150,7 @@
input {
height: 30px;
line-height: 28px;
line-height: 30px;
padding: 0 5px;
font-size: 14px;
color: #444;
... ... @@ -161,11 +161,11 @@
.email-btn,
.mobile-btn {
border: 1px solid #e6e6e6;
font-size: 13px;
background-color: #444;
color: #fff;
height: 30px;
border: none;
cursor: pointer;
width: 110px;
line-height: 30px;
... ... @@ -191,7 +191,7 @@
.mobile-area {
width: 70px;
line-height: 30px;
line-height: 26px;
height: 30px;
text-align: center;
border: 1px solid #e6e6e6;
... ... @@ -225,12 +225,12 @@
}
input.mobile-code {
width: 217px;
width: 200px;
}
.card-code,
.card-pwd {
width: 310px;
width: 330px;
}
.border-top-info {
... ... @@ -307,12 +307,24 @@
}
.confirm-sure {
margin-left: 45px;
margin-left: 65px;
}
.alert-sure {
width: 160px;
}
.activate-input-last {
margin-top: 30px;
}
.activate-center {
padding-bottom: 30px;
}
.bind-mobile-input {
margin: 30px 0 50px;
}
}
.me-gift-confirm.me-page {
... ...