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.

upload-card.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <template>
  2. <view class="picture-wrapper" @click="takePhotoMode('3')">
  3. <view class="bg">
  4. <view class="">
  5. <view class="name"> 行驶证主页 </view>
  6. <view class="value"> 上传行驶证的主页 </view>
  7. <view class="tip">
  8. <view class="tip-value"> 拍摄规范 </view>
  9. </view>
  10. </view>
  11. <image v-if="!form.licenseFrontUrl" class="icon" :src="`${$imgUrl}applyCard/car-zhu.png`">
  12. </image>
  13. <image v-else class="icon" :src="strReplace(form.licenseFrontUrl)"></image>
  14. </view>
  15. </view>
  16. <view class="picture-wrapper" @click="takePhotoMode('4')">
  17. <view class="bg">
  18. <view class="">
  19. <view class="name"> 行驶证副页 </view>
  20. <view class="value"> 上传行驶证的副页 </view>
  21. <view class="tip">
  22. <view class="tip-value"> 拍摄规范 </view>
  23. </view>
  24. </view>
  25. <image v-if="!form.licenseReverseUrl" class="icon" :src="`${$imgUrl}applyCard/car-fu.png`">
  26. </image>
  27. <image v-else class="icon" :src="strReplace(form.licenseReverseUrl)"></image>
  28. </view>
  29. </view>
  30. <view class="upload-box">
  31. <u-form :model="form" ref="myForm" :error-type="errorType">
  32. <view class="from">
  33. <view class="title"> 请填写注销原因 </view>
  34. <u-form-item prop="remark">
  35. <view class="from_item">
  36. <text><text style="color: red"></text>注销原因:</text>
  37. <view style="display: flex">
  38. <u-input v-model="form.ReasonCancellation" @click="showPicker()" class="input" disabled
  39. placeholder="请选择" />
  40. <u-icon name="arrow-right" style="margin-left: 10px;display: flex;"></u-icon>
  41. </view>
  42. </view>
  43. </u-form-item>
  44. </view>
  45. </u-form>
  46. <view v-if="form.cancelList">
  47. <view class="message">退款信息</view>
  48. <view class="list-item">
  49. <view>
  50. <view><text>姓名:</text><text>{{form.cancelList.cusName}}</text></view>
  51. <view><text>开户行:</text><text>{{bankData[form.cancelList.bankType]}}</text></view>
  52. <view><text>开户行支行:</text><text>{{form.cancelList.branchName}}</text></view>
  53. <view><text>银行卡号:</text><text>{{form.cancelList.bankCardId}}</text></view>
  54. </view>
  55. <view class="change" @click="next()">></view>
  56. </view>
  57. </view>
  58. <button class="submit" @click="next()" v-if="form.isShow">下一步</button>
  59. <button class="submit" @click="toPage()" v-else>注销</button>
  60. <view>
  61. <!-- 原因 -->
  62. <u-select v-model="show" mode="single-column" :list="list" @confirm="confirm"></u-select>
  63. </view>
  64. <view class="choice-takePhoto-wrap" v-if="state.isTakePhotoModeShow" @click="cancle">
  65. <view class="choice-takePhoto">
  66. <view @click.stop="takePhoto(state.choiceIndex)" style="border-radius: 20rpx 20rpx 0 0;">拍照</view>
  67. <view @click.stop="xiangce(state.choiceIndex)">从手机相册选择</view>
  68. <view @click.stop="cancle">取消</view>
  69. </view>
  70. </view>
  71. <viewfinder v-if="state.phoneType" :phoneType="state.phoneType" :images="state.images"
  72. :showStartPhoto="state.showImg" @confirmReturn="confirmReturn" @camera="camera"></viewfinder>
  73. </view>
  74. </template>
  75. <script lang="ts" setup>
  76. import {
  77. reactive,
  78. ref
  79. } from "vue";
  80. import {
  81. onLoad,
  82. onShow,
  83. onUnload,
  84. onReady,
  85. } from "@dcloudio/uni-app";
  86. import {
  87. navTo,
  88. checkStr,
  89. msg, strReplace, uploadFile, compressImage
  90. } from "@/utils/utils";
  91. import {
  92. request
  93. } from "@/utils/network/request.js";
  94. import {
  95. writeCardBack,
  96. CardSignCancellation,
  97. confirmSignCancellation, etcCarOcrCard
  98. } from "@/utils/network/api.js";
  99. import {
  100. stringToJson
  101. } from "@/utils/network/encryption.js";
  102. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  103. import { getItem } from "@/utils/storage";
  104. import { bankData } from "@/datas/bank.js";
  105. import viewfinder from "../../../components/viewfinder.vue"
  106. // 表单数据
  107. const form = reactive({
  108. userType: "",
  109. obuId: '',
  110. cardId: '',
  111. orderId: '',
  112. ReasonCancellation: "",
  113. equipmentState: '',
  114. licenseFrontUrl: "", //行驶证正面
  115. licenseReverseUrl: "",//行驶证反面
  116. customerIdnum: "",
  117. mobile: "",
  118. isShow: true,//储值卡要去下一步填写信息,记账卡直接注销
  119. cancelList: "",
  120. });
  121. const state = reactive({
  122. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  123. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  124. isTakePhotoModeShow: false, //选择拍照方式是否出来
  125. changeColor: false,
  126. showImg: true,
  127. images: '',
  128. })
  129. const list = reactive([]);
  130. // 验证提示类型(toast要版本为1.3.5才支持)
  131. const errorType = ["border-bottom", "toast"];
  132. // 设置验证规则
  133. const myForm = ref(null);
  134. onReady(() => {
  135. });
  136. onShow(() => {
  137. uni.$once('list', (query) => {
  138. console.log("111", query)
  139. form.cancelList = query.item
  140. form.isShow = false
  141. })
  142. })
  143. onLoad((option) => {
  144. let options = JSON.parse(decodeURIComponent(option.params))
  145. form.obuId = options.obuId;
  146. form.cardId = options.cardId;
  147. form.orderId = options.orderId
  148. form.equipmentState = options.equipmentState
  149. form.mobile = options.mobile
  150. form.customerIdnum = options.customerIdnum
  151. form.userType = options.userType
  152. if (form.cardId) {
  153. if (form.cardId.substring(8, 10) == "22") {
  154. form.isShow = true
  155. } else {
  156. form.isShow = false
  157. }
  158. }
  159. console.log("options.orderId", options, getItem('key')['LOGOFF'], "52011328220201990787".substring(8, 10))
  160. // 获取注销原因
  161. for (var k = 0; k < getItem('key')['LOGOFF'].length; k++) {
  162. var obj = {};
  163. obj['value'] = getItem('key')['LOGOFF'][k]['name']
  164. obj['label'] = getItem('key')['LOGOFF'][k]['name']
  165. list.push(obj)
  166. }
  167. console.log("list", list)
  168. /*监听蓝牙回调*/
  169. uni.$on('bluetoothLink', function (status) {
  170. queryCardSignCancellation(1, 1, 1).then((item : any) => {
  171. console.log("item========", item)
  172. instructAction(item).then(value => {
  173. console.log('orderStatus=======', value.orderStatus)
  174. })
  175. })
  176. })
  177. });
  178. onUnload(() => {
  179. /*移除监听*/
  180. uni.$off('bluetoothLink')
  181. });
  182. const show = ref(false);
  183. const showPicker = function () {
  184. show.value = true;
  185. };
  186. // 选择物流
  187. const confirm = (e) => {
  188. console.log(e);
  189. form.ReasonCancellation = e[0].value;
  190. };
  191. const toPage = () => {
  192. //参数说明
  193. let options = {};
  194. if (form.equipmentState === '1') {
  195. navTo("/pages/bluetooth/bluetooth?routeType=5");
  196. } else {
  197. queryCardSignCancellation(2, 2, 0).then((item : any) => {
  198. navTo("/subpackage/after-sale/ETC-log-off/log-off-result");
  199. })
  200. }
  201. };
  202. /*指令返回*/
  203. const instructAction = (data) => {
  204. let cmdArr = data.command.split(",");
  205. console.log("cmdArr=========", cmdArr);
  206. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  207. console.log("透传");
  208. console.log(res);
  209. var arraylenth = res.length;
  210. var status = res[arraylenth - 1].substring(
  211. res[arraylenth - 1].length - 4,
  212. res[arraylenth - 1].length
  213. );
  214. console.log("打印指令状态");
  215. console.log(status);
  216. var formes = {
  217. command: data.command,
  218. response: res.toString(),
  219. cosRecordId: data.cosRecordId,
  220. cardId: form.cardId,
  221. cosType: 9 //1- 开卡. 2- 修改卡内信息 4- 卡签绑定 9- 销卡
  222. };
  223. const options = {
  224. type: 2,
  225. data: formes,
  226. method: "POST",
  227. showLoading: true,
  228. };
  229. return new Promise(async (resolve, reject) => {
  230. const res = await request(writeCardBack, options);
  231. const data = stringToJson(res.bizContent);
  232. console.log('data--------------', data)
  233. if (status === "9000") {
  234. if (data.orderStatus === 1) {
  235. instructAction(data)
  236. } else {
  237. navTo("/subpackage/after-sale/ETC-log-off/log-off-result");
  238. }
  239. resolve(data);
  240. } else {
  241. reject("指令执行失败!");
  242. }
  243. }).catch((error) => {
  244. reject(error);
  245. });
  246. });
  247. };
  248. //注销申请
  249. const queryCardSignCancellation = (hasCard, hasObu, cosProvider) => {
  250. if (!form.licenseFrontUrl) {
  251. msg("请上传行驶证的主页");
  252. return;
  253. }
  254. if (!form.licenseReverseUrl) {
  255. msg("请上传行驶证的副页");
  256. return;
  257. }
  258. if (!form.ReasonCancellation) {
  259. msg("请选择注销原因");
  260. return;
  261. }
  262. if (form.orderId) {
  263. var options = {
  264. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  265. data: {
  266. hasCard: hasCard,
  267. hasObu: hasObu,
  268. cosProvider: cosProvider,
  269. cardId: form.cardId, //卡号
  270. obuId: form.obuId, //签号
  271. serviceType: 3, //注销类型 1-卡注销,2-签注销,3-卡签注销
  272. orderId: form.orderId, //订单编号
  273. signReason: form.ReasonCancellation,
  274. licenseFrontUrl: form.licenseFrontUrl,
  275. licenseReverseUrl: form.licenseReverseUrl,
  276. signId: form.cancelList.id
  277. }, //请求参数
  278. method: "POST", //提交方式(默认POST)
  279. showLoading: true, //是否显示加载中(默认显示)
  280. };
  281. } else {
  282. var options = {
  283. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  284. data: {
  285. hasCard: hasCard,
  286. hasObu: hasObu,
  287. cosProvider: cosProvider,
  288. cardId: form.cardId, //卡号
  289. obuId: form.obuId, //签号
  290. serviceType: 3, //注销类型 1-卡注销,2-签注销,3-卡签注销
  291. signReason: form.ReasonCancellation,
  292. licenseFrontUrl: form.licenseFrontUrl,
  293. licenseReverseUrl: form.licenseReverseUrl,
  294. signId: form.cancelList.id
  295. }, //请求参数
  296. method: "POST", //提交方式(默认POST)
  297. showLoading: true, //是否显示加载中(默认显示)
  298. };
  299. }
  300. console.log("options", options)
  301. return new Promise(async (resolve, reject) => {
  302. const res = await request(CardSignCancellation, options);
  303. const data = stringToJson(res.bizContent);
  304. console.log("注销申请此接口可能有问题", data)
  305. resolve(data);
  306. }).catch((error) => {
  307. reject(error);
  308. });
  309. }
  310. const next = () => {
  311. if (!form.licenseFrontUrl) {
  312. msg("请上传行驶证的主页");
  313. return;
  314. }
  315. if (!form.licenseReverseUrl) {
  316. msg("请上传行驶证的副页");
  317. return;
  318. }
  319. if (!form.ReasonCancellation) {
  320. msg("请选择注销原因");
  321. return;
  322. }
  323. navTo(`/subpackage/after-sale/ETC-log-off/refund-information-list?mobile=${form.mobile}&&customerIdnum=${form.customerIdnum}&&userType=${form.userType}`);
  324. }
  325. const xiangce = (val) => {
  326. console.log("val", val)
  327. if (state.choiceIndex == 3) {
  328. var imageType = 1;
  329. } else {
  330. var imageType = 2;
  331. }
  332. state.changeColor = true;
  333. uni.chooseImage({
  334. count: 1, //只能选取一张照片
  335. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  336. sourceType: ["album"], //从相册选择
  337. success: function (res) {
  338. console.log("tempFilePaths[0].startsWith('file://')", res.tempFilePaths[0], res.tempFilePaths[0].startsWith('file://'))
  339. compressImage(res.tempFilePaths[0], (res) => {
  340. console.log("过来了", res)
  341. if (state.choiceIndex == 3) {
  342. form.licenseFrontUrl = res.tempFilePath;
  343. } else {
  344. form.licenseReverseUrl = res.tempFilePath;
  345. }
  346. state.phoneType = state.choiceIndex
  347. state.showImg = false
  348. state.isTakePhotoModeShow = false
  349. })
  350. },
  351. })
  352. }
  353. const takePhoto = (val) => {
  354. console.log("拍照", val)
  355. state.phoneType = val;
  356. state.showImg = true;
  357. }
  358. const confirmReturn = (val) => {
  359. if (state.choiceIndex == 3) {
  360. var imageType = 1;
  361. } else {
  362. var imageType = 2;
  363. }
  364. state.changeColor = true;
  365. state.phoneType = 0
  366. state.isTakePhotoModeShow = false
  367. uploadFile(val.tempImagePath, imageType, etcCarOcrCard).then((data) => {
  368. // uploadFile(val.tempImagePath, state.choiceIndex, ocrAllQuery).then((data) => {
  369. console.log('输出内容=====================', state.choiceIndex)
  370. if (state.choiceIndex === "3") {
  371. form.licenseFrontUrl = data.imageUrl;
  372. } else {
  373. form.licenseReverseUrl = data.imageUrl;
  374. console.log('=====================', state.form.vehNegImgUrl, state)
  375. }
  376. state.isTakePhotoModeShow = false
  377. })
  378. console.log("图片地址val", val.tempImagePath)
  379. }
  380. const takePhotoMode = (index) => {
  381. console.log("index", index)
  382. state.isTakePhotoModeShow = true
  383. state.choiceIndex = index
  384. }
  385. const cancle = () => {
  386. state.isTakePhotoModeShow = false
  387. }
  388. const camera = () => {
  389. state.phoneType = 0
  390. }
  391. </script>
  392. <style>
  393. page {
  394. width: 100%;
  395. height: 100%;
  396. background-color: #EEF7F7;
  397. }
  398. </style>
  399. <style lang="scss" scoped>
  400. .upload-box {
  401. width: 92%;
  402. margin: 30rpx auto;
  403. .head-tips {
  404. text-indent: 2rem;
  405. font-size: 26rpx;
  406. font-family: Microsoft YaHei;
  407. font-weight: 400;
  408. color: #666666;
  409. line-height: 50rpx;
  410. margin-bottom: 45rpx;
  411. text {
  412. color: #ff8000;
  413. }
  414. }
  415. .upload-card {
  416. margin-bottom: 70rpx;
  417. height: 260rpx;
  418. background: #ffffff;
  419. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  420. border-radius: 20rpx;
  421. padding: 30rpx;
  422. display: flex;
  423. justify-content: space-between;
  424. .card-left {
  425. .item1 {
  426. font-size: 34rpx;
  427. font-family: Microsoft YaHei;
  428. font-weight: 400;
  429. color: #000000;
  430. margin-bottom: 30rpx;
  431. }
  432. .item2 {
  433. font-size: 24rpx;
  434. font-family: Microsoft YaHei;
  435. font-weight: 400;
  436. color: #999999;
  437. margin-bottom: 30rpx;
  438. }
  439. .item3 {
  440. width: 110rpx;
  441. height: 40rpx;
  442. background: #ecfbf8;
  443. border-radius: 6rpx;
  444. font-size: 20rpx;
  445. font-family: Microsoft YaHei;
  446. font-weight: 400;
  447. text-align: center;
  448. line-height: 40rpx;
  449. color: #0a8f8a;
  450. }
  451. }
  452. image {
  453. width: 295rpx;
  454. height: 188rpx;
  455. }
  456. }
  457. .from {
  458. background-color: #fff;
  459. margin-top: 30rpx;
  460. border-radius: 20rpx;
  461. padding: 10rpx 20rpx;
  462. box-sizing: border-box;
  463. ::v-deep .u-form-item {
  464. padding: 0;
  465. line-height: normal;
  466. .u-form-item__message {
  467. margin-bottom: 12rpx;
  468. }
  469. }
  470. .title {
  471. font-size: 30rpx;
  472. font-family: Microsoft YaHei;
  473. font-weight: 400;
  474. color: #000000;
  475. margin: 38rpx 0;
  476. }
  477. .from_item {
  478. display: flex;
  479. flex-wrap: nowrap;
  480. justify-content: space-between;
  481. align-items: center;
  482. height: 80rpx;
  483. border-bottom: 1rpx solid #dcdcdc;
  484. ::v-deep .input {
  485. text-align: right;
  486. flex: 1;
  487. input {
  488. text-align: right;
  489. }
  490. }
  491. }
  492. .from_item1 {
  493. display: flex;
  494. flex-wrap: nowrap;
  495. flex-direction: column;
  496. justify-content: space-between;
  497. padding: 30rpx;
  498. border-bottom: #dcdcdc 1px solid;
  499. input {
  500. text-align: right;
  501. }
  502. .textarea {
  503. background-color: #f1f1f1;
  504. width: 100%;
  505. border-radius: 20rpx;
  506. margin-top: 10rpx;
  507. text-indent: 1rem;
  508. height: 180rpx;
  509. padding: 20rpx;
  510. box-sizing: border-box;
  511. }
  512. }
  513. }
  514. .submit {
  515. height: 80rpx;
  516. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  517. border-radius: 40rpx;
  518. font-size: 32rpx;
  519. font-family: Microsoft YaHei;
  520. font-weight: 400;
  521. color: #ffffff;
  522. line-height: 80rpx;
  523. margin: 60rpx auto;
  524. }
  525. }
  526. .picture-wrapper {
  527. width: 92%;
  528. margin: 0 auto;
  529. margin-top: 40rpx;
  530. .bg {
  531. background: #ffffff;
  532. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  533. border-radius: 20rpx;
  534. padding: 40rpx;
  535. display: flex;
  536. justify-content: space-between;
  537. .name {
  538. font-size: 34rpx;
  539. font-family: Microsoft YaHei;
  540. font-weight: 400;
  541. color: #000000;
  542. line-height: 34rpx;
  543. }
  544. .value {
  545. margin-top: 20rpx;
  546. font-size: 24rpx;
  547. font-family: Microsoft YaHei;
  548. font-weight: 400;
  549. color: #999999;
  550. line-height: 24rpx;
  551. }
  552. .tip {
  553. margin-top: 20rpx;
  554. text-align: center;
  555. width: 110rpx;
  556. height: 40rpx;
  557. background: rgba(33, 190, 177, 0.2);
  558. border-radius: 6rpx;
  559. .tip-value {
  560. font-size: 20rpx;
  561. font-family: Microsoft YaHei;
  562. font-weight: 400;
  563. color: #0a8f8a;
  564. line-height: 40rpx;
  565. opacity: 1;
  566. }
  567. }
  568. }
  569. .icon {
  570. width: 294rpx;
  571. height: 188rpx;
  572. }
  573. }
  574. .list-item {
  575. width: 100%;
  576. border-radius: 10rpx;
  577. margin: 0 auto;
  578. font-size: 28rpx;
  579. border: 1rpx solid #ccc;
  580. padding: 20rpx;
  581. box-sizing: border-box;
  582. background-color: white;
  583. margin-bottom: 28rpx;
  584. display: flex;
  585. align-items: center;
  586. justify-content: space-between;
  587. }
  588. .message {
  589. font-size: 32rpx;
  590. margin: 40rpx 0 20rpx 0;
  591. font-weight: bold;
  592. }
  593. .change {
  594. // display: flex;
  595. // text-align: center;
  596. // justify-content: flex-end;
  597. // width: 100%;
  598. }
  599. // .change>view {
  600. // height: 60rpx;
  601. // background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  602. // border-radius: 40rpx;
  603. // font-size: 32rpx;
  604. // font-family: Microsoft YaHei;
  605. // color: #ffffff;
  606. // line-height: 60rpx;
  607. // width: 25%;
  608. // }
  609. .choice-takePhoto {
  610. position: absolute;
  611. bottom: 0;
  612. background-color: white;
  613. width: 100%;
  614. border-radius: 20rpx 20rpx 0 0;
  615. }
  616. .choice-takePhoto>view:first-child {
  617. text-align: center;
  618. height: 80rpx;
  619. line-height: 80rpx;
  620. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  621. background-color: white;
  622. }
  623. .choice-takePhoto>view:last-child {
  624. text-align: center;
  625. height: 80rpx;
  626. line-height: 80rpx;
  627. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  628. background-color: white;
  629. }
  630. .choice-takePhoto>view {
  631. text-align: center;
  632. height: 80rpx;
  633. line-height: 80rpx;
  634. background-color: white;
  635. }
  636. .choice-takePhoto-wrap {
  637. width: 100%;
  638. height: 100vh;
  639. background-color: rgba(127, 127, 127, 0.2);
  640. position: fixed;
  641. left: 0;
  642. top: 0;
  643. z-index: 11111;
  644. }
  645. </style>