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

View File

@ -1,9 +1,103 @@
import { Component, ReactNode } from 'react'; import { Component, ReactNode } from 'react';
import { View } from '@tarojs/components'; import { AtForm, AtInput, AtButton, AtMessage } from 'taro-ui';
import './about.scss'; 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 { 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()], }[pt.getCurLang()],
clicks: memberClickTimes, clicks: memberClickTimes,
isToastOpen: false, isToastOpen: false,
toastText: toastText: '',
pt.get().userPage.memberEntry.front +
memberClickTimes.toString() +
pt.get().userPage.memberEntry.behind,
}; };
// 以下是TabBar相关 // 以下是TabBar相关

View File

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

View File

@ -20,7 +20,7 @@ export const informPageZhCn: InformPageText = {
}, },
}; };
export const informtPageEnUs: InformPageText = { export const informPageEnUs: InformPageText = {
phoneText: { phoneText: {
title: 'Phone', title: 'Phone',
placeholder: '便于查询工单', 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 { UserPageText, userPageZhCn, userPageEnUs } from './UserPage';
import { TabBarText, tabBarEnUs, tabBarZhCn } from './TabBar'; import { TabBarText, tabBarEnUs, tabBarZhCn } from './TabBar';
import { ReportPageText, reportPageEnUs, reportPageZhCn } from './ReportPage'; 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 { AboutPageText, aboutPageEnUs, aboutPageZhCn } from './AboutPage';
import { ButtonText, buttonEnUs, buttonZhCn } from './Button'; import { ButtonText, buttonEnUs, buttonZhCn } from './Button';
import { MemberPageText, memberPageEnUs, memberPageZhCn } from './MemberPage';
interface TextRecord { interface TextRecord {
pageFooter: PageFooterText; pageFooter: PageFooterText;
@ -16,6 +17,7 @@ interface TextRecord {
informPage: InformPageText; informPage: InformPageText;
aboutPage: AboutPageText; aboutPage: AboutPageText;
button: ButtonText; button: ButtonText;
memberPage: MemberPageText;
} }
const textZhCn: TextRecord = { const textZhCn: TextRecord = {
@ -27,6 +29,7 @@ const textZhCn: TextRecord = {
informPage: informPageZhCn, informPage: informPageZhCn,
aboutPage: aboutPageZhCn, aboutPage: aboutPageZhCn,
button: buttonZhCn, button: buttonZhCn,
memberPage: memberPageZhCn,
}; };
const textEnUs: TextRecord = { const textEnUs: TextRecord = {
@ -35,9 +38,10 @@ const textEnUs: TextRecord = {
userPage: userPageEnUs, userPage: userPageEnUs,
tabBar: tabBarEnUs, tabBar: tabBarEnUs,
reportPage: reportPageEnUs, reportPage: reportPageEnUs,
informPage: informtPageEnUs, informPage: informPageEnUs,
aboutPage: aboutPageEnUs, aboutPage: aboutPageEnUs,
button: buttonEnUs, button: buttonEnUs,
memberPage: memberPageEnUs,
}; };
// type Lang = 'zh_CN' | 'en_US' | ...; // type Lang = 'zh_CN' | 'en_US' | ...;