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

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