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