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 (