index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <!-- @format -->
  2. <template>
  3. <view class="app-container">
  4. <view class="setps">
  5. <u-steps :current="current">
  6. <u-steps-item title="第一步"> </u-steps-item>
  7. <u-steps-item title="第二部"></u-steps-item>
  8. <u-steps-item title="第三步"></u-steps-item>
  9. <u-steps-item title="注册完成"></u-steps-item>
  10. </u-steps>
  11. </view>
  12. <view class="component">
  13. <component
  14. :formdData.sync="formdData"
  15. v-if="componentsKey[current] == 'uploadLicense'"
  16. :is="'uploadLicense'"
  17. ></component>
  18. <component
  19. :formdData.sync="formdData"
  20. :companiesInformationRef.sync="companiesInformationRef"
  21. v-if="componentsKey[current] == 'companiesInformation'"
  22. :is="'companiesInformation'"
  23. ></component>
  24. <component
  25. :formdData.sync="formdData"
  26. :authorizerRef.sync="authorizerRef"
  27. v-if="componentsKey[current] == 'authorizer'"
  28. :is="'authorizer'"
  29. ></component>
  30. <component
  31. :formdData.sync="formdData"
  32. v-if="componentsKey[current] == 'recognition'"
  33. :is="'recognition'"
  34. ></component>
  35. </view>
  36. <view class="btn">
  37. <u-button
  38. class="custom-style"
  39. @click="handlePre"
  40. :plain="true"
  41. shape="circle"
  42. type="primary"
  43. >{{ current == 0 ? "退出注册" : "上一步" }}</u-button
  44. >
  45. <u-button
  46. class="custom-style"
  47. @click="handleNext"
  48. shape="circle"
  49. type="primary"
  50. >{{
  51. formdData.isPass && current == 3 ? "完成注册" : "下一步"
  52. }}</u-button
  53. >
  54. </view>
  55. <view style="height: 100rpx"></view>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. businessLicenseIdentification,
  61. submitMiMechanism,
  62. } from "@/api/companiesRegistered";
  63. import uploadLicense from "@/components/companiesRegistered/uploadLicense";
  64. import companiesInformation from "@/components/companiesRegistered/companiesInformation";
  65. import authorizer from "@/components/companiesRegistered/authorizer";
  66. import recognition from "@/components/companiesRegistered/recognition";
  67. export default {
  68. components: {
  69. uploadLicense,
  70. companiesInformation,
  71. recognition,
  72. authorizer,
  73. },
  74. onLoad(options) {
  75. this.formdData.type = options.type;
  76. },
  77. data() {
  78. return {
  79. companiesInformationRef: null,
  80. authorizerRef: null,
  81. formdData: {
  82. type: null, //类别
  83. isPass: false, //是否通过
  84. //企业营业照
  85. imageUrl: null,
  86. //营业识别数据
  87. companiesOrcResult: {
  88. region: "", //单位区域
  89. location: "", //地理位置
  90. postalAddress: "", //详细地址
  91. type: "",
  92. regNum: "",
  93. name: "",
  94. address: "",
  95. person: "",
  96. }, //企业信息
  97. personCardOrcResult: {
  98. name: "", //用户名
  99. idNum: "", //身份证号
  100. userMobile: "", //联系人手机号
  101. landline: "", //单位联系电话
  102. cardFrontImg: null, //身份证正面
  103. cardBackImg: null, //身份证背面
  104. }, //申请人信息
  105. recognition: {},
  106. },
  107. componentsKey: {
  108. 0: "uploadLicense",
  109. 1: "companiesInformation",
  110. 2: "authorizer",
  111. 3: "recognition",
  112. },
  113. current: 0,
  114. };
  115. },
  116. computed: {
  117. isNextDisbaled() {
  118. if (
  119. this.formdData.personCardOrcResult.name &&
  120. this.formdData.companiesOrcResult.person
  121. ) {
  122. return (
  123. this.formdData.personCardOrcResult.name !==
  124. this.formdData.companiesOrcResult.person
  125. );
  126. } else {
  127. return false;
  128. }
  129. },
  130. },
  131. methods: {
  132. //确认个人信息
  133. handlePerson() {
  134. if (
  135. this.formdData.personCardOrcResult.name !==
  136. this.formdData.companiesOrcResult.person
  137. ) {
  138. uni.showToast({
  139. title: "识别结果不符,请到电脑端申请注册",
  140. //将值设置为 success 或者直接不用写icon这个参数
  141. icon: "none",
  142. //显示持续时间为 2秒
  143. duration: 2000,
  144. });
  145. return;
  146. }
  147. this.authorizerRef.validate().then((res) => {
  148. this.current++;
  149. });
  150. },
  151. //ocr识别
  152. async handleOcr() {
  153. if (!this.formdData.imageUrl) {
  154. uni.showToast({
  155. title: "请先上传营业执照",
  156. //将值设置为 success 或者直接不用写icon这个参数
  157. icon: "none",
  158. //显示持续时间为 2秒
  159. duration: 2000,
  160. });
  161. return;
  162. }
  163. uni.showLoading({
  164. title: "智能识别中...",
  165. });
  166. try {
  167. let {
  168. data: { orcResult },
  169. } = await businessLicenseIdentification({
  170. filePath: this.formdData.imageUrl,
  171. });
  172. Object.keys(orcResult).forEach((key) => {
  173. this.formdData.companiesOrcResult[key] = orcResult[key];
  174. });
  175. setTimeout(() => {
  176. uni.hideLoading();
  177. this.current++;
  178. }, 2000);
  179. } catch (error) {
  180. uni.showLoading({
  181. title: "识别错误",
  182. });
  183. } finally {
  184. setTimeout(() => {
  185. uni.hideLoading();
  186. }, 2000);
  187. }
  188. },
  189. //确认企业信息
  190. handleConrim() {
  191. this.companiesInformationRef.validate().then((res) => {
  192. this.current++;
  193. });
  194. // if (
  195. // !this.formdData.companiesOrcResult.region ||
  196. // !this.formdData.companiesOrcResult.location
  197. // ) {
  198. // uni.showToast({
  199. // title: "位置区域不能为空",
  200. // //将值设置为 success 或者直接不用写icon这个参数
  201. // icon: "none",
  202. // //显示持续时间为 2秒
  203. // duration: 2000,
  204. // });
  205. // } else {
  206. // this.current++;
  207. // }
  208. },
  209. //完成注册
  210. async handlefinish() {
  211. uni.showLoading({
  212. title: "提交中....",
  213. });
  214. try {
  215. const paramsParse = {
  216. name: this.formdData.companiesOrcResult.name,
  217. type: this.formdData.companiesOrcResult.type,
  218. code: this.formdData.companiesOrcResult.regNum,
  219. loginName: this.formdData.companiesOrcResult.regNum,
  220. region: this.formdData.companiesOrcResult.region,
  221. residence: this.formdData.companiesOrcResult.address,
  222. userName: this.formdData.companiesOrcResult.person,
  223. location: this.formdData.companiesOrcResult.location,
  224. postalAddress: this.formdData.companiesOrcResult.postalAddress,
  225. cardUp: this.formdData.personCardOrcResult.cardFrontImg,
  226. cardDown: this.formdData.personCardOrcResult.cardBackImg,
  227. principalCard: this.formdData.personCardOrcResult.idNum,
  228. principal: this.formdData.personCardOrcResult.name,
  229. landline: this.formdData.personCardOrcResult.landline,
  230. userMobile: this.formdData.personCardOrcResult.userMobile,
  231. };
  232. let res = await submitMiMechanism(paramsParse);
  233. uni.showToast({
  234. title: "注册完成",
  235. //将值设置为 success 或者直接不用写icon这个参数
  236. icon: "success",
  237. //显示持续时间为 2秒
  238. duration: 2000,
  239. });
  240. uni.navigateTo({
  241. url: `/pages/companiesRegistered/companiesPassword?adminUserName=${res.data.adminUser.name}&adminUserPwdOriginal=${res.data.adminUser.pwdOriginal}&userName=${res.data.user.name}&userPwdOriginal=${res.data.user.pwdOriginal}`,
  242. success: (res) => {},
  243. fail: () => {},
  244. complete: () => {},
  245. });
  246. } catch (error) {
  247. } finally {
  248. setTimeout(() => {
  249. uni.hideLoading();
  250. }, 2000);
  251. }
  252. },
  253. //下一步
  254. handleNext() {
  255. if (this.componentsKey[this.current] == "uploadLicense") {
  256. this.handleOcr();
  257. } else if (this.componentsKey[this.current] == "companiesInformation") {
  258. this.handleConrim();
  259. } else if (this.componentsKey[this.current] == "authorizer") {
  260. this.handlePerson();
  261. } else if (this.componentsKey[this.current] == "recognition") {
  262. if (this.formdData.isPass) {
  263. this.handlefinish();
  264. }
  265. }
  266. },
  267. //上一步
  268. handlePre() {
  269. if (this.current == 0) {
  270. uni.navigateBack({
  271. delta: 1,
  272. });
  273. }
  274. this.current--;
  275. },
  276. },
  277. };
  278. </script>
  279. <style>
  280. .component {
  281. width: 95%;
  282. margin: 40rpx auto;
  283. }
  284. ::v-deep .u-button {
  285. width: 280rpx !important;
  286. height: 70rpx !important;
  287. font-size: 30rpx !important;
  288. }
  289. .btn {
  290. display: flex;
  291. justify-content: space-between;
  292. align-items: center;
  293. background: #fff;
  294. padding: 20rpx;
  295. position: fixed;
  296. bottom: 0;
  297. left: 0;
  298. width: 100%;
  299. }
  300. .app-container {
  301. height: 100vh;
  302. background: rgb(248, 249, 250);
  303. }
  304. .setps {
  305. width: 95%;
  306. margin: 10rpx auto;
  307. background: #fff;
  308. padding: 20rpx;
  309. border-radius: 6px;
  310. }
  311. </style>