|
@@ -9,14 +9,14 @@ function checkLogin() {
|
|
const password = prompt('请输入密码');
|
|
const password = prompt('请输入密码');
|
|
// 发送登录请求
|
|
// 发送登录请求
|
|
const xhr = new XMLHttpRequest();
|
|
const xhr = new XMLHttpRequest();
|
|
- xhr.open('POST', 'https://api.tianyunperfect.cn/user/login', false);
|
|
|
|
|
|
+ xhr.open('POST', 'https://php.tianyunperfect.cn/controller/user.php?action=login', false);
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
xhr.send(JSON.stringify({
|
|
xhr.send(JSON.stringify({
|
|
username,
|
|
username,
|
|
password
|
|
password
|
|
}));
|
|
}));
|
|
const response = JSON.parse(xhr.responseText);
|
|
const response = JSON.parse(xhr.responseText);
|
|
- if (response.code === 1) {
|
|
|
|
|
|
+ if (response.code === 200) {
|
|
// 登录成功,设置 loginId 的 cookie,并放行
|
|
// 登录成功,设置 loginId 的 cookie,并放行
|
|
setCookie('loginId', response.data.token, 30);
|
|
setCookie('loginId', response.data.token, 30);
|
|
return true;
|
|
return true;
|