You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

activate.vue 32KB

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