@zuopngfei 8acd2266b4 wewe
2025-06-24 18:39:49 +08:00

75 lines
1.4 KiB
JavaScript

import request from '~/api/request';
import aesCryptoJS from '~/utils/aesCryptoJS';
Page({
data: {
code: '',
phoneNumber: '',
timer: null,
getCodeText: '获取验证码',
mobile: '13888888888',
password: 'doctor2025',
},
onLoad(options) {
},
bindKeyInput(e){
const { mode } = e.currentTarget.dataset;
this.setData({
[mode]: e.detail.value
})
},
async login() {
// 验证手机号
if (!this.data.mobile) {
wx.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
// 验证手机号格式
if (!/^1[3-9]\d{9}$/.test(this.data.mobile)) {
wx.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
// 验证验证码
if (!this.data.password) {
wx.showToast({
title: '请输入密码',
icon: 'none'
});
return;
}
const res = await request('doctor/login', 'post', {
password: aesCryptoJS(this.data.password),
mobile: this.data.mobile
});
await wx.setStorageSync('access_token', res.token);
wx.switchTab({
url: `/pages/my/index`,
});
// if (res.is_personal_information_complete) {
// wx.switchTab({
// url: `/pages/my/index`,
// });
// } else {
// wx.navigateTo({
// url: `/pages/my/info-edit/index`,
// });
// }
},
});