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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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. tools.hideLoadingAlert();
  219. }
  220. }
  221. tools.hideLoadingAlert();
  222. });
  223. };
  224. const checkQuanCengEvent = (val : any) => {
  225. console.log("val========", val)
  226. if (val.chargeStatus === 1) {
  227. let cmdArr = val.command.split(",");
  228. uni.showLoading({
  229. title: "写入中",
  230. });
  231. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  232. let response = res.toString();
  233. var dic = {
  234. command: val.command,
  235. cosResponse: response,
  236. };
  237. uni.hideLoading();
  238. quanApplyAction(dic).then((value) => {
  239. console.log("圈存申请完后的结果");
  240. console.log(value);
  241. //圈存初始化验证通过 , 进行圈存
  242. if (value.commandType === 2) {
  243. console.log("value============", value)
  244. uanConfirmAction(value)
  245. } else {
  246. msg("圈存初始化指令验证失败, 重新初始化");
  247. }
  248. });
  249. });
  250. } else {
  251. let cmdArr = val.command.split(",");
  252. uni.showLoading({
  253. title: "写入中",
  254. });
  255. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  256. var status = res[1].substring(res[1].length - 4, res[1].length);
  257. console.log("打印状态");
  258. console.log(status);
  259. if (status === "9000") {
  260. console.log("修复指令入参");
  261. let response = res.toString();
  262. var dic = {
  263. command: val.command,
  264. cosResponse: response,
  265. rechargeId: val.rechargeId,
  266. };
  267. quanFixAction(dic).then((value) => {
  268. console.log(value);
  269. console.log("修复结果返回");
  270. var fixStatus = value.fixStatus;
  271. //圈存修复COS指令Response信息不足,重新进行修复初始化
  272. if (fixStatus === 3) {
  273. let xfcmdArr = value.command.split(",");
  274. bluetoothUtil.transCmd(xfcmdArr, "10", function (resValueData) {
  275. var status = resValueData[1].substring(
  276. resValueData[1].length - 4,
  277. resValueData[1].length
  278. );
  279. console.log("打印状态");
  280. console.log(status);
  281. if (status === "9000") {
  282. console.log(resValueData);
  283. var valueResponse = resValueData.toString();
  284. console.log(response);
  285. var applyDic = {
  286. command: value.command,
  287. cosResponse: valueResponse,
  288. rechargeId: value.rechargeId,
  289. };
  290. console.log("消费成功");
  291. quanApplyAction(applyDic).then((applyValue) => {
  292. uanConfirmAction(value)
  293. });
  294. }
  295. });
  296. } else if (fixStatus === 2) {
  297. uanConfirmSucessAction(value).then((confirmResult) => {
  298. console.log("成功222222222222", confirmResult)
  299. navTo(
  300. `/subpackage/after-sale/refund-order-balance/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. const uanConfirmSucessAction = (data) => {
  314. var form = {
  315. command: data.command,
  316. cosResponse: "9000",
  317. rechargeId: data.rechargeId,
  318. paidAmount: data.fee,
  319. giftAmount: 0,
  320. };
  321. const options = {
  322. type: 2,
  323. data: form,
  324. method: "POST",
  325. showLoading: true,
  326. };
  327. return new Promise(async (resolve, reject) => {
  328. const res = await request(quanConfirm, options);
  329. const data = stringToJson(res.bizContent);
  330. resolve(data);
  331. }).catch((error) => {
  332. reject(error);
  333. });
  334. };
  335. const quanCheckActionTrue = () => {
  336. console.log("进行真实圈存检测");
  337. var data = {
  338. cardId: card.cardId,
  339. orderId: state.id,
  340. preBalance: card.money,
  341. fee: state.refundBalance,
  342. tradeType: 4,
  343. };
  344. const options = {
  345. type: 2,
  346. data: data,
  347. method: "POST",
  348. showLoading: true,
  349. };
  350. return new Promise(async (resolve, reject) => {
  351. const res = await request(quanCheck, options);
  352. const data = stringToJson(res.bizContent);
  353. resolve(data);
  354. }).catch((error) => {
  355. reject(error);
  356. });
  357. };
  358. /*圈存申请*/
  359. const quanApplyAction = (data) => {
  360. var form = {
  361. cardId: card.cardId,
  362. tradeType: 4,
  363. command: data.command,
  364. cosResponse: data.cosResponse,
  365. orderId: state.id,
  366. rechargeId: data.rechargeId,
  367. fee: state.refundBalance,
  368. preBalance: card.money,
  369. };
  370. const options = {
  371. type: 2,
  372. data: form,
  373. method: "POST",
  374. showLoading: true,
  375. };
  376. return new Promise(async (resolve, reject) => {
  377. console.log("70", options)
  378. const res = await request(quanApply, options);
  379. const data = stringToJson(res.bizContent);
  380. resolve(data);
  381. }).catch((error) => {
  382. reject(error);
  383. });
  384. };
  385. /*圈存确认*/
  386. const uanConfirmAction = (data) => {
  387. console.log("圈存确认进入", data);
  388. console.log("applyValue===========", data)
  389. let cmdArr = data.command.split(",");
  390. console.log(cmdArr);
  391. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  392. console.log("圈存透传");
  393. console.log(res);
  394. var arraylenth = res.length;
  395. var status = res[arraylenth - 1].substring(
  396. res[arraylenth - 1].length - 4,
  397. res[arraylenth - 1].length
  398. );
  399. console.log("打印圈存确认指令状态");
  400. console.log(status);
  401. if (status === "9000") {
  402. var form = {
  403. command: data.command,
  404. cosResponse: res.toString(),
  405. rechargeId: data.rechargeId,
  406. paidAmount: state.refundBalance,
  407. giftAmount: 0,
  408. };
  409. const options = {
  410. type: 2,
  411. data: form,
  412. method: "POST",
  413. showLoading: true,
  414. };
  415. request(quanConfirm, options).then((res) => {
  416. const result = stringToJson(res.bizContent);
  417. navTo(
  418. `/subpackage/after-sale/refund-order-balance/result`)
  419. });
  420. }
  421. });
  422. };
  423. /*圈存修复*/
  424. const quanFixAction = (val) => {
  425. var data = {
  426. command: val.command, //修复初始化的指令
  427. cosResponse: val.cosResponse, //修复初始化结果
  428. rechargeId: val.rechargeId, //充值流水号
  429. };
  430. const options = {
  431. type: 2,
  432. data: data,
  433. method: "POST",
  434. showLoading: true,
  435. };
  436. return new Promise(async (resolve, reject) => {
  437. const res = await request(quanXf, options);
  438. const data = stringToJson(res.bizContent);
  439. resolve(data);
  440. }).catch((error) => {
  441. reject(error);
  442. });
  443. };
  444. </script>
  445. <style>
  446. page {
  447. width: 100%;
  448. height: 100%;
  449. display: flex;
  450. flex-direction: column;
  451. background-color: #EEF7F7;
  452. box-sizing: border-box;
  453. }
  454. </style>
  455. <style lang="scss" scoped>
  456. .oderPage {
  457. .details {
  458. margin: 30rpx;
  459. position: relative;
  460. background: #fff;
  461. border-radius: 20rpx;
  462. padding: 30rpx;
  463. height: 370rpx;
  464. background: #FFFFFF;
  465. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  466. border-radius: 20rpx;
  467. .header {
  468. align-items: center;
  469. display: flex;
  470. padding-bottom: 30rpx;
  471. // border-bottom: 1px solid #DCDCDC;
  472. image {
  473. width: 51rpx;
  474. height: 31rpx;
  475. }
  476. text {
  477. font-size: 30rpx;
  478. margin-left: 20rpx;
  479. font-weight: 600;
  480. }
  481. }
  482. .hr {
  483. height: 1rpx;
  484. background: #DCDCDC;
  485. width: 100%;
  486. position: absolute;
  487. left: 50%;
  488. transform: translate(-50%);
  489. }
  490. .row {
  491. display: flex;
  492. margin: 34rpx 0;
  493. font-size: 26rpx;
  494. font-family: Noto Sans S Chinese;
  495. font-weight: 400;
  496. color: #333333;
  497. line-height: 30rpx;
  498. view {
  499. font-size: 26rpx;
  500. font-family: Noto Sans S Chinese;
  501. font-weight: 400;
  502. color: #999999;
  503. line-height: 30rpx;
  504. }
  505. }
  506. .line {
  507. width: 100%;
  508. height: 1rpx;
  509. background: #DCDCDC;
  510. }
  511. button {
  512. height: 61rpx;
  513. background: #FFFFFF;
  514. border: 1px solid #00B38B;
  515. border-radius: 30rpx;
  516. font-size: 26rpx;
  517. font-family: Noto Sans S Chinese;
  518. font-weight: 400;
  519. color: #00B38B;
  520. line-height: 32rpx;
  521. position: absolute;
  522. right: 30rpx;
  523. bottom: 20rpx;
  524. padding: 16rpx 28rpx;
  525. }
  526. }
  527. }
  528. </style>