修复了验证码bug
This commit is contained in:
@ -68,7 +68,7 @@ Page({
|
||||
|
||||
// 获取验证码(仅校验手机号)
|
||||
getSmsCode() {
|
||||
const { phone } = this.data;
|
||||
const { phone, role } = this.data;
|
||||
|
||||
// 1. 非空校验
|
||||
if (!validate(this.data, { phone: '请输入手机号' })) {
|
||||
@ -83,7 +83,10 @@ Page({
|
||||
wx.request({
|
||||
url: baseUrl + '/userInfo/code/pwd',
|
||||
method: 'POST',
|
||||
data: { templateString: phone },
|
||||
data: {
|
||||
phoneNumber: phone,
|
||||
userRole: role
|
||||
},
|
||||
success: (res) => {
|
||||
console.log('验证码发送--->',res.data);
|
||||
if (res.data.code === 1) {
|
||||
@ -176,7 +179,7 @@ Page({
|
||||
const token = res.data.data.token || res.data.data;
|
||||
// ← 新增:将 token 存到本地缓存
|
||||
wx.setStorageSync('token', token);
|
||||
|
||||
wx.setStorageSync('role', role)
|
||||
wx.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success',
|
||||
|
@ -54,7 +54,7 @@ Page({
|
||||
},
|
||||
|
||||
sendSmsCode() {
|
||||
const { phone } = this.data;
|
||||
const { phone, role } = this.data;
|
||||
if (!phone.trim()) {
|
||||
wx.showToast({ title: '请输入手机号', icon: 'none' });
|
||||
return;
|
||||
@ -68,7 +68,8 @@ Page({
|
||||
method: 'POST',
|
||||
header: { 'content-type': 'application/json' },
|
||||
data: {
|
||||
templateString: phone
|
||||
phoneNumber: phone,
|
||||
userRole: role
|
||||
},
|
||||
success: res => {
|
||||
// 假设后端返回 { success: true, ... }
|
||||
|
@ -33,6 +33,7 @@ Page({
|
||||
icon: 'success'
|
||||
})
|
||||
wx.removeStorageSync('token')
|
||||
wx.removeStorageSync('role')
|
||||
setTimeout(() => {
|
||||
wx.reLaunch({
|
||||
url: '/pages/welcome/homePage/homePage',
|
||||
|
@ -67,7 +67,8 @@ Page({
|
||||
Authorization: wx.getStorageSync('token')
|
||||
},
|
||||
data: {
|
||||
templateString: phone
|
||||
phoneNumber: phone,
|
||||
userRole: wx.getStorageSync('role')
|
||||
},
|
||||
success: res => {
|
||||
if (res.data.code === 1) {
|
||||
|
Reference in New Issue
Block a user