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

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