Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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