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.

renewal-confirm.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <view class="selectCar-box">
  3. <view class="details">
  4. <view class="title"> 基础信息 </view>
  5. <view class="details-item">
  6. <view> 订单编号: </view>
  7. <text>{{ orderInfos.orderId }}</text>
  8. </view>
  9. <view class="details-item">
  10. <view> 用户名称: </view>
  11. <text>{{ orderInfos.ownerName }}</text>
  12. </view>
  13. <view class="details-item">
  14. <view> 用户证件类型: </view>
  15. <text>{{ getCodeName('CERTIFICATE_TYPE',orderInfos.ownerIdtype) }}</text>
  16. </view>
  17. <view class="details-item">
  18. <view> 用户证件号: </view>
  19. <text>{{ orderInfos.ownerIdnum }}</text>
  20. </view>
  21. <view class="details-item">
  22. <view> 订单车牌号: </view>
  23. <text style="color: #00b38b">{{ orderInfos.vehiclePlate }}</text>
  24. </view>
  25. <view class="details-item">
  26. <view> 车牌颜色: </view>
  27. <text style="color: #00b38b">{{
  28. orderInfos.vehiclePlateColorStr
  29. }}</text>
  30. </view>
  31. <view class="details-item">
  32. <view> 收费车型: </view>
  33. <text>{{ orderInfos.vehicleType }}</text>
  34. </view>
  35. </view>
  36. <view class="title"> 卡信息 </view>
  37. <view class="card">
  38. <view class="card-left">
  39. <image :src="`${$imgUrl}card2.png`" mode=""></image>
  40. <view class="card-center">
  41. <view class="card-center-head"> {{orderInfos.cardId}} </view>
  42. <view class="tips">
  43. <text>储蓄卡</text>
  44. <text class="tips-card">{{getCodeName('CARD_STATE_TYPE',orderInfos.cardStatus)}}</text>
  45. </view>
  46. <view class="choose-item"> 有效期:{{orderInfos.cardExpireTime }}</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="title"> OBU设备信息 </view>
  51. <view class="card">
  52. <view class="card-left">
  53. <image :src="`${$imgUrl}card1.png`" mode=""></image>
  54. <view class="card-center">
  55. <view class="card-center-head"> {{orderInfos.obuId}} </view>
  56. <view class="tips">
  57. <!-- <text>储蓄卡</text> -->
  58. <text class="tips-card">{{getCodeName('OBU_STATE_TYPE',orderInfos.obuStatus)}}</text>
  59. </view>
  60. <view class="choose-item"> 有效期:{{orderInfos.obuExpireTime }} </view>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- <view class="title"> 注意事项 </view>
  65. <view class="remark">
  66. <view> 1.xxxxxxxx </view>
  67. <view> 2.xxxxxxxx </view>
  68. <view> 3.xxxxxxxx </view>
  69. <view> 4.xxxxxxxx </view>
  70. </view> -->
  71. <button class="submit" @click="toPage" v-if="!state.flag" >卡签续期</button>
  72. <button class="submit" @click="toBack" v-else="state.flag">返回服务中心</button>
  73. <view class="mask" v-show="state.showPopup">
  74. <view class="main">
  75. <view class="top">
  76. <image class="icon-close" :src="`${$imgUrl}common/icon-close.png`" @click="cancel"></image>
  77. </view>
  78. <image class="icon-success" :src="`${$imgUrl}bluetooth/card-success.png`"></image>
  79. <view class="title">卡签续期成功!</view>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script setup>
  85. import {
  86. getCodeName
  87. } from "@/datas/queryKey.js";
  88. import {
  89. reactive
  90. } from "vue";
  91. import {
  92. navTo
  93. } from "@/utils/utils";
  94. import {
  95. onLoad,
  96. onUnload,
  97. onShow
  98. } from "@dcloudio/uni-app";
  99. import {
  100. request
  101. } from "@/utils/network/request.js";
  102. import {
  103. orderDetail,
  104. cardRenewal,
  105. writeCardBack,
  106. cardModifyConfirm,
  107. obuRenewal
  108. } from "@/utils/network/api.js";
  109. const cmd = require("../../../static/etcUtil/cmdConfig.js");
  110. import {
  111. stringToJson
  112. } from "@/utils/network/encryption";
  113. const tools = require("../../../static/etcUtil/tools.js");
  114. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  115. const state = reactive({
  116. showPopup: false,
  117. flag: false
  118. })
  119. const orderInfos = reactive({
  120. orderId: "",
  121. ownerName: "",
  122. ownerIdtype: "",
  123. ownerIdnum: "",
  124. vehiclePlate: "",
  125. vehiclePlateColorStr: "",
  126. vehiclePlateColor: "",
  127. vehicleType: "",
  128. cardId: "",
  129. cardStatus: "",
  130. obuId: "",
  131. obuStatus: "",
  132. cardEnableTime: "",
  133. obuEnableTime: "",
  134. cardExpireTime:"",
  135. obuExpireTime:""
  136. });
  137. onLoad((option) => {
  138. //请求订单详情
  139. queryOrderDetail(option.id);
  140. });
  141. onShow((option) => {
  142. uni.$on('bluetoothLink', res => {
  143. console.log(res);
  144. if (res.status) {
  145. getCardRenewal()
  146. }
  147. })
  148. })
  149. onUnload(() => {
  150. //移除监听
  151. uni.$off('bluetoothLink')
  152. })
  153. //获取订单详情
  154. const queryOrderDetail = (id) => {
  155. const options = {
  156. type: 2,
  157. data: {
  158. id: id,
  159. },
  160. method: "POST",
  161. showLoading: true,
  162. };
  163. request(orderDetail, options).then((res) => {
  164. let orderInfo = JSON.parse(res.bizContent);
  165. console.log("orderInfo",orderInfo);
  166. orderInfos.orderId = orderInfo.orderId;
  167. orderInfos.ownerName = orderInfo.ownerName;
  168. orderInfos.ownerIdtype = orderInfo.ownerIdtype;
  169. orderInfos.ownerIdnum = orderInfo.ownerIdnum;
  170. orderInfos.vehiclePlate = orderInfo.vehiclePlate;
  171. orderInfos.vehiclePlateColorStr = orderInfo.vehiclePlateColorStr;
  172. orderInfos.vehiclePlateColor = orderInfo.vehiclePlateColor;
  173. orderInfos.vehicleType = orderInfo.vehicleType;
  174. orderInfos.cardId = orderInfo.cardId;
  175. orderInfos.cardStatus = orderInfo.cardStatus;
  176. orderInfos.obuId = orderInfo.obuId;
  177. orderInfos.obuStatus = orderInfo.obuStatus;
  178. orderInfos.cardEnableTime = orderInfo.cardEnableTime.substring(0, 10);
  179. orderInfos.obuEnableTime = orderInfo.obuEnableTime.substring(0, 10);
  180. orderInfos.cardExpireTime = orderInfo.cardExpireTime;
  181. orderInfos.obuExpireTime = orderInfo.obuExpireTime;
  182. console.log("orderInfos.cardExpiretime",orderInfos.cardExpiretime,orderInfo.cardExpiretime)
  183. });
  184. };
  185. //卡续期 请求
  186. const getCardRenewal = () => {
  187. const options = {
  188. type: 2,
  189. data: {
  190. cardId: orderInfos.cardId,
  191. },
  192. method: "POST",
  193. showLoading: true,
  194. };
  195. request(cardRenewal, options).then((res) => {
  196. let result = stringToJson(res.bizContent);
  197. let cmdArray = result.command.split(",");
  198. console.log(cmdArray);
  199. console.log(result.cosRecordId);
  200. if (cmdArray.length > 0) {
  201. tools.showLoadingAlert("正在执行指令");
  202. bluetoothUtil.transCmd(cmdArray, "10", function(res) {
  203. tools.hideLoadingAlert();
  204. let status = res[cmdArray.length - 1].substring(res[cmdArray.length - 1].length -
  205. 4, res[cmdArray.length - 1].length);
  206. if (status == "9000") {
  207. getCommandBack(result.command, result.cosRecordId, res.toString());
  208. }
  209. })
  210. }
  211. })
  212. };
  213. /**
  214. * 写卡指令返回 请求
  215. */
  216. const getCommandBack = (command, cosRecordId, response) => {
  217. console.log('======循环写卡指令中======')
  218. tools.showLoadingAlert("加载中");
  219. let options = {
  220. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  221. data: {
  222. cardId: orderInfos.cardId,
  223. orderId: orderInfos.orderId,
  224. command: command,
  225. response: response,
  226. cosRecordId: cosRecordId,
  227. cosType: 2
  228. }, //请求参数
  229. method: "POST", //提交方式(默认POST)
  230. showLoading: true, //是否显示加载中(默认显示)
  231. };
  232. //调用方式
  233. request(writeCardBack, options)
  234. .then((res) => {
  235. tools.hideLoadingAlert();
  236. let result = JSON.parse(res.bizContent);
  237. if (result.orderStatus == 1 || result.orderStatus == "1") {
  238. tools.showLoadingAlert("执行指令中");
  239. bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
  240. tools.hideLoadingAlert();
  241. let response = res.toString();
  242. getCommandBack(result.command, cosRecordId, response);
  243. });
  244. } else {
  245. getCardModifyConfirm(cosRecordId);
  246. }
  247. })
  248. };
  249. //卡信息变更确认
  250. const getCardModifyConfirm = (cosRecordId) => {
  251. const options = {
  252. type: 2,
  253. data: {
  254. cardId: orderInfos.cardId,
  255. operation: 1,
  256. cosRecordId: cosRecordId
  257. },
  258. method: "POST",
  259. showLoading: true,
  260. };
  261. request(cardModifyConfirm, options).then((res) => {
  262. getObuRenewal()
  263. })
  264. }
  265. //去连接蓝牙
  266. const toPage = () => {
  267. console.log("getCurrentPages()", getCurrentPages())
  268. navTo("/pages/bluetooth/bluetooth?routeType=5"); //去连接蓝牙
  269. };
  270. //返回列表
  271. const toBack = () => {
  272. uni.redirectTo({
  273. url: "/pages/service/service"
  274. })
  275. }
  276. //关闭弹窗
  277. const cancel = () => {
  278. state.flag = true;
  279. state.showPopup = false;
  280. }
  281. //签续期 请求
  282. const getObuRenewal = () => {
  283. console.log("899执行之前",);
  284. let cmdArray1 = [cmd.HOME_DIRECTORY, cmd.OBU_DF01, cmd.OBU_EF01, cmd.RANDOM_NUMBER];
  285. if (cmdArray1.length > 0) {
  286. tools.showLoadingAlert("正在执行指令");
  287. bluetoothUtil.transCmd(cmdArray1, "20", function(res) {
  288. tools.hideLoadingAlert();
  289. var str = res[3].substring(res[3].length - 4, res[3].length);
  290. if (str == "9000") {
  291. let cmdRandNum = res[3].substring(0, res[3].length - 4);
  292. const options = {
  293. type: 2,
  294. data: {
  295. obuId: orderInfos.obuId,
  296. random:cmdRandNum
  297. },
  298. method: "POST",
  299. showLoading: true,
  300. };
  301. request(obuRenewal, options).then((res) => {
  302. let result = stringToJson(res.bizContent);
  303. let cmdArray = result.command.split(",");
  304. console.log("899",result,cmdArray);
  305. console.log(result.cosRecordId);
  306. if (cmdArray.length > 0) {
  307. tools.showLoadingAlert("正在执行指令");
  308. bluetoothUtil.transCmd(cmdArray, "20", function(res) {
  309. tools.hideLoadingAlert();
  310. state.showPopup = true;
  311. })
  312. }
  313. })
  314. } else {
  315. tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
  316. }
  317. })
  318. }
  319. };
  320. </script>
  321. <style>
  322. page {
  323. width: 100%;
  324. height: 100%;
  325. background-color: #fff;
  326. }
  327. </style>
  328. <style lang="scss" scoped>
  329. .mask {
  330. background: rgba(0, 0, 0, .35);
  331. position: fixed;
  332. left: 0;
  333. top: 0;
  334. bottom: 0;
  335. right: 0;
  336. }
  337. .main {
  338. width: 560rpx;
  339. padding: 25rpx 20rpx 55rpx;
  340. text-align: center;
  341. background: #fff;
  342. position: absolute;
  343. left: 50%;
  344. top: 50%;
  345. transform: translate(-50%, -50%);
  346. border-radius: 20rpx;
  347. .top {
  348. text-align: right;
  349. .icon-close {
  350. width: 48rpx;
  351. height: 48rpx;
  352. }
  353. }
  354. .icon-success {
  355. width: 500rpx;
  356. height: 320rpx;
  357. margin-top: 22rpx;
  358. }
  359. .title {
  360. color: #333333;
  361. font-size: 40rpx;
  362. font-weight: 600;
  363. text-align: center;
  364. margin-top: 55rpx;
  365. }
  366. }
  367. .selectCar-box {
  368. // width: 100%;
  369. // height: 100%;
  370. padding: 30rpx;
  371. .title {
  372. font-size: 30rpx;
  373. font-family: Microsoft YaHei UI;
  374. font-weight: 400;
  375. color: #333333;
  376. margin-bottom: 30rpx;
  377. }
  378. .details {
  379. .title {
  380. font-size: 30rpx;
  381. font-family: Microsoft YaHei UI;
  382. font-weight: 400;
  383. color: #333333;
  384. margin-bottom: 30rpx;
  385. }
  386. .details-item {
  387. display: flex;
  388. font-size: 26rpx;
  389. font-family: Noto Sans S Chinese;
  390. font-weight: 400;
  391. color: #999999;
  392. margin-bottom: 30rpx;
  393. text {
  394. font-size: 26rpx;
  395. font-family: Noto Sans S Chinese;
  396. font-weight: 400;
  397. color: #333333;
  398. }
  399. }
  400. }
  401. .card {
  402. height: 150rpx;
  403. background: #ffffff;
  404. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  405. border-radius: 20rpx;
  406. padding: 30rpx;
  407. display: flex;
  408. justify-content: space-between;
  409. align-items: center;
  410. margin-bottom: 60rpx;
  411. .card-left {
  412. display: flex;
  413. align-items: center;
  414. image {
  415. width: 100rpx;
  416. height: 90rpx;
  417. }
  418. .card-center {
  419. margin-left: 30rpx;
  420. .card-center-head {
  421. font-size: 32rpx;
  422. font-family: Noto Sans S Chinese;
  423. font-weight: 400;
  424. color: #333333;
  425. }
  426. .tips {
  427. font-size: 26rpx;
  428. font-family: Noto Sans S Chinese;
  429. font-weight: 400;
  430. color: #666666;
  431. .tips-card {
  432. width: 70rpx;
  433. height: 40rpx;
  434. background: #d3f2ef;
  435. border-radius: 6rpx;
  436. font-size: 20rpx;
  437. font-family: Noto Sans S Chinese;
  438. font-weight: 400;
  439. color: #0a8f8a;
  440. padding: 5rpx 10rpx;
  441. margin-left: 20rpx;
  442. }
  443. }
  444. }
  445. }
  446. .choose-item {
  447. margin-right: 20rpx;
  448. /* width: 50rpx; */
  449. // height: 50rpx;
  450. /* border: 1rpx solid #00B38B; */
  451. border-radius: 50%;
  452. // display: flex;
  453. // justify-content: center;
  454. // align-items: center;
  455. font-size: 25rpx;
  456. // align-self: end;
  457. .active {
  458. width: 38rpx;
  459. height: 38rpx;
  460. background: #00b38b;
  461. border-radius: 50%;
  462. }
  463. }
  464. }
  465. .remark {
  466. font-size: 26rpx;
  467. font-family: Microsoft YaHei UI;
  468. font-weight: 400;
  469. color: #666666;
  470. text-indent: 30rpx;
  471. margin-bottom: 30rpx;
  472. }
  473. .submit {
  474. margin-top: 100rpx;
  475. width: 670rpx;
  476. height: 80rpx;
  477. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  478. border-radius: 40rpx;
  479. font-size: 32rpx;
  480. font-family: Noto Sans S Chinese;
  481. font-weight: 400;
  482. color: #ffffff;
  483. line-height: 80rpx;
  484. }
  485. }
  486. </style>