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"> <view class="regField">
<text class="regLabel">{{i18n.regist.code}}</text> <text class="regLabel">{{i18n.regist.code}}</text>
<view class="regInputBox regInputRow"> <view class="regInputBox regInputRow">
<input class="regInput" type="text" v-model="code" :placeholder="i18n.regist.codeTag" /> <input class="regInput" type="number" v-model="code" :placeholder="i18n.regist.codeTag" />
<text class="regCodeBtn" @click="cutTime()">{{codeText}}</text> <image class="regCaptchaImg" :src="captchaImg" mode="aspectFit" @click="loadCaptcha()"></image>
<text class="regCaptchaRefresh" @click="loadCaptcha()"></text>
</view> </view>
</view> </view>
@@ -93,22 +94,15 @@
code: '', code: '',
referral_code: '', referral_code: '',
flag: true, flag: true,
time: '获取验证码',
timeFlag: true,
agreed: false, agreed: false,
theme: '', theme: '',
captchaImg: '',
captchaKey: '',
} }
}, },
computed: { computed: {
i18n() { i18n() {
return this.$t('message'); return this.$t('message');
},
codeText() {
if (this.time > 0) {
return this.time + " s"
} else {
return this.i18n.regist.get
}
} }
}, },
onLoad(e) { onLoad(e) {
@@ -116,6 +110,7 @@
if (e && e.code) { if (e && e.code) {
this.referral_code = e.code this.referral_code = e.code
} }
this.loadCaptcha()
}, },
onShow() { onShow() {
if (uni.getStorageSync("theme") == "dark") { if (uni.getStorageSync("theme") == "dark") {
@@ -163,6 +158,7 @@
email: this.email, email: this.email,
password: this.password, password: this.password,
code: this.code, code: this.code,
captcha_key: this.captchaKey,
referral_code: this.referral_code, referral_code: this.referral_code,
} }
if (this.mobile) { if (this.mobile) {
@@ -179,40 +175,17 @@
url: '/pages/login/index?email=' + this.email url: '/pages/login/index?email=' + this.email
}) })
}, 500) }, 500)
} else {
// 注册失败刷新验证码
this.loadCaptcha()
} }
}) })
}, },
cutTime() { loadCaptcha() {
if (!this.timeFlag) return this.post('/common/captcha', {}).then(res => {
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()
if (res.code == 1) { if (res.code == 1) {
this.tos(res.msg) this.captchaImg = res.data.captcha_img
this.time = 120 this.captchaKey = res.data.captcha_key
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
} }
}) })
} }
@@ -289,13 +262,19 @@
color: #111111; color: #111111;
} }
.regCodeBtn { .regCaptchaImg {
font-size: 26rpx; width: 200rpx;
font-weight: 700; height: 60rpx;
color: #1A74FF;
margin-left: 18rpx; margin-left: 18rpx;
flex: 0 0 auto; flex: 0 0 auto;
white-space: nowrap; border-radius: 6rpx;
}
.regCaptchaRefresh {
font-size: 36rpx;
color: #1A74FF;
margin-left: 12rpx;
flex: 0 0 auto;
} }
.regAgree { .regAgree {