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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  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. //根据车牌查询信息
  111. queryRefundAction().then(val => {
  112. state.list = val.data
  113. })
  114. /*监听蓝牙回调*/
  115. uni.$on('bluetoothLink', function (status) {
  116. getCardId()
  117. })
  118. });
  119. onUnload(() => {
  120. /*移除监听*/
  121. uni.$off('bluetoothLink')
  122. });
  123. //功能跳转入口
  124. const refundTypeAction = (val : any) => {
  125. state.refundBalance = val.refundBalance
  126. if (val.refundType === 'GLYQR') {
  127. /*余额补领申请*/
  128. queryRefundApplyAction(val.orderId).then((value : any) => {
  129. state.id = value.id
  130. msg('圈存退费申请成功')
  131. /*查询完刷新状态*/
  132. queryRefundAction().then((result : any) => {
  133. state.list = result.data
  134. })
  135. })
  136. } else if (val.refundType === 'BALSUP') {
  137. /*圈存*/
  138. //链接蓝牙
  139. state.id = val.orderId
  140. uni.navigateTo({
  141. url: `/pages/bluetooth/bluetooth?routeType=5`,
  142. });
  143. }
  144. }
  145. //储值卡注销退费查询接口
  146. const queryRefundAction = () => {
  147. var data = {
  148. vehicleId: state.vehicleId
  149. };
  150. const options = {
  151. type: 2,
  152. data: data,
  153. method: "POST",
  154. showLoading: true,
  155. };
  156. return new Promise(async (resolve, reject) => {
  157. const res = await request(queryRefund, options);
  158. const data = stringToJson(res.bizContent);
  159. console.log("储值卡注销退费查询接口", data)
  160. resolve(data);
  161. }).catch((error) => {
  162. reject(error);
  163. });
  164. }
  165. //储值卡注销余额补领申请接口
  166. const queryRefundApplyAction = (id) => {
  167. var data = {
  168. orderId: id
  169. };
  170. const options = {
  171. type: 2,
  172. data: data,
  173. method: "POST",
  174. showLoading: true,
  175. };
  176. return new Promise(async (resolve, reject) => {
  177. const res = await request(queryRefundApply, options);
  178. const data = stringToJson(res.bizContent);
  179. resolve(data);
  180. }).catch((error) => {
  181. reject(error);
  182. });
  183. }
  184. /*读卡*/
  185. const getCardId = () => {
  186. console.log("======获取卡信息======");
  187. let cmdArr = [
  188. cmd.HOME_DIRECTORY,
  189. //选择主目
  190. cmd.APPLICATION_DIRECTORY,
  191. //选择文件1001--DF01联网收费应用目录
  192. cmd.CMD_READBINARY,
  193. //15文件--卡片发行基本数据文件
  194. cmd.CMD_GETBALANCE,
  195. //钱包
  196. ];
  197. tools.showLoadingAlert("正在执行指令");
  198. //10:写卡 20:写OBU
  199. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  200. tools.hideLoadingAlert();
  201. let str = res[2].substring(res[2].length - 4, res[2].length);
  202. let str3 = res[3].substring(res[3].length - 4, res[3].length);
  203. if (str == "9000" || str3 == "9000") {
  204. if (res[2].length > 86 || res[3] >= 12) {
  205. card.cardId = res[2].substring(20, 40); //卡号
  206. card.startTime = res[2].substring(40, 48);
  207. card.endTime = res[2].substring(48, 56);
  208. card.version = res[2].substring(18, 19) >= 4 ? "4x" : "2x";
  209. card.netId = res[2].substring(20, 24);
  210. card.cardType = res[2].substring(28, 29) == 23 ? 1 : 2;
  211. card.vehiclePlateColor = parseInt(res[2].substring(82, 84), 16);
  212. (card.money = parseInt(parseInt(res[3].substring(0, 8), 16), 10)),
  213. console.log("======卡信息======", card);
  214. quanCheckActionTrue().then((val) => {
  215. checkQuanCengEvent(val);
  216. });
  217. } else {
  218. console.error("CMD_READBINARY指令长度不符" + res[2]);
  219. tools.hideLoadingAlert();
  220. }
  221. }
  222. tools.hideLoadingAlert();
  223. });
  224. };
  225. const checkQuanCengEvent = (val : any) => {
  226. console.log("val========", val)
  227. if (val.chargeStatus === 1) {
  228. let cmdArr = val.command.split(",");
  229. uni.showLoading({
  230. title: "写入中",
  231. });
  232. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  233. let response = res.toString();
  234. var dic = {
  235. command: val.command,
  236. cosResponse: response,
  237. };
  238. uni.hideLoading();
  239. quanApplyAction(dic).then((value) => {
  240. console.log("圈存申请完后的结果");
  241. console.log(value);
  242. //圈存初始化验证通过 , 进行圈存
  243. if (value.commandType === 2) {
  244. console.log("value============", value)
  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. console.log("成功222222222222", confirmResult)
  300. navTo(
  301. `/subpackage/after-sale/refund-order-balance/result`)
  302. });
  303. } else if (fixStatus === 1) {
  304. quanCheckActionTrue().then((val) => {
  305. checkQuanCengEvent(val);
  306. });
  307. }
  308. });
  309. uni.hideLoading();
  310. }
  311. });
  312. }
  313. };
  314. const uanConfirmSucessAction = (data) => {
  315. var form = {
  316. command: data.command,
  317. cosResponse: "9000",
  318. rechargeId: data.rechargeId,
  319. paidAmount: data.fee,
  320. giftAmount: 0,
  321. };
  322. const options = {
  323. type: 2,
  324. data: form,
  325. method: "POST",
  326. showLoading: true,
  327. };
  328. return new Promise(async (resolve, reject) => {
  329. const res = await request(quanConfirm, options);
  330. const data = stringToJson(res.bizContent);
  331. resolve(data);
  332. }).catch((error) => {
  333. reject(error);
  334. });
  335. };
  336. const quanCheckActionTrue = () => {
  337. console.log("进行真实圈存检测");
  338. var data = {
  339. cardId: card.cardId,
  340. orderId: state.id,
  341. preBalance: card.money,
  342. fee: state.refundBalance,
  343. tradeType: 4,
  344. };
  345. const options = {
  346. type: 2,
  347. data: data,
  348. method: "POST",
  349. showLoading: true,
  350. };
  351. return new Promise(async (resolve, reject) => {
  352. const res = await request(quanCheck, options);
  353. const data = stringToJson(res.bizContent);
  354. resolve(data);
  355. }).catch((error) => {
  356. reject(error);
  357. });
  358. };
  359. /*圈存申请*/
  360. const quanApplyAction = (data) => {
  361. var form = {
  362. cardId: card.cardId,
  363. tradeType: 4,
  364. command: data.command,
  365. cosResponse: data.cosResponse,
  366. orderId: state.id,
  367. rechargeId: data.rechargeId,
  368. fee: state.refundBalance,
  369. preBalance: card.money,
  370. };
  371. const options = {
  372. type: 2,
  373. data: form,
  374. method: "POST",
  375. showLoading: true,
  376. };
  377. return new Promise(async (resolve, reject) => {
  378. console.log("70", options)
  379. const res = await request(quanApply, options);
  380. const data = stringToJson(res.bizContent);
  381. resolve(data);
  382. }).catch((error) => {
  383. reject(error);
  384. });
  385. };
  386. /*圈存确认*/
  387. const uanConfirmAction = (data) => {
  388. console.log("圈存确认进入", data);
  389. console.log("applyValue===========", data)
  390. let cmdArr = data.command.split(",");
  391. console.log(cmdArr);
  392. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  393. console.log("圈存透传");
  394. console.log(res);
  395. var arraylenth = res.length;
  396. var status = res[arraylenth - 1].substring(
  397. res[arraylenth - 1].length - 4,
  398. res[arraylenth - 1].length
  399. );
  400. console.log("打印圈存确认指令状态");
  401. console.log(status);
  402. if (status === "9000") {
  403. var form = {
  404. command: data.command,
  405. cosResponse: res.toString(),
  406. rechargeId: data.rechargeId,
  407. paidAmount: state.refundBalance,
  408. giftAmount: 0,
  409. };
  410. const options = {
  411. type: 2,
  412. data: form,
  413. method: "POST",
  414. showLoading: true,
  415. };
  416. request(quanConfirm, options).then((res) => {
  417. const result = stringToJson(res.bizContent);
  418. navTo(
  419. `/subpackage/after-sale/refund-order-balance/result`)
  420. });
  421. }
  422. });
  423. };
  424. /*圈存修复*/
  425. const quanFixAction = (val) => {
  426. var data = {
  427. command: val.command, //修复初始化的指令
  428. cosResponse: val.cosResponse, //修复初始化结果
  429. rechargeId: val.rechargeId, //充值流水号
  430. };
  431. const options = {
  432. type: 2,
  433. data: data,
  434. method: "POST",
  435. showLoading: true,
  436. };
  437. return new Promise(async (resolve, reject) => {
  438. const res = await request(quanXf, options);
  439. const data = stringToJson(res.bizContent);
  440. resolve(data);
  441. }).catch((error) => {
  442. reject(error);
  443. });
  444. };
  445. </script>
  446. <style>
  447. page {
  448. width: 100%;
  449. height: 100%;
  450. display: flex;
  451. flex-direction: column;
  452. background-color: #EEF7F7;
  453. box-sizing: border-box;
  454. }
  455. </style>
  456. <style lang="scss" scoped>
  457. .oderPage {
  458. .details {
  459. margin: 30rpx;
  460. position: relative;
  461. background: #fff;
  462. border-radius: 20rpx;
  463. padding: 30rpx;
  464. height: 370rpx;
  465. background: #FFFFFF;
  466. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  467. border-radius: 20rpx;
  468. .header {
  469. align-items: center;
  470. display: flex;
  471. padding-bottom: 30rpx;
  472. // border-bottom: 1px solid #DCDCDC;
  473. image {
  474. width: 51rpx;
  475. height: 31rpx;
  476. }
  477. text {
  478. font-size: 30rpx;
  479. margin-left: 20rpx;
  480. font-weight: 600;
  481. }
  482. }
  483. .hr {
  484. height: 1rpx;
  485. background: #DCDCDC;
  486. width: 100%;
  487. position: absolute;
  488. left: 50%;
  489. transform: translate(-50%);
  490. }
  491. .row {
  492. display: flex;
  493. margin: 34rpx 0;
  494. font-size: 26rpx;
  495. font-family: Noto Sans S Chinese;
  496. font-weight: 400;
  497. color: #333333;
  498. line-height: 30rpx;
  499. view {
  500. font-size: 26rpx;
  501. font-family: Noto Sans S Chinese;
  502. font-weight: 400;
  503. color: #999999;
  504. line-height: 30rpx;
  505. }
  506. }
  507. .line {
  508. width: 100%;
  509. height: 1rpx;
  510. background: #DCDCDC;
  511. }
  512. button {
  513. height: 61rpx;
  514. background: #FFFFFF;
  515. border: 1px solid #00B38B;
  516. border-radius: 30rpx;
  517. font-size: 26rpx;
  518. font-family: Noto Sans S Chinese;
  519. font-weight: 400;
  520. color: #00B38B;
  521. line-height: 32rpx;
  522. position: absolute;
  523. right: 30rpx;
  524. bottom: 20rpx;
  525. padding: 16rpx 28rpx;
  526. }
  527. }
  528. }
  529. </style>