Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

activate.vue 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  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">
  18. <text>卡号</text>
  19. <text>{{ fileDataStrings.cardId }}</text>
  20. </view>
  21. <view class="info_plate">
  22. <text>OBU号</text>
  23. <text>{{ fileDataStrings.obuId }}</text>
  24. </view>
  25. </view>
  26. <view class="up_btn">
  27. <button aria-disabled="true" @click="btn" :disabled="disabled">
  28. 点击开始激活
  29. </button>
  30. </view>
  31. </view>
  32. <!-- 激活成功popup -->
  33. <u-popup v-model="state.showPopup" mode="center">
  34. <active-success @cancel="state.showPopup = false"></active-success>
  35. </u-popup>
  36. </template>
  37. <script setup>
  38. import {
  39. reactive,
  40. ref
  41. } from "vue";
  42. import {
  43. formatTime,
  44. expireDate,
  45. expireDate2,
  46. getFormatDate
  47. } from "@/utils/utils";
  48. import {
  49. onLoad
  50. } from '@dcloudio/uni-app'
  51. import {
  52. getItem
  53. } from "@/utils/storage";
  54. import {
  55. request
  56. } from "@/utils/network/request.js";
  57. import {
  58. IntegerToHexString,
  59. AsciToHexString,
  60. } from "@/utils/util/fileData.js";
  61. import {
  62. stringToJson
  63. } from "@/utils/network/encryption.js";
  64. import * as IFCODE from "@/utils/network/api.js";
  65. const cmd = require("@/static/etcUtil/cmdConfig.js");
  66. const tools = require("@/static/etcUtil/tools.js");
  67. const bluetoothUtil = require("@/static/etcUtil/index.js");
  68. import activeSuccess from "./components/popup-device-active-success";
  69. const state = reactive({
  70. orderId: "",
  71. id: "",
  72. cardStatus: "",
  73. obuStatus: ""
  74. })
  75. onLoad(() => {
  76. //读取传入 存储的数据orderInfo
  77. let orderData = getItem("orderInfo");
  78. state.id = orderData.id;
  79. state.orderId = orderData.orderId;
  80. console.log(state);
  81. //获取订单详情
  82. getOrderDetails(state.id);
  83. })
  84. const card = reactive({
  85. cardId: "",
  86. netId: "",
  87. cardType: "",
  88. startTime: "",
  89. endTime: "",
  90. userName: "",
  91. idNum: "",
  92. vehiclePlate: "",
  93. vehiclePlateColor: "",
  94. color: "",
  95. version: "",
  96. type: "",
  97. favourable: "",
  98. money: "",
  99. v_userType: "",
  100. });
  101. const obu = reactive({
  102. obuId: "",
  103. startTime: "",
  104. endTime: "",
  105. version: "",
  106. approvedCount: "",
  107. axleCount: "",
  108. axleDistance: "",
  109. engineNum: "",
  110. type: "",
  111. userType: "",
  112. contractNo: "",
  113. vehiclePlate: "",
  114. vehiclePlateColor: "",
  115. vin: "",
  116. wheelCount: "",
  117. isJH: ""
  118. });
  119. const disabled = ref(false);
  120. let cmdRandNum = '';
  121. let orderInfo = {};
  122. const fileDataStrings = reactive({
  123. approvedCount: 0, //核载人数
  124. cardId: "", //卡号
  125. obuId: "", //obu号
  126. obuId: "", //obu号
  127. packageNum: "", //套餐编号
  128. axleCount: 0, //轴数
  129. axleDistance: "", //轴距
  130. engineNum: "", //发动机
  131. vehicleVin: "",
  132. vehicleEngineNum: "",
  133. cardStatus: "",
  134. obuStatus: "",
  135. type: 0, //类型
  136. userType: 0, //用户类型
  137. vehiclePlate: "", //车牌
  138. vehiclePlateColor: 0, //车牌颜色
  139. vehicleDimensions: "",
  140. outlineL: 0, //外廓 长
  141. outlineW: 0, //外廓 宽
  142. outlineH: 0, //外廓 高
  143. wheelCount: "", //车轮数
  144. vehicleIdNo: "", //车牌号
  145. vehiclePlateColorStr: "",
  146. customerTel: "",
  147. customerId: "",
  148. orderId: ""
  149. });
  150. //开始激活 按钮事件
  151. const btn = () => {
  152. console.log('orderInfo参数', orderInfo)
  153. if (orderInfo) {
  154. //根据订单详情走相应的断步功能
  155. const cardId = orderInfo.cardId;
  156. const cardStatus = orderInfo.cardStatus != null ? orderInfo.cardStatus : '0'
  157. const obuId = orderInfo.obuId;
  158. const obuStatus = orderInfo.obuStatus != null ? orderInfo.obuStatus : '9'
  159. console.log('当前卡签状态', cardId, obuId, cardStatus, obuStatus)
  160. if (obu.obuId != fileDataStrings.obuId) {
  161. tools.showModalAlert("订单设备号信息与当前设备号信息不符!");
  162. return
  163. }
  164. if (!cardId) { //卡发行
  165. getCardId()
  166. } else if (cardId && cardStatus == '0') { //卡发行
  167. getCardId()
  168. } else if (!obuId) { //OBU发行
  169. getObuApply();
  170. } else if (obuId && obuStatus == '9') { //OBU发行
  171. getObuApply();
  172. } else if (cardId && obuId && (obuStatus == '1' || obuStatus == '11' || obuStatus ==
  173. '0')) {
  174. getInstallApply(); //激活
  175. } else {
  176. getCardId()
  177. }
  178. }
  179. };
  180. //获取订单详情
  181. const getOrderDetails = (id) => {
  182. console.log('======获取订单信息======')
  183. const options = {
  184. type: 2,
  185. data: {
  186. id: id,
  187. },
  188. method: "POST",
  189. showLoading: true,
  190. };
  191. request(IFCODE.orderDetail, options).then((res) => {
  192. orderInfo = JSON.parse(res.bizContent);
  193. console.log("orderInfo",orderInfo);
  194. if (orderInfo) {
  195. fileDataStrings.userType = orderInfo.userType; //用户类型
  196. fileDataStrings.approvedCount = parseInt(orderInfo.vehicleApprovedCount); //核载人数
  197. fileDataStrings.cardId = orderInfo.cardId;
  198. fileDataStrings.packageNum = orderInfo.packageNum;
  199. fileDataStrings.obuId = orderInfo.obuId;
  200. fileDataStrings.vehicleVin = orderInfo.vehicleVin;
  201. fileDataStrings.vehicleEngineNum = orderInfo.vehicleEngineNum;
  202. fileDataStrings.axleCount = parseInt(orderInfo.vehicleAxleCount); //轴数
  203. fileDataStrings.engineNum = orderInfo.vehicleVin; //发动机
  204. fileDataStrings.type = parseInt(orderInfo.vehicleType); //类型
  205. fileDataStrings.vehiclePlate = orderInfo.vehiclePlate; //车牌
  206. fileDataStrings.vehiclePlateColor = orderInfo.vehiclePlateColor; //车牌颜色
  207. fileDataStrings.vehicleDimensions = orderInfo.vehicleDimensions;
  208. let arr = orderInfo.vehicleDimensions.split("X");
  209. fileDataStrings.outlineL = parseInt(arr[0]); //外廓 长
  210. fileDataStrings.outlineW = parseInt(arr[1]); //外廓 宽
  211. fileDataStrings.outlineH = parseInt(arr[2].substring(0, arr[2].length - 2)); //外廓 高
  212. fileDataStrings.vehicleIdNo = orderInfo.vehicleEngineNum; //车编号
  213. fileDataStrings.vehiclePlateColorStr = orderInfo.vehiclePlateColorStr;
  214. fileDataStrings.customerTel = orderInfo.customerTel;
  215. fileDataStrings.customerId = orderInfo.customerId;
  216. fileDataStrings.orderId = orderInfo.orderId;
  217. getObuId();
  218. }
  219. });
  220. };
  221. /**
  222. * 获取OBU号 读OBU
  223. */
  224. const getObuId = () => {
  225. console.log('======获取OBU号======')
  226. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  227. tools.showLoadingAlert("正在执行指令");
  228. bluetoothUtil.transCmd(cmdArray, "20", function(res) {
  229. tools.hideLoadingAlert();
  230. var status = res[1].substring(res[1].length - 4, res[1].length);
  231. console.log('获取OBU号执行结果' + status)
  232. //第一次获取随机数
  233. if (status == "9000") {
  234. obu.obuId = res[1].substring(20, 36);
  235. obu.vin = res[1].substring(18, 20);
  236. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  237. cmdRandNum = res[2].substring(0, res[2].length - 4);
  238. }
  239. });
  240. };
  241. //获取fileData
  242. const getFileData = () => {
  243. console.log(fileDataStrings);
  244. //获取fileData 拼接字符串
  245. let res1 = AsciToHexString(fileDataStrings.vehiclePlate, 24); //车牌号
  246. let res2 = IntegerToHexString(fileDataStrings.vehiclePlateColor, 4); //车牌颜色
  247. let res3 = IntegerToHexString(1, 2); //类型
  248. let res4 = IntegerToHexString(1, 2); //用户类型
  249. let res5 = IntegerToHexString(fileDataStrings.outlineL, 4); //车辆尺寸 长
  250. let res6 = IntegerToHexString(fileDataStrings.outlineW, 2); //车辆尺寸 宽
  251. let res7 = IntegerToHexString(fileDataStrings.outlineH, 2); //车辆尺寸 高
  252. let res8 = IntegerToHexString(4, 2); //获取轮数
  253. let res9 = IntegerToHexString(4, 2); //轴数
  254. let res10 = IntegerToHexString(null, 4); //轴距32
  255. let res11 = IntegerToHexString(fileDataStrings.approvedCount, 6); //核载人数
  256. let res12 = AsciToHexString(fileDataStrings.vehicleVin, 32); //车编号
  257. let res13 = AsciToHexString(fileDataStrings.vehicleEngineNum, 32); //发动机
  258. return res1 + res2 + res3 + res4 + res5 + res6 + res7 + res8 + res9 + res10 + res11 + res12 + res13;
  259. };
  260. /**
  261. * 获取卡号 读卡
  262. */
  263. const getCardId = () => {
  264. console.log('======获取卡信息======')
  265. let cmdArr = [
  266. cmd.HOME_DIRECTORY,
  267. //选择主目
  268. cmd.APPLICATION_DIRECTORY,
  269. //选择文件1001--DF01联网收费应用目录
  270. cmd.CMD_READBINARY,
  271. //15文件--卡片发行基本数据文件
  272. cmd.CMD_GETBALANCE
  273. //钱包
  274. ];
  275. tools.showLoadingAlert("正在执行指令");
  276. bluetoothUtil.transCmd(cmdArr, "10", function(res) {
  277. tools.hideLoadingAlert();
  278. //10:写卡 20:写OBU
  279. let str = res[2].substring(res[2].length - 4, res[2].length);
  280. let str3 = res[3].substring(res[3].length - 4, res[3].length);
  281. if (str == "9000" || str3 == "9000") {
  282. if (res[2].length > 86 || res[3] >= 12) {
  283. card.cardId = res[2].substring(20, 40); //卡号
  284. card.startTime = res[2].substring(40, 48); //启用
  285. card.endTime = res[2].substring(48, 56);
  286. card.version = res[2].substring(18, 19) >= 4 ? "4x" : "2x";
  287. card.netId = res[2].substring(20, 24);
  288. card.cardType = res[2].substring(28, 30) == 23 ? 1 : 2; //23记账卡 非 23储值卡 1:记账卡 2:储值卡
  289. card.vehiclePlateColor = parseInt(res[2].substring(82, 84), 16);
  290. console.log('======卡信息======', card)
  291. if (card.cardId != fileDataStrings.cardId) {
  292. tools.showModalAlert("订单卡号与当前设备卡号信息不符!");
  293. return
  294. }
  295. getCardApply()
  296. } else {
  297. console.error("CMD_READBINARY指令长度不符" + res[2])
  298. tools.hideLoadingAlert();
  299. }
  300. }
  301. console.error("CMD_READBINARY指令长度不符" + res[2])
  302. tools.hideLoadingAlert();
  303. });
  304. };
  305. // *------------------------------------*
  306. // OBU开卡模块
  307. // *------------------------------------*
  308. /**
  309. * 写卡指令申请 请求
  310. */
  311. const getCardApply = () => {
  312. console.log('======写卡指令申请======')
  313. tools.showLoadingAlert("加载中");
  314. let options = {
  315. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  316. data: {
  317. cardId: card.cardId,
  318. orderId: fileDataStrings.orderId,
  319. cardType: card.cardType,
  320. userId: fileDataStrings.customerId,
  321. vehicleId: fileDataStrings.vehiclePlate + "_" + fileDataStrings.vehiclePlateColor,
  322. cosProvider: "1",
  323. enableTime: getFormatDate(new Date(), "yyyyMMdd"),
  324. expireTime: expireDate2(new Date())
  325. }, //请求参数
  326. method: "POST", //提交方式(默认POST)
  327. showLoading: true, //是否显示加载中(默认显示)
  328. };
  329. //调用方式
  330. request(IFCODE.writeCardApply, options)
  331. .then((res) => {
  332. tools.hideLoadingAlert();
  333. let result = stringToJson(res.bizContent);
  334. tools.showLoadingAlert("执行指令中");
  335. bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
  336. tools.hideLoadingAlert();
  337. getCommandBack(result.command, result.cosRecordId, res.toString());
  338. });
  339. })
  340. };
  341. /**
  342. * 写卡指令返回 请求
  343. */
  344. const getCommandBack = (command, cosRecordId, response) => {
  345. console.log('======循环写卡指令中======')
  346. tools.showLoadingAlert("加载中");
  347. let options = {
  348. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  349. data: {
  350. cardId: card.cardId,
  351. orderId: fileDataStrings.orderId,
  352. command: command,
  353. response: response,
  354. cosRecordId: cosRecordId,
  355. cosType: "1"
  356. }, //请求参数
  357. method: "POST", //提交方式(默认POST)
  358. showLoading: true, //是否显示加载中(默认显示)
  359. };
  360. //调用方式
  361. request(IFCODE.writeCardBack, options)
  362. .then((res) => {
  363. tools.hideLoadingAlert();
  364. let result = JSON.parse(res.bizContent);
  365. if (result.orderStatus == 1 || result.orderStatus == "1") {
  366. tools.showLoadingAlert("执行指令中");
  367. bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
  368. tools.hideLoadingAlert();
  369. let response = res.toString();
  370. getCommandBack(result.command, cosRecordId, response);
  371. });
  372. } else {
  373. getWriteCard();
  374. }
  375. })
  376. };
  377. /**
  378. * 写卡确认 请求
  379. */
  380. const getWriteCard = () => {
  381. tools.showLoadingAlert("请求中");
  382. console.log('======写卡确认======')
  383. let options = {
  384. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  385. data: {
  386. cardId: card.cardId,
  387. orderId: fileDataStrings.orderId,
  388. netId: card.netId,
  389. packageNum: fileDataStrings.packageNum,
  390. cardType: card.cardType == 1 ? "111" : "211",
  391. brand: "3",
  392. model: "0",
  393. enableTime: formatTime(new Date()),
  394. expireTime: formatTime(new Date()),
  395. accountOrganization: "",
  396. accountCardNo: "",
  397. cosRecordId: ""
  398. }, //请求参数
  399. method: "POST", //提交方式(默认POST)
  400. showLoading: true, //是否显示加载中(默认显示)
  401. };
  402. //调用方式
  403. request(IFCODE.writeCardConfirm, options)
  404. .then((res) => {
  405. tools.hideLoadingAlert();
  406. console.log(stringToJson(res.bizContent));
  407. //OBU发行申请 请求
  408. getObuApply()
  409. })
  410. .catch((err) => {
  411. console.log(err);
  412. });
  413. };
  414. // *------------------------------------*
  415. // OBU 发行模块
  416. // *------------------------------------*
  417. /**
  418. * OBU发行申请 请求
  419. */
  420. const getObuApply = () => {
  421. console.log('======OBU发行申请======')
  422. tools.showLoadingAlert("加载中");
  423. let options = {
  424. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  425. data: {
  426. obuId: obu.obuId,
  427. userId: fileDataStrings.customerId,
  428. vehicleId: fileDataStrings.vehiclePlate + "_" + fileDataStrings.vehiclePlateColor
  429. }, //请求参数
  430. method: "POST", //提交方式(默认POST)
  431. showLoading: true, //是否显示加载中(默认显示)
  432. };
  433. //调用方式
  434. request(IFCODE.writeObuApply, options)
  435. .then(() => {
  436. tools.hideLoadingAlert();
  437. modifyFileInfo()
  438. })
  439. };
  440. /**
  441. * 修改系统信息 请求
  442. */
  443. const modifyFileInfo = () => {
  444. console.log('======修改系统信息请求======')
  445. var datetime = new Date();
  446. var year = datetime.getFullYear();
  447. var year1 = datetime.getFullYear() + 10;
  448. var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
  449. var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
  450. tools.showLoadingAlert("加载中");
  451. let options = {
  452. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  453. data: {
  454. obuSerailNo: obu.obuId, //OBU号
  455. obuVersion: obu.vin, //OBU版本号
  456. effTime: year + "" + month + "" + date, //启用时间
  457. expIime: year1 + "" + month + "" + date, //结束时间
  458. plateNo: fileDataStrings.vehiclePlate,
  459. pColor: fileDataStrings.vehiclePlateColor,
  460. random: cmdRandNum
  461. }, //请求参数
  462. method: "POST", //提交方式(默认POST)
  463. showLoading: true, //是否显示加载中(默认显示)
  464. };
  465. //调用方式
  466. request(IFCODE.modifyObuSysInfo, options)
  467. .then((res) => {
  468. tools.hideLoadingAlert();
  469. const datas = stringToJson(res.bizContent);
  470. tools.showLoadingAlert("执行指令");
  471. //如果存在APDU->穿透指令
  472. if (datas.data.APDU) {
  473. bluetoothUtil.transCmd([datas.data.APDU], "20", function(res) {
  474. tools.hideLoadingAlert();
  475. if (res[0] == "9000") {
  476. tools.showLoadingAlert("执行指令");
  477. //再次获取随机数
  478. let cmdArr = [cmd.HOME_DIRECTORY, cmd.OBU_DF01, cmd.OBU_EF01, cmd.RANDOM_NUMBER];
  479. bluetoothUtil.transCmd(cmdArr, '20', function(res) {
  480. var str = res[3].substring(res[3].length - 4, res[3].length);
  481. if (str == "9000") {
  482. cmdRandNum = res[3].substring(0, res[3].length - 4);
  483. modifyVehicle();
  484. } else {
  485. tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
  486. }
  487. })
  488. }
  489. });
  490. }
  491. })
  492. .catch((err) => {
  493. console.log(err);
  494. });
  495. };
  496. /**
  497. * 修改车辆信息 请求
  498. */
  499. const modifyVehicle = () => {
  500. tools.showLoadingAlert("加载中");
  501. console.log('======修改车辆信息======')
  502. let options = {
  503. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  504. data: {
  505. Status: "0",
  506. random: cmdRandNum, //5202192509222239
  507. obuSerailNo: obu.obuId, //5202192509551922
  508. fileData: getFileData(),
  509. orderId: fileDataStrings.orderId,
  510. }, //请求参数
  511. method: "POST", //提交方式(默认POST)
  512. showLoading: true, //是否显示加载中(默认显示)
  513. };
  514. //调用方式
  515. request(IFCODE.modifyObuVehicleInfo, options)
  516. .then((res) => {
  517. tools.hideLoadingAlert();
  518. const datas = stringToJson(res.bizContent);
  519. tools.showLoadingAlert("正在执行指令");
  520. if (datas.data.APDU) {
  521. bluetoothUtil.transCmd([datas.data.APDU], "20", function(res) {
  522. console.log('执行指令结果', res)
  523. tools.hideLoadingAlert();
  524. if (res[0] == "9000") {
  525. getObuConfirm();
  526. }
  527. });
  528. }
  529. })
  530. };
  531. /**
  532. * OBU确认发行 请求
  533. */
  534. const getObuConfirm = () => {
  535. console.log('======OBU确认发行======')
  536. tools.showLoadingAlert("加载中");
  537. let options = {
  538. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  539. data: {
  540. obuId: obu.obuId,
  541. orderId: fileDataStrings.orderId,
  542. netId: obu.obuId.substring(0, 4),
  543. brand: obu.brand,
  544. model: obu.version,
  545. enableTime: formatTime(new Date()),
  546. expireTime: expireDate(new Date())
  547. }, //请求参数
  548. method: "POST", //提交方式(默认POST)
  549. showLoading: true, //是否显示加载中(默认显示)
  550. };
  551. //调用方式
  552. request(IFCODE.obuConfirm, options)
  553. .then((res) => {
  554. tools.hideLoadingAlert();
  555. let datas = stringToJson(res.bizContent);
  556. if (datas.obuId) {
  557. getInstallApply()
  558. }
  559. })
  560. .catch((err) => {
  561. console.log(err);
  562. });
  563. };
  564. // *------------------------------------*
  565. // 设备发行模块
  566. // *------------------------------------*
  567. /**
  568. * BDS-安装申请 请求
  569. */
  570. const getInstallApply = () => {
  571. console.log('======安装申请======')
  572. tools.showLoadingAlert("加载中");
  573. let options = {
  574. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  575. data: {
  576. obuId: obu.obuId,
  577. vehicleId: fileDataStrings.vehiclePlate + "_" + fileDataStrings.vehiclePlateColor,
  578. orderId: fileDataStrings.orderId,
  579. agentId: "52010106004",
  580. channelId: "5201010200601130001",
  581. channelType: "1",
  582. staffId: "opId",
  583. terminalId: "999999999",
  584. }, //请求参数
  585. method: "POST", //提交方式(默认POST)
  586. showLoading: true, //是否显示加载中(默认显示)
  587. };
  588. //调用方式
  589. request(IFCODE.installApply, options)
  590. .then(() => {
  591. tools.hideLoadingAlert();
  592. // //再次获取随机数
  593. // let cmdArr = [cmd.HOME_DIRECTORY, cmd.RANDOM_NUMBER];
  594. // bluetoothUtil.transCmd(cmdArr, '20', function(res) {
  595. // var str = res[1].substring(res[1].length - 4, res[1].length);
  596. // if (str == "9000") {
  597. // cmdRandNum = res[1].substring(0, res[1].length - 4);
  598. // getObuActivation(cmdRandNum);
  599. // } else {
  600. // tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
  601. // }
  602. // })
  603. //再次获取随机数
  604. let cmdArr = [cmd.HOME_DIRECTORY, cmd.RANDOM_NUMBER];
  605. bluetoothUtil.transCmd(cmdArr, '20', function(res) {
  606. var str = res[1].substring(res[1].length - 4, res[1].length);
  607. if (str == "9000") {
  608. cmdRandNum = res[1].substring(0, res[1].length - 4);
  609. getObuActivation();
  610. } else {
  611. tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
  612. }
  613. })
  614. })
  615. };
  616. /**
  617. * VFJ-OBU在线激活 请求
  618. */
  619. const getObuActivation = () => {
  620. console.log('======VFJ-OBU在线激活======')
  621. tools.showLoadingAlert("加载中");
  622. let options = {
  623. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  624. data: {
  625. random: cmdRandNum,
  626. obuSerailNo: obu.obuId,
  627. orderId: fileDataStrings.orderId,
  628. }, //请求参数
  629. method: "POST", //提交方式(默认POST)
  630. showLoading: true, //是否显示加载中(默认显示)
  631. };
  632. //调用方式
  633. request(IFCODE.obuActivation, options)
  634. .then((res) => {
  635. tools.hideLoadingAlert();
  636. console.log("在线激活 请求");
  637. console.log(stringToJson(res.bizContent));
  638. const datas = stringToJson(res.bizContent);
  639. tools.showLoadingAlert("执行指令");
  640. bluetoothUtil.transCmd([datas.data.APDU], "20", function(res) {
  641. tools.hideLoadingAlert();
  642. console.log(res);
  643. if (res[0] == "9000") {
  644. console.log("在线激活执行指令88888 请求", res);
  645. getObuInstall(0, ""); //status 0 - 安装成功 || 1 - 安装失败
  646. }
  647. });
  648. })
  649. .catch((err) => {
  650. console.log(err);
  651. });
  652. };
  653. /**
  654. * BDS-安装确认 请求
  655. */
  656. const getObuInstall = (status, reason) => {
  657. console.log('======OBU安装确认======')
  658. tools.showLoadingAlert("加载中");
  659. let options = {
  660. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  661. data: {
  662. installStatus: status,
  663. failReason: reason,
  664. installType: "1",
  665. installChannelId: "5201010200601130001",
  666. obuId: obu.obuId,
  667. orderId: fileDataStrings.orderId
  668. }, //请求参数
  669. method: "POST", //提交方式(默认POST)
  670. showLoading: true, //是否显示加载中(默认显示)
  671. };
  672. //调用方式
  673. request(IFCODE.obuInstall, options)
  674. .then(() => {
  675. tools.hideLoadingAlert();
  676. // uni.navigateTo({
  677. // url: "/subpackage/orders/order-details-new?id=" +
  678. // state.id +
  679. // "&orderId=" +
  680. // state.orderId,
  681. // });
  682. uni.navigateTo({
  683. url: "/subpackage/after-sale/deviceInfo/deviceInfo",
  684. });
  685. });
  686. };
  687. </script>
  688. <style>
  689. .containers {
  690. height: 100%;
  691. display: flex;
  692. flex-direction: column;
  693. align-items: center;
  694. justify-content: space-between;
  695. box-sizing: border-box;
  696. }
  697. .sec_info {
  698. width: 90%;
  699. height: auto;
  700. margin: 0 auto;
  701. box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.2);
  702. margin-top: 50rpx;
  703. border-radius: 20rpx;
  704. }
  705. .info_txt {
  706. width: 100%;
  707. height: 120rpx;
  708. line-height: 120rpx;
  709. text-align: center;
  710. color: #000;
  711. font-size: 36rpx;
  712. margin-bottom: 20rpx;
  713. }
  714. .info_plate {
  715. display: flex;
  716. flex-direction: row;
  717. width: 94%;
  718. height: 100rpx;
  719. margin: 0 auto;
  720. border-bottom: 2rpx solid #f2f2f2;
  721. }
  722. .info_plate text:nth-child(1) {
  723. height: 100rpx;
  724. text-align: left;
  725. line-height: 100rpx;
  726. font-size: 32rpx;
  727. color: #999;
  728. }
  729. .info_plate text:nth-child(2) {
  730. flex: 1;
  731. height: 100rpx;
  732. line-height: 100rpx;
  733. font-size: 32rpx;
  734. color: #333;
  735. margin-left: 50rpx;
  736. text-align: right;
  737. }
  738. /*提交按钮样式*/
  739. .up_btn {
  740. width: 85%;
  741. height: 100rpx;
  742. margin: 0 auto;
  743. margin-top: 50rpx;
  744. margin-bottom: 100rpx;
  745. }
  746. .up_btn button {
  747. width: 100%;
  748. height: 80rpx;
  749. line-height: 80rpx;
  750. color: white;
  751. font-size: 32rpx;
  752. text-align: center;
  753. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  754. border-radius: 40rpx;
  755. outline: none;
  756. border: #4cd95f;
  757. }
  758. .up_btn button[disabled] {
  759. background-color: rgba(0, 191, 112, 0.5);
  760. color: white;
  761. font-size: 34rpx;
  762. border-radius: 20rpx;
  763. }
  764. </style>