修改计划列表和增加刷新后读取用户信息

release
Jimmy Liow 2 years ago
parent 962de1e246
commit ec27fb6732

@ -1,7 +1,7 @@
import { makeAutoObservable, runInAction } from "mobx"; import { makeAutoObservable, runInAction } from "mobx";
import { fetchJSON, postForm } from '@/utils/request'; import { fetchJSON, postForm } from '@/utils/request';
import { HT_HOST } from "@/config"; import { HT_HOST } from "@/config";
import { prepareUrl } from '@/utils/commons'; import { isNotEmpty, prepareUrl } from '@/utils/commons';
const KEY_LOGIN_TOKEN = 'KEY_LOGIN_TOKEN'; const KEY_LOGIN_TOKEN = 'KEY_LOGIN_TOKEN';
@ -11,6 +11,9 @@ class Auth {
makeAutoObservable(this, { rootStore: false }); makeAutoObservable(this, { rootStore: false });
this.root = root; this.root = root;
this.login.token = root.getSession(KEY_LOGIN_TOKEN); this.login.token = root.getSession(KEY_LOGIN_TOKEN);
if (isNotEmpty(this.login.token)) {
this.fetchUserDetail();
}
setInterval(() => { setInterval(() => {
// console.info('Auth.check.token.'); // console.info('Auth.check.token.');
}, 10000); }, 10000);
@ -34,7 +37,7 @@ class Auth {
}); });
} }
fetchUserDetail(userId) { fetchUserDetail() {
const fetchUrl = prepareUrl(HT_HOST + '/service-CooperateSOA/GetLinkManInfo') const fetchUrl = prepareUrl(HT_HOST + '/service-CooperateSOA/GetLinkManInfo')
.append('token', this.login.token) .append('token', this.login.token)
.build(); .build();

@ -14,7 +14,7 @@ function Login() {
authStore.valdateUserPassword(values.username, values.password) authStore.valdateUserPassword(values.username, values.password)
.then((userId) => { .then((userId) => {
noticeStore.getBulletinUnReadCount(userId); noticeStore.getBulletinUnReadCount(userId);
authStore.fetchUserDetail(userId) authStore.fetchUserDetail()
.then((user) => { .then((user) => {
// navigate(-1) is equivalent to hitting the back button. // navigate(-1) is equivalent to hitting the back button.
navigate("/reservation/newest"); navigate("/reservation/newest");

@ -49,14 +49,14 @@ function Newest() {
if (reservation.guide === '') { if (reservation.guide === '') {
return ( return (
<Space size="middle"> <Space size="middle">
<Button type="link" onClick={() => showCityGuideModal(reservation)}>Fill in</Button> <Button type="link" onClick={() => showCityGuideModal(reservation)}>Add</Button>
</Space> </Space>
); );
} else { } else {
return ( return (
<Space size="middle"> <Space size="middle">
<span>{reservation.guide}</span> <span>{reservation.guide}</span>
<Button type="link" onClick={() => showCityGuideModal(reservation)}>Modify</Button> <Button type="link" onClick={() => showCityGuideModal(reservation)}>Edit</Button>
</Space> </Space>
); );
} }
@ -107,7 +107,7 @@ function Newest() {
onSearchClick(1, 1); onSearchClick(1, 1);
} }
return () => { return () => {
console.info('unmount...'); // unmount...
}; };
}, []); }, []);

Loading…
Cancel
Save