You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

opening-account-unit.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <template>
  2. <navBar title="ETC开户新办申请-单位" :scrollTop="scrollTop"></navBar>
  3. <navBgCar></navBgCar>
  4. <view class="content-wrap">
  5. <view class="item-tips">
  6. <view class="title"> 上传后请核对识别信息 </view>
  7. <view class="tip"> 如有错误请及时手动修改 </view>
  8. </view>
  9. <view class="picture-wrapper" @click="cardImageOcrYY()">
  10. <view class="bg">
  11. <view class="">
  12. <view class="name"> 营业执照 </view>
  13. <view class="value"> 上传企业的营业执照 </view>
  14. <view class="tip">
  15. <view class="tip-value"> 拍摄规范 </view>
  16. </view>
  17. </view>
  18. <image v-if="!state.form.posImgUrl" class="icon" :src="`${$imgUrl}applyCard/zhizhao.png`">
  19. </image>
  20. <image v-else class="icon" :src="strReplace(state.form.posImgUrl)"></image>
  21. </view>
  22. </view>
  23. <view class="picture-wrapper" @click="takePhotoMode('1')">
  24. <view class="bg">
  25. <view class="">
  26. <view class="name"> 人像面 </view>
  27. <view class="value"> 上传身份证的人像面 </view>
  28. <view class="tip">
  29. <view class="tip-value"> 拍摄规范 </view>
  30. </view>
  31. </view>
  32. <image v-if="!state.form.agentPosImgUrl" class="icon" :src="`${$imgUrl}applyCard/renxiang.png`">
  33. </image>
  34. <image v-else class="icon" :src="strReplace(state.form.agentPosImgUrl)"></image>
  35. </view>
  36. </view>
  37. <view class="picture-wrapper" @click="takePhotoMode('2')">
  38. <view class="bg">
  39. <view class="">
  40. <view class="name"> 国徽面 </view>
  41. <view class="value"> 上传身份证的国徽面 </view>
  42. <view class="tip">
  43. <view class="tip-value"> 拍摄规范 </view>
  44. </view>
  45. </view>
  46. <image v-if="!state.form.agentNegImgUrl" class="icon" :src="`${$imgUrl}applyCard/guohui.png`">
  47. </image>
  48. <image v-else class="icon" :src="strReplace(state.form.agentNegImgUrl)"></image>
  49. </view>
  50. </view>
  51. <view class="picture-wrapper" @click="cardFileImageUpdate()">
  52. <view class="bg">
  53. <view class="">
  54. <view class="name"> 委托书 </view>
  55. <view class="value"> 上传文字清晰的委托书 </view>
  56. <view class="tip">
  57. <view class="tip-value"> 拍摄规范 </view>
  58. </view>
  59. </view>
  60. <image v-if="!state.form.proxyUrl" class="icon" :src="`${$imgUrl}applyCard/weituoshu.png`">
  61. </image>
  62. <image v-else class="icon" :src="strReplace(state.form.proxyUrl)"></image>
  63. </view>
  64. </view>
  65. <view class="shibie-wrapper">
  66. <view class="title"> 识别内容如下 </view>
  67. <u-form label-width="200" :model="state.form" ref="uForm">
  68. <u-form-item label="公司名称">
  69. <u-input inputAlign="right" class="clearBg" placeholder='请输入公司名称' v-model="state.form.userName" />
  70. </u-form-item>
  71. <u-form-item label="部门名称">
  72. <u-input inputAlign="right" class="clearBg" placeholder='请输入部门名称' v-model="state.form.department" />
  73. </u-form-item>
  74. <u-form-item label="社会信用代码">
  75. <u-input inputAlign="right" class="clearBg" placeholder='请输入社会信用代码'
  76. v-model="state.form.userIdNum" />
  77. </u-form-item>
  78. <u-form-item label="经办人姓名">
  79. <u-input inputAlign="right" class="clearBg" placeholder='请输入经办人姓名' v-model="state.form.agentName" />
  80. </u-form-item>
  81. <u-form-item label="经办人身份证号">
  82. <u-input inputAlign="right" class="clearBg" placeholder='请输入经办人身份证号'
  83. v-model="state.form.agentIdNum" />
  84. </u-form-item>
  85. <u-form-item label="经办人联系方式">
  86. <u-input inputAlign="right" class="clearBg" placeholder='请输入经办人联系方式' v-model="state.form.tel" />
  87. </u-form-item>
  88. </u-form>
  89. </view>
  90. <view class="green-tip">
  91. 如识别信息有误,请手动修改,确认无误后,点击下一步!
  92. </view>
  93. <view class="action">
  94. <button type="default" class="button" @click="savaHandle()">
  95. 下一步
  96. </button>
  97. </view>
  98. <view class="choice-takePhoto-wrap" v-if="state.isTakePhotoModeShow" @click="cancle">
  99. <view class="choice-takePhoto">
  100. <view @click.stop="takePhoto(state.choiceIndex)" style="border-radius: 20rpx 20rpx 0 0;">拍照</view>
  101. <view @click.stop="xiangce(state.choiceIndex)">从手机相册选择</view>
  102. <view @click.stop="cancle">取消</view>
  103. </view>
  104. </view>
  105. <viewfinder v-if="state.phoneType" :phoneType="state.phoneType" :images="state.images"
  106. :showStartPhoto="state.showImg" @confirmReturn="confirmReturn" @camera="camera"></viewfinder>
  107. </view>
  108. </template>
  109. <script setup lang="ts">
  110. import {
  111. reactive, ref
  112. } from "vue";
  113. import navBgCar from "./components/nav-bg-car3";
  114. import navBar from "@/components/nav-bar/nav-bar2.vue";
  115. import viewfinder from "../../components/viewfinder.vue"
  116. import {
  117. pathToBase64
  118. } from "@/utils/image-tools/index.js";
  119. import {
  120. ocrAllQuery,
  121. fileUpload,
  122. envs,
  123. etcOcrCard,
  124. etcCompanyCardInfoSubmit,
  125. register,
  126. } from "@/utils/network/api.js";
  127. import {
  128. request
  129. } from "@/utils/network/request.js";
  130. import {
  131. stringToJson
  132. } from "@/utils/network/encryption";
  133. import {
  134. onLoad,
  135. onPageScroll,
  136. } from "@dcloudio/uni-app";
  137. import {
  138. setItem,
  139. getItem,
  140. } from "@/utils/storage";
  141. import {
  142. msg,
  143. checkStr,
  144. strReplace,
  145. uploadFile
  146. } from "@/utils/utils";
  147. const scrollTop = ref(0);//滚动距离
  148. const state = reactive({
  149. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  150. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  151. isTakePhotoModeShow: false, //选择拍照方式是否出来
  152. images: '',
  153. showImg: true,
  154. form: {
  155. orderId: "", //订单ID
  156. //营业执照信息
  157. userName: "", //开户名称/账户名称
  158. userIdType: "203", //用户证件类型 203//营业执照
  159. userIdNum: "", //营业执照号码
  160. posImgUrl: "", //营业执照证明
  161. department: '本部', //不超过50个字符,若单位仅开一个账户,填写“本部”
  162. address: "", //单位地址
  163. //经办人信息
  164. agentName: "",
  165. agentIdType: "101",
  166. agentIdNum: "",
  167. agentAddress: "",
  168. agentPhone: "",
  169. agentIdVld: '',
  170. tel: '',
  171. agentGender: '',
  172. agentPosImgUrl: "",
  173. agentNegImgUrl: "",
  174. proxyUrl: "",
  175. sceneType: "", //用户协议支撑服务场景(发行服务机构和用户签订的协议)
  176. channelId: "", //渠道id
  177. opId: '',
  178. orderSource: 'WECHAT',
  179. },
  180. orderId: "",
  181. vehiclePlateColor: '',
  182. isSign: ''
  183. });
  184. const savaHandle = () => {
  185. if (state.form.agentGender === '男') {
  186. state.form.agentGender = 'MAN'
  187. } else {
  188. state.form.agentGender = 'WOMAN'
  189. }
  190. if (!state.form.posImgUrl) {
  191. msg('请上传营业执照');
  192. return;
  193. }
  194. if (!state.form.agentPosImgUrl) {
  195. msg('上传身份证的人像面');
  196. return;
  197. }
  198. if (!state.form.agentNegImgUrl) {
  199. msg('上传身份证的国徽面');
  200. return;
  201. }
  202. if (!state.form.proxyUrl) {
  203. msg('上传身份证的委托书');
  204. return;
  205. }
  206. if (!state.form.userName) {
  207. msg('请输入公司名称');
  208. return;
  209. }
  210. if (!state.form.department) {
  211. msg('请输入社会信用代码');
  212. return;
  213. }
  214. if (!state.form.agentName) {
  215. msg('请输入经办人姓名');
  216. return;
  217. }
  218. if (!checkStr(state.form.agentIdNum, 'card')) {
  219. msg('请输入正确的经办人身份证号');
  220. return;
  221. }
  222. if (!checkStr(state.form.tel, 'mobile')) {
  223. msg('请输入正确的经办人联系方式');
  224. return;
  225. }
  226. //如果未登录||新用户
  227. // if (!getItem('openId')) {
  228. let data = {
  229. userType: "ENTERPRISE",
  230. idNum: state.form.userIdNum,
  231. idType: state.form.userIdType,
  232. mobile: state.form.tel,
  233. userName: state.form.userName,
  234. gender: 'UNKOWN',
  235. certifyChannel: "BAIDUOCR",
  236. address: state.form.address,
  237. agentIdNum: state.form.agentIdNum,
  238. agentIdType: state.form.agentIdType,
  239. agentName: state.form.agentName,
  240. department: state.form.department,
  241. userIdImgUrl: state.form.posImgUrl,
  242. userIdImgBase64: "",
  243. }
  244. const options = {
  245. type: 2,
  246. data: data,
  247. method: "POST",
  248. showLoading: true,
  249. };
  250. request(register, options).then((res) => {
  251. let result = stringToJson(res.bizContent);
  252. if (result.accessToken && result.openId) {
  253. setItem('token', result.accessToken)
  254. setItem('openId', result.openId)
  255. state.form.opId = result.openId;
  256. let data = state.form;
  257. const options = {
  258. type: 2,
  259. data: data,
  260. method: "POST",
  261. showLoading: true,
  262. };
  263. request(etcCompanyCardInfoSubmit, options).then((res) => {
  264. // let result = stringToJson(res.bizContent);
  265. console.log(res);
  266. uni.redirectTo({
  267. url: `/subpackage/orders/car-release?orderId=${state.orderId}&vehiclePlateColor=${state.vehiclePlateColor}&type=1&isSign=${state.isSign}`,
  268. });
  269. });
  270. }
  271. })
  272. // }else{
  273. // var data = state.form;
  274. // const options = {
  275. // type: 2,
  276. // data: data,
  277. // method: "POST",
  278. // showLoading: true,
  279. // };
  280. // request(etcCompanyCardInfoSubmit, options).then((res) => {
  281. // const data = stringToJson(res.bizContent);
  282. // uni.redirectTo({
  283. // url: `/subpackage/orders/car-release?orderId=${state.orderId}&&vehiclePlateColor=${state.vehiclePlateColor}&isSign=${state.isSign}`,
  284. // });
  285. // });
  286. // }
  287. };
  288. onLoad((option : any) => {
  289. state.form.orderId = option.orderId;
  290. state.orderId = option.orderId;
  291. state.vehiclePlateColor = option.vehiclePlateColor;
  292. state.form.opId = getItem('openId') ? getItem('openId') : '';
  293. state.isSign = option.isSign;
  294. });
  295. //监听页面滚动
  296. onPageScroll((e) => {
  297. scrollTop.value = e.scrollTop;
  298. });
  299. //营业执照Orc接口调用
  300. const cardImageOcrYY = () => {
  301. uni.chooseImage({
  302. count: 1, //只能选取一张照片
  303. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  304. sourceType: ["camera", "album"], //从相册选择
  305. success: function (res) {
  306. uploadFile(res.tempFilePaths[0], 1, ocrAllQuery).then((data) => {
  307. if (data.result) {
  308. state.form.userName = stringToJson(data.result
  309. .businessLicense)[
  310. '名称'];
  311. state.form.userIdNum = stringToJson(data.result
  312. .businessLicense)[
  313. '统一社会信用代码'];
  314. cardFileImageUpdateyy(path)
  315. }
  316. })
  317. // pathToBase64(res.tempFilePaths[0])
  318. // .then((path) => {
  319. // var data = {
  320. // type: 'business_license',
  321. // base64: path,
  322. // };
  323. // const options = {
  324. // type: 2,
  325. // data: data,
  326. // method: "POST",
  327. // showLoading: true,
  328. // };
  329. // request(ocrAllQuery, options).then((res) => {
  330. // const data = stringToJson(res.bizContent);
  331. // if (data.result) {
  332. // state.form.userName = stringToJson(data.result
  333. // .businessLicense)[
  334. // '名称'];
  335. // state.form.userIdNum = stringToJson(data.result
  336. // .businessLicense)[
  337. // '统一社会信用代码'];
  338. // cardFileImageUpdateyy(path)
  339. // }
  340. // });
  341. // })
  342. // .catch((error) => { });
  343. },
  344. });
  345. };
  346. //委托书获取图片给后端
  347. const cardFileImageUpdateyy = (val : any) => {
  348. var data = {
  349. fileBase64: val,
  350. };
  351. const options = {
  352. type: 2,
  353. data: data,
  354. method: "POST",
  355. showLoading: true,
  356. };
  357. request(fileUpload, options).then((res) => {
  358. const data = stringToJson(res.bizContent);
  359. state.form.posImgUrl = data.data.url;
  360. });
  361. };
  362. const camera = () => {
  363. state.phoneType = 0
  364. }
  365. const cardFileImageUpdate = () => {
  366. uni.chooseImage({
  367. count: 1, //只能选取一张照片
  368. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  369. sourceType: ["camera", "album"], //从相册选择
  370. success: function (res) {
  371. uploadFile(res.tempFilePaths[0], "", "").then((data) => {
  372. state.form.proxyUrl = data;
  373. })
  374. },
  375. });
  376. };
  377. const takePhotoMode = (index) => {
  378. console.log("index", index)
  379. state.isTakePhotoModeShow = true
  380. state.choiceIndex = index
  381. }
  382. const xiangce = (val) => {
  383. console.log("val", val)
  384. var imageType = val;
  385. uni.chooseImage({
  386. count: 1, //只能选取一张照片
  387. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  388. sourceType: ["album"], //从相册选择
  389. success: function (res) {
  390. state.showImg = false
  391. state.images = res.tempFilePaths[0]
  392. state.phoneType = state.choiceIndex
  393. state.isTakePhotoModeShow = false
  394. console.log("tempFilePaths[0].startsWith('file://')", res.tempFilePaths[0], res.tempFilePaths[0].startsWith('file://'))
  395. },
  396. })
  397. }
  398. const takePhoto = (val) => {
  399. console.log("拍照", val)
  400. state.showImg = true
  401. state.phoneType = val;
  402. }
  403. const confirmReturn = (val) => {
  404. state.phoneType = 0
  405. state.isTakePhotoModeShow = false
  406. var imageType = state.choiceIndex;
  407. console.log("图片地址val", val.tempImagePath)
  408. uploadFile(val.tempImagePath, imageType, etcOcrCard).then((data) => {
  409. console.log("身份证上传", data)
  410. if (state.choiceIndex === "1") {
  411. state.form.agentName = data.name;
  412. state.form.agentIdNum = data.idno;
  413. state.form.agentPosImgUrl = data.imageUrl;
  414. state.form.address = data.address;
  415. state.form.agentGender = data.gender;
  416. } else {
  417. state.form.agentIdVld = data.enddate;
  418. state.form.agentNegImgUrl = data.imageUrl;
  419. }
  420. state.isTakePhotoModeShow = false
  421. })
  422. }
  423. const cancle = () => {
  424. state.isTakePhotoModeShow = false
  425. }
  426. </script>
  427. <style lang="scss" scoped>
  428. .content-wrap {
  429. position: relative;
  430. margin-top: -50rpx;
  431. padding: 0rpx 30rpx;
  432. position: relative;
  433. .action {
  434. padding-left: 20rpx;
  435. padding-right: 20rpx;
  436. padding-bottom: 30rpx;
  437. .button {
  438. height: 80rpx;
  439. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  440. border-radius: 40rpx;
  441. font-size: 32rpx;
  442. font-weight: 400;
  443. color: #ffffff;
  444. line-height: 80rpx;
  445. }
  446. }
  447. .item-tips {
  448. .title {
  449. font-size: 30rpx;
  450. font-family: Microsoft YaHei;
  451. font-weight: 400;
  452. color: #000000;
  453. line-height: 24rpx;
  454. }
  455. .tip {
  456. margin-top: 16rpx;
  457. font-size: 24rpx;
  458. font-family: Microsoft YaHei;
  459. font-weight: 400;
  460. color: #999999;
  461. line-height: 24rpx;
  462. }
  463. }
  464. .picture-wrapper {
  465. margin-top: 40rpx;
  466. .bg {
  467. background: #ffffff;
  468. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  469. border-radius: 20rpx;
  470. padding: 40rpx;
  471. display: flex;
  472. // align-items: center;
  473. justify-content: space-between;
  474. .name {
  475. font-size: 34rpx;
  476. font-family: Microsoft YaHei;
  477. font-weight: 400;
  478. color: #000000;
  479. line-height: 34rpx;
  480. }
  481. .value {
  482. margin-top: 20rpx;
  483. font-size: 24rpx;
  484. font-family: Microsoft YaHei;
  485. font-weight: 400;
  486. color: #999999;
  487. line-height: 24rpx;
  488. }
  489. .tip {
  490. margin-top: 20rpx;
  491. text-align: center;
  492. width: 110rpx;
  493. height: 40rpx;
  494. background: rgba(33, 190, 177, 0.2);
  495. border-radius: 6rpx;
  496. .tip-value {
  497. font-size: 20rpx;
  498. font-family: Microsoft YaHei;
  499. font-weight: 400;
  500. color: #0a8f8a;
  501. line-height: 40rpx;
  502. opacity: 1;
  503. }
  504. }
  505. }
  506. .icon {
  507. width: 294rpx;
  508. height: 188rpx;
  509. }
  510. }
  511. .shibie-wrapper {
  512. margin-top: 60rpx;
  513. .title {
  514. font-size: 30rpx;
  515. font-family: Microsoft YaHei;
  516. font-weight: 400;
  517. color: #000000;
  518. line-height: 30rpx;
  519. }
  520. }
  521. .buchong-wrapper {
  522. margin-top: 60rpx;
  523. .title {
  524. font-size: 30rpx;
  525. font-family: Microsoft YaHei;
  526. font-weight: 400;
  527. color: #000000;
  528. line-height: 30rpx;
  529. }
  530. }
  531. .green-tip {
  532. margin-top: 50rpx;
  533. font-size: 24rpx;
  534. font-family: Microsoft YaHei;
  535. font-weight: 400;
  536. color: #00b38b;
  537. line-height: 24rpx;
  538. margin-bottom: 60rpx;
  539. }
  540. }
  541. ::v-deep .u-input__input {
  542. background: transparent;
  543. }
  544. ::v-deep .u-form-item--left .u-form-item--left__content {
  545. padding-right: 0px;
  546. }
  547. .choice-takePhoto {
  548. position: absolute;
  549. bottom: 0;
  550. background-color: white;
  551. width: 100%;
  552. border-radius: 20rpx 20rpx 0 0;
  553. }
  554. .choice-takePhoto>view:first-child {
  555. text-align: center;
  556. height: 80rpx;
  557. line-height: 80rpx;
  558. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  559. background-color: white;
  560. }
  561. .choice-takePhoto>view:last-child {
  562. text-align: center;
  563. height: 80rpx;
  564. line-height: 80rpx;
  565. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  566. background-color: white;
  567. }
  568. .choice-takePhoto>view {
  569. text-align: center;
  570. height: 80rpx;
  571. line-height: 80rpx;
  572. background-color: white;
  573. }
  574. .choice-takePhoto-wrap {
  575. width: 100%;
  576. height: 100vh;
  577. background-color: rgba(127, 127, 127, 0.2);
  578. position: fixed;
  579. left: 0;
  580. top: 0;
  581. z-index: 11111;
  582. }
  583. </style>