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.

flowingWater.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <template>
  2. <view class="wrapper" v-if="state.haveData">
  3. <!-- 背景颜色充满屏 -->
  4. <view class="bg-color"></view>
  5. <!-- 补卡额订单列表-->
  6. <view class="list-wrap">
  7. <view class="card-info" v-for="(item,index) in state.list" :key="item.id">
  8. <view class="info-wrap">
  9. <view class="info-left">
  10. <view class="info-left-text">
  11. <text class="label">车牌号:</text>
  12. <text class="val">{{item.vehiclePlate}}</text>
  13. </view>
  14. <view>
  15. <text class="label">ETC卡号:</text>
  16. <text class="val">{{item.cardId}}</text>
  17. </view>
  18. </view>
  19. <view class="info-right">
  20. <view class="price-label">
  21. 交易金额
  22. </view>
  23. <view class="price-val">
  24. <u-icon name="rmb"></u-icon>
  25. <text class="price-val-text">{{item.cardBalance/100}}</text>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="btn-wrap">
  30. <view>
  31. <text v-if="item.status === 1" class="status-wrap">审核进度:<text>已进行</text></text>
  32. <text v-if="item.status === 2" class="status-wrap">审核进度:<text
  33. class="status-text">未进行</text></text>
  34. <text v-if="item.status === -1" class="status-wrap">审核进度:<text>驳回</text></text>
  35. <text v-if="item.status === 3" class="status-wrap">审核进度:<text>待审核</text></text>
  36. </view>
  37. <view class="btn-1 btn" v-if="item.status === 2" @click="refundTypeAction(item)">圈存</view>
  38. <!-- <view class="btn-1 btn" v-if="item.status === 1" @click="toApply(item)">补卡额申请</view>
  39. <view class="btn-1 btn" v-if="item.status === 2" @click="toView(item)">查看进度</view>
  40. <view class="btn-1 btn" v-if="item.status === 3" @click="toEvaluate(item)">去评价</view> -->
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="no" v-if="state.list.length==0">暂无补卡额圈存数据</view>
  46. </template>
  47. <script lang="ts" setup>
  48. import { reactive, ref } from "vue";
  49. import { onLoad, onUnload } from "@dcloudio/uni-app";
  50. import { request } from "@/utils/network/request.js";
  51. import { queryCardLimit, quanCheck, quanApply, quanConfirm, quanXf } from "@/utils/network/api";
  52. import { stringToJson } from "@/utils/network/encryption";
  53. import { msg } from "@/utils/utils";
  54. const cmd = require("../../static/etcUtil/cmdConfig.js");
  55. const tools = require("../../static/etcUtil/tools.js");
  56. const bluetoothUtil = require("../../static/etcUtil/index.js");
  57. import { navTo } from "@/utils/utils"
  58. const card = reactive({
  59. /*卡相关信息*/
  60. cardId: "",
  61. netId: "",
  62. cardType: "",
  63. startTime: "",
  64. endTime: "",
  65. userName: "",
  66. idNum: "",
  67. vehiclePlate: "",
  68. vehiclePlateColor: "",
  69. color: "",
  70. version: "",
  71. type: "",
  72. favourable: "",
  73. money: undefined,
  74. v_userType: "",
  75. });
  76. const show = ref(false);
  77. const dataTime = reactive({
  78. startDate: "",
  79. endDate: ""
  80. })
  81. const state = reactive({
  82. vehicleId: "",//车牌号
  83. id: "",
  84. list: [],
  85. cardBalance: "",
  86. haveData: false, //是否有数据
  87. refundBalance: "",
  88. })
  89. const listData = reactive(null)
  90. onLoad((options) => {
  91. state.vehicleId = options.vehicleId
  92. //根据车牌查询信息.data
  93. queryRefundAction().then(val => {
  94. console.log("val", val)
  95. if (val.data) {
  96. state.list = val.data
  97. state.haveData = true
  98. }
  99. })
  100. /*监听蓝牙回调*/
  101. uni.$on('bluetoothLink', function (status) {
  102. getCardId()
  103. })
  104. });
  105. onUnload(() => {
  106. /*移除监听*/
  107. uni.$off('bluetoothLink')
  108. });
  109. // 补卡额列表查询接口
  110. const queryRefundAction = () => {
  111. const options = {
  112. type: 2,
  113. data: {
  114. "vehicleId": state.vehicleId,
  115. "systemType": "WX"
  116. },
  117. method: "POST",
  118. showLoading: true,
  119. };
  120. return new Promise(async (resolve, reject) => {
  121. const res = await request(queryCardLimit, options);
  122. const data = stringToJson(res.bizContent);
  123. console.log("储值卡注销退费查询接口", data)
  124. resolve(data);
  125. }).catch((error) => {
  126. reject(error);
  127. });
  128. };
  129. // 日期修改
  130. function changeHandle(e) {
  131. dataTime.startDate = e.startDate;
  132. dataTime.endDate = e.endDate;
  133. }
  134. // 补卡申请
  135. function toApply(item) {
  136. uni.navigateTo({
  137. url: `/subpackage/orders/cardAmount?id=${item.id}`
  138. });
  139. }
  140. // 去评价
  141. function toEvaluate(item) {
  142. uni.navigateTo({
  143. url: `/subpackage/orders/order-evaluate?id=${item.id}`
  144. });
  145. }
  146. // 查看进度
  147. function toView(item) {
  148. uni.navigateTo({
  149. url: `/subpackage/orders/cardAmountDetail?id=${item.id}`
  150. });
  151. }
  152. // 去圈存
  153. //功能跳转入口
  154. const refundTypeAction = (val : any) => {
  155. /*圈存*/
  156. //链接蓝牙
  157. console.log("val.id", val.id)
  158. state.id = val.id;
  159. state.cardBalance = val.cardBalance
  160. uni.navigateTo({
  161. url: `/pages/bluetooth/bluetooth?routeType=5`,
  162. });
  163. }
  164. /*读卡*/
  165. const getCardId = () => {
  166. console.log("======获取卡信息======");
  167. let cmdArr = [
  168. cmd.HOME_DIRECTORY,
  169. //选择主目
  170. cmd.APPLICATION_DIRECTORY,
  171. //选择文件1001--DF01联网收费应用目录
  172. cmd.CMD_READBINARY,
  173. //15文件--卡片发行基本数据文件
  174. cmd.CMD_GETBALANCE,
  175. //钱包
  176. ];
  177. tools.showLoadingAlert("正在执行指令");
  178. //10:写卡 20:写OBU
  179. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  180. tools.hideLoadingAlert();
  181. let str = res[2].substring(res[2].length - 4, res[2].length);
  182. let str3 = res[3].substring(res[3].length - 4, res[3].length);
  183. if (str == "9000" || str3 == "9000") {
  184. if (res[2].length > 86 || res[3] >= 12) {
  185. card.cardId = res[2].substring(20, 40); //卡号
  186. card.startTime = res[2].substring(40, 48);
  187. card.endTime = res[2].substring(48, 56);
  188. card.version = res[2].substring(18, 19) >= 4 ? "4x" : "2x";
  189. card.netId = res[2].substring(20, 24);
  190. card.cardType = res[2].substring(28, 29) == 23 ? 1 : 2;
  191. card.vehiclePlateColor = parseInt(res[2].substring(82, 84), 16);
  192. (card.money = parseInt(parseInt(res[3].substring(0, 8), 16), 10)),
  193. console.log("======卡信息======", card);
  194. quanCheckActionTrue().then((val) => {
  195. checkQuanCengEvent(val);
  196. });
  197. } else {
  198. tools.hideLoadingAlert();
  199. }
  200. }
  201. tools.hideLoadingAlert();
  202. });
  203. };
  204. const quanCheckActionTrue = () => {
  205. console.log("进行真实圈存检测");
  206. var data = {
  207. cardId: card.cardId,
  208. orderId: state.id,
  209. preBalance: card.money,
  210. fee: state.cardBalance,
  211. tradeType: 5,
  212. };
  213. const options = {
  214. type: 2,
  215. data: data,
  216. method: "POST",
  217. showLoading: true,
  218. };
  219. return new Promise(async (resolve, reject) => {
  220. const res = await request(quanCheck, options);
  221. const data = stringToJson(res.bizContent);
  222. resolve(data);
  223. }).catch((error) => {
  224. reject(error);
  225. });
  226. };
  227. const checkQuanCengEvent = (val : any) => {
  228. if (val.chargeStatus === 1) {
  229. let cmdArr = val.command.split(",");
  230. uni.showLoading({
  231. title: "写入中",
  232. });
  233. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  234. let response = res.toString();
  235. var dic = {
  236. command: val.command,
  237. cosResponse: response,
  238. };
  239. uni.hideLoading();
  240. quanApplyAction(dic).then((value) => {
  241. console.log("圈存申请完后的结果");
  242. console.log(value);
  243. //圈存初始化验证通过 , 进行圈存
  244. if (value.commandType === 2) {
  245. uanConfirmAction(value)
  246. } else {
  247. msg("圈存初始化指令验证失败, 重新初始化");
  248. }
  249. });
  250. });
  251. } else {
  252. let cmdArr = val.command.split(",");
  253. uni.showLoading({
  254. title: "写入中",
  255. });
  256. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  257. var status = res[1].substring(res[1].length - 4, res[1].length);
  258. console.log("打印状态");
  259. console.log(status);
  260. if (status === "9000") {
  261. console.log("修复指令入参");
  262. let response = res.toString();
  263. var dic = {
  264. command: val.command,
  265. cosResponse: response,
  266. rechargeId: val.rechargeId,
  267. };
  268. quanFixAction(dic).then((value) => {
  269. console.log(value);
  270. console.log("修复结果返回");
  271. var fixStatus = value.fixStatus;
  272. //圈存修复COS指令Response信息不足,重新进行修复初始化
  273. if (fixStatus === 3) {
  274. let xfcmdArr = value.command.split(",");
  275. bluetoothUtil.transCmd(xfcmdArr, "10", function (resValueData) {
  276. var status = resValueData[1].substring(
  277. resValueData[1].length - 4,
  278. resValueData[1].length
  279. );
  280. console.log("打印状态");
  281. console.log(status);
  282. if (status === "9000") {
  283. console.log(resValueData);
  284. var valueResponse = resValueData.toString();
  285. console.log(response);
  286. var applyDic = {
  287. command: value.command,
  288. cosResponse: valueResponse,
  289. rechargeId: value.rechargeId,
  290. };
  291. console.log("消费成功");
  292. quanApplyAction(applyDic).then((applyValue) => {
  293. uanConfirmAction(value)
  294. });
  295. }
  296. });
  297. } else if (fixStatus === 2) {
  298. uanConfirmSucessAction(value).then((confirmResult) => {
  299. navTo(
  300. `/subpackage/orders/flowingWater-result`)
  301. });
  302. } else if (fixStatus === 1) {
  303. quanCheckActionTrue().then((val) => {
  304. checkQuanCengEvent(val);
  305. });
  306. }
  307. });
  308. uni.hideLoading();
  309. }
  310. });
  311. }
  312. };
  313. /*圈存申请*/
  314. const quanApplyAction = (data) => {
  315. var form = {
  316. cardId: card.cardId,
  317. tradeType: 5,
  318. command: data.command,
  319. cosResponse: data.cosResponse,
  320. orderId: state.id,
  321. rechargeId: data.rechargeId,
  322. fee: state.cardBalance,
  323. preBalance: card.money,
  324. };
  325. const options = {
  326. type: 2,
  327. data: form,
  328. method: "POST",
  329. showLoading: true,
  330. };
  331. return new Promise(async (resolve, reject) => {
  332. console.log("70", options)
  333. const res = await request(quanApply, options);
  334. const data = stringToJson(res.bizContent);
  335. resolve(data);
  336. }).catch((error) => {
  337. reject(error);
  338. });
  339. };
  340. /*圈存确认*/
  341. const uanConfirmAction = (data) => {
  342. console.log("圈存确认进入");
  343. let cmdArr = data.command.split(",");
  344. console.log(cmdArr);
  345. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  346. console.log("圈存透传");
  347. console.log(res);
  348. var arraylenth = res.length;
  349. var status = res[arraylenth - 1].substring(
  350. res[arraylenth - 1].length - 4,
  351. res[arraylenth - 1].length
  352. );
  353. console.log("打印圈存确认指令状态");
  354. console.log(status);
  355. if (status === "9000") {
  356. var form = {
  357. command: data.command,
  358. cosResponse: res.toString(),
  359. rechargeId: data.rechargeId,
  360. paidAmount: state.cardBalance,
  361. giftAmount: 0,
  362. };
  363. const options = {
  364. type: 2,
  365. data: form,
  366. method: "POST",
  367. showLoading: true,
  368. };
  369. request(quanConfirm, options).then((res) => {
  370. const result = stringToJson(res.bizContent);
  371. navTo(`/subpackage/orders/flowingWater-result`)
  372. });
  373. }
  374. });
  375. };
  376. const uanConfirmSucessAction = (data) => {
  377. var form = {
  378. command: data.command,
  379. cosResponse: "9000",
  380. rechargeId: data.rechargeId,
  381. paidAmount: data.fee,
  382. giftAmount: 0,
  383. };
  384. const options = {
  385. type: 2,
  386. data: form,
  387. method: "POST",
  388. showLoading: true,
  389. };
  390. return new Promise(async (resolve, reject) => {
  391. const res = await request(quanConfirm, options);
  392. const data = stringToJson(res.bizContent);
  393. resolve(data);
  394. }).catch((error) => {
  395. reject(error);
  396. });
  397. };
  398. /*圈存修复*/
  399. const quanFixAction = (val) => {
  400. var data = {
  401. command: val.command, //修复初始化的指令
  402. cosResponse: val.cosResponse, //修复初始化结果
  403. rechargeId: val.rechargeId, //充值流水号
  404. };
  405. const options = {
  406. type: 2,
  407. data: data,
  408. method: "POST",
  409. showLoading: true,
  410. };
  411. return new Promise(async (resolve, reject) => {
  412. const res = await request(quanXf, options);
  413. const data = stringToJson(res.bizContent);
  414. resolve(data);
  415. }).catch((error) => {
  416. reject(error);
  417. });
  418. };
  419. </script>
  420. <style lang="scss" scoped>
  421. .no {
  422. text-align: center;
  423. font-size: 32rpx;
  424. margin: 20rpx auto;
  425. }
  426. .bg-color {
  427. position: fixed;
  428. top: 0;
  429. left: 0;
  430. right: 0;
  431. bottom: 0;
  432. background: #EEF7F7;
  433. z-index: -1;
  434. }
  435. .search-box {
  436. margin: 30rpx 30rpx 20rpx 30rpx;
  437. height: 72rpx;
  438. height: 81rpx;
  439. background: #FFFFFF;
  440. border: 1px solid #DCDCDC;
  441. border-radius: 40rpx;
  442. display: flex;
  443. justify-content: center;
  444. align-items: center;
  445. box-sizing: border-box;
  446. }
  447. .search-box .icon {
  448. width: 48rpx;
  449. height: 48rpx;
  450. margin: 0 20rpx;
  451. }
  452. .search-box .search {
  453. flex: 1;
  454. margin-right: 20rpx;
  455. height: 100%;
  456. padding: 0 10rpx;
  457. font-size: 28rpx;
  458. color: #00b38b;
  459. }
  460. .scroll-view {
  461. white-space: nowrap;
  462. position: sticky;
  463. top: 0;
  464. background: #ffffff;
  465. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  466. }
  467. .search-time {
  468. // width: 100%;
  469. display: flex;
  470. padding: 10rpx 30rpx 30rpx;
  471. .search-time-box {
  472. flex: 1;
  473. }
  474. .time-btn {
  475. width: 130rpx;
  476. height: 80rpx;
  477. background: #00B38B;
  478. border-radius: 40rpx;
  479. color: #FFFFFF;
  480. font-size: 32rpx;
  481. line-height: 80rpx;
  482. text-align: center;
  483. margin-left: 20rpx;
  484. }
  485. .show-info {
  486. // width: 541rpx;
  487. width: 85%;
  488. height: 81rpx;
  489. padding: 0 31rpx;
  490. background: #FFFFFF;
  491. border: 1px solid #DCDCDC;
  492. border-radius: 40rpx;
  493. display: flex;
  494. justify-content: space-between;
  495. align-items: center;
  496. .show-text {
  497. display: flex;
  498. align-items: center;
  499. }
  500. .date-text {
  501. color: #999999;
  502. font-size: 28rpx;
  503. }
  504. .text-val {
  505. color: #333
  506. }
  507. .line {
  508. width: 25rpx;
  509. height: 1rpx;
  510. background: #999999;
  511. margin: 0 24rpx;
  512. }
  513. }
  514. }
  515. .total-num {
  516. font-size: 28rpx;
  517. color: #999999;
  518. margin-left: 30rpx;
  519. }
  520. .list-wrap {
  521. margin: 30rpx;
  522. padding-bottom: 20rpx;
  523. }
  524. .card-info {
  525. background: #FFFFFF;
  526. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  527. border-radius: 20rpx;
  528. margin-bottom: 30rpx;
  529. padding: 30rpx 30px 13rpx 30rpx;
  530. .info-wrap {
  531. display: flex;
  532. justify-content: space-between;
  533. align-items: center;
  534. border-bottom: 1px solid #dcdcdc;
  535. padding-bottom: 30rpx;
  536. .info-left-text {
  537. margin-bottom: 20rpx;
  538. }
  539. .label {
  540. color: #999999;
  541. font-size: 26rpx;
  542. font-weight: 400;
  543. }
  544. .val {
  545. color: #333333;
  546. font-size: 26rpx;
  547. font-weight: 400;
  548. }
  549. .price-label {
  550. color: #999999;
  551. font-size: 24rpx;
  552. font-weight: 400;
  553. margin-bottom: 22rpx;
  554. text-align: center;
  555. }
  556. .price-val-text {
  557. font-size: 36rpx;
  558. font-weight: 700;
  559. color: #333333;
  560. margin-left: 9rpx;
  561. }
  562. .price-val {
  563. font-size: 26rpx;
  564. color: #333333;
  565. }
  566. }
  567. .card-text-wrap {
  568. display: flex;
  569. justify-content: space-between;
  570. align-items: center;
  571. margin: 38rpx 0 46rpx 0;
  572. .text-box {
  573. display: flex;
  574. flex-direction: column;
  575. align-items: center;
  576. .name-text {
  577. font-size: 30rpx;
  578. font-weight: 400;
  579. color: #333333;
  580. }
  581. .time-text {
  582. font-size: 30rpx;
  583. color: #333333;
  584. font-weight: 400;
  585. margin-top: 8rpx;
  586. }
  587. .date-text {
  588. font-size: 24rpx;
  589. color: #999999;
  590. font-weight: 400;
  591. margin-top: 8rpx;
  592. }
  593. }
  594. .arrow-wrap {
  595. display: flex;
  596. flex-direction: column;
  597. align-items: center;
  598. .d-img {
  599. width: 186rpx;
  600. height: 12rpx;
  601. }
  602. .arrow-text {
  603. color: #666666;
  604. font-size: 26rpx;
  605. }
  606. }
  607. }
  608. .btn-wrap {
  609. margin-top: 30rpx;
  610. display: flex;
  611. justify-content: space-between;
  612. align-items: center;
  613. .status-wrap {
  614. color: #999999;
  615. font-size: 26rpx;
  616. margin-right: 23rpx;
  617. }
  618. .status-text {
  619. color: #00B38B;
  620. }
  621. .btn {
  622. background: #FFFFFF;
  623. border: 1px solid #00B38B;
  624. border-radius: 30rpx;
  625. line-height: 50rpx;
  626. text-align: center;
  627. color: #00B38B;
  628. font-size: 26rpx;
  629. }
  630. .btn-1 {
  631. width: 140rpx;
  632. height: 50rpx;
  633. }
  634. .btn-2 {
  635. width: 141rpx;
  636. height: 50rpx;
  637. }
  638. .btn-3 {
  639. width: 121rpx;
  640. height: 50rpx;
  641. }
  642. }
  643. }
  644. </style>