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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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. console.log("圈存====", val)
  229. if (val.chargeStatus === 1) {
  230. let cmdArr = val.command.split(",");
  231. uni.showLoading({
  232. title: "写入中",
  233. });
  234. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  235. let response = res.toString();
  236. var dic = {
  237. command: val.command,
  238. cosResponse: response
  239. };
  240. uni.hideLoading();
  241. quanApplyAction(dic).then((value) => {
  242. console.log("圈存申请完后的结果");
  243. console.log(value);
  244. //圈存初始化验证通过 , 进行圈存
  245. if (value.commandType === 2) {
  246. uanConfirmAction(value)
  247. } else {
  248. // 一直写,写到成功为止
  249. let cmdArrTwo = value.command.split(",")
  250. bluetoothUtil.transCmd(cmdArrTwo, "10", function (res) {
  251. console.log(value);
  252. var valueResponse = res.toString();
  253. console.log(response);
  254. var applyDic = {
  255. command: value.command,
  256. cosResponse: valueResponse,
  257. rechargeId: value.rechargeId,
  258. };
  259. quanApplyAction(applyDic).then((applyValue) => {
  260. uanConfirmAction(applyValue)
  261. });
  262. })
  263. // msg("圈存初始化指令验证失败, 重新初始化");
  264. }
  265. });
  266. });
  267. } else {
  268. let cmdArr = val.command.split(",");
  269. uni.showLoading({
  270. title: "写入中",
  271. });
  272. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  273. var status = res[1].substring(res[1].length - 4, res[1].length);
  274. console.log("打印状态");
  275. console.log(status);
  276. if (status === "9000") {
  277. console.log("修复指令入参");
  278. let response = res.toString();
  279. var dic = {
  280. command: val.command,
  281. cosResponse: response,
  282. rechargeId: val.rechargeId,
  283. };
  284. quanFixAction(dic).then((value) => {
  285. console.log(value);
  286. console.log("修复结果返回");
  287. var fixStatus = value.fixStatus;
  288. //圈存修复COS指令Response信息不足,重新进行修复初始化
  289. if (fixStatus === 3) {
  290. let xfcmdArr = value.command.split(",");
  291. bluetoothUtil.transCmd(xfcmdArr, "10", function (resValueData) {
  292. var status = resValueData[1].substring(
  293. resValueData[1].length - 4,
  294. resValueData[1].length
  295. );
  296. console.log("打印状态");
  297. console.log(status);
  298. if (status === "9000") {
  299. console.log(resValueData);
  300. var valueResponse = resValueData.toString();
  301. console.log(response);
  302. var applyDic = {
  303. command: value.command,
  304. cosResponse: valueResponse,
  305. rechargeId: value.rechargeId,
  306. };
  307. console.log("消费成功");
  308. quanApplyAction(applyDic).then((applyValue) => {
  309. uanConfirmAction(value)
  310. });
  311. }
  312. });
  313. } else if (fixStatus === 2) {
  314. uanConfirmSucessAction(value).then((confirmResult) => {
  315. navTo(
  316. `/subpackage/orders/flowingWater-result`)
  317. });
  318. } else if (fixStatus === 1) {
  319. quanCheckActionTrue().then((val) => {
  320. checkQuanCengEvent(val);
  321. });
  322. }
  323. });
  324. uni.hideLoading();
  325. }
  326. });
  327. }
  328. };
  329. /*圈存申请*/
  330. const quanApplyAction = (data) => {
  331. var form = {
  332. cardId: card.cardId,
  333. tradeType: 5,
  334. command: data.command,
  335. cosResponse: data.cosResponse,
  336. orderId: state.id,
  337. rechargeId: data.rechargeId,
  338. fee: state.cardBalance,
  339. preBalance: card.money,
  340. };
  341. const options = {
  342. type: 2,
  343. data: form,
  344. method: "POST",
  345. showLoading: true,
  346. };
  347. return new Promise(async (resolve, reject) => {
  348. console.log("70", options)
  349. const res = await request(quanApply, options);
  350. const data = stringToJson(res.bizContent);
  351. resolve(data);
  352. }).catch((error) => {
  353. reject(error);
  354. });
  355. };
  356. /*圈存确认*/
  357. const uanConfirmAction = (data) => {
  358. console.log("圈存确认进入");
  359. let cmdArr = data.command.split(",");
  360. console.log(cmdArr);
  361. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  362. console.log("圈存透传");
  363. console.log(res);
  364. var arraylenth = res.length;
  365. var status = res[arraylenth - 1].substring(
  366. res[arraylenth - 1].length - 4,
  367. res[arraylenth - 1].length
  368. );
  369. console.log("打印圈存确认指令状态");
  370. console.log(status);
  371. if (status === "9000") {
  372. var form = {
  373. command: data.command,
  374. cosResponse: res.toString(),
  375. rechargeId: data.rechargeId,
  376. paidAmount: state.cardBalance,
  377. giftAmount: 0,
  378. };
  379. const options = {
  380. type: 2,
  381. data: form,
  382. method: "POST",
  383. showLoading: true,
  384. };
  385. request(quanConfirm, options).then((res) => {
  386. const result = stringToJson(res.bizContent);
  387. navTo(`/subpackage/orders/flowingWater-result`)
  388. });
  389. }
  390. });
  391. };
  392. const uanConfirmSucessAction = (data) => {
  393. var form = {
  394. command: data.command,
  395. cosResponse: "9000",
  396. rechargeId: data.rechargeId,
  397. paidAmount: data.fee,
  398. giftAmount: 0,
  399. };
  400. const options = {
  401. type: 2,
  402. data: form,
  403. method: "POST",
  404. showLoading: true,
  405. };
  406. return new Promise(async (resolve, reject) => {
  407. const res = await request(quanConfirm, options);
  408. const data = stringToJson(res.bizContent);
  409. resolve(data);
  410. }).catch((error) => {
  411. reject(error);
  412. });
  413. };
  414. /*圈存修复*/
  415. const quanFixAction = (val) => {
  416. var data = {
  417. command: val.command, //修复初始化的指令
  418. cosResponse: val.cosResponse, //修复初始化结果
  419. rechargeId: val.rechargeId, //充值流水号
  420. };
  421. const options = {
  422. type: 2,
  423. data: data,
  424. method: "POST",
  425. showLoading: true,
  426. };
  427. return new Promise(async (resolve, reject) => {
  428. const res = await request(quanXf, options);
  429. const data = stringToJson(res.bizContent);
  430. resolve(data);
  431. }).catch((error) => {
  432. reject(error);
  433. });
  434. };
  435. </script>
  436. <style lang="scss" scoped>
  437. .no {
  438. text-align: center;
  439. font-size: 32rpx;
  440. margin: 20rpx auto;
  441. }
  442. .bg-color {
  443. position: fixed;
  444. top: 0;
  445. left: 0;
  446. right: 0;
  447. bottom: 0;
  448. background: #EEF7F7;
  449. z-index: -1;
  450. }
  451. .search-box {
  452. margin: 30rpx 30rpx 20rpx 30rpx;
  453. height: 72rpx;
  454. height: 81rpx;
  455. background: #FFFFFF;
  456. border: 1px solid #DCDCDC;
  457. border-radius: 40rpx;
  458. display: flex;
  459. justify-content: center;
  460. align-items: center;
  461. box-sizing: border-box;
  462. }
  463. .search-box .icon {
  464. width: 48rpx;
  465. height: 48rpx;
  466. margin: 0 20rpx;
  467. }
  468. .search-box .search {
  469. flex: 1;
  470. margin-right: 20rpx;
  471. height: 100%;
  472. padding: 0 10rpx;
  473. font-size: 28rpx;
  474. color: #00b38b;
  475. }
  476. .scroll-view {
  477. white-space: nowrap;
  478. position: sticky;
  479. top: 0;
  480. background: #ffffff;
  481. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  482. }
  483. .search-time {
  484. // width: 100%;
  485. display: flex;
  486. padding: 10rpx 30rpx 30rpx;
  487. .search-time-box {
  488. flex: 1;
  489. }
  490. .time-btn {
  491. width: 130rpx;
  492. height: 80rpx;
  493. background: #00B38B;
  494. border-radius: 40rpx;
  495. color: #FFFFFF;
  496. font-size: 32rpx;
  497. line-height: 80rpx;
  498. text-align: center;
  499. margin-left: 20rpx;
  500. }
  501. .show-info {
  502. // width: 541rpx;
  503. width: 85%;
  504. height: 81rpx;
  505. padding: 0 31rpx;
  506. background: #FFFFFF;
  507. border: 1px solid #DCDCDC;
  508. border-radius: 40rpx;
  509. display: flex;
  510. justify-content: space-between;
  511. align-items: center;
  512. .show-text {
  513. display: flex;
  514. align-items: center;
  515. }
  516. .date-text {
  517. color: #999999;
  518. font-size: 28rpx;
  519. }
  520. .text-val {
  521. color: #333
  522. }
  523. .line {
  524. width: 25rpx;
  525. height: 1rpx;
  526. background: #999999;
  527. margin: 0 24rpx;
  528. }
  529. }
  530. }
  531. .total-num {
  532. font-size: 28rpx;
  533. color: #999999;
  534. margin-left: 30rpx;
  535. }
  536. .list-wrap {
  537. margin: 30rpx;
  538. padding-bottom: 20rpx;
  539. }
  540. .card-info {
  541. background: #FFFFFF;
  542. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  543. border-radius: 20rpx;
  544. margin-bottom: 30rpx;
  545. padding: 30rpx 30px 13rpx 30rpx;
  546. .info-wrap {
  547. display: flex;
  548. justify-content: space-between;
  549. align-items: center;
  550. border-bottom: 1px solid #dcdcdc;
  551. padding-bottom: 30rpx;
  552. .info-left-text {
  553. margin-bottom: 20rpx;
  554. }
  555. .label {
  556. color: #999999;
  557. font-size: 26rpx;
  558. font-weight: 400;
  559. }
  560. .val {
  561. color: #333333;
  562. font-size: 26rpx;
  563. font-weight: 400;
  564. }
  565. .price-label {
  566. color: #999999;
  567. font-size: 24rpx;
  568. font-weight: 400;
  569. margin-bottom: 22rpx;
  570. text-align: center;
  571. }
  572. .price-val-text {
  573. font-size: 36rpx;
  574. font-weight: 700;
  575. color: #333333;
  576. margin-left: 9rpx;
  577. }
  578. .price-val {
  579. font-size: 26rpx;
  580. color: #333333;
  581. }
  582. }
  583. .card-text-wrap {
  584. display: flex;
  585. justify-content: space-between;
  586. align-items: center;
  587. margin: 38rpx 0 46rpx 0;
  588. .text-box {
  589. display: flex;
  590. flex-direction: column;
  591. align-items: center;
  592. .name-text {
  593. font-size: 30rpx;
  594. font-weight: 400;
  595. color: #333333;
  596. }
  597. .time-text {
  598. font-size: 30rpx;
  599. color: #333333;
  600. font-weight: 400;
  601. margin-top: 8rpx;
  602. }
  603. .date-text {
  604. font-size: 24rpx;
  605. color: #999999;
  606. font-weight: 400;
  607. margin-top: 8rpx;
  608. }
  609. }
  610. .arrow-wrap {
  611. display: flex;
  612. flex-direction: column;
  613. align-items: center;
  614. .d-img {
  615. width: 186rpx;
  616. height: 12rpx;
  617. }
  618. .arrow-text {
  619. color: #666666;
  620. font-size: 26rpx;
  621. }
  622. }
  623. }
  624. .btn-wrap {
  625. margin-top: 30rpx;
  626. display: flex;
  627. justify-content: space-between;
  628. align-items: center;
  629. .status-wrap {
  630. color: #999999;
  631. font-size: 26rpx;
  632. margin-right: 23rpx;
  633. }
  634. .status-text {
  635. color: #00B38B;
  636. }
  637. .btn {
  638. background: #FFFFFF;
  639. border: 1px solid #00B38B;
  640. border-radius: 30rpx;
  641. line-height: 50rpx;
  642. text-align: center;
  643. color: #00B38B;
  644. font-size: 26rpx;
  645. }
  646. .btn-1 {
  647. width: 140rpx;
  648. height: 50rpx;
  649. }
  650. .btn-2 {
  651. width: 141rpx;
  652. height: 50rpx;
  653. }
  654. .btn-3 {
  655. width: 121rpx;
  656. height: 50rpx;
  657. }
  658. }
  659. }
  660. </style>