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.

refund-order-balance.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <template>
  2. <view class="oderPage">
  3. <view v-if="state.list&&state.list.length>0" v-for="(item,index) in state.list" class="details">
  4. <view class="header">
  5. <image :src="`${$imgUrl}order/no1.png`" mode=""></image>
  6. <text>{{item.orderId}}</text>
  7. </view>
  8. <view class="hr">
  9. </view>
  10. <view class="row">
  11. <view class="">
  12. 订单车牌号:
  13. </view>
  14. <text>{{item.vehiclePlate}}</text>
  15. </view>
  16. <view class="row">
  17. <view class="">
  18. 旧卡号:
  19. </view>
  20. <text>{{item.cardId}}</text>
  21. </view>
  22. <view class="row">
  23. <view class="">
  24. 可退费金额:
  25. </view>
  26. <text>{{item.refundBalance / 100}}</text>
  27. </view>
  28. <view class="line">
  29. </view>
  30. <button v-if="item.refundType === 'WTJTF'">未提交退费</button>
  31. <button v-if="item.refundType === 'YTJTF'">已提交退费</button>
  32. <button v-if="item.refundType === 'GLYQR'" @click="refundTypeAction(item)"> 补领申请</button>
  33. <button v-if="item.refundType === 'YWCTF'">已完成退费</button>
  34. <button v-if="item.refundType === 'TFYDC'">已导出退费</button>
  35. <button v-if="item.refundType === 'ECHDTF'">二次核定退费</button>
  36. <button v-if="item.refundType === 'RFFL'">退费失败</button>
  37. <button v-if="item.refundType === 'ALRS'">已拒付</button>
  38. <button v-if="item.refundType === 'FJWQR'">附件未确认</button>
  39. <button v-if="item.refundType === 'WGZYQ'">未过争议期</button>
  40. <button v-if="item.refundType === 'REQUESTED'">已申请</button>
  41. <!-- <button v-if="item.refundType === 'BALSUP'">余额补领</button> -->
  42. <button v-if="item.refundType === 'BALSUP'" @click="refundTypeAction(item)"> 圈存</button>
  43. <button v-if="item.refundType === 'BALSUPCOS'"> 余额补领已圈存</button>
  44. </view>
  45. <view v-else>
  46. <empty title='暂无找到该车牌相关余额补领信息' />
  47. </view>
  48. </view>
  49. </template>
  50. <script setup lang="ts">
  51. import {
  52. reactive,
  53. ref
  54. } from "vue"
  55. import {
  56. navTo
  57. } from "@/utils/utils"
  58. import {
  59. onLoad,
  60. onUnload
  61. } from "@dcloudio/uni-app";
  62. import {
  63. queryRefund,
  64. queryRefundApply,
  65. quanApply,
  66. quanCheck,
  67. quanConfirm,
  68. quanXf
  69. } from "@/utils/network/api.js";
  70. import {
  71. request
  72. } from "@/utils/network/request.js";
  73. import {
  74. msg
  75. } from "@/utils/utils";
  76. import {
  77. stringToJson
  78. } from "@/utils/network/encryption";
  79. //-----蓝牙模块
  80. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  81. const cmd = require("../../../static/etcUtil/cmdConfig.js");
  82. const tools = require("../../../static/etcUtil/tools.js");
  83. const card = reactive({
  84. /*卡相关信息*/
  85. cardId: "",
  86. netId: "",
  87. cardType: "",
  88. startTime: "",
  89. endTime: "",
  90. userName: "",
  91. idNum: "",
  92. vehiclePlate: "",
  93. vehiclePlateColor: "",
  94. color: "",
  95. version: "",
  96. type: "",
  97. favourable: "",
  98. money: undefined,
  99. v_userType: "",
  100. });
  101. const state = reactive({
  102. vehicleId: '',
  103. list: [],
  104. id: '',//退费信息编号
  105. refundBalance: "",
  106. });
  107. /*视图进入后操作*/
  108. onLoad((option) => {
  109. state.vehicleId = option.vehicleId
  110. if (option.id) {
  111. state.id = option.id
  112. }
  113. if (option.refundBalance) {
  114. state.refundBalance = option.refundBalance
  115. }
  116. if (option.status) {
  117. queryRefundAction().then(val => {
  118. state.list = val.data
  119. getCardId()
  120. })
  121. } else {
  122. queryRefundAction().then(val => {
  123. state.list = val.data
  124. })
  125. }
  126. //根据车牌查询信息
  127. // queryRefundAction().then(val => {
  128. // state.list = val.data
  129. // })
  130. // /*监听蓝牙回调*/
  131. // uni.$on('bluetoothLink', function (status) {
  132. // getCardId()
  133. // })
  134. });
  135. onUnload(() => {
  136. /*移除监听*/
  137. uni.$off('bluetoothLink')
  138. });
  139. //功能跳转入口
  140. const refundTypeAction = (val : any) => {
  141. state.refundBalance = val.refundBalance
  142. if (val.refundType === 'GLYQR') {
  143. /*余额补领申请*/
  144. queryRefundApplyAction(val.orderId).then((value : any) => {
  145. state.id = value.id
  146. msg('圈存退费申请成功')
  147. /*查询完刷新状态*/
  148. queryRefundAction().then((result : any) => {
  149. state.list = result.data
  150. })
  151. })
  152. } else if (val.refundType === 'BALSUP') {
  153. /*圈存*/
  154. //链接蓝牙
  155. state.id = val.orderId
  156. uni.navigateTo({
  157. url: `/pages/bluetooth/bluetooth?routeType=5&&vehicleId=${state.vehicleId}&&difference=2&&id=${val.orderId}&&refundBalance=${val.refundBalance}`,
  158. });
  159. }
  160. }
  161. //储值卡注销退费查询接口
  162. const queryRefundAction = () => {
  163. var data = {
  164. vehicleId: state.vehicleId
  165. };
  166. const options = {
  167. type: 2,
  168. data: data,
  169. method: "POST",
  170. showLoading: true,
  171. };
  172. return new Promise(async (resolve, reject) => {
  173. const res = await request(queryRefund, options);
  174. const data = stringToJson(res.bizContent);
  175. console.log("储值卡注销退费查询接口", data)
  176. resolve(data);
  177. }).catch((error) => {
  178. reject(error);
  179. });
  180. }
  181. //储值卡注销余额补领申请接口
  182. const queryRefundApplyAction = (id) => {
  183. var data = {
  184. orderId: id
  185. };
  186. const options = {
  187. type: 2,
  188. data: data,
  189. method: "POST",
  190. showLoading: true,
  191. };
  192. return new Promise(async (resolve, reject) => {
  193. const res = await request(queryRefundApply, options);
  194. const data = stringToJson(res.bizContent);
  195. resolve(data);
  196. }).catch((error) => {
  197. reject(error);
  198. });
  199. }
  200. /*读卡*/
  201. const getCardId = () => {
  202. console.log("======获取卡信息======");
  203. let cmdArr = [
  204. cmd.HOME_DIRECTORY,
  205. //选择主目
  206. cmd.APPLICATION_DIRECTORY,
  207. //选择文件1001--DF01联网收费应用目录
  208. cmd.CMD_READBINARY,
  209. //15文件--卡片发行基本数据文件
  210. cmd.CMD_GETBALANCE,
  211. //钱包
  212. ];
  213. tools.showLoadingAlert("正在执行指令");
  214. //10:写卡 20:写OBU
  215. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  216. tools.hideLoadingAlert();
  217. let str = res[2].substring(res[2].length - 4, res[2].length);
  218. let str3 = res[3].substring(res[3].length - 4, res[3].length);
  219. if (str == "9000" || str3 == "9000") {
  220. if (res[2].length > 86 || res[3] >= 12) {
  221. card.cardId = res[2].substring(20, 40); //卡号
  222. card.startTime = res[2].substring(40, 48);
  223. card.endTime = res[2].substring(48, 56);
  224. card.version = res[2].substring(18, 19) >= 4 ? "4x" : "2x";
  225. card.netId = res[2].substring(20, 24);
  226. card.cardType = res[2].substring(28, 29) == 23 ? 1 : 2;
  227. card.vehiclePlateColor = parseInt(res[2].substring(82, 84), 16);
  228. (card.money = parseInt(parseInt(res[3].substring(0, 8), 16), 10)),
  229. console.log("======卡信息======", card);
  230. quanCheckActionTrue().then((val) => {
  231. checkQuanCengEvent(val);
  232. });
  233. } else {
  234. tools.hideLoadingAlert();
  235. }
  236. }
  237. tools.hideLoadingAlert();
  238. });
  239. };
  240. const checkQuanCengEvent = (val : any) => {
  241. console.log("val========", val)
  242. if (val.chargeStatus === 1) {
  243. let cmdArr = val.command.split(",");
  244. uni.showLoading({
  245. title: "写入中",
  246. });
  247. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  248. let response = res.toString();
  249. var dic = {
  250. command: val.command,
  251. cosResponse: response,
  252. };
  253. uni.hideLoading();
  254. quanApplyAction(dic).then((value) => {
  255. console.log("圈存申请完后的结果");
  256. console.log(value);
  257. //圈存初始化验证通过 , 进行圈存
  258. if (value.commandType === 2) {
  259. console.log("value============", value)
  260. uanConfirmAction(value)
  261. } else {
  262. // 一直写,写到成功为止
  263. let cmdArrTwo = value.command.split(",")
  264. bluetoothUtil.transCmd(cmdArrTwo, "10", function (res) {
  265. console.log(value);
  266. var valueResponse = res.toString();
  267. console.log(response);
  268. var applyDic = {
  269. command: value.command,
  270. cosResponse: valueResponse,
  271. rechargeId: value.rechargeId,
  272. };
  273. quanApplyAction(applyDic).then((applyValue) => {
  274. uanConfirmAction(applyValue)
  275. });
  276. })
  277. // msg("圈存初始化指令验证失败, 重新初始化");
  278. }
  279. });
  280. });
  281. } else {
  282. let cmdArr = val.command.split(",");
  283. uni.showLoading({
  284. title: "写入中",
  285. });
  286. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  287. var status = res[1].substring(res[1].length - 4, res[1].length);
  288. console.log("打印状态");
  289. console.log(status);
  290. if (status === "9000") {
  291. console.log("修复指令入参");
  292. let response = res.toString();
  293. var dic = {
  294. command: val.command,
  295. cosResponse: response,
  296. rechargeId: val.rechargeId,
  297. };
  298. quanFixAction(dic).then((value) => {
  299. console.log(value);
  300. console.log("修复结果返回");
  301. var fixStatus = value.fixStatus;
  302. //圈存修复COS指令Response信息不足,重新进行修复初始化
  303. if (fixStatus === 3) {
  304. let xfcmdArr = value.command.split(",");
  305. bluetoothUtil.transCmd(xfcmdArr, "10", function (resValueData) {
  306. var status = resValueData[1].substring(
  307. resValueData[1].length - 4,
  308. resValueData[1].length
  309. );
  310. console.log("打印状态");
  311. console.log(status);
  312. if (status === "9000") {
  313. console.log(resValueData);
  314. var valueResponse = resValueData.toString();
  315. console.log(response);
  316. var applyDic = {
  317. command: value.command,
  318. cosResponse: valueResponse,
  319. rechargeId: value.rechargeId,
  320. };
  321. console.log("消费成功");
  322. quanApplyAction(applyDic).then((applyValue) => {
  323. uanConfirmAction(value)
  324. });
  325. }
  326. });
  327. } else if (fixStatus === 2) {
  328. uanConfirmSucessAction(value).then((confirmResult) => {
  329. console.log("成功222222222222", confirmResult)
  330. navTo(
  331. `/subpackage/after-sale/refund-order-balance/result`)
  332. });
  333. } else if (fixStatus === 1) {
  334. quanCheckActionTrue().then((val) => {
  335. checkQuanCengEvent(val);
  336. });
  337. }
  338. });
  339. uni.hideLoading();
  340. }
  341. });
  342. }
  343. };
  344. const uanConfirmSucessAction = (data) => {
  345. var form = {
  346. command: data.command,
  347. cosResponse: "9000",
  348. rechargeId: data.rechargeId,
  349. paidAmount: data.fee,
  350. giftAmount: 0,
  351. };
  352. const options = {
  353. type: 2,
  354. data: form,
  355. method: "POST",
  356. showLoading: true,
  357. };
  358. return new Promise(async (resolve, reject) => {
  359. const res = await request(quanConfirm, options);
  360. const data = stringToJson(res.bizContent);
  361. resolve(data);
  362. }).catch((error) => {
  363. reject(error);
  364. });
  365. };
  366. const quanCheckActionTrue = () => {
  367. console.log("进行真实圈存检测");
  368. var data = {
  369. cardId: card.cardId,
  370. orderId: state.id,
  371. preBalance: card.money,
  372. fee: state.refundBalance,
  373. tradeType: 4,
  374. };
  375. const options = {
  376. type: 2,
  377. data: data,
  378. method: "POST",
  379. showLoading: true,
  380. };
  381. return new Promise(async (resolve, reject) => {
  382. const res = await request(quanCheck, options);
  383. const data = stringToJson(res.bizContent);
  384. resolve(data);
  385. }).catch((error) => {
  386. reject(error);
  387. });
  388. };
  389. /*圈存申请*/
  390. const quanApplyAction = (data) => {
  391. var form = {
  392. cardId: card.cardId,
  393. tradeType: 4,
  394. command: data.command,
  395. cosResponse: data.cosResponse,
  396. orderId: state.id,
  397. rechargeId: data.rechargeId,
  398. fee: state.refundBalance,
  399. preBalance: card.money,
  400. };
  401. const options = {
  402. type: 2,
  403. data: form,
  404. method: "POST",
  405. showLoading: true,
  406. };
  407. return new Promise(async (resolve, reject) => {
  408. console.log("70", options)
  409. const res = await request(quanApply, options);
  410. const data = stringToJson(res.bizContent);
  411. resolve(data);
  412. }).catch((error) => {
  413. reject(error);
  414. });
  415. };
  416. /*圈存确认*/
  417. const uanConfirmAction = (data) => {
  418. console.log("圈存确认进入", data);
  419. console.log("applyValue===========", data)
  420. let cmdArr = data.command.split(",");
  421. console.log(cmdArr);
  422. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  423. console.log("圈存透传");
  424. console.log(res);
  425. var arraylenth = res.length;
  426. var status = res[arraylenth - 1].substring(
  427. res[arraylenth - 1].length - 4,
  428. res[arraylenth - 1].length
  429. );
  430. console.log("打印圈存确认指令状态");
  431. console.log(status);
  432. if (status === "9000") {
  433. var form = {
  434. command: data.command,
  435. cosResponse: res.toString(),
  436. rechargeId: data.rechargeId,
  437. paidAmount: state.refundBalance,
  438. giftAmount: 0,
  439. };
  440. const options = {
  441. type: 2,
  442. data: form,
  443. method: "POST",
  444. showLoading: true,
  445. };
  446. request(quanConfirm, options).then((res) => {
  447. const result = stringToJson(res.bizContent);
  448. navTo(
  449. `/subpackage/after-sale/refund-order-balance/result`)
  450. });
  451. }
  452. });
  453. };
  454. /*圈存修复*/
  455. const quanFixAction = (val) => {
  456. var data = {
  457. command: val.command, //修复初始化的指令
  458. cosResponse: val.cosResponse, //修复初始化结果
  459. rechargeId: val.rechargeId, //充值流水号
  460. };
  461. const options = {
  462. type: 2,
  463. data: data,
  464. method: "POST",
  465. showLoading: true,
  466. };
  467. return new Promise(async (resolve, reject) => {
  468. const res = await request(quanXf, options);
  469. const data = stringToJson(res.bizContent);
  470. resolve(data);
  471. }).catch((error) => {
  472. reject(error);
  473. });
  474. };
  475. </script>
  476. <style>
  477. page {
  478. width: 100%;
  479. height: 100%;
  480. display: flex;
  481. flex-direction: column;
  482. background-color: #EEF7F7;
  483. box-sizing: border-box;
  484. }
  485. </style>
  486. <style lang="scss" scoped>
  487. .oderPage {
  488. .details {
  489. margin: 30rpx;
  490. position: relative;
  491. background: #fff;
  492. border-radius: 20rpx;
  493. padding: 30rpx;
  494. height: 370rpx;
  495. background: #FFFFFF;
  496. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  497. border-radius: 20rpx;
  498. .header {
  499. align-items: center;
  500. display: flex;
  501. padding-bottom: 30rpx;
  502. // border-bottom: 1px solid #DCDCDC;
  503. image {
  504. width: 51rpx;
  505. height: 31rpx;
  506. }
  507. text {
  508. font-size: 30rpx;
  509. margin-left: 20rpx;
  510. font-weight: 600;
  511. }
  512. }
  513. .hr {
  514. height: 1rpx;
  515. background: #DCDCDC;
  516. width: 100%;
  517. position: absolute;
  518. left: 50%;
  519. transform: translate(-50%);
  520. }
  521. .row {
  522. display: flex;
  523. margin: 34rpx 0;
  524. font-size: 26rpx;
  525. font-family: Noto Sans S Chinese;
  526. font-weight: 400;
  527. color: #333333;
  528. line-height: 30rpx;
  529. view {
  530. font-size: 26rpx;
  531. font-family: Noto Sans S Chinese;
  532. font-weight: 400;
  533. color: #999999;
  534. line-height: 30rpx;
  535. }
  536. }
  537. .line {
  538. width: 100%;
  539. height: 1rpx;
  540. background: #DCDCDC;
  541. }
  542. button {
  543. height: 61rpx;
  544. background: #FFFFFF;
  545. border: 1px solid #00B38B;
  546. border-radius: 30rpx;
  547. font-size: 26rpx;
  548. font-family: Noto Sans S Chinese;
  549. font-weight: 400;
  550. color: #00B38B;
  551. line-height: 32rpx;
  552. position: absolute;
  553. right: 30rpx;
  554. bottom: 20rpx;
  555. padding: 16rpx 28rpx;
  556. }
  557. }
  558. }
  559. </style>