You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GHHub/src/stores/Auth.js

62 lines
1.7 KiB
JavaScript

import { makeAutoObservable, runInAction } from "mobx";
import { fetchJSON } from '@/utils/request';
import { HT_HOST } from "@/config";
import { prepareUrl } from '@/utils/commons';
class Auth {
constructor(root) {
makeAutoObservable(this, { rootStore: false });
this.root = root;
}
valdateUserPassword(usr, pwd) {
const fetchUrl = prepareUrl(HT_HOST + '/service-Cooperate/Cooperate/Login')
.append('username', usr)
.append('password', pwd)
.build();
return fetchJSON(fetchUrl)
.then(json => {
if (json.errcode == 0) {
return json.Result.WU_LMI_SN;
} else {
throw new Error(json.errmsg + ': ' + json.errcode);
}
});
}
fetchUserDetail(userId) {
const fetchUrl = prepareUrl(HT_HOST + '/service-Cooperate/Cooperate/GetLinkManInfo')
.append('LMI_SN', userId)
.build();
return fetchJSON(fetchUrl)
.then(json => {
if (json.errcode == 0) {
runInAction(() => {
this.login = {
userId: json.Result.LMI_SN,
username: json.Result.LoginName,
travelAgencyId: json.Result.LMI_VEI_SN,
travelAgencyName: json.Result.VName,
cityId: json.Result.citysn
}
});
return json.Result.LoginName;
} else {
throw new Error(json.errmsg + ': ' + json.errcode);
}
});
}
login = {
userId: 1,
username: 'Vu Xuan Giang',
travelAgencyId: 32531, //30008供应商id对应HT的VEI_SN
travelAgencyName: 'ANP',
cityId: 0
}
}
export default Auth;