Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

activate.vue 33KB

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