第一次输错验证码后,再次获取验证码时需输入图形验证码

This commit is contained in:
zhl 2019-02-28 11:04:15 +08:00
parent 372b7a5c9e
commit f3a78fb8f6
2 changed files with 17 additions and 4 deletions

View File

@ -43,9 +43,9 @@ cc.Class({
onLoad () { onLoad () {
let self = this; let self = this;
if (this.top.needCode) { if (this.top.needCode) {
this.showCaptchaInput(); this.showCaptchaImage();
this.codeImg.node.on('click', function () { this.codeImg.node.on('click', function () {
self.showCaptchaInput(); self.showCaptchaImage();
}) })
} }
this.closeBtn.on('click', function () { this.closeBtn.on('click', function () {
@ -78,7 +78,6 @@ cc.Class({
alert('发送太过频繁,请稍候再试。'); alert('发送太过频繁,请稍候再试。');
} else if (res.errcode === 101) { } else if (res.errcode === 101) {
alert('图形验证码错误。'); alert('图形验证码错误。');
self.showCaptchaInput();
} else { } else {
alert('短信已发送至您手机, 请输入收到的验证码。'); alert('短信已发送至您手机, 请输入收到的验证码。');
} }
@ -97,7 +96,7 @@ cc.Class({
this.top.node.addChild(result, 11); this.top.node.addChild(result, 11);
}, },
showCaptchaInput() { showCaptchaImage() {
let self = this; let self = this;
cc.loader.load({ cc.loader.load({
url: webapi.captchaUrl()+'?token='+cc.sys.localStorage.getItem('activity_token')+'&data='+new Date(), url: webapi.captchaUrl()+'?token='+cc.sys.localStorage.getItem('activity_token')+'&data='+new Date(),
@ -127,5 +126,8 @@ cc.Class({
return false; return false;
} }
this.top.userLogin(mobile, moileCaptcha); this.top.userLogin(mobile, moileCaptcha);
},
setMobileVal(mobile) {
this.mobileInput.string = mobile;
} }
}); });

View File

@ -179,6 +179,12 @@ cc.Class({
this.infoView.getComponent('infoMenu').top = this; this.infoView.getComponent('infoMenu').top = this;
this.node.addChild(this.infoView, 11); this.node.addChild(this.infoView, 11);
}, },
changeInfoMenu(mobile) {
this.needCode = true;
this.infoView.removeFromParent(true);
this.showInfoMenu();
this.infoView.getComponent('infoMenu').setMobileVal(mobile);
},
showResultView() { showResultView() {
this.infoView.getComponent('infoMenu').hide(); this.infoView.getComponent('infoMenu').hide();
let resultView = cc.instantiate(this.resultPrefab); let resultView = cc.instantiate(this.resultPrefab);
@ -237,6 +243,11 @@ cc.Class({
if (this.logined && !this.allshow) { if (this.logined && !this.allshow) {
this.scheduleUpdateInfo(); this.scheduleUpdateInfo();
} }
} else if (rep.errcode === 104) {
alert('验证码错误, 请重新输入或重新获取');
if (!self.needCode) {
self.changeInfoMenu(mobile);
}
} }
}) })
.catch (err => { .catch (err => {