import { Dialog, Picker, Popup, Toast, Uploader, UploaderValueItem, hooks } from 'react-vant'; import './index.less' import React, { useRef, useState } from "react"; import downArrow from './../../assets/images/downArrow.png' import api from '~/api'; export const InviteBusiness: React.FC = (props: any) => { let imgList: UploaderValueItem[] = [] const [careerVisible, setCareerVisible] = useState(false) const [sexVisible, setSexVisible] = useState(false) const [projectVisible, setProjectVisible] = useState(false) const [businessForm, updateBusinessForm] = hooks.useSetState({ career: 0, careerName: '', sexName: '', document: '', name: '', phone: '', project: 0, projectName: '', reason: '', sex: 0, wechar: '' }) const submitBusinessForm = () => { if (!businessForm.name) { Toast({ type: 'fail', message: "请填写名字" }) return } if (!businessForm.sex) { Toast({ type: 'fail', message: "请填写性别" }) return } if (!businessForm.career) { Toast({ type: 'fail', message: "请填写职业" }) return } if (imgList.length == 0) { console.log(imgList) Toast({ type: 'fail', message: "请上传图片" }) return } if (!/^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/.test(businessForm.phone)) { Toast({ type: 'fail', message: "请填写正确电话号码" }) return } if (!businessForm.wechar) { Toast({ type: 'fail', message: "请填写微信号" }) return } if (!businessForm.project) { Toast({ type: 'fail', message: "请填写代理项目" }) return } if (!businessForm.reason) { Toast({ type: 'fail', message: "请填写缘由" }) return } Dialog.confirm({ title: '提交', message: '是否提交你的表单', }).then(async () => { if (imgList.length > 0) { let data1 = new FormData() data1.append('coverFiles', imgList[0].file as File) data1.append('businessType', '招商文件') let res1 try { res1 = await api.openApiFileInfoFileUp(data1) } catch (e) { Toast('图片上传失败') } api.openApiAentInfo({ ...businessForm, document: res1?.data.data }).then(res => { if (res.data.code == 200) { Toast.success({ message: '上传成功' }) } }) } }) } return (
姓名
updateBusinessForm({ name: val.target.value })} placeholder="请填写姓名" type="text" />
setSexVisible(true)} className="field">
性别
setCareerVisible(true)} className="field">
职业
{ imgList = v, console.log(imgList) } } />
请上传身份证或驾照或营业执照等 身份证明
手机
updateBusinessForm({ phone: val.target.value })} value={businessForm.phone} placeholder="请填写手机" type="text" />
微信
updateBusinessForm({ wechar: val.target.value })} value={businessForm.wechar} placeholder="请填写微信号" type="text" />
{ setProjectVisible(true) }} className="field">
代理项目
submitBusinessForm()} className='button1'>提交
setProjectVisible(false)}> setProjectVisible(false)} onConfirm={(val: string, item: string, index: number | undefined) => { setProjectVisible(false) updateBusinessForm({ project: index === undefined ? 0 : (index + 1), projectName: val }) return val }} columns={[ '软件代理', '书籍代理', '软件+书籍', '软件开发' ]} /> setCareerVisible(false)}> setCareerVisible(false)} onConfirm={(val: string, item: string, index: number | undefined) => { setCareerVisible(false) updateBusinessForm({ career: index === undefined ? 0 : (index + 1), careerName: val }) return val }} columns={[ '教练', '驾校', '自媒体', '相关从业者' ]} /> setSexVisible(false)}> setSexVisible(false)} onConfirm={(val: string, item: string, index: number | undefined) => { setSexVisible(false) updateBusinessForm({ sex: index === undefined ? 0 : (index + 1), sexName: val }) return val }} columns={[ '男', '女' ]} />
) }