react表单提交
程序员文章站
2022-05-29 12:08:14
...
<input
className='design_scheme_ipt'
type='number'
placeholder='请输入您的手机号'
onChange={this.inputChange.bind(this)}
value={tel}
/>
inputChange(e) {
this.setState({
tel: e.target.value
})
}
<div
className='design_scheme_btn'
onClick={this.designerSaveInfo.bind(this)}
>
获取设计方案
</div>
designerSaveInfo() {
let source = '获取设计方案'
let sourceUrl = 'page/Styles_result'
let {tel} = this.state
if (tel === '') {
Toast.info('手机号码为空~', 1)
}else if(/^1(3|4|5|6|7|8|9)\d{9}$/.test(tel)){
this.post(
`${this.api.getCustomerCollect}?phone=${tel}&source=${source}&sourceUrl=${sourceUrl}`,
''
).then((res) => {
if (res.code === 0) {
this.setState({
visible: false,
tel:''
})
Toast.success('已提交信息', 1)
}
})
}else{
Toast.fail('手机号码格式不正确~')
}
}
记录一下~