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 13KB

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