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

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