完善手机号校验和验证码发送限制
This commit is contained in:
@@ -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' })
|
||||
|
||||
Reference in New Issue
Block a user