From cfb64e1eaca94ffcbe2adbca655fee02c2c1e5ef Mon Sep 17 00:00:00 2001 From: Anyon Date: Fri, 27 Dec 2019 11:25:04 +0800 Subject: [PATCH] Update login.js --- public/static/login.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/public/static/login.js b/public/static/login.js index 85de1af10..9606a39ec 100644 --- a/public/static/login.js +++ b/public/static/login.js @@ -33,23 +33,25 @@ $(function () { /*! 登录图形验证码刷新 */ $body.on('click', '[data-captcha]', function () { - var type, token, $that, verifyField, uniqidField, captchaUrl; + var type, token, $that, verify, uniqid, captchaUrl; $that = $(this), captchaUrl = this.getAttribute('data-captcha') || ''; if (captchaUrl.length < 5) return $.msg.tips('请设置验证码请求地址'); - uniqidField = this.getAttribute('data-field-uniqid') || 'uniqid'; - verifyField = this.getAttribute('data-field-verify') || 'verify'; + uniqid = this.getAttribute('data-field-uniqid') || 'uniqid'; + verify = this.getAttribute('data-field-verify') || 'verify'; type = this.getAttribute('data-captcha-type') || 'captcha-type'; token = this.getAttribute('data-captcha-token') || 'captcha-token'; $.form.load(captchaUrl, {type: type, token: token}, 'post', function (ret) { - $that.html(''); - $that.append($('img').attr('src', ret.data.image)); - $that.append($('').attr('name', uniqidField || 'uniqid').val(ret.data.uniqid)); - if (ret.data.code) { - $that.parents('form').find('[name=' + (verifyField || 'verify') + ']').attr('value', ret.data.code); - } else { - $that.parents('form').find('[name=' + (verifyField || 'verify') + ']').attr('value', ''); + if (ret.code) { + $that.html(''); + $that.append($('img').attr('src', ret.data.image)); + $that.append($('').attr('name', uniqid).val(ret.data.uniqid)); + if (ret.data.code) { + $that.parents('form').find('[name=' + verify + ']').attr('value', ret.data.code); + } else { + $that.parents('form').find('[name=' + verify + ']').attr('value', ''); + } + return false; } - return false; }, false); });