您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

activate.vue 26KB

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