完善手机号校验和验证码发送限制

This commit is contained in:
2026-09-16 09:22:30 +08:00
parent 0c827782ff
commit e8e8e5a404
12 changed files with 44 additions and 12 deletions
+7 -1
View File
@@ -121,8 +121,11 @@ Page({
onInput(event) {
const field = event.currentTarget.dataset.field
const value = field === 'phone'
? String(event.detail.value || '').replace(/\D/g, '').slice(0, 11)
: event.detail.value
this.setData({
[`form.${field}`]: event.detail.value
[`form.${field}`]: value
})
},
@@ -135,6 +138,9 @@ Page({
},
async sendLoginCode() {
if (!this.ensureAgreementAccepted()) {
return
}
const phone = String(this.data.form.phone || '').trim()
if (!PHONE_REGEX.test(phone)) {
wx.showToast({ title: '请输入正确手机号', icon: 'none' })