import {url} from '../../request' Page({ data: { }, phone(e){ this.setData({ phone:e.detail.value }) console.log(e.detail.value); }, yanzhengma(e){ this.setData({ yanzhengma:e.detail.value }) console.log(e.detail.value); }, password(e){ this.setData({ password:e.detail.value }) console.log(e.detail.value); }, passwordagain(e){ this.setData({ passwordagain:e.detail.value }) console.log(e.detail.value); }, subimt(){ const phone = this.data.phone const yanzhengma = this.data.yanzhengma const password = this.data.password const passwordagain = this.data.passwordagain console.log(phone,'aslkjyhdkjashdjkashkj'); if (!/^\d{11}$/.test(phone)) { wx.showToast({ title: '请输入11位的手机号', icon: 'none' }); return; } if (!/^\d{6}$/.test(yanzhengma)) { wx.showToast({ title: '请输入6位的验证码', icon: 'none' }); return; } if (!/^[a-zA-Z0-9]{6,10}$/.test(password)) { wx.showToast({ title: '请输入6~10位的密码', icon: 'none' }); return; } if (!/^[a-zA-Z0-9]{6,10}$/.test(passwordagain)) { wx.showToast({ title: '请再次输入密码', icon: 'none' }); return; } if(password !== passwordagain){ wx.showToast({ title: '两次输入的密码不一致,请重新输入', icon: 'none' }); return; } wx.request({ url: url + '/userInfo/mini/out/reset/pwd', method: 'POST', data: { phoneNumber: this.data.phone, verificationCode: this.data.yanzhengma, userPassword: this.data.password, userConfirmPassword: this.data.passwordagain }, header: { 'content-type': 'application/json' }, success(res) { console.log('重置成功', res); if(res.data.code==1){ wx.showToast({ title: '重置成功', icon: 'success', duration: 2000 }); setTimeout(() => { wx.navigateBack({ delta: 1 }) }, 2000); }else{ wx.showToast({ title: res.data.message, icon: 'error', duration: 2000 }); } }, fail(err) { console.error('请求失败', err); } }); }, // 获取验证码 getcode(){ const phone = this.data.phone; console.log(phone,'askjhdsakjhdjkashjk'); if (!/^\d{11}$/.test(phone)) { wx.showToast({ title: '请输入11位的手机号', icon: 'none' }); return; } wx.request({ url: url + '/userInfo/code', method: 'POST', data: { templateString: this.data.phone }, header: { 'content-type': 'application/json' }, success(res) { console.log('发送成功', res); if(res.data.code==1){ wx.showToast({ title: '发送成功', icon: 'success', duration: 2000 }); }else{ wx.showToast({ title: res.data.message, icon: 'success', duration: 2000 }); } }, fail(err) { console.error('请求失败', err); } }); }, })