Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
update login fetch userInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
marunrun committed Sep 4, 2022
1 parent 167ac37 commit 1e8a39f
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "showstart",
"version": "0.1.0"
"version": "2.0.0"
},
"tauri": {
"allowlist": {
Expand Down
3 changes: 2 additions & 1 deletion src/component/chooseUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {ApiParams} from "../network/apiParams";
export type UserInfoProps = {
onPerformerChange: (value: performerInfo[]) => void;
onAddressChange: (value: AddressInfo) => void;
isLogin : boolean
}


Expand Down Expand Up @@ -39,7 +40,7 @@ const ChooseUser: React.FC<UserInfoProps> = (props) => {
// 初始化
useEffect(() => {
fetchInfo()
}, [])
}, [props.isLogin])


// 观影人信息更新
Expand Down
108 changes: 56 additions & 52 deletions src/component/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import {ApiParams} from "../network/apiParams";
import {store} from "../constant/store";
import {LOGIN_PWD} from "../network/api/login";

class LoginForm extends React.Component<any, any> {

onFinish = (values: any) => {
export interface LoginProps {
afterLoginSuccess: () => void
}


const LoginForm: React.FC<LoginProps> = (props) => {

function onFinish(values: any) {

localStorage.setItem(store.mobile, values.mobile)
localStorage.setItem(store.password, values.password)
Expand All @@ -18,62 +23,61 @@ class LoginForm extends React.Component<any, any> {
apiParams.set("password", values.password)
post(LOGIN_PWD, apiParams, (res) => {
message.success("登录成功")
localStorage.setItem(store.userSign,res.sign)
localStorage.setItem(store.userId,res.userId)
localStorage.setItem(store.userSign, res.sign)
localStorage.setItem(store.userId, res.userId)
props.afterLoginSuccess()
})
};
}

render() {
return <>
<Form
size="small"
initialValues={{
mobile: localStorage.getItem(store.mobile),
password: localStorage.getItem(store.password)
}}
onFinish={onFinish}
autoComplete="off"
>
<Form.Item
label="账号"
name="mobile"
rules={[
{
required: true,
message: '请输入账号',
},
]}
>
<Input/>
</Form.Item>

return (
<Form
size="small"
initialValues={{
mobile: localStorage.getItem(store.mobile),
password: localStorage.getItem(store.password)
}}
onFinish={this.onFinish}
autoComplete="off"
<Form.Item
label="密码"
name="password"
rules={[
{
required: true,
message: '请输入密码',
},
]}
>
<Form.Item
label="账号"
name="mobile"
rules={[
{
required: true,
message: '请输入账号',
},
]}
>
<Input/>
</Form.Item>
<Input/>
</Form.Item>

<Form.Item
label="密码"
name="password"
rules={[
{
required: true,
message: '请输入密码',
},
]}
>
<Input/>
</Form.Item>
<Form.Item
wrapperCol={{
offset: 2,
span: 16,
}}
>
<Button type="primary" htmlType="submit">
登录
</Button>
</Form.Item>
</Form>
</>

<Form.Item
wrapperCol={{
offset: 2,
span: 16,
}}
>
<Button type="primary" htmlType="submit">
登录
</Button>
</Form.Item>
</Form>
);
}
}

export default LoginForm
6 changes: 4 additions & 2 deletions src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const Home: React.FC = () => {
const [address, setAddress] = React.useState<AddressInfo>();


const [isLogin , setIsLogin] = React.useState<boolean>(false);

// 捡漏
const [pickupEnable, setPickupEnable] = React.useState<boolean>(false);
const [pickupTimer, setPickupTimer] = React.useState<number>(0);
Expand Down Expand Up @@ -265,10 +267,10 @@ const Home: React.FC = () => {
<>
<ProCard gutter={8} title="用户信息">
<ProCard>
<LoginForm/>
<LoginForm afterLoginSuccess={() => { setIsLogin(true) }}/>
</ProCard>
<ProCard>
<ChooseUser onAddressChange={addressChange} onPerformerChange={performerChange}/>
<ChooseUser isLogin={isLogin} onAddressChange={addressChange} onPerformerChange={performerChange}/>
</ProCard>
</ProCard>
<ProCard style={{marginBlockStart: 8}} gutter={8} title="选择演出">
Expand Down

0 comments on commit 1e8a39f

Please sign in to comment.