登录对接

This commit is contained in:
speakeloudest 2025-12-31 02:36:33 -08:00
parent 259d5a416c
commit 033dda7744
5 changed files with 41 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 KiB

View File

@ -56,6 +56,9 @@ import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { toast } from 'vue-sonner'
import CodeSentTip from '@/pages/Home/components/CodeSentTip.vue'
import request from '@/utils/request'
import { useRouter } from 'vue-router'
const CodeSentTipRef = ref(null)
const email = ref('')
const code = ref('')
@ -68,16 +71,39 @@ const handleGetCode = () => {
return
}
CodeSentTipRef.value.show()
//
countdown.value = 60
const timer = setInterval(() => {
countdown.value--
if (countdown.value <= 0) clearInterval(timer)
}, 1000)
}
request
.get('/api/v1/auth/check', {
email: email.value,
})
.then(({ exist }) => {
console.log(exist)
request
.post('/api/v1/common/send_code', {
// 1=, 2=,
email: email.value,
type: exist ? 2 : 1,
})
.then(() => {
countdown.value = 60
const timer = setInterval(() => {
countdown.value--
if (countdown.value <= 0) clearInterval(timer)
}, 1000)
})
})
}
const router = useRouter()
const handleLogin = () => {
console.log('登录提交', { email: email.value, code: code.value })
request
.post('/api/v1/auth/login/email', {
email: email.value,
code: code.value,
})
.then((res) => {
localStorage.setItem('Authorization', res.token)
router.push({ path: '/user-center' })
})
}
</script>

View File

@ -1,6 +1,6 @@
<template>
<div
class="relative min-h-screen overflow-hidden bg-[#24963e] pb-[calc(1rem+env(safe-area-inset-bottom))] font-sans text-white md:flex md:flex-col md:pb-6"
class="relative min-h-screen overflow-hidden bg-[#24963e] bg-[url('@/pages/Home/bg-mobile.jpg')] bg-cover bg-center bg-no-repeat pb-[calc(1rem+env(safe-area-inset-bottom))] font-sans text-white md:flex md:flex-col md:bg-[url('@/pages/Home/bg-desktop.jpg')] md:pb-6"
>
<!-- Full Width Header -->
<div class="h-[88px] md:h-[125px]">
@ -32,7 +32,7 @@
</div>
<button
@click="openLoginModal"
class="flex h-[48px] items-center rounded-full bg-[#70C877] px-6 text-sm font-bold backdrop-blur-md transition hover:bg-white/30 md:text-2xl"
class="flex h-[48px] items-center rounded-full bg-[#70C877] px-6 text-sm font-bold backdrop-blur-md transition hover:scale-[0.97] hover:bg-white/30 md:text-2xl"
>
登录 / 注册
</button>

View File

@ -163,6 +163,11 @@ export default class Request {
redirectLogin()
return
}
if (data.code == 70001) {
toast.error('验证码错误')
redirectLogin()
return
}
const resData = config.extraConfig?.originResponseData ? response : responseData
if (config.extraConfig?.handleResponse) {
if (data.code === 200) {