From 7985e60a54a67bad874d4ccaa24291bfb0cce76c Mon Sep 17 00:00:00 2001 From: guoxing <1369478551@qq.com> Date: Thu, 23 Feb 2023 10:10:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mallplusui-uniapp-app/pages/public/login.vue | 80 +++++++++++--------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/mallplusui-uniapp-app/pages/public/login.vue b/mallplusui-uniapp-app/pages/public/login.vue index c61e153..d75dc45 100644 --- a/mallplusui-uniapp-app/pages/public/login.vue +++ b/mallplusui-uniapp-app/pages/public/login.vue @@ -12,8 +12,7 @@ - 账号登录 + 账号登录 短信登录 @@ -58,11 +57,11 @@ - - 账号登录 - 短信登录 + 账号登录 + + 短信登录 @@ -160,7 +159,7 @@ }, // 获取验证码 async getCode() { - var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; + var myreg = /^1[1-9][0-9]\d{8}$/; if (!myreg.test(this.phone)) { uni.showToast({ icon: 'none', @@ -491,45 +490,56 @@ async toLogin() { var that = this; let phoneReg = /^1[1-9][0-9]\d{8}$/; - + try { + if (this.phone == '') { + throw '请填写手机号'; + } + if (!phoneReg.test(this.phone)) { + throw '手机号格式有误'; + } + if (this.password == '') { + throw '请填写密码'; + } + } catch (err) { + this.$api.msg(err); + return; + } + console.log("1111111111"); + this.logining = false; if (that.selectKey == 1) { // 短信登录 - uni.showToast({ - icon: 'none', - title: '暂不支持此登录方式' - }); - return; + // uni.showToast({ + // icon: 'none', + // title: '暂不支持此登录方式' + // }); + // return; + let params = { + phone: this.phone, + authCode: this.code + }; + let data = await Api.apiCall('post', Api.index.loginByCode, params); + //this.logining = false; + if (data) { + console.log(data); + that.login(data) + uni.setStorageSync('userInfos', data.userInfo); + uni.setStorageSync('token', data.tokenHead + data.token); + console.log(uni.getStorageSync('token')) + uni.switchTab({ + url: '/pages/index/user' + }); + } } else { // 账号登录 - try { - if (this.phone == '') { - throw '请填写手机号'; - } - if (!phoneReg.test(this.phone)) { - throw '手机号格式有误'; - } - if (this.password == '') { - throw '请填写密码'; - } - } catch (err) { - this.$api.msg(err); - return; - } - console.log("1111111111"); - this.logining = false; let params = { phone: this.phone, password: this.password }; let data = await Api.apiCall('post', Api.index.login, params); - //this.logining = false; - console.log("1111111111"); if (data) { console.log(data); - console.log("22222222222"); that.login(data); - console.log("33333333333333"); uni.setStorageSync('userInfos', data.userInfo); uni.setStorageSync('token', data.tokenHead + data.token); // uni.setStorageSync('adminToken', data.tokenHead + data.token); @@ -704,9 +714,7 @@ margin-bottom: 15upx; align-items: center; - .select_lay_text { - - } + .select_lay_text {} .select_lay_text1 { font-size: 30upx;