feat: 登录/注册接口对接
This commit is contained in:
@@ -46,14 +46,16 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useUserInfoStore } from '@/stores'
|
||||
import { showToast } from 'vant'
|
||||
import { google } from '@/assets/base64'
|
||||
import { fetchLogin } from '@/api/login'
|
||||
import { fetchRegisterOrLogin } from '@/api/login'
|
||||
|
||||
const router = useRouter()
|
||||
const userInfoStore = useUserInfoStore()
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive<Record<string, string>>({
|
||||
const formData = reactive({
|
||||
email: '',
|
||||
password: ''
|
||||
})
|
||||
@@ -109,19 +111,14 @@ const handleLogin = async () => {
|
||||
|
||||
isLoading.value = true
|
||||
|
||||
const response: any = await fetchLogin({ ...formData, operationType: 'LOGIN' } as any)
|
||||
if (response.code === 200) {
|
||||
console.log('登录成功', response)
|
||||
// showToast('登录成功')
|
||||
// router.push('/stylist/customer')
|
||||
} else {
|
||||
showToast(response.message)
|
||||
}
|
||||
fetchRegisterOrLogin({ ...formData, operationType: 'LOGIN' }).then((response) => {
|
||||
console.log('登录成功', response)
|
||||
userInfoStore.setToken(response.token)
|
||||
userInfoStore.setUserInfo(response.user)
|
||||
showToast('登录成功')
|
||||
router.replace('/stylist/customer')
|
||||
})
|
||||
|
||||
// showToast('登录成功')
|
||||
|
||||
// 登录成功后跳转到主页或工作台
|
||||
// router.push('/stylist/customer')
|
||||
}
|
||||
|
||||
// 处理忘记密码
|
||||
|
||||
Reference in New Issue
Block a user