完成登录的axios
This commit is contained in:
parent
fdf634618a
commit
b6d7b0e5e0
|
@ -2,7 +2,7 @@
|
|||
import axios from "axios";
|
||||
const myAxios = axios.create({
|
||||
withCredentials:true,
|
||||
baseURL: '123.249.108.160:8080/api'//测试服务器
|
||||
baseURL: 'http://127.0.0.1:8888/api'//测试服务器
|
||||
});
|
||||
// 添加请求拦截器
|
||||
axios.interceptors.request.use(function (config) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div style="margin-bottom: 10px;">
|
||||
<el-button type="success" @click="Add_type">新增类别</el-button>
|
||||
<el-button type="success" @click="Add_type">添加类别</el-button>
|
||||
<el-button type="danger" @click="">删除类别</el-button>
|
||||
</div>
|
||||
|
||||
|
@ -102,12 +102,17 @@ const handleSelectionChange = (row: any) => {
|
|||
|
||||
const Add_type =()=>{
|
||||
dialogVisible.value = true;
|
||||
form.value = {
|
||||
img: '',
|
||||
type_name: '',
|
||||
tips: ''
|
||||
}
|
||||
}
|
||||
const tableData = [
|
||||
{
|
||||
img: 'https://s21.ax1x.com/2024/10/24/pAdzjZ6.png',
|
||||
type_name: 'Tom',
|
||||
tips: 'No. 189, Grove St, Los Angeles',
|
||||
type_name: '材料包',
|
||||
tips: '提供用户自定义DIY',
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
border-radius: 20px;
|
||||
background-color: rgb(172, 115, 82);
|
||||
line-height: 40px;
|
||||
" @click="login">登录</div>
|
||||
" @click="Login">登录</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
@ -40,17 +40,29 @@
|
|||
import {ref, reactive} from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {useRouter} from 'vue-router'
|
||||
import myAxios from '@/api/myAxiso';
|
||||
|
||||
const user = ref({})
|
||||
const username = ref('')
|
||||
const password = ref('')
|
||||
const router = useRouter()
|
||||
const login = () => {
|
||||
// console.log(username)
|
||||
// console.log(password)
|
||||
if(username.value ==="a"&& password.value ==="1"){
|
||||
router.push("/UserManagement")
|
||||
}}
|
||||
const Login = async ()=>{
|
||||
const res: any = await myAxios.post("/user/login",{
|
||||
userAccount: username.value,
|
||||
userPassword: password.value
|
||||
})
|
||||
console.log(res.data.code)
|
||||
if(res.data.code === 1 && res ?.data) {
|
||||
//存储角色
|
||||
await router.replace('/PersonalCenter')
|
||||
}
|
||||
}
|
||||
// const login = () => {
|
||||
// // console.log(username)
|
||||
// // console.log(password)
|
||||
// if(username.value ==="a"&& password.value ==="1"){
|
||||
// router.push("/UserManagement")
|
||||
// }}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
Loading…
Reference in New Issue
Block a user