import request from '~/api/request'; import aesCryptoJS from '~/utils/aesCryptoJS.js'; Page({ data: { code: '', phoneNumber: '', timer: null, getCodeText: '获取验证码', mobile: '',//13888888888 password: '',//doctor2025 showPassword: false, }, 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`, }); }, toBack() { wx.navigateBack({ delta: 1, }); }, togglePassword() { this.setData({ showPassword: !this.data.showPassword }); }, });