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 33KB

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