|
@@ -4,7 +4,7 @@ import {Injectable} from '@angular/core';
|
|
|
//得到用户列表
|
|
|
import * as Parse from "parse"
|
|
|
|
|
|
-(Parse as any).serverURL = "http://metapunk:9999/parse";
|
|
|
+(Parse as any).serverURL = "https://web2023.fmode.cn/parse";
|
|
|
// https://web2023.fmode.cn/s0210490/api/user/login
|
|
|
Parse.initialize("dev")
|
|
|
|
|
@@ -15,7 +15,7 @@ export class UserService {
|
|
|
|
|
|
get currentUser() {
|
|
|
try {
|
|
|
- let currentUser = JSON.parse(localStorage.getItem("USER_AUTH") || "error")
|
|
|
+ let currentUser = JSON.parse(localStorage.getItem("USER_AUTH") || "error");
|
|
|
return currentUser
|
|
|
} catch (err) {
|
|
|
|
|
@@ -79,7 +79,7 @@ export class UserService {
|
|
|
// console.log(user.password)
|
|
|
// return new Promise<boolean>(async (resolve, reject) => {
|
|
|
// // try {
|
|
|
- // // const url = 'http://web2023.fmode.cn:23000/s0210490/user/login/get'; // 替换为实际的接口 URL
|
|
|
+ // // const url = 'https://web2023.fmode.cn/s0210490/user/login/get'; // 替换为实际的接口 URL
|
|
|
// // const response = await this.http.post(url, user).toPromise();
|
|
|
// // return response as boolean;
|
|
|
// // } catch (error) {
|
|
@@ -115,7 +115,7 @@ export class UserService {
|
|
|
|
|
|
async checkUserByAccount(username: string, password: string) {
|
|
|
//region
|
|
|
- // const url = 'http://web2023.fmode.cn:23000/user/login';
|
|
|
+ // const url = 'https://web2023.fmode.cn/user/login';
|
|
|
// const url = 'https://web2023.fmode.cn/s0210490/api/user/login';
|
|
|
//
|
|
|
// // const url = 'http://localhost:23000/user/login';
|
|
@@ -151,8 +151,7 @@ export class UserService {
|
|
|
// });
|
|
|
// })
|
|
|
//endregion
|
|
|
- let isLogin = await this.login_user(username, password);
|
|
|
- console.log(isLogin)
|
|
|
+ let isLogin: any = await this.login_user(username, password);
|
|
|
if (isLogin) {
|
|
|
return true;
|
|
|
} else {
|
|
@@ -161,19 +160,48 @@ export class UserService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
async login_user(username: string, password: string) {
|
|
|
// if (!username) {
|
|
|
// throw "账户不存在"
|
|
|
// }
|
|
|
try {
|
|
|
console.log(username, password)
|
|
|
- let user = await Parse.User.logIn(username, password);
|
|
|
- console.log(user)
|
|
|
- return true;
|
|
|
+ let user: any = await Parse.User.logIn(username, password);
|
|
|
+ const userQuery = new Parse.Query("LjUser");
|
|
|
+ userQuery.equalTo("account", username);
|
|
|
+ let list = await userQuery.first();
|
|
|
+ // console.log(list)
|
|
|
+ // console.log(JSON.stringify(list))
|
|
|
+ // console.log(JSON.parse(JSON.stringify(list)))
|
|
|
+ localStorage.setItem("USER_AUTH", JSON.stringify(list));
|
|
|
+ if (user?.id) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ //region
|
|
|
+ // localStorage.setItem("USER_AUTH", JSON.stringify(user_info.first()));
|
|
|
+
|
|
|
+ // localStorage.setItem("USER_AUTH", JSON.stringify(Parse.User.current()));
|
|
|
+ // user_info.first().then(function (result: Parse.Object<Parse.Attributes> | undefined) {
|
|
|
+ // console.log(result)
|
|
|
+ // localStorage.setItem("USER_AUTH", JSON.stringify(result));
|
|
|
+ // }).catch(function (error) {
|
|
|
+ // console.log(error)
|
|
|
+ // });
|
|
|
+
|
|
|
+ // query.include("account");
|
|
|
+ // // query.include("password")
|
|
|
+ // query.include("isFirstRegister")
|
|
|
+ // query.include("availableBalance")
|
|
|
+ // query.include("gender")
|
|
|
+ // if (user?.id) {
|
|
|
+ // }
|
|
|
+ //endregion
|
|
|
} catch (e) {
|
|
|
console.error(e)
|
|
|
throw e;
|
|
|
}
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
|