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.

deactivation-activation-confirm.vue 11KB

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