登录对接
This commit is contained in:
parent
259d5a416c
commit
033dda7744
BIN
src/pages/Home/bg-desktop.jpg
Normal file
BIN
src/pages/Home/bg-desktop.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 335 KiB |
BIN
src/pages/Home/bg-mobile.jpg
Normal file
BIN
src/pages/Home/bg-mobile.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 501 KiB |
@ -56,6 +56,9 @@ import { Button } from '@/components/ui/button'
|
|||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
import { toast } from 'vue-sonner'
|
import { toast } from 'vue-sonner'
|
||||||
import CodeSentTip from '@/pages/Home/components/CodeSentTip.vue'
|
import CodeSentTip from '@/pages/Home/components/CodeSentTip.vue'
|
||||||
|
import request from '@/utils/request'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
const CodeSentTipRef = ref(null)
|
const CodeSentTipRef = ref(null)
|
||||||
const email = ref('')
|
const email = ref('')
|
||||||
const code = ref('')
|
const code = ref('')
|
||||||
@ -68,16 +71,39 @@ const handleGetCode = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
CodeSentTipRef.value.show()
|
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 = () => {
|
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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<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 -->
|
<!-- Full Width Header -->
|
||||||
<div class="h-[88px] md:h-[125px]">
|
<div class="h-[88px] md:h-[125px]">
|
||||||
@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
@click="openLoginModal"
|
@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>
|
</button>
|
||||||
|
|||||||
@ -163,6 +163,11 @@ export default class Request {
|
|||||||
redirectLogin()
|
redirectLogin()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (data.code == 70001) {
|
||||||
|
toast.error('验证码错误')
|
||||||
|
redirectLogin()
|
||||||
|
return
|
||||||
|
}
|
||||||
const resData = config.extraConfig?.originResponseData ? response : responseData
|
const resData = config.extraConfig?.originResponseData ? response : responseData
|
||||||
if (config.extraConfig?.handleResponse) {
|
if (config.extraConfig?.handleResponse) {
|
||||||
if (data.code === 200) {
|
if (data.code === 200) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user