2024-06-29 08:53:03 +00:00
|
|
|
import axios from "axios";
|
|
|
|
|
import { useRouter } from 'vue-router';
|
|
|
|
|
import {ref} from "vue";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
login(account, password){
|
|
|
|
|
const url='http://localhost:8080/checkLogin'
|
|
|
|
|
const data={
|
|
|
|
|
account:account,
|
|
|
|
|
password:password
|
|
|
|
|
}
|
|
|
|
|
return axios.post(url, data)
|
|
|
|
|
.then(response => {
|
|
|
|
|
const user=ref(null);
|
|
|
|
|
const router=useRouter();
|
|
|
|
|
user.value=response.data;
|
|
|
|
|
if(user.value.account!=null) {
|
|
|
|
|
alert("登录成功");
|
|
|
|
|
if (user.value.account === "123" && user.value.password === "123") {
|
|
|
|
|
alert("进入管理员界面");
|
|
|
|
|
location.href="/userManagement";
|
|
|
|
|
} else {
|
|
|
|
|
alert("进入用户界面");
|
|
|
|
|
location.href="/tenantManagement";
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
alert("登录失败");
|
|
|
|
|
}
|
|
|
|
|
// 处理登录成功的逻辑
|
|
|
|
|
console.log(response.data);
|
|
|
|
|
return response.data;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
register(user){
|
|
|
|
|
const url='http://localhost:8080/checkRegister'
|
|
|
|
|
return axios.post(url, user)
|
|
|
|
|
.then(response=>{
|
|
|
|
|
return response.data;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|