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

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