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) { runInAction(() => { this.login = { userId: json.Result.WU_LMI_SN, username: json.Result.WU_UserName, } }); } 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 } }); } 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;