index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <script lang="ts">
  2. import { MobileOutlined, MailOutlined, LockOutlined, PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue';
  3. export default defineComponent({
  4. name: 'register',
  5. components: {
  6. MobileOutlined,
  7. MailOutlined,
  8. LockOutlined,
  9. PlusOutlined,
  10. LoadingOutlined
  11. },
  12. })
  13. </script>
  14. <script setup lang='ts'>
  15. import { FormProps, message, UploadFile } from 'ant-design-vue';
  16. import type { UploadChangeParam, UploadProps } from 'ant-design-vue';
  17. import { defineComponent, onMounted, reactive, ref, UnwrapRef, watch } from 'vue'
  18. import { sendSms, verification, applyDevelop } from '@/api/index'
  19. import AMapLoader from '@amap/amap-jsapi-loader';
  20. import util from '@/util/index'
  21. import router from '@/router';
  22. const current = ref<number>(0);
  23. const steps = ref<Array<any>>([
  24. '账号信息', '资料提交', '完成注册',
  25. ])
  26. let verifyText = ref<string>('点击获取')
  27. let firstDisabled = ref<Boolean>(true)
  28. let submitDisabled = ref<Boolean>(true)
  29. let loading = ref<boolean>(false);
  30. let fileList = ref([]);
  31. let time = ref<number>(60)
  32. let timer = ref<number>()
  33. let canSendSms = ref<boolean>(true)
  34. let labelCol = ref<object>({ style: { width: '200px' } })
  35. let action = ref<string>('http://153.37.175.42:8070/app/common/upload')
  36. interface FormState {
  37. provinceName: string,
  38. cityName: string,
  39. cityCode: string,
  40. districtName: string,
  41. userAccount: string;
  42. password: string;
  43. passwordAgain: string;
  44. code?: number
  45. licenseType: number,
  46. merchantType: number,
  47. categoryId: number,
  48. address: string,
  49. street: string,
  50. merchantName: string,
  51. bizLicenseNo: string,
  52. bizLicense: string
  53. legalPerson: string,
  54. idcardType: number,
  55. idcardNo: string,
  56. idcardFront: string,
  57. idcardBack: string,
  58. bizLicenseIdcard: string,
  59. contactName: string,
  60. mobile: string
  61. }
  62. const formState: UnwrapRef<FormState> = reactive({
  63. provinceName: '',
  64. cityName: '',
  65. cityCode: '',
  66. districtName: '',
  67. userAccount: '',
  68. password: '',
  69. passwordAgain: '',
  70. licenseType: 3,
  71. merchantType: 2,
  72. categoryId: 2,
  73. address: '',
  74. street: '',
  75. merchantName: '',
  76. bizLicenseNo: '',
  77. bizLicense: '',
  78. legalPerson: '',
  79. idcardType: 1,
  80. idcardNo: '',
  81. idcardFront: '',
  82. idcardBack: '',
  83. bizLicenseIdcard: '',
  84. contactName: '',
  85. mobile: ''
  86. });
  87. window._AMapSecurityConfig = {
  88. securityJsCode: '23cf1bca0e52bbf8cb129047cdb46f10'
  89. }
  90. onMounted(() => {
  91. })
  92. watch(formState, (newValue) => {
  93. console.log('数据:', newValue);
  94. if (newValue.userAccount && newValue.password && newValue.passwordAgain && newValue.code) {
  95. firstDisabled.value = false
  96. if (newValue.address && newValue.street && newValue.merchantName && newValue.bizLicenseNo && newValue.bizLicense && newValue.legalPerson && newValue.idcardNo && newValue.idcardFront && newValue.idcardBack && newValue.bizLicenseIdcard && newValue.contactName && newValue.mobile) {
  97. submitDisabled.value = false
  98. } else {
  99. submitDisabled.value = true
  100. }
  101. } else {
  102. firstDisabled.value = true
  103. }
  104. }, { deep: true })
  105. const next = async () => {
  106. if (formState.password !== formState.passwordAgain) {
  107. return message.error('俩次输入的密码不一致,请修改为相同密码!')
  108. }
  109. let res: any = await verification({ mobile: formState.userAccount, code: formState.code })
  110. if (res.code !== 200) {
  111. return message.error(res.message)
  112. }
  113. if (!util.mobile(formState.userAccount)) {
  114. return message.error('请填写正确格式的注册手机号!')
  115. }
  116. current.value++;
  117. };
  118. const prev = () => {
  119. current.value--;
  120. };
  121. function getAddressInfo() {
  122. return new Promise((resolve, reject) => {
  123. AMapLoader.load({
  124. "key": "21132ea36aed6ab1884085a836f12ca9", // 申请好的Web端开发者Key,首次调用 load 时必填
  125. "version": "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
  126. "plugins": ['AMap.Geocoder'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
  127. }).then((AMap: { Geocoder: new () => any; }) => {
  128. let geocoder = new AMap.Geocoder()
  129. geocoder.getLocation(formState.address, function (status: string, result: { info: string; }) {
  130. console.log('result:', status, result);
  131. if (status === 'complete' && result.info === 'OK') {
  132. // result中对应详细地理坐标信息
  133. resolve(result)
  134. } else {
  135. return message.error('请正确填写企业地址的省市区')
  136. reject(result)
  137. }
  138. })
  139. })
  140. })
  141. }
  142. const submit = async () => {
  143. let result: any = await getAddressInfo()
  144. console.log('result:', result);
  145. let addressComponent = result?.geocodes[0]?.addressComponent
  146. if (result.info === 'OK' && addressComponent.province && addressComponent.city && addressComponent.district) {
  147. formState.provinceName = addressComponent.province
  148. formState.cityName = addressComponent.city
  149. formState.cityCode = addressComponent.citycode
  150. formState.districtName = addressComponent.district
  151. } else {
  152. message.error('请正确填写企业地址的省市区')
  153. }
  154. if (!util.mobile(formState.mobile)) {
  155. return message.error('请填写正确格式的联系电话!')
  156. }
  157. applyDevelop(formState).then((res: any) => {
  158. if (res.code === 0) {
  159. current.value++;
  160. } else {
  161. message.error(res.message)
  162. }
  163. })
  164. }
  165. const doSendSms = () => {
  166. if (!util.mobile(formState.userAccount)) {
  167. return message.error('请填写正确格式的注册手机号!')
  168. }
  169. sendSms({ mobile: formState.userAccount, type: 1 }).then((res: any) => {
  170. console.log(res);
  171. if (res.code === 200) {
  172. message.success('发送成功,请查收短信验证码!')
  173. timer.value = setInterval(() => {
  174. canSendSms.value = false
  175. time.value--
  176. verifyText.value = `重新获取 (${time.value})`
  177. if (!time.value) {
  178. verifyText.value = `重新获取`
  179. canSendSms.value = true
  180. clearInterval(timer.value)
  181. time.value = 60
  182. }
  183. }, 1000)
  184. } else {
  185. message.error(res.msg)
  186. }
  187. })
  188. }
  189. const handleChanges = (info: any, type: number) => {
  190. if (info.file.status === 'uploading') {
  191. loading.value = true;
  192. return;
  193. }
  194. if (info.file.status === 'done') {
  195. loading.value = false;
  196. console.log('info.file:', info.file);
  197. let url = info.file.response.data.url
  198. switch (type) {
  199. case 1:
  200. formState.bizLicense = url
  201. break;
  202. case 2:
  203. formState.idcardFront = url
  204. break;
  205. case 3:
  206. formState.idcardBack = url
  207. break;
  208. case 4:
  209. formState.bizLicenseIdcard = url
  210. break;
  211. default:
  212. break;
  213. }
  214. }
  215. if (info.file.status === 'error') {
  216. loading.value = false;
  217. message.error('upload error');
  218. }
  219. }
  220. const handleChange = (info: UploadChangeParam) => {
  221. handleChanges(info, 1)
  222. };
  223. const handleChange2 = (info: UploadChangeParam) => {
  224. handleChanges(info, 2)
  225. };
  226. const handleChange3 = (info: UploadChangeParam) => {
  227. handleChanges(info, 3)
  228. };
  229. const handleChange4 = (info: UploadChangeParam) => {
  230. handleChanges(info, 4)
  231. };
  232. </script>
  233. <template>
  234. <div class=" pt-120px flex flex-col items-center">
  235. <a-steps :current="current" labelPlacement="vertical" class="w-700px">
  236. <a-step v-for="item in steps" :key="item" :title="item" />
  237. </a-steps>
  238. <div class="mt-60px">
  239. <!-- 账号信息 -->
  240. <a-form v-if="current === 0" :model="formState" class="w-600px">
  241. <a-form-item>
  242. <a-input v-model:value="formState.userAccount" :maxlength="11" allowClear placeholder="输入注册手机号">
  243. <template #prefix>
  244. <MobileOutlined style="color: rgba(0, 0, 0, 0.25)" />
  245. </template>
  246. </a-input>
  247. </a-form-item>
  248. <a-form-item>
  249. <a-input-password v-model:value="formState.password" allowClear placeholder="输入登录密码">
  250. <template #prefix>
  251. <LockOutlined style="color: rgba(0, 0, 0, 0.25)" />
  252. </template>
  253. </a-input-password>
  254. </a-form-item>
  255. <a-form-item>
  256. <a-input-password v-model:value="formState.passwordAgain" allowClear placeholder="再次输入登录密码">
  257. <template #prefix>
  258. <LockOutlined style="color: rgba(0, 0, 0, 0.25)" />
  259. </template>
  260. </a-input-password>
  261. </a-form-item>
  262. <a-form-item>
  263. <a-input v-model:value="formState.code" :maxlength="4" placeholder="输入短信验证码" allowClear
  264. style="width: calc(100% - 130px)">
  265. <template #prefix>
  266. <MailOutlined style="color: rgba(0, 0, 0, 0.25)" />
  267. </template>
  268. </a-input>
  269. <a-button @click="doSendSms" :disabled="!canSendSms" class="ml-20px w-110px" type="primary">{{ verifyText }}
  270. </a-button>
  271. </a-form-item>
  272. </a-form>
  273. <!-- 资料提交 -->
  274. <a-form v-if="current === 1" :model="formState" :label-col="labelCol">
  275. <a-form-item label="企业地址" :rules="[{ required: true }]">
  276. <a-input v-model:value="formState.address" allowClear placeholder="输入企业地址省市区" />
  277. <a-textarea class="mt-24px" v-model:value="formState.street" placeholder="输入企业详细地址" />
  278. </a-form-item>
  279. <a-form-item label="企业名称" :rules="[{ required: true }]">
  280. <a-input v-model:value="formState.merchantName" allowClear placeholder="输入企业名称" />
  281. </a-form-item>
  282. <a-form-item label="统一社会信用代码" :rules="[{ required: true }]">
  283. <a-input v-model:value="formState.bizLicenseNo" allowClear placeholder="输入企业统一社会信用代码" />
  284. </a-form-item>
  285. <a-form-item label="营业执照" :rules="[{ required: true }]">
  286. <template class="flex justify-between">
  287. <a-upload class="avatar-uploader" v-model:file-list="fileList" name="file" list-type="picture-card"
  288. :show-upload-list="false" :action="action" @change="handleChange">
  289. <img class="w-150px h-100px" v-if="formState.bizLicense" :src="formState.bizLicense" alt="avatar" />
  290. <div v-else>
  291. <loading-outlined v-if="loading"></loading-outlined>
  292. <plus-outlined v-else></plus-outlined>
  293. <div class="ant-upload-text">点击上传</div>
  294. </div>
  295. </a-upload>
  296. <div class="flex items-start flex-shrink-0">
  297. <div class="text-14px font-500 text-dark-200 flex-shrink-0 mt-10px mr-20px">示例</div>
  298. <img class="w-150px h-100px" src="@/assets/images/14.png" alt="" srcset="">
  299. </div>
  300. </template>
  301. </a-form-item>
  302. <a-form-item label="法人/实际控制人姓名" :rules="[{ required: true }]">
  303. <a-input v-model:value="formState.legalPerson" allowClear placeholder="输入企业法人/实际控制人姓名" />
  304. </a-form-item>
  305. <a-form-item label="法人/实际控制人证件类型" :rules="[{ required: true }]">
  306. <a-select v-model:value="formState.idcardType">
  307. <a-select-option :value="1">中国大陆身份证</a-select-option>
  308. <a-select-option :value="2">港澳台(身份证/居民通行证)</a-select-option>
  309. <a-select-option :value="3">护照(限境外人士)</a-select-option>
  310. </a-select>
  311. </a-form-item>
  312. <a-form-item label="法人/实际控制人证件号码" :rules="[{ required: true }]">
  313. <a-input v-model:value="formState.idcardNo" allowClear placeholder="输入法人/实际控制人证件号码" />
  314. </a-form-item>
  315. <a-form-item label="证件照正面" :rules="[{ required: true }]">
  316. <template class="flex justify-between">
  317. <a-upload class="avatar-uploader" v-model:file-list="fileList" name="file" list-type="picture-card"
  318. :show-upload-list="false" :action="action" @change="handleChange2">
  319. <img v-if="formState.idcardFront" :src="formState.idcardFront" class="w-150px h-100px" alt="avatar" />
  320. <div v-else>
  321. <loading-outlined v-if="loading"></loading-outlined>
  322. <plus-outlined v-else></plus-outlined>
  323. <div class="ant-upload-text">点击上传</div>
  324. </div>
  325. </a-upload>
  326. <div class="flex items-start flex-shrink-0">
  327. <div class="text-14px font-500 text-dark-200 flex-shrink-0 mt-10px mr-20px">示例</div>
  328. <img class="w-150px h-100px" src="@/assets/images/14-1.png" alt="" srcset="">
  329. </div>
  330. </template>
  331. </a-form-item>
  332. <a-form-item label="证件照反面" :rules="[{ required: true }]">
  333. <template class="flex justify-between">
  334. <a-upload class="avatar-uploader" v-model:file-list="fileList" name="file" list-type="picture-card"
  335. :show-upload-list="false" :action="action" @change="handleChange3">
  336. <img v-if="formState.idcardBack" :src="formState.idcardBack" class="w-150px h-100px" alt="avatar" />
  337. <div v-else>
  338. <loading-outlined v-if="loading"></loading-outlined>
  339. <plus-outlined v-else></plus-outlined>
  340. <div class="ant-upload-text">点击上传</div>
  341. </div>
  342. </a-upload>
  343. <div class="flex items-start flex-shrink-0">
  344. <div class="text-14px font-500 text-dark-200 flex-shrink-0 mt-10px mr-20px">示例</div>
  345. <img class="w-150px h-100px" src="@/assets/images/14-2.png" alt="" srcset="">
  346. </div>
  347. </template>
  348. </a-form-item>
  349. <a-form-item label="手持证件照" :rules="[{ required: true }]">
  350. <template class="flex justify-between">
  351. <a-upload class="avatar-uploader" v-model:file-list="fileList" name="file" list-type="picture-card"
  352. :show-upload-list="false" :action="action" @change="handleChange4">
  353. <img v-if="formState.bizLicenseIdcard" :src="formState.bizLicenseIdcard" class="w-150px h-100px"
  354. alt="avatar" />
  355. <div v-else>
  356. <loading-outlined v-if="loading"></loading-outlined>
  357. <plus-outlined v-else></plus-outlined>
  358. <div class="ant-upload-text">点击上传</div>
  359. </div>
  360. </a-upload>
  361. <div class="flex items-start flex-shrink-0">
  362. <div class="text-14px font-500 text-dark-200 flex-shrink-0 mt-10px mr-20px">示例</div>
  363. <img class="w-150px h-100px" src="@/assets/images/14-3.png" alt="" srcset="">
  364. </div>
  365. </template>
  366. </a-form-item>
  367. <a-form-item label="公司联系人" :rules="[{ required: true }]">
  368. <a-input v-model:value="formState.contactName" allowClear placeholder="输入公司联系人" />
  369. </a-form-item>
  370. <a-form-item label="联系电话" :rules="[{ required: true }]">
  371. <a-input v-model:value="formState.mobile" allowClear placeholder="输入联系电话" :maxlength="11" />
  372. </a-form-item>
  373. </a-form>
  374. <!-- 提交成功 -->
  375. <div v-if="current === 2" class="flex flex-col items-center">
  376. <img class="w-88px h-88px" src="@/assets/images/15.png" alt="" srcset="">
  377. <div class="text-24px font-500 text-dark-500 leading-33px mt-30px mb-10px">提交成功</div>
  378. <div class="flex text-16px text-gray-400">
  379. <div>恭喜您,资料提交成功,去</div>
  380. <div @click="router.push('/login')" class="text-blue-500 cursor-pointer">登录</div>
  381. </div>
  382. </div>
  383. </div>
  384. <div class="w-600px flex items-center justify-between mb-100px">
  385. <a-button v-if="current === 1" @click="prev">上一步</a-button>
  386. <a-button class="w-600px mt-50px" v-if="!current" :disabled="firstDisabled" type="primary" @click="next">下一步
  387. </a-button>
  388. <a-button class="w-400px" v-if="current === 1" :disabled="submitDisabled" type="primary" @click="submit">
  389. 提交资料
  390. </a-button>
  391. </div>
  392. </div>
  393. </template>
  394. <style lang='scss' scoped>
  395. .avatar-uploader :deep(.ant-upload) {
  396. width: 150px !important;
  397. height: 100px !important;
  398. }
  399. </style>