完成了登录模块

This commit is contained in:
2025-05-19 09:08:33 +08:00
parent 7c934ded5f
commit 3fe9c3c209
20 changed files with 364 additions and 208 deletions

View File

@ -41,12 +41,16 @@ Page({
}
// 3. 请求验证码
wx.request({
url: baseUrl + '/userInfo/code',
url: baseUrl + '/userInfo/code/pwd',
method: 'POST',
data: { templateString: phone },
success: () => {
wx.showToast({ title: '验证码已发送', icon: 'none' });
this._startCountdown(60);
success: (res) => {
if (res.data.code === 1) {
wx.showToast({ title: '验证码已发送', icon: 'none' });
this._startCountdown(60);
} else {
wx.showToast({ title: res.data.message, icon: 'none' });
}
},
fail: () => {
wx.showToast({ title: '发送失败,请重试', icon: 'none' });
@ -96,14 +100,14 @@ Page({
newPwd: '请输入新密码',
confirmPwd: '请再次输入新密码'
})) return;
// 2. 密码一致
if (newPwd !== confirmPwd) {
return wx.showToast({ title: '两次密码不一致', icon: 'none' });
}
// 3. 格式校验手机号
if (!/^1\d{10}$/.test(phone)) {
return wx.showToast({ title: '手机号格式不正确', icon: 'none' });
}
// 2. 密码一致
if (newPwd !== confirmPwd) {
return wx.showToast({ title: '两次密码不一致', icon: 'none' });
}
// 4. 发起重置请求
wx.request({
url: baseUrl + '/userInfo/mini/forgetPwd',