add inform page request
parent
b174304d74
commit
dd770b8ece
|
|
@ -1,9 +1,12 @@
|
|||
import { Component, ReactNode } from 'react';
|
||||
import { AtForm, AtInput, AtButton, AtMessage } from 'taro-ui';
|
||||
import { getUrl } from '@/service';
|
||||
import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import './inform.scss';
|
||||
|
||||
const submitInterval = 5000;
|
||||
|
||||
export default class InformPage extends Component {
|
||||
state = {
|
||||
phone: '',
|
||||
|
|
@ -29,19 +32,39 @@ export default class InformPage extends Component {
|
|||
isDisable: true,
|
||||
});
|
||||
console.log(this.state.name, this.state.phone);
|
||||
Taro.request({
|
||||
url: getUrl('/user/update'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
name: this.state.name,
|
||||
phone: this.state.phone,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
console.log(res.data);
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.success,
|
||||
type: 'success',
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.error + err.toString(),
|
||||
type: 'error',
|
||||
});
|
||||
});
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
Taro.atMessage({
|
||||
message: pt.get().informPage.submitText.success,
|
||||
type: 'success',
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, 5000);
|
||||
}, submitInterval);
|
||||
}
|
||||
|
||||
onReset() {
|
||||
this.setState({
|
||||
phone: '',
|
||||
|
|
@ -79,10 +102,10 @@ export default class InformPage extends Component {
|
|||
type='primary'
|
||||
disabled={this.state.isDisable}
|
||||
>
|
||||
{pt.get().informPage.buttonText.submit}
|
||||
{pt.get().button.buttonText.submit}
|
||||
</AtButton>
|
||||
<AtButton formType='reset' type='secondary'>
|
||||
{pt.get().informPage.buttonText.reset}
|
||||
{pt.get().button.buttonText.reset}
|
||||
</AtButton>
|
||||
</AtForm>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -35,14 +35,14 @@ export default class SettingsPage extends Component {
|
|||
.then(res => {
|
||||
console.log(res.data);
|
||||
Taro.atMessage({
|
||||
message: '提交成功',
|
||||
message: pt.get().button.submitText.success,
|
||||
type: 'success',
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
Taro.atMessage({
|
||||
message: '提交失败,错误为:' + err.toString(),
|
||||
message: pt.get().button.submitText.error + err.toString(),
|
||||
type: 'error',
|
||||
});
|
||||
});
|
||||
|
|
@ -79,10 +79,10 @@ export default class SettingsPage extends Component {
|
|||
type='primary'
|
||||
disabled={this.state.isDisable}
|
||||
>
|
||||
{pt.get().reportPage.buttonText.submit}
|
||||
{pt.get().button.buttonText.submit}
|
||||
</AtButton>
|
||||
<AtButton formType='reset' type='secondary'>
|
||||
{pt.get().reportPage.buttonText.reset}
|
||||
{pt.get().button.buttonText.reset}
|
||||
</AtButton>
|
||||
</AtForm>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import pt, { Lang } from '@/plain-text';
|
|||
import logo from '@/assets/images/UserPage/logo.png';
|
||||
import './user.scss';
|
||||
|
||||
const listLangInterval = 20;
|
||||
|
||||
export default class UserPage extends Component {
|
||||
state = {
|
||||
selector: ['简体中文', 'English'],
|
||||
|
|
@ -123,7 +125,7 @@ export default class UserPage extends Component {
|
|||
thumb={aboutIcon}
|
||||
onClick={this.aboutPage}
|
||||
/>
|
||||
<View style={{ height: 20 }}></View>
|
||||
<View style={{ height: listLangInterval }}></View>
|
||||
<Picker
|
||||
mode='selector'
|
||||
range={this.state.selector}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
export interface ButtonText {
|
||||
buttonText: {
|
||||
submit: string;
|
||||
reset: string;
|
||||
};
|
||||
submitText: {
|
||||
success: string;
|
||||
error: string;
|
||||
};
|
||||
}
|
||||
|
||||
export const buttonZhCn: ButtonText = {
|
||||
buttonText: {
|
||||
submit: '提交',
|
||||
reset: '清空',
|
||||
},
|
||||
submitText: {
|
||||
success: '提交成功',
|
||||
error: '提交失败:',
|
||||
},
|
||||
};
|
||||
|
||||
export const buttonEnUs: ButtonText = {
|
||||
buttonText: {
|
||||
submit: 'Submit',
|
||||
reset: 'Reset',
|
||||
},
|
||||
submitText: {
|
||||
success: 'Success',
|
||||
error: 'Error: ',
|
||||
},
|
||||
};
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
export interface InformPageText {
|
||||
submitText: {
|
||||
success: string;
|
||||
};
|
||||
phoneText: {
|
||||
title: string;
|
||||
placeholder: string;
|
||||
|
|
@ -10,16 +7,9 @@ export interface InformPageText {
|
|||
title: string;
|
||||
placeholder: string;
|
||||
};
|
||||
buttonText: {
|
||||
submit: string;
|
||||
reset: string;
|
||||
};
|
||||
}
|
||||
|
||||
export const informPageZhCn: InformPageText = {
|
||||
submitText: {
|
||||
success: '提交成功',
|
||||
},
|
||||
phoneText: {
|
||||
title: '手机号码',
|
||||
placeholder: '便于查询工单',
|
||||
|
|
@ -28,16 +18,9 @@ export const informPageZhCn: InformPageText = {
|
|||
title: '真实姓名',
|
||||
placeholder: '必填,与工单绑定',
|
||||
},
|
||||
buttonText: {
|
||||
submit: '提交',
|
||||
reset: '清空',
|
||||
},
|
||||
};
|
||||
|
||||
export const informtPageEnUs: InformPageText = {
|
||||
submitText: {
|
||||
success: 'Success',
|
||||
},
|
||||
phoneText: {
|
||||
title: 'Phone',
|
||||
placeholder: '便于查询工单',
|
||||
|
|
@ -46,8 +29,4 @@ export const informtPageEnUs: InformPageText = {
|
|||
title: 'Real Name',
|
||||
placeholder: '必填,与工单绑定',
|
||||
},
|
||||
buttonText: {
|
||||
submit: 'Submit',
|
||||
reset: 'Reset',
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,25 +1,13 @@
|
|||
export interface ReportPageText {
|
||||
placeHolderText: string;
|
||||
buttonText: {
|
||||
submit: string;
|
||||
reset: string;
|
||||
};
|
||||
}
|
||||
|
||||
export const reportPageZhCn: ReportPageText = {
|
||||
placeHolderText:
|
||||
'无论是有关于小程序的建议,还是关于E志者协会的建议,都可以提出来哦!',
|
||||
buttonText: {
|
||||
submit: '提交',
|
||||
reset: '清空',
|
||||
},
|
||||
};
|
||||
|
||||
export const reportPageEnUs: ReportPageText = {
|
||||
placeHolderText:
|
||||
'无论是有关于小程序的建议,还是关于E志者协会的建议,都可以提出来哦!',
|
||||
buttonText: {
|
||||
submit: 'Submit',
|
||||
reset: 'Reset',
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { TabBarText, tabBarEnUs, tabBarZhCn } from './TabBar';
|
|||
import { ReportPageText, reportPageEnUs, reportPageZhCn } from './ReportPage';
|
||||
import { InformPageText, informPageZhCn, informtPageEnUs } from './InformPage';
|
||||
import { AboutPageText, aboutPageEnUs, aboutPageZhCn } from './AboutPage';
|
||||
import { ButtonText, buttonEnUs, buttonZhCn } from './Button';
|
||||
|
||||
interface TextRecord {
|
||||
pageFooter: PageFooterText;
|
||||
|
|
@ -14,6 +15,7 @@ interface TextRecord {
|
|||
reportPage: ReportPageText;
|
||||
informPage: InformPageText;
|
||||
aboutPage: AboutPageText;
|
||||
button: ButtonText;
|
||||
}
|
||||
|
||||
const textZhCn: TextRecord = {
|
||||
|
|
@ -24,6 +26,7 @@ const textZhCn: TextRecord = {
|
|||
reportPage: reportPageZhCn,
|
||||
informPage: informPageZhCn,
|
||||
aboutPage: aboutPageZhCn,
|
||||
button: buttonZhCn,
|
||||
};
|
||||
|
||||
const textEnUs: TextRecord = {
|
||||
|
|
@ -34,6 +37,7 @@ const textEnUs: TextRecord = {
|
|||
reportPage: reportPageEnUs,
|
||||
informPage: informtPageEnUs,
|
||||
aboutPage: aboutPageEnUs,
|
||||
button: buttonEnUs,
|
||||
};
|
||||
|
||||
// type Lang = 'zh_CN' | 'en_US' | ...;
|
||||
|
|
|
|||
Loading…
Reference in New Issue