commission--yt-commit

This commit is contained in:
2025-06-17 19:25:58 +08:00
parent bd98398c4e
commit 8c0a108e8f
2 changed files with 25 additions and 2 deletions

View File

@ -92,6 +92,7 @@ Page({
// 注册按钮点击
async onRegister() {
const { nickname, phone, captcha, inviteCode, password } = this.data;
// 调用通用校验,失败时已提示并 return
if (!validate(this.data, {
nickname: '昵称不能为空',
@ -102,17 +103,38 @@ Page({
})) {
return;
}
// 手机号必须为11位
const phoneReg = /^\d{11}$/;
if (!phoneReg.test(phone)) {
wx.showToast({
title: '请输入11位手机号',
icon: 'none'
})
return;
}
// 密码
const pwdReg = /^(?!^\d+$)^.{6,13}$/;
if (!pwdReg.test(password)) {
wx.showToast({
title: '密码不能为纯数字6-13位',
icon: 'none'
})
return;
}
// 2. 再单独校验协议勾选
if (!this.data.agree) {
wx.showToast({ title: '请先同意用户协议', icon: 'none' });
return;
}
const { nickname, phone, captcha, inviteCode, password } = this.data;
wx.showLoading({
title: '加载中',
mask: true
})
const res = await requestAsync({
const res = await requestAsync({
url: baseUrl + '/userInfo/register',
method: 'POST',
header: { 'content-type': 'application/json' },