2024-06-24 11:19:51 +00:00
|
|
|
import axios from "axios";
|
2024-06-24 09:15:21 +00:00
|
|
|
|
2024-06-24 11:19:51 +00:00
|
|
|
export default {
|
|
|
|
|
login(username, password, apiUrl="http://localhost:8080"){
|
2024-06-25 06:54:39 +00:00
|
|
|
const url = `${apiUrl}/users/checkLogin`
|
|
|
|
|
const data = {
|
|
|
|
|
username: username,
|
|
|
|
|
password: password
|
|
|
|
|
};
|
|
|
|
|
return axios.post(url, data)
|
2024-06-24 11:19:51 +00:00
|
|
|
.then(response => {
|
2024-06-25 06:54:39 +00:00
|
|
|
alert(">login方法中<");
|
2024-06-25 08:22:01 +00:00
|
|
|
alert(response.data.username);
|
2024-06-24 11:19:51 +00:00
|
|
|
return response.data;
|
|
|
|
|
});
|
2024-06-25 06:54:39 +00:00
|
|
|
},
|
2024-06-25 08:22:01 +00:00
|
|
|
register(user){
|
|
|
|
|
const url = `${apiUrl}/users/checkLogin`
|
|
|
|
|
const data = {
|
|
|
|
|
username: username,
|
|
|
|
|
password: password
|
|
|
|
|
};
|
|
|
|
|
return axios.post(url, data)
|
|
|
|
|
.then(response => {
|
|
|
|
|
alert(">login方法中<");
|
|
|
|
|
alert(response.data.username);
|
|
|
|
|
return response.data;
|
|
|
|
|
});
|
2024-06-25 06:54:39 +00:00
|
|
|
//跳转逻辑
|
2024-06-24 11:19:51 +00:00
|
|
|
}
|
|
|
|
|
}
|