feat: 注册页面自动图形验证码

1. 移除邮箱/手机OTP发送逻辑
2. 新增算术图形验证码(如 15 + 3 = ?)
3. 点击验证码图片可刷新
4. 注册失败自动刷新验证码
This commit is contained in:
li
2026-03-31 10:53:17 +08:00
parent 6c085426de
commit 61c10db52a
+25 -46
View File
@@ -56,8 +56,9 @@
<view class="regField">
<text class="regLabel">{{i18n.regist.code}}</text>
<view class="regInputBox regInputRow">
<input class="regInput" type="text" v-model="code" :placeholder="i18n.regist.codeTag" />
<text class="regCodeBtn" @click="cutTime()">{{codeText}}</text>
<input class="regInput" type="number" v-model="code" :placeholder="i18n.regist.codeTag" />
<image class="regCaptchaImg" :src="captchaImg" mode="aspectFit" @click="loadCaptcha()"></image>
<text class="regCaptchaRefresh" @click="loadCaptcha()"></text>
</view>
</view>
@@ -93,22 +94,15 @@
code: '',
referral_code: '',
flag: true,
time: '获取验证码',
timeFlag: true,
agreed: false,
theme: '',
captchaImg: '',
captchaKey: '',
}
},
computed: {
i18n() {
return this.$t('message');
},
codeText() {
if (this.time > 0) {
return this.time + " s"
} else {
return this.i18n.regist.get
}
}
},
onLoad(e) {
@@ -116,6 +110,7 @@
if (e && e.code) {
this.referral_code = e.code
}
this.loadCaptcha()
},
onShow() {
if (uni.getStorageSync("theme") == "dark") {
@@ -163,6 +158,7 @@
email: this.email,
password: this.password,
code: this.code,
captcha_key: this.captchaKey,
referral_code: this.referral_code,
}
if (this.mobile) {
@@ -179,40 +175,17 @@
url: '/pages/login/index?email=' + this.email
})
}, 500)
} else {
// 注册失败刷新验证码
this.loadCaptcha()
}
})
},
cutTime() {
if (!this.timeFlag) return
if (this.email == "") {
this.tos(this.i18n.regist.phoneTag)
return
}
uni.showLoading({
title: this.i18n.regist.loading,
mask: true
})
this.timeFlag = false
this.post('/ems/send', {
email: this.email,
event: "register",
}).then(res => {
uni.hideLoading()
loadCaptcha() {
this.post('/common/captcha', {}).then(res => {
if (res.code == 1) {
this.tos(res.msg)
this.time = 120
var that = this
let timeName = setInterval(() => {
if (that.time > 0) {
that.time--
} else {
that.time = 0
that.timeFlag = true
clearInterval(timeName)
}
}, 1000)
} else {
this.timeFlag = true
this.captchaImg = res.data.captcha_img
this.captchaKey = res.data.captcha_key
}
})
}
@@ -289,13 +262,19 @@
color: #111111;
}
.regCodeBtn {
font-size: 26rpx;
font-weight: 700;
color: #1A74FF;
.regCaptchaImg {
width: 200rpx;
height: 60rpx;
margin-left: 18rpx;
flex: 0 0 auto;
white-space: nowrap;
border-radius: 6rpx;
}
.regCaptchaRefresh {
font-size: 36rpx;
color: #1A74FF;
margin-left: 12rpx;
flex: 0 0 auto;
}
.regAgree {