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

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