Compare commits
No commits in common. "1fcc9dfdf17087f511cd7291b4168a8e8c8fffc1" and "0096587bd765dcbae467995c76b2df61ebe209f9" have entirely different histories.
1fcc9dfdf1
...
0096587bd7
|
@ -1,16 +0,0 @@
|
|||
import service from '@/utils/request'
|
||||
import { LoginVo } from '@/api/book/user'
|
||||
|
||||
/*
|
||||
* 用户登录
|
||||
* */
|
||||
export const useLogin = (data: LoginVo) => {
|
||||
return service.post('/maku/t_user/login', data)
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取用户信息
|
||||
* */
|
||||
export const getUserInfo = () => {
|
||||
return service.get('/maku/t_user/info')
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
export interface LoginVo {
|
||||
username: string
|
||||
password: string
|
||||
}
|
|
@ -4,7 +4,6 @@ import { ElMessage } from 'element-plus'
|
|||
import { useUserStore } from '@/store/modules/user'
|
||||
import cache from '@/utils/cache'
|
||||
import { ElMessageBox } from 'element-plus/es'
|
||||
import { getCookie } from '@/utils/tokenUtil'
|
||||
|
||||
// axios实例
|
||||
const service = axios.create({
|
||||
|
@ -22,11 +21,6 @@ service.interceptors.request.use(
|
|||
config.headers.Authorization = userStore.token
|
||||
}
|
||||
|
||||
var token = getCookie('book_user')
|
||||
if (token) {
|
||||
config.headers['cookie'] = token
|
||||
}
|
||||
|
||||
config.headers['Accept-Language'] = cache.getLanguage()
|
||||
|
||||
// 追加时间戳,防止GET请求缓存
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
export function getCookie(name: string) {
|
||||
let nameEQ = name + '='
|
||||
let ca = document.cookie.split(';')
|
||||
for (let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i]
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1, c.length)
|
||||
}
|
||||
if (c.indexOf(nameEQ) === 0) {
|
||||
return c.substring(nameEQ.length, c.length)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { useRouter } from 'vue-router'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { getCookie } from '@/utils/tokenUtil'
|
||||
import { getUserInfo } from '@/api/book'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const router = useRouter()
|
||||
// 记录切换值
|
||||
const changeValue = ref('/book/index')
|
||||
|
@ -15,13 +14,6 @@ const changeRouters = () => {
|
|||
}
|
||||
router.push(changeValue.value)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
console.log(getCookie('book_user'))
|
||||
// getUserInfo().then(res => {
|
||||
// console.log(res)
|
||||
// })
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -1,29 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useLogin } from '@/api/book'
|
||||
import { ElNotification } from 'element-plus'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const loginForm = ref({
|
||||
username: 'admin1',
|
||||
password: '123456',
|
||||
rePassword: '123456'
|
||||
})
|
||||
const handleLogin = () => {
|
||||
if (active.value == '0') {
|
||||
console.log('登录')
|
||||
useLogin(loginForm.value).then(res => {
|
||||
ElNotification({
|
||||
title: '登录成功!!',
|
||||
type: 'success'
|
||||
})
|
||||
if (route.query.returnUrl) {
|
||||
router.push(route.query.returnUrl as string)
|
||||
}
|
||||
window.document.cookie = 'book_user=' + res.data
|
||||
})
|
||||
} else if (active.value == '1') {
|
||||
active.value = '0'
|
||||
}
|
||||
|
@ -46,9 +32,9 @@ const active = ref('0')
|
|||
<div :class="{ active: active == '0' }" @click="active = '0'">用户登录</div>
|
||||
<div :class="{ active: active == '1' }" @click="active = '1'">用户注册</div>
|
||||
</div>
|
||||
<input v-model="loginForm.username" class="fm-text" placeholder="用户名" />
|
||||
<input v-model="loginForm.password" class="fm-text" placeholder="密码" type="password" />
|
||||
<input v-if="active == '1'" v-model="loginForm.rePassword" class="fm-text" placeholder="确认密码" type="password" />
|
||||
<input class="fm-text" placeholder="用户名" />
|
||||
<input class="fm-text" placeholder="密码" type="password" />
|
||||
<input v-if="active == '1'" class="fm-text" placeholder="确认密码" type="password" />
|
||||
<button @click.prevent="handleLogin">{{ active == '0' ? '登录' : '注册' }}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user