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.

activate.vue 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. <template>
  2. <view class="containers">
  3. <view class="sec_info">
  4. <view class="info_txt">信息确认</view>
  5. <view class="info_plate">
  6. <text>车牌号码</text>
  7. <text>{{ fileDataStrings.vehiclePlate }}</text>
  8. </view>
  9. <view class="info_plate">
  10. <text>车牌颜色</text>
  11. <text>{{ fileDataStrings.vehiclePlateColorStr }}</text>
  12. </view>
  13. <view class="info_plate">
  14. <text>手机号码</text>
  15. <text>{{ fileDataStrings.customerTel }}</text>
  16. </view>
  17. <view class="info_plate" style="border: none" v-if="fileDataStrings.cardId">
  18. <text>卡号</text>
  19. <text>{{ fileDataStrings.cardId }}</text>
  20. </view>
  21. <view class="info_plate" v-if="fileDataStrings.obuId">
  22. <text>OBU号</text>
  23. <text>{{ fileDataStrings.obuId }}</text>
  24. </view>
  25. <view class="info_plate">
  26. <text>收费车型</text>
  27. <text>{{ fileDataStrings.vehicleClassStr }}</text>
  28. </view>
  29. </view>
  30. <view class="up_btn" v-if="state.showBtn">
  31. <button aria-disabled="true" @click="btn" v-if="!state.isSuccess" :class="state.disabled?'button':'hui'">
  32. 点击开始激活
  33. </button>
  34. <button aria-disabled="true" @click="back" v-else>
  35. 点击返回首页
  36. </button>
  37. </view>
  38. </view>
  39. <!-- 激活成功popup -->
  40. <view v-if="state.showPopup" class="mask">
  41. <piaoyi-progress-bar canvasId="progressCanvas4" :progress="state.progressNum" progressBackgroundColor="#07C160"
  42. :showText="true" textColor="#fff" :textSize="28" :height="22" :isCircular="true"
  43. :diameter="300"></piaoyi-progress-bar>
  44. </view>
  45. </template>
  46. <script setup>
  47. import {
  48. reactive,
  49. ref
  50. } from "vue";
  51. import {
  52. formatTime,
  53. formatTime2,
  54. expireDate,
  55. expireDate2,
  56. getFormatDate,
  57. msg,
  58. navTo
  59. } from "@/utils/utils";
  60. import {
  61. onLoad,
  62. onUnload
  63. } from '@dcloudio/uni-app'
  64. import {
  65. getItem
  66. } from "@/utils/storage";
  67. import {
  68. requestNew
  69. } from "@/utils/network/request.js";
  70. import {
  71. IntegerToHexString,
  72. } from "@/utils/util/fileData.js";
  73. import {
  74. issueApply,
  75. issueCallback,
  76. orderDetailQuery,
  77. errorLogAdd,
  78. cardObuQuery,
  79. cardObuQueryinLog,
  80. obuFileDataDecrypt
  81. } from "@/utils/network/api";
  82. import {
  83. agentId
  84. } from "@/utils/network/difference";
  85. import {
  86. startHeartbeat,
  87. stopHeartbeat
  88. } from "@/pages/bluetooth/heartbeatService"
  89. const cmd = require("../../../static/etcUtil/cmdConfig.js");
  90. const tools = require("../../../static/etcUtil/tools.js");
  91. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  92. import activeSuccess from "./components/popup-device-active-success";
  93. const datas = require("../../../static/etcUtil/datas.js");
  94. import {
  95. getVehicleType
  96. } from "@/subpackage/after-sale/js/vehicleType.js"
  97. import {
  98. getVehiclePlateColor
  99. } from "@/datas/vehiclePlateColor";
  100. import {
  101. searchVehicleInfoQuery
  102. } from "@/subpackage/after-sale/js/publicRequest";
  103. import {
  104. decryptCardVehicleInformation
  105. } from "@/datas/publicRequest";
  106. import {
  107. channelId
  108. } from "@/utils/network/difference";
  109. const state = reactive({
  110. orderId: "",
  111. id: "",
  112. cardStatus: "",
  113. obuStatus: "",
  114. isSuccess: false, //是否激活成功
  115. showPopup: false,
  116. transfer: 0, //0 是原来的激活 1 是过户激活
  117. showBtn: true,
  118. disabled: true,
  119. progressNum: 0
  120. })
  121. onLoad((option) => {
  122. //读取传入 存储的数据orderInfo
  123. let orderData = getItem("orderInfo");
  124. state.id = orderData.id;
  125. console.log(state);
  126. state.transfer = Number(option.transfer)
  127. //获取订单详情
  128. getOrderDetails(orderData.orderId);
  129. console.log("state.transfer", state.transfer, state.transfer == 0, state.transfer == 1, getItem(
  130. "orderInfo"))
  131. })
  132. // ====================== 页面卸载时清理资源 ======================
  133. onUnload(() => {
  134. stopHeartbeat();
  135. // 实际项目中需调用 uni.closeBLEConnection 断开连接
  136. console.log('页面卸载,清理资源');
  137. });
  138. const card = reactive({
  139. cardId: "",
  140. cardNo: "",
  141. startTime: "",
  142. endTime: "",
  143. userName: "",
  144. userNameStr: "",
  145. idNum: "",
  146. idNumStr: "",
  147. vehiclePlate: "",
  148. vehiclePlateColor: "",
  149. color: "",
  150. colorStr: "",
  151. version: "",
  152. type: "",
  153. typeStr: "",
  154. favourable: "",
  155. favourableStr: "",
  156. money: "",
  157. v_userType: ""
  158. });
  159. const obu = reactive({
  160. obuId: "",
  161. num: "",
  162. startTime: "",
  163. endTime: "",
  164. version: "",
  165. approvedCount: "",
  166. axleCount: "",
  167. axleDistance: "",
  168. engineNum: "",
  169. type: "",
  170. typeStr: "",
  171. userType: "",
  172. userTypeStr: "",
  173. vehiclePlate: "",
  174. vehiclePlateColor: "",
  175. vehiclePlateColorStr: "",
  176. vin: "",
  177. wheelCount: "",
  178. isJH: "",
  179. isJHStr: "",
  180. outsideDimensions: "",
  181. loadStatus: ""
  182. });
  183. let cmdRandNum = '';
  184. let orderInfo = {};
  185. const fileDataStrings = reactive({
  186. approvedCount: 0, //核载人数
  187. cardId: "", //卡号
  188. obuId: "", //obu号
  189. packageNum: "", //套餐编号
  190. axleCount: 0, //轴数
  191. axleDistance: "", //轴距
  192. engineNum: "", //发动机
  193. vehicleVin: "",
  194. vehicleEngineNum: "",
  195. cardStatus: "",
  196. obuStatus: "",
  197. type: 0, //类型
  198. userType: 0, //用户类型
  199. vehiclePlate: "", //车牌
  200. vehiclePlateColor: 0, //车牌颜色
  201. vehicleDimensions: "",
  202. wheelCount: 0, //车轮数
  203. vehicleIdNo: "", //车牌号
  204. vehiclePlateColorStr: "",
  205. customerTel: "",
  206. customerId: "",
  207. orderId: "",
  208. vehicleClassStr: ""
  209. });
  210. function cmdResult1() {
  211. // tools.showLoadingAlert('正在激活,请等待')
  212. state.progressNum = 10
  213. const options = {
  214. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  215. showLoading: false,
  216. data: {
  217. orderId: orderInfo.orderNo,
  218. issueType: state.transfer ? 2 : 1, //1正常激活 2 过户激活
  219. cardId: card.cardId,
  220. obuId: obu.obuId
  221. }, //请求参数
  222. method: "POST", //提交方式(默认POST)
  223. };
  224. console.log("options==", options)
  225. console.log("二发指令申请==前,/iaw/issue/order/issueApply",new Date(),options)
  226. //BDS-二发指令申请
  227. requestNew(issueApply, options)
  228. .then((res) => {
  229. console.log("在线激活 请求");
  230. console.log(res);
  231. const datas = res;
  232. console.log("二发指令申请==后,/iaw/issue/order/issueApply",new Date(),res)
  233. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  234. implementCmd(datas.transOrderId, datas.cmd, res.toString(), datas.stepNo)
  235. }, (err) => {
  236. showModals(err.msg)
  237. console.log("err", err)
  238. errorLog(datas.cmd, JSON.stringify(err), datas.stepNo)
  239. tools.hideLoadingAlert();
  240. state.showPopup = false
  241. state.disabled = true
  242. });
  243. })
  244. .catch((err) => {
  245. console.log(err);
  246. tools.hideLoadingAlert();
  247. state.showPopup = false
  248. state.disabled = true
  249. });
  250. }
  251. function implementCmd(transOrderId, cmd, cmdResult, stepNo) {
  252. console.log("datas.stepNo1", stepNo)
  253. state.progressNum = Number(stepNo) * 10 + 10
  254. const options = {
  255. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  256. showLoading: false,
  257. data: {
  258. transOrderId, //步骤号
  259. cmd,
  260. cmdResult,
  261. stepNo,
  262. mpOpenId: getItem('mpOpenId') //公众号openid
  263. }, //请求参数
  264. method: "POST", //提交方式(默认POST)
  265. };
  266. console.log("options2222", options)
  267. console.log("二发指令回传==前,/iaw/issue/order/issueCallback",new Date(),options)
  268. //BDS-二发指令回传
  269. requestNew(issueCallback, options)
  270. .then((res) => {
  271. console.log("BDS-二发指令回传 ", res);
  272. const datas = res;
  273. console.log("二发指令回传==后,/iaw/issue/order/issueCallback",new Date(),res)
  274. console.log("在线激活 请求", datas);
  275. if (datas.stepNo == 100) {
  276. state.disabled = true
  277. tools.hideLoadingAlert();
  278. state.progressNum = 100
  279. setTimeout(() => {
  280. state.showPopup = false
  281. }, 1000)
  282. setTimeout(() => {
  283. msg("激活成功", {
  284. 'icon': 'success',
  285. 'duration': 3000
  286. })
  287. }, 2000)
  288. setTimeout(() => {
  289. getCardIdCommit()
  290. }, 5000)
  291. } else {
  292. console.log("datas.stepNo", datas.stepNo)
  293. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  294. implementCmd(transOrderId, datas.cmd, res.toString(), datas.stepNo)
  295. }, (err) => {
  296. console.log("err", err)
  297. state.showPopup = false
  298. state.disabled = true
  299. errorLog(datas.cmd, JSON.stringify(err), datas.stepNo)
  300. showModals(err.msg)
  301. });
  302. }
  303. })
  304. .catch((err) => {
  305. console.log(err);
  306. tools.hideLoadingAlert();
  307. state.showPopup = false
  308. state.disabled = true
  309. });
  310. }
  311. //开始激活 按钮事件
  312. const btn = () => {
  313. if (!state.disabled) {
  314. return;
  315. }
  316. state.disabled = false
  317. state.showPopup = true
  318. console.log('orderInfo参数', orderInfo, state.disabled)
  319. stopHeartbeat();
  320. cmdResult1()
  321. };
  322. //获取订单详情
  323. const getOrderDetails = (orderId) => {
  324. console.log('======获取订单信息======')
  325. const options = {
  326. type: 2,
  327. data: {
  328. orderId
  329. },
  330. method: "POST",
  331. showLoading: false,
  332. };
  333. state.disabled = false
  334. requestNew(orderDetailQuery, options).then((res) => {
  335. console.log("orderInfo", res);
  336. orderInfo = res.data;
  337. console.log("orderInfores", res);
  338. if (orderInfo) {
  339. fileDataStrings.userType = orderInfo.userType; //用户类型
  340. fileDataStrings.cardId = orderInfo.cardId;
  341. fileDataStrings.packageNum = orderInfo.packageNum;
  342. fileDataStrings.obuId = orderInfo.obuId;
  343. fileDataStrings.customerTel = orderInfo.customerTel;
  344. fileDataStrings.customerId = orderInfo.customerId;
  345. fileDataStrings.orderId = orderInfo.orderNo;
  346. fileDataStrings.vehiclePlateColorStr = getVehiclePlateColor(orderInfo
  347. .vehiclePlateColor);
  348. fileDataStrings.vehiclePlate = orderInfo.vehiclePlate; //车牌
  349. fileDataStrings.vehicleClassStr = orderInfo.vehicleClassStr;
  350. }
  351. });
  352. getObuId();
  353. };
  354. /**
  355. * 获取OBU号 读OBU
  356. */
  357. const getObuId = () => {
  358. console.log('======获取OBU号======')
  359. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  360. bluetoothUtil.transCmd(cmdArray, "20", function(res) {
  361. var status = res[1].substring(res[1].length - 4, res[1].length);
  362. console.log('获取OBU号执行结果' + status, res)
  363. //第一次获取随机数
  364. if (status == "9000") {
  365. state.disabled = true
  366. obu.obuId = res[1].substring(20, 36);
  367. obu.vin = res[1].substring(18, 20);
  368. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  369. cmdRandNum = res[2].substring(0, res[2].length - 4);
  370. getCardId()
  371. } else {
  372. showModals('获取设备信息错误!')
  373. }
  374. }, () => {
  375. showModals('获取设备信息错误')
  376. });
  377. };
  378. function showModals(msg) {
  379. uni.showModal({
  380. title: '提示',
  381. content: msg,
  382. showCancel: false,
  383. success: function(res) {
  384. if (res.confirm) {
  385. uni.navigateBack()
  386. console.log('用户点击确定1');
  387. } else if (res.cancel) {
  388. console.log('用户点击取消1');
  389. }
  390. }
  391. });
  392. }
  393. const back = () => {
  394. uni.switchTab({
  395. url: "/pages/index/index"
  396. });
  397. }
  398. const getCardId = () => {
  399. //执行0015文件
  400. tools.showLoadingAlert("执行指令");
  401. let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY, cmd.CMD_GETBALANCE];
  402. console.log(cmdArr);
  403. console.log(bluetoothUtil);
  404. bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU
  405. console.log("5201", res)
  406. let str = res[2].substring(res[2].length - 4, res[2].length); //判断是否为9000
  407. let str3 = res[3].substring(res[3].length - 4, res[3].length); //判断是否为9000
  408. if (str == "9000" || str3 == "9000") {
  409. if (res[2].length > 86 || res[3] >= 12) {
  410. card.cardId = res[2].substring(20, 40);
  411. tools.hideLoadingAlert();
  412. state.showBtn = true
  413. startHeartbeat()
  414. } else {
  415. alertF("CMD_READBINARY指令长度不符" + res[2]);
  416. }
  417. return;
  418. }
  419. alertF("CMD_READBINARY指令长度不符" + res[2]);
  420. })
  421. };
  422. const errorLog = (cmd, error, step) => {
  423. console.log('激活异常提交')
  424. const options = {
  425. type: 2,
  426. data: {
  427. cardId: card.cardId,
  428. obuId: obu.obuId,
  429. orderType: "1",
  430. factory: datas.getData("deviceName") + "_" + datas.getData("deviceNameZW"),
  431. orderNo: orderInfo.orderNo,
  432. cmd,
  433. error,
  434. step
  435. },
  436. method: "POST",
  437. showLoading: false,
  438. };
  439. requestNew(errorLogAdd, options).then((res) => {
  440. console.log("错误提交成功", res);
  441. });
  442. };
  443. /**
  444. * 获取卡号
  445. */
  446. const getCardIdCommit = () => {
  447. //执行0015文件
  448. tools.showLoadingAlert("执行指令");
  449. let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY, cmd.CMD_GETBALANCE];
  450. console.log(cmdArr);
  451. console.log(bluetoothUtil);
  452. bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU
  453. console.log("5201", res)
  454. let str = res[2].substring(res[2].length - 4, res[2].length); //判断是否为9000
  455. let str3 = res[3].substring(res[3].length - 4, res[3].length); //判断是否为9000
  456. if (str == "9000" || str3 == "9000") {
  457. if (res[2].length > 86 || res[3] >= 12) {
  458. console.log("res[2]", res[2].substring(84, 86), getVehiclePlateColor(parseInt(res[2]
  459. .substring(82, 84), 16)), res[2].substring(18, 19))
  460. card.cardNo = res[2].substring(20, 40);
  461. card.startTime = res[2].substring(40, 48);
  462. card.endTime = res[2].substring(48, 56);
  463. card.version = res[2].substring(18, 20);
  464. card.money = res[3].substring(0, 8);
  465. card.v_userType = parseInt(res[2].substring(80, 82), 16);
  466. console.log("card.v_userType", card.v_userType)
  467. decryptCardVehicleInformation(res[2].substring(56, 80), function(res) {
  468. card.vehiclePlate = res;
  469. });
  470. console.log("res[2].substring(18, 19)", res[2].substring(18, 20))
  471. if (res[2].substring(18, 19) >= 4) {
  472. //4x卡
  473. card.type = parseInt(res[2].substring(84, 86), 16);
  474. card.typeStr = getVehicleType(parseInt(res[2].substring(84, 86), 16));
  475. card.color = parseInt(res[2].substring(82, 84), 16)
  476. card.colorStr = getVehiclePlateColor(parseInt(res[2].substring(82, 84), 16))
  477. } else {
  478. //2x卡--获取车牌颜色
  479. card.type = "--";
  480. card.color = parseInt(res[2].substring(82, 84), 16)
  481. card.colorStr = getVehiclePlateColor(parseInt(res[2].substring(82, 84), 16))
  482. card.typeStr = getVehicleType(parseInt(res[2].substring(84, 86), 16));
  483. }
  484. state.vehicleId = card.vehiclePlate + "_" + parseInt(res[2].substring(82, 84), 16)
  485. // 读卡信息
  486. //执行0016文件
  487. let arr = [cmd.HOME_DIRECTORY, cmd.PERSONAL_INFORMATION]
  488. bluetoothUtil.transCmd(arr, '10', function(res) {
  489. let str2 = res[1].substring(res[1].length - 4, res[1].length);
  490. if (str2 == "9000") {
  491. if (res[1].length > 108) {
  492. console.log("res====", res)
  493. decryptCardVehicleInformation(res[1].substring(4, 44), function(res) {
  494. card.userName = res; //姓名
  495. card.userNameStr = card.userName[0] + '*'.repeat(card
  496. .userName.length - 1)
  497. });
  498. decryptCardVehicleInformation(res[1].substring(44, 108), function(
  499. res) {
  500. card.idNum = res; //身份证号码
  501. card.idNumStr = res.replace(/^\d{14}/, '**************')
  502. });
  503. //获取是否有优惠
  504. let cmdArr3 = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd
  505. .CMD_00B08E0000
  506. ];
  507. bluetoothUtil.transCmd(cmdArr3, '10', function(res) {
  508. let str3 = res[2].substring(res[2].length - 4, res[2]
  509. .length);
  510. if (str3 == "9000") {
  511. if (res[2].length > 131) {
  512. let _str = parseInt(res[2].substring(129, 130),
  513. 16);
  514. card.favourable = _str
  515. switch (_str) {
  516. case 0:
  517. card.favourableStr = "否";
  518. break;
  519. case 1:
  520. card.favourableStr = "是";
  521. break;
  522. default:
  523. card.favourableStr = '未知' + "_" + _str;
  524. break;
  525. }
  526. //回调读取OBU指令
  527. getObuIdCommit()
  528. tools.hideLoadingAlert();
  529. } else {
  530. alertF("CMD_00B08E0000指令长度不符" + res[2]);
  531. }
  532. return;
  533. }
  534. alertF(cmd.PERSONAL_INFORMATION + "_" + str);
  535. })
  536. } else {
  537. alertF("PERSONAL_INFORMATION指令长度不符" + res[1]);
  538. }
  539. return;
  540. }
  541. alertF("PERSONAL_INFORMATION指令长度不符" + res[1]);
  542. })
  543. } else {
  544. alertF("CMD_READBINARY指令长度不符" + res[2]);
  545. }
  546. return;
  547. }
  548. alertF("CMD_READBINARY指令长度不符" + res[2]);
  549. })
  550. };
  551. /**
  552. * 获取OBU号
  553. */
  554. const getObuIdCommit = () => {
  555. tools.showLoadingAlert("执行指令");
  556. let cmdArr = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE];
  557. bluetoothUtil.transCmd(cmdArr, '20', function(res) {
  558. let str = res[1].substring(res[1].length - 4, res[1].length);
  559. if (str == "9000") {
  560. if (res[1].length > 52) {
  561. obu.num = res[1].substring(20, 36);
  562. obu.startTime = res[1].substring(36, 44);
  563. obu.endTime = res[1].substring(44, 52);
  564. obu.version = res[1].substring(18, 20);
  565. obu.isJH = res[1].substring(53, 54)
  566. obu.isJHStr = res[1].substring(53, 54) == "1" ? "是" : res[1].substring(53, 54) == "0" ?
  567. "否" : "其他:" + res[1].substring(53, 54);
  568. obu.loadStatus = res[1].substring(52, 54) == '01' ? '正常' : '已拆卸',
  569. console.log("开始执行车辆信息识读");
  570. let rand = res[1].substring(18, 20) >= 50 ? '40' : '00';
  571. var arr = [cmd.OBU_DF01, '00B400000A000000000000000045' + rand];
  572. bluetoothUtil.transCmd(arr, '20', function(res) {
  573. console.log(res);
  574. console.log("开始执行车辆信息识读成功");
  575. let str2 = res[1].substring(res[1].length - 4, res[1].length);
  576. let obuVersion = res[1].substring(18, 20);
  577. let keyIndex = obuVersion > 50 ? '40' : '00';
  578. let reqType = '00';
  579. let proviceCode = '5201';
  580. if (str2 == "9000") {
  581. console.log("===========", obu.num, res[1].substring(0, res[1].length - 4))
  582. decryptObuVehicleInfo(obu.num, res[1].substring(0, res[1].length - 4),
  583. obuVersion, rand, reqType, proviceCode,
  584. function(res) {
  585. obu.approvedCount = res.approvedCount;
  586. obu.axleCount = res.axleCount;
  587. obu.axleDistance = res.axleDistance;
  588. obu.engineNum = res.engineNumber.replace(/\u0000/g, '');
  589. obu.type = res.collectionType;
  590. obu.typeStr = getVehicleType(res.collectionType);
  591. obu.userType = res.userType;
  592. if (res.userType == 0) {
  593. obu.userTypeStr = "普通车";
  594. } else if (res.userType == 6) {
  595. obu.userTypeStr = "公务车";
  596. }
  597. obu.vehiclePlate = res.vehiclePlate.replace(/\u0000/g, '');
  598. //获取车牌颜色
  599. obu.vehiclePlateColor = res.vehiclePlateColor;
  600. obu.vehiclePlateColorStr = getVehiclePlateColor(res
  601. .vehiclePlateColor);
  602. obu.vin = res.vin.replace(/\u0000/g, '');
  603. obu.wheelCount = res.wheelsCount;
  604. obu.outsideDimensions = res.carLong + "x" + res.carWidth +
  605. "x" + res.carHeight
  606. getObuList();
  607. tools.hideLoadingAlert();
  608. });
  609. //断开蓝牙
  610. bluetoothUtil.disconnectDevice();
  611. tools.showToastAlert("蓝牙已断开");
  612. console.log('蓝牙已断开=========')
  613. return;
  614. }
  615. alertF("OBU_00B400000A+rand+OBU_4F00指令长度不符" + res[1]);
  616. })
  617. } else {
  618. alertF("OBU_SYSTEM_FILE指令长度不符" + res[1]);
  619. }
  620. return;
  621. }
  622. alertF("OBU_SYSTEM_FILE指令长度不符" + res[1]);
  623. })
  624. };
  625. const getObuList = () => {
  626. var data = {
  627. obuId: obu.num,
  628. cardId: card.cardNo,
  629. };
  630. const options = {
  631. type: 2,
  632. data: data,
  633. method: "POST",
  634. showLoading: true,
  635. };
  636. requestNew(cardObuQuery, options).then((res) => {
  637. tools.hideLoadingAlert();
  638. let result = res;
  639. state.obuStatus = result.obuStatus ? result.obuStatus : ""
  640. state.cardStatus = result.cardStatus
  641. if (result.cardType == 1 && result.debitType == 1) {
  642. state.cardTypeName = "预存卡"
  643. card['cardTypeName'] = 3
  644. } else if (result.cardType == 2) {
  645. state.cardTypeName = "储值卡"
  646. card['cardTypeName'] = 2
  647. } else {
  648. state.cardTypeName = "记账卡"
  649. card['cardTypeName'] = 1
  650. }
  651. // 卡签提交得信息
  652. card['cardStatus'] = result.cardStatus
  653. obu['obuStatus'] = result.obuStatus ? result.obuStatus : ""
  654. cardObuMsgUp()
  655. })
  656. }
  657. // 签信息提交日志记录
  658. const cardObuMsgUp = () => {
  659. var data = {
  660. cardLogInfo: card,
  661. obuLogInfo: obu,
  662. type: "active"
  663. };
  664. const options = {
  665. type: 2,
  666. data: data,
  667. method: "POST",
  668. showLoading: true,
  669. };
  670. requestNew(cardObuQueryinLog, options).then((res) => {
  671. tools.hideLoadingAlert();
  672. navTo(`/subpackage/after-sale/activation/result`)
  673. console.log("提交成功")
  674. })
  675. }
  676. /**
  677. * 解密OBU车辆信息
  678. */
  679. const decryptObuVehicleInfo = (num, data, obuVersion, keyIndex, reqType, proviceCode, func) => {
  680. const options = {
  681. type: 2,
  682. data: {
  683. contractSN: num,
  684. cipherData: data,
  685. reqType: reqType,
  686. keyIndex: keyIndex,
  687. proviceCode: proviceCode
  688. },
  689. method: "POST",
  690. showLoading: true,
  691. };
  692. requestNew(obuFileDataDecrypt, options).then((res) => {
  693. console.log("obuFileDataDecrypt", res)
  694. const data = res
  695. func(data)
  696. });
  697. };
  698. //提示对话框
  699. const alertF = (msg) => {
  700. //隐藏加载框
  701. tools.hideLoadingAlert();
  702. //提示对话框
  703. tools.showModalAlert(msg);
  704. stopHeartbeat();
  705. }
  706. </script>
  707. <style>
  708. .containers {
  709. height: 100%;
  710. display: flex;
  711. flex-direction: column;
  712. align-items: center;
  713. justify-content: space-between;
  714. box-sizing: border-box;
  715. }
  716. .sec_info {
  717. width: 90%;
  718. height: auto;
  719. margin: 0 auto;
  720. box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.2);
  721. margin-top: 50rpx;
  722. border-radius: 20rpx;
  723. }
  724. .info_txt {
  725. width: 100%;
  726. height: 120rpx;
  727. line-height: 120rpx;
  728. text-align: center;
  729. color: #000;
  730. font-size: 36rpx;
  731. margin-bottom: 20rpx;
  732. }
  733. .info_plate {
  734. display: flex;
  735. flex-direction: row;
  736. width: 94%;
  737. height: 100rpx;
  738. margin: 0 auto;
  739. border-bottom: 2rpx solid #f2f2f2;
  740. }
  741. .info_plate text:nth-child(1) {
  742. height: 100rpx;
  743. text-align: left;
  744. line-height: 100rpx;
  745. font-size: 32rpx;
  746. color: #999;
  747. }
  748. .info_plate text:nth-child(2) {
  749. flex: 1;
  750. height: 100rpx;
  751. line-height: 100rpx;
  752. font-size: 32rpx;
  753. color: #333;
  754. margin-left: 50rpx;
  755. text-align: right;
  756. }
  757. /*提交按钮样式*/
  758. .up_btn {
  759. width: 85%;
  760. height: 100rpx;
  761. margin: 0 auto;
  762. margin-top: 50rpx;
  763. margin-bottom: 100rpx;
  764. }
  765. .up_btn button {
  766. width: 100%;
  767. height: 80rpx;
  768. line-height: 80rpx;
  769. color: white;
  770. font-size: 32rpx;
  771. text-align: center;
  772. background: linear-gradient(to right, #01243A, #004576);
  773. border-radius: 40rpx;
  774. outline: none;
  775. border: #4cd95f;
  776. }
  777. .button {
  778. width: 100%;
  779. height: 80rpx;
  780. line-height: 80rpx;
  781. color: white;
  782. font-size: 32rpx;
  783. text-align: center;
  784. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  785. border-radius: 40rpx;
  786. outline: none;
  787. border: #4cd95f;
  788. }
  789. .hui {
  790. width: 100%;
  791. height: 80rpx;
  792. line-height: 80rpx;
  793. color: white;
  794. font-size: 32rpx;
  795. text-align: center;
  796. background: linear-gradient(to left, #b9b9b9 0%, #e7e7e7 100%) !important;
  797. border-radius: 40rpx;
  798. outline: none;
  799. border: #4cd95f;
  800. }
  801. .up_btn button[disabled] {
  802. background-color: rgba(0, 191, 112, 0.5);
  803. color: white;
  804. font-size: 34rpx;
  805. border-radius: 20rpx;
  806. }
  807. .mask {
  808. width: 100%;
  809. height: 100vh;
  810. background: rgba(0, 0, 0, 0.63);
  811. position: fixed;
  812. left: 0;
  813. top: 0;
  814. right: 0;
  815. bottom: 0;
  816. z-index: 999;
  817. display: flex;
  818. align-items: center;
  819. justify-content: center;
  820. }
  821. </style>