102 lines
2.6 KiB
TypeScript
102 lines
2.6 KiB
TypeScript
import { Component, ReactNode } from 'react';
|
|
import { AtForm, AtInput, AtButton, AtMessage } from 'taro-ui';
|
|
import { View } from '@tarojs/components';
|
|
import Taro from '@tarojs/taro';
|
|
import pt from '@/plain-text';
|
|
import { updateUserInfo } from '@/service/userData';
|
|
import wechatUser from '@/wechat';
|
|
import './inform.scss';
|
|
|
|
const submitInterval = 5000;
|
|
|
|
export default class InformPage extends Component {
|
|
state = {
|
|
phone: wechatUser.getInfo().phone,
|
|
name: wechatUser.getInfo().name,
|
|
isLoading: false,
|
|
isDisable: false,
|
|
};
|
|
|
|
componentDidMount(): void {
|
|
Taro.setNavigationBarTitle({
|
|
title: pt.get().navBar.user.inform,
|
|
});
|
|
}
|
|
|
|
handleChangePhone(phone: string) {
|
|
this.setState({
|
|
phone: phone,
|
|
});
|
|
return phone;
|
|
}
|
|
handleChangeName(name: string) {
|
|
this.setState({
|
|
name: name,
|
|
});
|
|
return name;
|
|
}
|
|
onSubmit() {
|
|
this.setState({
|
|
isDisable: true,
|
|
});
|
|
if (this.state.name == '' || this.state.phone == '') {
|
|
Taro.atMessage({
|
|
message: pt.get().button.submitText.blank,
|
|
type: 'error',
|
|
});
|
|
setTimeout(() => {
|
|
this.setState({
|
|
isDisable: false,
|
|
});
|
|
}, submitInterval);
|
|
return;
|
|
}
|
|
updateUserInfo(this);
|
|
setTimeout(() => {
|
|
this.setState({
|
|
isDisable: false,
|
|
});
|
|
}, submitInterval);
|
|
}
|
|
|
|
render(): ReactNode {
|
|
return (
|
|
<View style={{ marginTop: '30rpx', width: '94%', marginLeft: '3%' }}>
|
|
<AtForm onSubmit={this.onSubmit.bind(this)}>
|
|
<AtMessage />
|
|
<AtInput
|
|
clear
|
|
required
|
|
name='phone'
|
|
title={pt.get().informPage.phoneText.title}
|
|
type='number'
|
|
placeholder={pt.get().informPage.phoneText.placeholder}
|
|
value={this.state.phone}
|
|
onChange={this.handleChangePhone.bind(this)}
|
|
/>
|
|
<AtInput
|
|
required
|
|
clear
|
|
name='name'
|
|
title={pt.get().informPage.nameText.title}
|
|
type='text'
|
|
placeholder={pt.get().informPage.nameText.placeholder}
|
|
value={this.state.name}
|
|
onChange={this.handleChangeName.bind(this)}
|
|
/>
|
|
<View style={{ marginTop: '30rpx' }}>
|
|
<AtButton
|
|
loading={this.state.isLoading}
|
|
formType='submit'
|
|
type='primary'
|
|
disabled={this.state.isDisable}
|
|
>
|
|
{pt.get().button.buttonText.submit}
|
|
</AtButton>
|
|
</View>
|
|
</AtForm>
|
|
</View>
|
|
);
|
|
}
|
|
}
|