From 7497401f5ef70ef8b95b00871398bdb8ed76ed19 Mon Sep 17 00:00:00 2001 From: jsy_zjg <31502350@qq.com> Date: Fri, 10 Jan 2025 15:01:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/login.js | 7 ++++-- pages/login.vue | 59 +++++++++++-------------------------------------- 2 files changed, 18 insertions(+), 48 deletions(-) diff --git a/api/login.js b/api/login.js index a2c61cf..4c2a5d6 100644 --- a/api/login.js +++ b/api/login.js @@ -20,7 +20,7 @@ export function login(username, password, code, uuid) { //获取手机号验证码 export function getCodePhone(data) { return request({ - url: '/sms/' + data, + url: '/auth/sms/' + data, method: 'get' }) } @@ -28,7 +28,10 @@ export function getCodePhone(data) { //手机号登录 export function phoneLogin(data) { return request({ - url: '/login/user/app/mobile', + url: '/auth/loginPhone', + headers: { + isToken: false + }, method: 'post', data: data }) diff --git a/pages/login.vue b/pages/login.vue index 2acec29..24d391f 100644 --- a/pages/login.vue +++ b/pages/login.vue @@ -30,7 +30,6 @@ - @@ -43,8 +42,6 @@ 请在验证码有效期内登录,过期请重新获取 - @@ -76,6 +73,7 @@ watch, computed } from "vue"; + import plugin from "@/plugins" import { onLoad, } from "@dcloudio/uni-app" @@ -85,7 +83,7 @@ rsaDecrypt } from "@/utils/rsa" import config from '@/config.js' - + import { getCodePhone } from "@/api/login"; const loginForm = ref({ loginName: "admin", password: "admin123", @@ -197,51 +195,20 @@ return } codeBtnDisabled.value = true; - uni.showLoading({ title: "正在获取验证码...", mask: true }) - - // setTimeout(() => { - // uni.hideLoading(); - // setCodeTimer(); - // }, 3000) - store - .dispatch("onGetCodePhone", loginForm.value.phone) - .then(res => { - uni.hideLoading(); - if (res.smsResponse) { - plugin.modal.showToast("短信已发送") - tipText.value = true - countingDown.value = true - loginForm.value.uuid = res.uuid - seconds.value = 60 - timer = setInterval(() => { - seconds.value-- - tips.value = `${seconds.value}s` - if (seconds.value <= 0) { - tipText.value = false - if (!loginForm.value.code) { - tipText2.value = true - } - tips.value = "重新获取" - countingDown.value = false - seconds.value = 60 - clearInterval(timer) - timer = null - } - }, 1000) - } else { - plugin.modal.msgError(res.msg) - } - }) - .catch(error => { - plugin.modal.msgError("短信发送失败," + error) - }) - .finally(() => { - plugin.modal.closeLoading() - }) + getCodePhone(loginForm.value.phone).then(res =>{ + plugin.modal.closeLoading() + if (res.smsResponse) { + plugin.modal.showToast("短信已发送") + loginForm.value.uuid = res.uuid + codeBtnTimer.value = 60 + setCodeTimer(); + } + }); + }; //验证正确手机号 function checkTelephone(telephone) { @@ -292,7 +259,7 @@ } } } else { - loginObj.loginName = loginObj.phone; + loginObj.mobilePhone = loginObj.phone; loginAPI = { url: "phoneLogin", data: loginObj