Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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