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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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 }}mm</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. getCardId()
  192. })
  193. /**
  194. * 获取卡号
  195. */
  196. const getCardId = () => {
  197. //执行0015文件
  198. tools.showLoadingAlert("执行指令");
  199. let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY, cmd.CMD_GETBALANCE];
  200. console.log(cmdArr);
  201. console.log(bluetoothUtil);
  202. bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU
  203. let str = res[2].substring(res[2].length - 4, res[2].length); //判断是否为9000
  204. let str3 = res[3].substring(res[3].length - 4, res[3].length); //判断是否为9000
  205. if (str == "9000" || str3 == "9000") {
  206. if (res[2].length > 86 || res[3] >= 12) {
  207. console.log("res[2]", res[2], res[2].substring(18, 19))
  208. card.cardNo = res[2].substring(20, 40);
  209. card.startTime = res[2].substring(40, 48);
  210. card.endTime = res[2].substring(48, 56);
  211. card.version = res[2].substring(18, 19) >= 4 ? "4x" : "2x";
  212. card.money = res[3].substring(0, 8);
  213. card.v_userType = parseInt(res[2].substring(80, 82), 16);
  214. card.vehiclePlate = HexToStrig(res[2].substring(56, 80));
  215. if (res[2].substring(18, 19) >= 4) {
  216. card.type = getVehicleType(parseInt(res[2].substring(84, 86), 16));
  217. // card.vehiclePlateColor = parseInt(res[2].substring(82, 84), 16);
  218. card.color = getVehiclePlateColor(parseInt(res[2].substring(82, 84), 16))
  219. } else {
  220. card.type = "--";
  221. // card.vehiclePlateColor = parseInt(res[2].substring(82, 84), 16);
  222. card.color = getVehiclePlateColor(parseInt(res[2].substring(82, 84), 16))
  223. }
  224. //执行0016文件
  225. let arr = [cmd.HOME_DIRECTORY, cmd.PERSONAL_INFORMATION]
  226. bluetoothUtil.transCmd(arr, '10', function(res) {
  227. let str2 = res[1].substring(res[1].length - 4, res[1].length);
  228. if (str2 == "9000") {
  229. if (res[1].length > 108) {
  230. card.userName = HexToStrig(res[1].substring(4, 44)); //姓名
  231. card.idNum = HexToStrig(res[1].substring(44, 108)); //身份证号码
  232. //获取是否有优惠
  233. let cmdArr3 = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd
  234. .CMD_00B08E0000
  235. ];
  236. bluetoothUtil.transCmd(cmdArr3, '10', function(res) {
  237. let str3 = res[2].substring(res[2].length - 4, res[2]
  238. .length);
  239. if (str3 == "9000") {
  240. if (res[2].length > 131) {
  241. let _str = parseInt(res[2].substring(129, 130),
  242. 16);
  243. switch (_str) {
  244. case 0:
  245. card.favourable = "否";
  246. break;
  247. case 1:
  248. card.favourable = "是";
  249. break;
  250. default:
  251. card.favourable = '未知' + "_" + _str;
  252. break;
  253. }
  254. //回调读取OBU指令
  255. getObuId()
  256. tools.hideLoadingAlert();
  257. } else {
  258. alertF("CMD_00B08E0000指令长度不符" + res[2]);
  259. }
  260. return;
  261. }
  262. alertF(cmd.PERSONAL_INFORMATION + "_" + str);
  263. })
  264. } else {
  265. alertF("PERSONAL_INFORMATION指令长度不符" + res[1]);
  266. }
  267. return;
  268. }
  269. alertF("PERSONAL_INFORMATION指令长度不符" + res[1]);
  270. })
  271. } else {
  272. alertF("CMD_READBINARY指令长度不符" + res[2]);
  273. }
  274. return;
  275. }
  276. alertF("CMD_READBINARY指令长度不符" + res[2]);
  277. })
  278. };
  279. /**
  280. * 获取OBU号
  281. */
  282. const getObuId = () => {
  283. tools.showLoadingAlert("执行指令");
  284. let cmdArr = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE];
  285. bluetoothUtil.transCmd(cmdArr, '20', function(res) {
  286. let str = res[1].substring(res[1].length - 4, res[1].length);
  287. if (str == "9000") {
  288. if (res[1].length > 52) {
  289. obu.num = res[1].substring(20, 36);
  290. obu.startTime = res[1].substring(36, 44);
  291. obu.endTime = res[1].substring(44, 52);
  292. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  293. obu.isJH = res[1].substring(53, 54) == "1" ? "是" : res[1].substring(53, 54) == "0" ?
  294. "否" : "其他:" + res[1].substring(53, 54);
  295. let rand = datas.generateMixed(16);
  296. let arr = [cmd.OBU_DF01, cmd.OBU_00B400000A + rand + cmd.OBU_4F00];
  297. bluetoothUtil.transCmd(arr, '20', function(res) {
  298. console.log(res);
  299. let str2 = res[1].substring(res[1].length - 4, res[1].length);
  300. if (str2 == "9000") {
  301. decryptObuVehicleInfo(obu.num, res[1].substring(0, res[1].length - 4),
  302. function(res) {
  303. console.log(res);
  304. obu.approvedCount = HexToInt(res.substring(48, 54));
  305. obu.axleCount = HexToInt(res.substring(44, 48));
  306. obu.axleDistance = HexToInt(res.substring(44, 48));
  307. obu.engineNum = HexToStrig(res.substring(86, 118));
  308. obu.type = getVehicleType(HexToInt(res.substring(28, 30)));
  309. obu.userType = HexToInt(res.substring(30, 32)) == 1 ? "个人用户" :
  310. "单位用户";
  311. obu.vehiclePlate = HexToStrig(res.substring(0, 24), 2);
  312. //获取车牌颜色
  313. obu.vehiclePlateColor = getVehiclePlateColor(HexToInt(res
  314. .substring(24, 28)));
  315. obu.vin = HexToStrig(res.substring(54, 86));
  316. obu.wheelCount = HexToInt(res.substring(40, 42));
  317. obu.outsideDimensions = HexToInt(res.substring(32, 36)) + "x" +
  318. HexToInt(res.substring(36, 38)) + "x" + HexToInt(res
  319. .substring(38, 40))
  320. tools.hideLoadingAlert();
  321. //提交设备信息
  322. // that.submitDeviceInfo();
  323. });
  324. //断开蓝牙
  325. bluetoothUtil.disconnectDevice();
  326. return;
  327. }
  328. alertF("OBU_00B400000A+rand+OBU_4F00指令长度不符" + res[1]);
  329. })
  330. } else {
  331. alertF("OBU_SYSTEM_FILE指令长度不符" + res[1]);
  332. }
  333. return;
  334. }
  335. alertF("OBU_SYSTEM_FILE指令长度不符" + res[1]);
  336. })
  337. };
  338. /**
  339. * 解密OBU车辆信息
  340. */
  341. const decryptObuVehicleInfo = (num, data, func) => {
  342. const options = {
  343. type: 2,
  344. data: {
  345. obuSerailNo: num,
  346. fileData: data
  347. },
  348. method: "POST",
  349. showLoading: true,
  350. };
  351. request(obuDecrypt, options).then((res) => {
  352. const data = stringToJson(res.bizContent)
  353. const FileData = data.data.FileData
  354. func(FileData)
  355. });
  356. };
  357. //返回按钮
  358. const back = () => {
  359. uni.$emit("refreshOrder");
  360. uni.switchTab({
  361. url: "/pages/order/order"
  362. })
  363. }
  364. //提示对话框
  365. const alertF = (msg) => {
  366. //隐藏加载框
  367. tools.hideLoadingAlert();
  368. //提示对话框
  369. tools.showModalAlert(msg);
  370. }
  371. </script>
  372. <style scoped>
  373. .wrapper {
  374. padding-bottom: 50rpx;
  375. }
  376. .info-card {
  377. margin: 30rpx;
  378. border-radius: 16rpx;
  379. padding-bottom: 40rpx;
  380. box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.3);
  381. }
  382. .info-card .title {
  383. padding: 30rpx 0;
  384. font-size: 36rpx;
  385. text-align: center;
  386. color: #13E7C1;
  387. }
  388. .info-card .cell {
  389. display: flex;
  390. flex-direction: row;
  391. padding: 15rpx 40rpx;
  392. font-size: 30rpx;
  393. }
  394. .cell-left {
  395. flex: 1;
  396. text-align: left;
  397. color: #666;
  398. }
  399. .cell-right {
  400. margin-left: 30rpx;
  401. text-align: right;
  402. color: #333;
  403. overflow: hidden;
  404. }
  405. .btn {
  406. background: linear-gradient(to right, #13E7C1, #43A1E0);
  407. opacity: 1;
  408. border-radius: 100rpx;
  409. color: #fff;
  410. font-size: 30rpx;
  411. height: 80rpx;
  412. line-height: 80rpx;
  413. box-shadow: 0rpx 4rpx 11rpx 1rpx rgba(223, 223, 223, 0.5);
  414. width: 670rpx;
  415. margin: 40rpx;
  416. text-align: center;
  417. }
  418. </style>