// index.ts import { loginType } from "../../utils/loginType" import { httpUtil } from "../../utils/restful"; Page({ data: { login_check_tab: 0, loginType: 0, showAccPwd: true, showUpdatePassWordLayout: false, //短信验证码登录参数 inputPhoneNum: '', inputVCodeNum: '', inputPhonePwdLoginNum: '', inputPwdText: '' }, onLoad(opention: any) { console.log("opention.loginType:", opention.loginType) this.setData({ login_check_tab: 0, loginType: opention.loginType }) }, // 点击短信验证码登录 clickPhoneNumLogin: function (event: any) { console.log("短信验证码登录") console.log(event) this.setData({ login_check_tab: 0, inputPhoneNum: '', inputPhonePwdLoginNum: '' }) }, // 点击账号密码登录 clicAccountPasswordLogin: function (event: any) { console.log("账号密码登录") console.log(event) this.setData({ login_check_tab: 1, inputPhoneNum: '', inputPhonePwdLoginNum: '' }) }, // 获取验证码 clickGetVCode: function (event: any) { console.log("账号密码登录") }, //账号密码登录——--------------------------- showAccountPwd: function (event: any) { if (this.data.showAccPwd) { this.setData({ showAccPwd: false }) } else { this.setData({ showAccPwd: true }) } }, //显示修改密码的框 showUpdatePwdLayout: function (event: any) { if (this.data.showUpdatePassWordLayout) { this.setData({ showUpdatePassWordLayout: false }) } else { this.setData({ showUpdatePassWordLayout: true }) } }, //跳转注册界面 toRegisterPage: function () { wx.navigateTo({ url: '../register/register', }) }, //判断是短信登录还是账号密码登录进行相应登录 toTabIndex: function () { switch (Number(this.data.login_check_tab)) { case 0: //短信验证码登录 this.phoneVCodeLogin(); break; case 1: //账号密码登录 this.pwdPhoneLogin(); break; } // this.toNextPage(); }, //短信验证码登录 phoneVCodeLogin: function () { console.log("this.data.inputPhoneNum:" + this.data.inputPhoneNum) if (!this.data.inputPhoneNum) { this.showToast('请输入手机号') return; } if (!this.data.inputVCodeNum) { this.showToast('请输入验证码') } let phone = this.data.inputPhoneNum; let vcode = this.data.inputVCodeNum; }, //账号密码登录 pwdPhoneLogin: function () { if (!this.data.inputPhonePwdLoginNum) { this.showToast('请输入手机号') return; } if (!this.data.inputPwdText) { this.showToast('请输入密码') } let params = { password: this.data.inputPwdText, userName: this.data.inputPhonePwdLoginNum } httpUtil.wxPost(httpUtil.interfaces.pwdPhoneLogin, params).then((res: any) => { console.log("res:", res.data) if (res.data.success) { console.log("res.data.data:", res.data.data.id) httpUtil.httpData.userId = res.data.data.id this.toNextPage() } else { this.showToast(res.data.message) } }).catch((res) => { console.log(res) }) }, bindPhoneInput: function (event: any) { this.setData({ inputPhoneNum: event.detail.value }) }, bindPwdLoginPhoneInput: function (event: any) { this.setData({ inputPhonePwdLoginNum: event.detail.value }) }, bindVCodeInput: function (event: any) { this.setData({ inputVCodeNum: event.detail.value }) }, bindPwdInput: function (event: any) { this.setData({ inputPwdText: event.detail.value }) }, //登录成功后跳转界面 toNextPage: function () { let toUrl = ''; switch (Number(this.data.loginType)) { case loginType.Teacher: //教师(去教师的index页面) toUrl = "../teacher/index/index" break; case loginType.Installer: //安装员(去安装员的index页面) toUrl = "../installer/index/index" break; case loginType.Repairman: //维修员(去维修员的index页面) toUrl = "../repairman/index/index" break; case loginType.IT: //IT管理员(去IT管理员的index页面) toUrl = "../itadministrator/index/index" break; } wx.navigateTo({ url: toUrl, }) }, showToast: function (message: string) { wx.showToast({ title: message, icon: 'none' }) }, })