登陆成功跳转到团计划

release
Jimmy Liow 2 years ago
parent b9938d2c19
commit 044c5c3b8a

@ -19,12 +19,7 @@ class Auth {
return fetchJSON(fetchUrl) return fetchJSON(fetchUrl)
.then(json => { .then(json => {
if (json.errcode == 0) { if (json.errcode == 0) {
runInAction(() => { return json.Result.WU_LMI_SN;
this.login = {
userId: json.Result.WU_LMI_SN,
username: json.Result.WU_UserName,
}
});
} else { } else {
throw new Error(json.errmsg + ': ' + json.errcode); throw new Error(json.errmsg + ': ' + json.errcode);
} }
@ -48,6 +43,7 @@ class Auth {
cityId: json.Result.citysn cityId: json.Result.citysn
} }
}); });
return json.Result.LoginName;
} else { } else {
throw new Error(json.errmsg + ': ' + json.errcode); throw new Error(json.errmsg + ': ' + json.errcode);
} }

@ -1,14 +1,38 @@
import { useNavigate } from "react-router-dom";
import { Button, Checkbox, Form, Input, Row, App } from 'antd'; import { Button, Checkbox, Form, Input, Row, App } from 'antd';
import { useStore } from '@/stores/StoreContext.js'; import { useStore } from '@/stores/StoreContext.js';
function Login() { function Login() {
const { authStore } = useStore(); const { authStore } = useStore();
const navigate = useNavigate();
const { notification } = App.useApp(); const { notification } = App.useApp();
const onFinish = (values) => { const onFinish = (values) => {
console.log('Success:', values); authStore.valdateUserPassword(values.username, values.password)
authStore.valdateUserPassword(values.username, values.password); .then((userId) => {
authStore.fetchUserDetail(userId)
.then((user) => {
// navigate(-1) is equivalent to hitting the back button.
navigate("/reservation/newest");
})
.catch(ex => {
notification.error({
message: `Notification`,
description: ex.message,
placement: 'top',
duration: 4,
});
});
})
.catch(ex => {
notification.error({
message: `Notification`,
description: ex.message,
placement: 'top',
duration: 4,
});
});
}; };
const onFinishFailed = (errorInfo) => { const onFinishFailed = (errorInfo) => {
@ -47,7 +71,6 @@ function Login() {
> >
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="Password" label="Password"
name="password" name="password"
@ -60,7 +83,6 @@ function Login() {
> >
<Input.Password /> <Input.Password />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
name="remember" name="remember"
valuePropName="checked" valuePropName="checked"
@ -71,7 +93,6 @@ function Login() {
> >
<Checkbox>Remember me</Checkbox> <Checkbox>Remember me</Checkbox>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
wrapperCol={{ wrapperCol={{
offset: 8, offset: 8,

Loading…
Cancel
Save