index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. v-if="componentsKey[current] == 'companiesInformation'"
  21. :is="'companiesInformation'"
  22. ></component>
  23. <component
  24. :formdData.sync="formdData"
  25. v-if="componentsKey[current] == 'authorizer'"
  26. :is="'authorizer'"
  27. ></component>
  28. </view>
  29. <view class="btn">
  30. <u-button
  31. class="custom-style"
  32. @click="handlePre"
  33. :plain="true"
  34. shape="circle"
  35. type="primary"
  36. >上一步</u-button
  37. >
  38. <u-button
  39. class="custom-style"
  40. @click="handleNext"
  41. shape="circle"
  42. type="primary"
  43. >下一步</u-button
  44. >
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import { businessLicenseIdentification } from "@/api/personRegistered";
  50. import uploadLicense from "@/components/companiesRegistered/uploadLicense";
  51. import companiesInformation from "@/components/companiesRegistered/companiesInformation";
  52. import authorizer from "@/components/companiesRegistered/authorizer";
  53. export default {
  54. components: {
  55. uploadLicense,
  56. companiesInformation,
  57. authorizer,
  58. },
  59. data() {
  60. return {
  61. formdData: {
  62. //企业营业照
  63. imageUrl: null,
  64. //营业识别数据
  65. companiesOrcResult: {
  66. region: "", //单位区域
  67. location: "", //地理位置
  68. postalAddress: "", //详细地址
  69. },
  70. },
  71. componentsKey: {
  72. 0: "uploadLicense",
  73. 1: "companiesInformation",
  74. 2: "authorizer",
  75. },
  76. current: 2,
  77. };
  78. },
  79. methods: {
  80. //ocr识别
  81. async handleOcr() {
  82. uni.showLoading({
  83. title: "智能识别中...",
  84. });
  85. try {
  86. let {
  87. data: { orcResult },
  88. } = await businessLicenseIdentification({
  89. filePath: this.formdData.imageUrl,
  90. });
  91. Object.keys(orcResult).forEach((key) => {
  92. this.formdData.companiesOrcResult[key] = orcResult[key];
  93. });
  94. setTimeout(() => {
  95. uni.hideLoading();
  96. this.current++;
  97. }, 2000);
  98. } catch (error) {
  99. uni.showLoading({
  100. title: "识别错误",
  101. });
  102. setTimeout(() => {
  103. uni.hideLoading();
  104. }, 2000);
  105. } finally {
  106. }
  107. },
  108. //确认企业信息
  109. handleConrim() {
  110. // if (
  111. // !this.formdData.companiesOrcResult.region ||
  112. // !this.formdData.companiesOrcResult.location
  113. // ) {
  114. // uni.showToast({
  115. // title: "位置区域不能为空",
  116. // //将值设置为 success 或者直接不用写icon这个参数
  117. // icon: "none",
  118. // //显示持续时间为 2秒
  119. // duration: 2000,
  120. // });
  121. // } else {
  122. // this.current++;
  123. // }
  124. this.current++;
  125. },
  126. //下一步
  127. handleNext() {
  128. if (this.componentsKey[this.current] == "uploadLicense") {
  129. this.handleOcr();
  130. } else if (this.componentsKey[this.current] == "companiesInformation") {
  131. this.handleConrim();
  132. }
  133. },
  134. //上一步
  135. handlePre() {
  136. this.current--;
  137. },
  138. },
  139. };
  140. </script>
  141. <style>
  142. .component {
  143. width: 95%;
  144. margin: 40rpx auto;
  145. }
  146. ::v-deep .u-button {
  147. width: 280rpx !important;
  148. height: 70rpx !important;
  149. font-size: 30rpx !important;
  150. }
  151. .btn {
  152. display: flex;
  153. justify-content: space-between;
  154. align-items: center;
  155. background: #fff;
  156. padding: 20rpx;
  157. position: fixed;
  158. bottom: 0;
  159. left: 0;
  160. width: 100%;
  161. }
  162. .app-container {
  163. height: 100vh;
  164. background: rgb(248, 249, 250);
  165. }
  166. .setps {
  167. width: 95%;
  168. margin: 10rpx auto;
  169. background: #fff;
  170. padding: 20rpx;
  171. border-radius: 6px;
  172. }
  173. </style>