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

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