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

activate.vue 32KB

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