index.vue 9.2 KB

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