add member login page

yhy
Dawn_Ocean 2024-03-11 13:52:09 +08:00
parent fd6a60d1d3
commit 806e7a393c
7 changed files with 155 additions and 13 deletions

View File

@ -22,7 +22,7 @@ export default class InformPage extends Component {
}
handleChangeName(name: string) {
this.setState({
name: name,
passwd: name,
});
return name;
}
@ -68,7 +68,7 @@ export default class InformPage extends Component {
onReset() {
this.setState({
phone: '',
name: '',
passwd: '',
});
}

View File

@ -1,9 +1,103 @@
import { Component, ReactNode } from 'react';
import { View } from '@tarojs/components';
import './about.scss';
import { AtForm, AtInput, AtButton, AtMessage } from 'taro-ui';
import { getUrl } from '@/service';
import Taro from '@tarojs/taro';
import pt from '@/plain-text';
import './member.scss';
const loginInterval = 5000;
export default class MemberPage extends Component {
state = {
stuid: '',
passwd: '',
isLoading: false,
isDisable: false,
};
handleChangeStuid(stuid: string) {
this.setState({
stuid: stuid,
});
return stuid;
}
handleChangePasswd(passwd: string) {
this.setState({
passwd: passwd,
});
return passwd;
}
onSubmit() {
this.setState({
isLoading: true,
isDisable: true,
});
console.log([this.state.stuid, this.state.passwd]);
Taro.request({
url: getUrl('/user/update'),
method: 'POST',
data: {
token: 'token_test',
name: this.state.stuid,
passwd: this.state.passwd,
},
})
.then(res => {
console.log(res.data);
Taro.atMessage({
message: pt.get().button.loginText.success,
type: 'success',
});
})
.catch(err => {
console.log(err);
Taro.atMessage({
message: pt.get().button.loginText.error + err.toString(),
type: 'error',
});
});
this.setState({
isLoading: false,
});
setTimeout(() => {
this.setState({
isDisable: false,
});
}, loginInterval);
}
export default class SettingsPage extends Component {
render(): ReactNode {
return <View></View>;
return (
<AtForm onSubmit={this.onSubmit.bind(this)}>
<AtMessage />
<AtInput
required
name='stuid'
title={pt.get().memberPage.stuidText.title}
type='text'
clear
placeholder={pt.get().memberPage.stuidText.placeholder}
value={this.state.stuid}
onChange={this.handleChangeStuid.bind(this)}
/>
<AtInput
clear
required
name='name'
title={pt.get().memberPage.passwdText.title}
type='password'
placeholder={pt.get().memberPage.passwdText.placeholder}
value={this.state.passwd}
onChange={this.handleChangePasswd.bind(this)}
/>
<AtButton
loading={this.state.isLoading}
formType='submit'
type='primary'
disabled={this.state.isDisable}
>
{pt.get().button.buttonText.login}
</AtButton>
</AtForm>
);
}
}

View File

@ -22,10 +22,7 @@ export default class UserPage extends Component {
}[pt.getCurLang()],
clicks: memberClickTimes,
isToastOpen: false,
toastText:
pt.get().userPage.memberEntry.front +
memberClickTimes.toString() +
pt.get().userPage.memberEntry.behind,
toastText: '',
};
// 以下是TabBar相关

View File

@ -2,31 +2,46 @@ export interface ButtonText {
buttonText: {
submit: string;
reset: string;
login: string;
};
submitText: {
success: string;
error: string;
};
loginText: {
success: string;
error: string;
};
}
export const buttonZhCn: ButtonText = {
buttonText: {
submit: '提交',
reset: '清空',
login: '登录',
},
submitText: {
success: '提交成功',
error: '提交失败:',
},
loginText: {
success: '登录成功',
error: '登录失败',
},
};
export const buttonEnUs: ButtonText = {
buttonText: {
submit: 'Submit',
reset: 'Reset',
login: 'Login',
},
submitText: {
success: 'Success',
error: 'Error: ',
},
loginText: {
success: '登录成功',
error: '登录失败',
},
};

View File

@ -20,7 +20,7 @@ export const informPageZhCn: InformPageText = {
},
};
export const informtPageEnUs: InformPageText = {
export const informPageEnUs: InformPageText = {
phoneText: {
title: 'Phone',
placeholder: '便于查询工单',

View File

@ -0,0 +1,32 @@
export interface MemberPageText {
stuidText: {
title: string;
placeholder: string;
};
passwdText: {
title: string;
placeholder: string;
};
}
export const memberPageZhCn: MemberPageText = {
stuidText: {
title: '学号',
placeholder: '与统一身份认证学号一致',
},
passwdText: {
title: '密码',
placeholder: '与 EVA 统一身份认证一致',
},
};
export const memberPageEnUs: MemberPageText = {
stuidText: {
title: 'Student ID',
placeholder: '与统一身份认证学号一致',
},
passwdText: {
title: 'Password',
placeholder: '与 EVA 统一身份认证一致',
},
};

View File

@ -3,9 +3,10 @@ import { MainPageText, mainPageZhCn, mainPageEnUs } from './MainPage';
import { UserPageText, userPageZhCn, userPageEnUs } from './UserPage';
import { TabBarText, tabBarEnUs, tabBarZhCn } from './TabBar';
import { ReportPageText, reportPageEnUs, reportPageZhCn } from './ReportPage';
import { InformPageText, informPageZhCn, informtPageEnUs } from './InformPage';
import { InformPageText, informPageZhCn, informPageEnUs } from './InformPage';
import { AboutPageText, aboutPageEnUs, aboutPageZhCn } from './AboutPage';
import { ButtonText, buttonEnUs, buttonZhCn } from './Button';
import { MemberPageText, memberPageEnUs, memberPageZhCn } from './MemberPage';
interface TextRecord {
pageFooter: PageFooterText;
@ -16,6 +17,7 @@ interface TextRecord {
informPage: InformPageText;
aboutPage: AboutPageText;
button: ButtonText;
memberPage: MemberPageText;
}
const textZhCn: TextRecord = {
@ -27,6 +29,7 @@ const textZhCn: TextRecord = {
informPage: informPageZhCn,
aboutPage: aboutPageZhCn,
button: buttonZhCn,
memberPage: memberPageZhCn,
};
const textEnUs: TextRecord = {
@ -35,9 +38,10 @@ const textEnUs: TextRecord = {
userPage: userPageEnUs,
tabBar: tabBarEnUs,
reportPage: reportPageEnUs,
informPage: informtPageEnUs,
informPage: informPageEnUs,
aboutPage: aboutPageEnUs,
button: buttonEnUs,
memberPage: memberPageEnUs,
};
// type Lang = 'zh_CN' | 'en_US' | ...;