From fbbb30040e24ee2648403bc58043b590f429e673 Mon Sep 17 00:00:00 2001 From: xingyy <64720302+Concur-max@users.noreply.github.com> Date: Fri, 17 Jan 2025 14:07:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(auth):=20=E5=AE=9E=E7=8E=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=99=BB=E5=BD=95=E5=92=8C=E5=AE=9E=E5=90=8D=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增用户登录接口和相关逻辑 - 实现实名认证页面,包括表单填写和提交功能 - 添加用户信息存储和展示 - 优化页面样式和交互 --- app/api/auth/index.js | 14 +++ app/api/http.js | 4 +- app/pages/login/index.vue | 56 +++++---- app/pages/realAuth/components/detail.vue | 65 ++++++++++ app/pages/realAuth/index.vue | 144 +++++++++++++++-------- 5 files changed, 212 insertions(+), 71 deletions(-) create mode 100644 app/pages/realAuth/components/detail.vue diff --git a/app/api/auth/index.js b/app/api/auth/index.js index b974d76..5187568 100644 --- a/app/api/auth/index.js +++ b/app/api/auth/index.js @@ -7,3 +7,17 @@ export async function senCode(data) { body: data, }) } +export async function userLogin(data) { + const http = getHttp() + return await http('/api/v1/m/user/login', { + method: 'POST', + body: data, + }) +} +export async function userUpdate(data) { + const http = getHttp() + return await http('/api/v1/m/user/update', { + method: 'POST', + body: data, + }) +} \ No newline at end of file diff --git a/app/api/http.js b/app/api/http.js index d9ec74b..db74379 100644 --- a/app/api/http.js +++ b/app/api/http.js @@ -18,7 +18,6 @@ export function setupHttp() { headers: { 'Content-Type': 'application/json' }, async onRequest({ options }) { const token = localStorage.getItem('token') - options.headers = { ...options.headers, ...(token && { Authorization: token }), @@ -26,11 +25,10 @@ export function setupHttp() { }, async onResponse({ response }) { if (response._data.status===1){ - message.warning(response._data.msg) + message.error(response._data.msg) } }, async onResponseError({ response }) { - console.log('error错误') const { message } = response._data if (Array.isArray(message)) { message.forEach((item) => { diff --git a/app/pages/login/index.vue b/app/pages/login/index.vue index 6ee9289..9f16851 100644 --- a/app/pages/login/index.vue +++ b/app/pages/login/index.vue @@ -2,8 +2,9 @@ import { useRouter, useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n' import countryCode from '../countryRegion/data/index.js' -import {senCode} from "@/api/auth/index.js"; - +import {senCode, userLogin} from "@/api/auth/index.js"; +import {authStore} from "~/stores/auth/index.js"; +const {userInfo,token}= authStore() const router = useRouter(); const route = useRoute(); const { locale } = useI18n() @@ -30,8 +31,8 @@ const startCountdown=()=> { }, 1000); } const countdown = ref(0); -const phoneNum = ref('') -const code = ref('') +const phoneNum = ref('17630920520') +const code = ref('655119') const pane = ref(0) const showKeyboard = ref(false); // 根据语言获取默认国家 @@ -78,19 +79,23 @@ watch(locale, () => { }) const vanSwipeRef=ref(null) const getCode =async () => { - loadingRef.value.loading1=true - const res=await senCode({ - telNum:phoneNum.value, - zone:selectedZone.value - }) - loadingRef.value.loading1=false - if (res.status===0){ - pane.value = 1 - vanSwipeRef.value?.swipeTo(pane.value) - showKeyboard.value=true - startCountdown(); - - } + // loadingRef.value.loading1=true + // const res=await senCode({ + // telNum:phoneNum.value, + // zone:selectedZone.value + // }) + // loadingRef.value.loading1=false + // if (res.status===0){ + // pane.value = 1 + // vanSwipeRef.value?.swipeTo(pane.value) + // showKeyboard.value=true + // startCountdown(); + // + // } + pane.value = 1 + vanSwipeRef.value?.swipeTo(pane.value) + showKeyboard.value=true + startCountdown(); } const goBack = () => { @@ -98,9 +103,20 @@ const goBack = () => { pane.value = 0 vanSwipeRef.value?.swipeTo(pane.value) } -const goLogin = () => { - router.push('/realAuth'); -} +const goLogin =async () => { + const res=await userLogin({ + telNum:phoneNum.value, + zone:selectedZone.value, + code:code.value + }) + if (res.status===0){ + userInfo.value=res.data.accountInfo + token.value=res.data.token + if (!res.data.isReal){ + router.push('/realAuth'); + } + } +}