From 806e7a393c6e656ced0f2d248af3cfe6b30f8c10 Mon Sep 17 00:00:00 2001
From: Dawn_Ocean <1785590531@qq.com>
Date: Mon, 11 Mar 2024 13:52:09 +0800
Subject: [PATCH] add member login page
---
src/pages/user/inform/inform.tsx | 4 +-
src/pages/user/member/member.tsx | 102 +++++++++++++++++++++++++++++--
src/pages/user/user.tsx | 5 +-
src/plain-text/Button.ts | 15 +++++
src/plain-text/InformPage.ts | 2 +-
src/plain-text/MemberPage.ts | 32 ++++++++++
src/plain-text/index.ts | 8 ++-
7 files changed, 155 insertions(+), 13 deletions(-)
create mode 100644 src/plain-text/MemberPage.ts
diff --git a/src/pages/user/inform/inform.tsx b/src/pages/user/inform/inform.tsx
index a0bf0f6..5695072 100644
--- a/src/pages/user/inform/inform.tsx
+++ b/src/pages/user/inform/inform.tsx
@@ -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: '',
});
}
diff --git a/src/pages/user/member/member.tsx b/src/pages/user/member/member.tsx
index c9fb205..c728e8b 100644
--- a/src/pages/user/member/member.tsx
+++ b/src/pages/user/member/member.tsx
@@ -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 ;
+ return (
+
+
+
+
+
+ {pt.get().button.buttonText.login}
+
+
+ );
}
}
diff --git a/src/pages/user/user.tsx b/src/pages/user/user.tsx
index c9bd882..9a6de84 100644
--- a/src/pages/user/user.tsx
+++ b/src/pages/user/user.tsx
@@ -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相关
diff --git a/src/plain-text/Button.ts b/src/plain-text/Button.ts
index e01592d..3b770db 100644
--- a/src/plain-text/Button.ts
+++ b/src/plain-text/Button.ts
@@ -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: '登录失败',
+ },
};
diff --git a/src/plain-text/InformPage.ts b/src/plain-text/InformPage.ts
index b2f5f9e..1a39a95 100644
--- a/src/plain-text/InformPage.ts
+++ b/src/plain-text/InformPage.ts
@@ -20,7 +20,7 @@ export const informPageZhCn: InformPageText = {
},
};
-export const informtPageEnUs: InformPageText = {
+export const informPageEnUs: InformPageText = {
phoneText: {
title: 'Phone',
placeholder: '便于查询工单',
diff --git a/src/plain-text/MemberPage.ts b/src/plain-text/MemberPage.ts
new file mode 100644
index 0000000..6eafa25
--- /dev/null
+++ b/src/plain-text/MemberPage.ts
@@ -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 统一身份认证一致',
+ },
+};
diff --git a/src/plain-text/index.ts b/src/plain-text/index.ts
index 1134154..8706ec7 100644
--- a/src/plain-text/index.ts
+++ b/src/plain-text/index.ts
@@ -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' | ...;