Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

activate.vue 27KB

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