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.

deviceInfo.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <template>
  2. <view class="wrapper">
  3. <view class="info-card">
  4. <view class="title">卡信息</view>
  5. <view class="cell">
  6. <view class="cell-left">卡号</view>
  7. <view class="cell-right">{{ card.cardNo }}</view>
  8. </view>
  9. <view class="cell">
  10. <view class="cell-left">用户姓名</view>
  11. <view class="cell-right">{{ card.userName }}</view>
  12. </view>
  13. <view class="cell">
  14. <view class="cell-left">身份证号</view>
  15. <view class="cell-right">{{ card.idNum }}</view>
  16. </view>
  17. <view class="cell">
  18. <view class="cell-left">车辆类型</view>
  19. <view class="cell-right">{{ card.type }}</view>
  20. </view>
  21. <view class="cell">
  22. <view class="cell-left">车辆用户类型</view>
  23. <view class="cell-right">{{ card.v_userType }}</view>
  24. </view>
  25. <view class="cell">
  26. <view class="cell-left">车牌号</view>
  27. <view class="cell-right">{{ card.vehiclePlate }}</view>
  28. </view>
  29. <view class="cell">
  30. <view class="cell-left">车牌颜色</view>
  31. <view class="cell-right">{{ card.color }}</view>
  32. </view>
  33. <view class="cell">
  34. <view class="cell-left">启用时间</view>
  35. <view class="cell-right">{{ card.startTime }}</view>
  36. </view>
  37. <view class="cell">
  38. <view class="cell-left">结束时间</view>
  39. <view class="cell-right">{{ card.endTime }}</view>
  40. </view>
  41. <view class="cell">
  42. <view class="cell-left">卡签绑定</view>
  43. <view class="cell-right">{{ card.favourable }}</view>
  44. </view>
  45. <view class="cell">
  46. <view class="cell-left">校验值</view>
  47. <view class="cell-right">{{ card.money }}</view>
  48. </view>
  49. <view class="cell">
  50. <view class="cell-left">版本号</view>
  51. <view class="cell-right">{{ card.version }}</view>
  52. </view>
  53. </view>
  54. <view class="info-card">
  55. <view class="title">OBU信息</view>
  56. <view class="cell">
  57. <view class="cell-left">序列号</view>
  58. <view class="cell-right">{{ obu.num }}</view>
  59. </view>
  60. <view class="cell">
  61. <view class="cell-left">车辆类型</view>
  62. <view class="cell-right">{{ obu.type }}</view>
  63. </view>
  64. <view class="cell">
  65. <view class="cell-left">车辆用户类型</view>
  66. <view class="cell-right">{{ obu.userType }}</view>
  67. </view>
  68. <view class="cell">
  69. <view class="cell-left">车牌号</view>
  70. <view class="cell-right">{{ obu.vehiclePlate }}</view>
  71. </view>
  72. <view class="cell">
  73. <view class="cell-left">车牌颜色</view>
  74. <view class="cell-right">{{ obu.vehiclePlateColor }}</view>
  75. </view>
  76. <view class="cell">
  77. <view class="cell-left">核定载人数</view>
  78. <view class="cell-right">{{ obu.approvedCount }}</view>
  79. </view>
  80. <view class="cell">
  81. <view class="cell-left">车辆识别代号</view>
  82. <view class="cell-right">{{ obu.vin }}</view>
  83. </view>
  84. <view class="cell">
  85. <view class="cell-left">车牌发动机号</view>
  86. <view class="cell-right">{{ obu.engineNum }}</view>
  87. </view>
  88. <view class="cell">
  89. <view class="cell-left">车轴数</view>
  90. <view class="cell-right">{{ obu.axleCount }}</view>
  91. </view>
  92. <view class="cell">
  93. <view class="cell-left">车轮数</view>
  94. <view class="cell-right">{{ obu.wheelCount }}</view>
  95. </view>
  96. <view class="cell">
  97. <view class="cell-left">轴距</view>
  98. <view class="cell-right">{{ obu.axleDistance }}</view>
  99. </view>
  100. <view class="cell">
  101. <view class="cell-left">外廓尺寸</view>
  102. <view class="cell-right">{{ obu.outsideDimensions }}</view>
  103. </view>
  104. <view class="cell">
  105. <view class="cell-left">启用时间</view>
  106. <view class="cell-right">{{ obu.startTime }}</view>
  107. </view>
  108. <view class="cell">
  109. <view class="cell-left">结束时间</view>
  110. <view class="cell-right">{{ obu.endTime }}</view>
  111. </view>
  112. <view class="cell">
  113. <view class="cell-left">是否激活</view>
  114. <view class="cell-right">{{ obu.isJH }}</view>
  115. </view>
  116. <view class="cell">
  117. <view class="cell-left">版本号</view>
  118. <view class="cell-right">{{ obu.version }}</view>
  119. </view>
  120. </view>
  121. <view class="btn" @click="back">返回订单列表</view>
  122. </view>
  123. </template>
  124. <script setup>
  125. import {
  126. reactive
  127. } from "vue";
  128. import {
  129. onLoad,
  130. onUnload
  131. } from "@dcloudio/uni-app";
  132. import {
  133. request
  134. } from "@/utils/network/request";
  135. import {
  136. obuDecrypt,
  137. orderDetail
  138. } from "@/utils/network/api";
  139. import {
  140. stringToJson
  141. } from "@/utils/network/encryption";
  142. import {
  143. HexToStrig,
  144. hexStringToByteArray,
  145. HexToInt
  146. } from "../../utils/util/fileData.js";
  147. import {
  148. getVehicleType
  149. } from "../../datas/vehicleType.js"
  150. import {
  151. getVehiclePlateColor
  152. } from "../../datas/vehiclePlateColor.js"
  153. const cmd = require("../../static/etcUtil/cmdConfig.js");
  154. const tools = require("../../static/etcUtil/tools.js");
  155. const datas = require("../../static/etcUtil/datas.js");
  156. const bluetoothUtil = require("../../static/etcUtil/index.js");
  157. const card = reactive({
  158. cardNo: "",
  159. startTime: "",
  160. endTime: "",
  161. userName: "",
  162. idNum: "",
  163. vehiclePlate: "",
  164. vehiclePlateColor: "",
  165. color: "",
  166. version: "",
  167. type: "",
  168. favourable: "",
  169. money: "",
  170. v_userType: "",
  171. })
  172. const obu = reactive({
  173. num: "",
  174. startTime: "",
  175. endTime: "",
  176. version: "",
  177. approvedCount: "",
  178. axleCount: "",
  179. axleDistance: "",
  180. engineNum: "",
  181. type: "",
  182. userType: "",
  183. vehiclePlate: "",
  184. vehiclePlateColor: "",
  185. vin: "",
  186. wheelCount: "",
  187. isJH: "",
  188. outsideDimensions: "",
  189. })
  190. onLoad((option) => {
  191. // getOrderDetails("f04b28632a2b4dd5959752d0eb2cdb6e")
  192. getCardId(getObuId())
  193. })
  194. //获取订单详情
  195. const getOrderDetails = (id) => {
  196. const options = {
  197. type: 2,
  198. data: {
  199. "id": id
  200. },
  201. method: 'POST',
  202. showLoading: true,
  203. }
  204. request(orderDetail, options).then((res) => {
  205. console.log(res.bizContent);
  206. const result = stringToJson(res.bizContent);
  207. card.cardNo = result.cardId;
  208. card.userName = result.ownerName;
  209. card.idNum = result.ownerIdnum;
  210. card.v_userType = result.vehicleClass;
  211. card.vehiclePlate = result.vehiclePlate,
  212. card.vehiclePlateColor = result.vehiclePlateColor;
  213. card.startTime = result.cardEnableTime;
  214. card.endTime = "";
  215. obu.num = result.obuId;
  216. obu.startTime = result.obuEnableTime;
  217. obu.approvedCount = result.vehicleApprovedCount;
  218. obu.axleCount = result.vehicleAxleCount;
  219. obu.engineNum = result.vehicleEngineNum;
  220. obu.vehiclePlate = result.vehiclePlate;
  221. obu.vehiclePlateColor = result.vehiclePlateColor;
  222. //测试
  223. // state.orderInfo.orderStep = OrderStatus.待激活;
  224. })
  225. };
  226. /**
  227. * 获取卡号
  228. */
  229. const getCardId = (func) => {
  230. //执行0015文件
  231. tools.showLoadingAlert("执行指令");
  232. let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY, cmd.CMD_GETBALANCE];
  233. bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU
  234. let str = res[2].substring(res[2].length - 4, res[2].length); //判断是否为9000
  235. let str3 = res[3].substring(res[3].length - 4, res[3].length); //判断是否为9000
  236. if (str == "9000" || str3 == "9000") {
  237. if (res[2].length > 86 || res[3] >= 12) {
  238. card.cardNo = res[2].substring(20, 40);
  239. card.startTime = res[2].substring(40, 48);
  240. card.endTime = res[2].substring(48, 56);
  241. card.version = res[2].substring(18, 19) >= 4 ? "4x" : "2x";
  242. card.money = res[3].substring(0, 8);
  243. card.v_userType = parseInt(res[2].substring(80, 82), 16);
  244. card.vehiclePlate = HexToStrig(res[2].substring(56, 80));
  245. if (res[2].substring(18, 19) >= 4) {
  246. card.type = getVehicleType(parseInt(res[2].substring(84, 86), 16));
  247. // card.vehiclePlateColor = parseInt(res[2].substring(82, 84), 16);
  248. card.color = getVehiclePlateColor(parseInt(res[2].substring(82, 84), 16))
  249. } else {
  250. card.type = "--";
  251. // card.vehiclePlateColor = parseInt(res[2].substring(82, 84), 16);
  252. card.color = getVehiclePlateColor(parseInt(res[2].substring(82, 84), 16))
  253. }
  254. //执行0016文件
  255. let arr = [cmd.HOME_DIRECTORY, cmd.PERSONAL_INFORMATION]
  256. bluetoothUtil.transCmd(arr, '10', function(res) {
  257. let str2 = res[1].substring(res[1].length - 4, res[1].length);
  258. if (str2 == "9000") {
  259. if (res[1].length > 108) {
  260. card.userName = HexToStrig(res[1].substring(4, 44)); //姓名
  261. card.idNum = HexToStrig(res[1].substring(44, 108)); //身份证号码
  262. //获取是否有优惠
  263. let cmdArr3 = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd
  264. .CMD_00B08E0000
  265. ];
  266. bluetoothUtil.transCmd(cmdArr3, '10', function(res) {
  267. let str3 = res[2].substring(res[2].length - 4, res[2]
  268. .length);
  269. if (str3 == "9000") {
  270. if (res[2].length > 131) {
  271. let _str = parseInt(res[2].substring(129, 130),
  272. 16);
  273. switch (_str) {
  274. case 0:
  275. card.favourable = "否";
  276. break;
  277. case 1:
  278. card.favourable = "是";
  279. break;
  280. default:
  281. card.favourable = '未知' + "_" + _str;
  282. break;
  283. }
  284. //回调读取OBU指令
  285. tools.hideLoadingAlert();
  286. func();
  287. } else {
  288. alertF("CMD_00B08E0000指令长度不符" + res[2]);
  289. }
  290. return;
  291. }
  292. alertF(cmd.PERSONAL_INFORMATION + "_" + str);
  293. })
  294. } else {
  295. alertF("PERSONAL_INFORMATION指令长度不符" + res[1]);
  296. }
  297. return;
  298. }
  299. alertF("PERSONAL_INFORMATION指令长度不符" + res[1]);
  300. })
  301. } else {
  302. alertF("CMD_READBINARY指令长度不符" + res[2]);
  303. }
  304. return;
  305. }
  306. alertF("CMD_READBINARY指令长度不符" + res[2]);
  307. })
  308. };
  309. /**
  310. * 获取OBU号
  311. */
  312. const getObuId = () => {
  313. tools.showLoadingAlert("执行指令");
  314. let cmdArr = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE];
  315. bluetoothUtil.transCmd(cmdArr, '20', function(res) {
  316. let str = res[1].substring(res[1].length - 4, res[1].length);
  317. if (str == "9000") {
  318. if (res[1].length > 52) {
  319. obu.num = res[1].substring(20, 36);
  320. obu.startTime = res[1].substring(36, 44);
  321. obu.endTime = res[1].substring(44, 52);
  322. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  323. obu.isJH = res[1].substring(53, 54) == "1" ? "是" : res[1].substring(53, 54) == "0" ?
  324. "否" : "其他:" + res[1].substring(53, 54);
  325. let rand = datas.generateMixed(16);
  326. let arr = [cmd.OBU_DF01, cmd.OBU_00B400000A + rand + cmd.OBU_4F00];
  327. bluetoothUtil.transCmd(arr, '20', function(res) {
  328. console.log(res);
  329. let str2 = res[1].substring(res[1].length - 4, res[1].length);
  330. if (str2 == "9000") {
  331. decryptObuVehicleInfo(obu.num, res[1].substring(0, res[1].length - 4),
  332. function(res) {
  333. obu.approvedCount = HexToInt(res.substring(48, 54));
  334. obu.axleCount = HexToInt(res.substring(44, 48));
  335. obu.axleDistance = HexToInt(res.substring(44, 48));
  336. obu.engineNum = HexToStrig(res.substring(86, 118));
  337. obu.type = HexToInt(res.substring(28, 30));
  338. obu.userType = HexToInt(res.substring(30, 32));
  339. obu.vehiclePlate = HexToStrig(res.substring(0, 24));
  340. //获取车牌颜色
  341. obu.vehiclePlateColor = HexToInt(res.substring(24, 28))
  342. obu.vin = HexToStrig(res.substring(54, 86));
  343. obu.wheelCount = HexToInt(res.substring(40, 42));
  344. obu.outsideDimensions = HexToInt(res.substring(32, 36)) + "x" +
  345. HexToInt(res.substring(36, 38)) + "x" + HexToInt(res
  346. .substring(38, 40))
  347. tools.hideLoadingAlert();
  348. //提交设备信息
  349. // that.submitDeviceInfo();
  350. });
  351. //断开蓝牙
  352. bluetoothUtil.disconnectDevice();
  353. return;
  354. }
  355. alertF("OBU_00B400000A+rand+OBU_4F00指令长度不符" + res[1]);
  356. })
  357. } else {
  358. alertF("OBU_SYSTEM_FILE指令长度不符" + res[1]);
  359. }
  360. return;
  361. }
  362. alertF("OBU_SYSTEM_FILE指令长度不符" + res[1]);
  363. })
  364. };
  365. /**
  366. * 解密OBU车辆信息
  367. */
  368. function decryptObuVehicleInfo(num, data, func) {
  369. const options = {
  370. type: 2,
  371. data: {
  372. obuSerailNo: num,
  373. fileData: data
  374. },
  375. method: "POST",
  376. showLoading: true,
  377. };
  378. request(obuDecrypt, options).then((res) => {
  379. func(stringToJson(res.bizContent))
  380. });
  381. };
  382. const back = () => {
  383. uni.$emit("refreshOrder");
  384. uni.switchTab({
  385. url: "/pages/order/order"
  386. })
  387. }
  388. const alertF = (msg) => {
  389. //隐藏加载框
  390. tools.hideLoadingAlert();
  391. //提示对话框
  392. tools.showModalAlert(msg);
  393. }
  394. </script>
  395. <style scoped>
  396. .wrapper {
  397. padding-bottom: 50rpx;
  398. }
  399. .info-card {
  400. margin: 30rpx;
  401. border-radius: 16rpx;
  402. padding-bottom: 40rpx;
  403. box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.3);
  404. }
  405. .info-card .title {
  406. padding: 30rpx 0;
  407. font-size: 36rpx;
  408. text-align: center;
  409. color: #4cd95f;
  410. }
  411. .info-card .cell {
  412. display: flex;
  413. flex-direction: row;
  414. padding: 15rpx 40rpx;
  415. font-size: 30rpx;
  416. }
  417. .cell-left {
  418. flex: 1;
  419. text-align: left;
  420. color: #666;
  421. }
  422. .cell-right {
  423. margin-left: 30rpx;
  424. text-align: right;
  425. color: #333;
  426. overflow: hidden;
  427. }
  428. .btn {
  429. background: linear-gradient(to right, #13E7C1, #43A1E0);
  430. opacity: 1;
  431. border-radius: 100rpx;
  432. color: #fff;
  433. font-size: 30rpx;
  434. height: 80rpx;
  435. line-height: 80rpx;
  436. box-shadow: 0rpx 4rpx 11rpx 1rpx rgba(223, 223, 223, 0.5);
  437. width: 670rpx;
  438. margin: 40rpx;
  439. text-align: center;
  440. }
  441. </style>