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.

activation-once-again.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <view class="selectCar-box">
  3. <view class="details">
  4. <view class="title"> 基础信息 </view>
  5. <view class="details-item">
  6. <view> 订单编号: </view>
  7. <text>{{ orderInfos.orderId }}</text>
  8. </view>
  9. <view class="details-item">
  10. <view> 用户名称: </view>
  11. <text>{{ orderInfos.ownerName }}</text>
  12. </view>
  13. <view class="details-item">
  14. <view> 用户证件类型: </view>
  15. <text>{{ getCodeName('CERTIFICATE_TYPE',orderInfos.ownerIdtype) }}</text>
  16. </view>
  17. <view class="details-item">
  18. <view> 用户证件号: </view>
  19. <text>{{ orderInfos.ownerIdnum }}</text>
  20. </view>
  21. <view class="details-item">
  22. <view> 订单车牌号: </view>
  23. <text style="color: #00b38b">{{ orderInfos.vehiclePlate }}</text>
  24. </view>
  25. <view class="details-item">
  26. <view> 车牌颜色: </view>
  27. <text style="color: #00b38b">{{
  28. orderInfos.vehiclePlateColorStr
  29. }}</text>
  30. </view>
  31. <view class="details-item">
  32. <view> 收费车型: </view>
  33. <text>{{ orderInfos.vehicleType }}</text>
  34. </view>
  35. </view>
  36. <view class="title"> 卡信息 </view>
  37. <view class="card">
  38. <view class="card-left">
  39. <image :src="`${$imgUrl}card2.png`" mode=""></image>
  40. <view class="card-center">
  41. <view class="card-center-head"> {{orderInfos.cardId}} </view>
  42. <view class="tips">
  43. <text>储蓄卡</text>
  44. <text class="tips-card">{{getCodeName('CARD_STATE_TYPE',orderInfos.cardStatus)}}</text>
  45. </view>
  46. <!-- <view class="choose-item"> 有效期:xxxx-xx-xx </view> -->
  47. </view>
  48. </view>
  49. </view>
  50. <view class="title"> OBU设备信息 </view>
  51. <view class="card">
  52. <view class="card-left">
  53. <image :src="`${$imgUrl}card1.png`" mode=""></image>
  54. <view class="card-center">
  55. <view class="card-center-head"> {{orderInfos.obuId}} </view>
  56. <view class="tips">
  57. <!-- <text>储蓄卡</text> -->
  58. <text class="tips-card">{{getCodeName('OBU_STATE_TYPE',orderInfos.obuStatus)}}</text>
  59. </view>
  60. <!-- <view class="choose-item"> 有效期:xxxx-xx-xx </view> -->
  61. </view>
  62. </view>
  63. </view>
  64. <button class="submit" @click="toPage">再次激活</button>
  65. <view class="mask" v-show="state.showPopup">
  66. <view class="main">
  67. <view class="top">
  68. <image class="icon-close" :src="`${$imgUrl}common/icon-close.png`" @click="cancel"></image>
  69. </view>
  70. <image class="icon-success" :src="`${$imgUrl}bluetooth/device-active-success.png`"></image>
  71. <view class="title">设备激活成功!</view>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script lang="ts" setup>
  77. import {
  78. reactive,
  79. ref
  80. } from "vue";
  81. import {
  82. formatTime,
  83. expireDate,
  84. expireDate2,
  85. getFormatDate,
  86. msg,
  87. navTo
  88. } from "@/utils/utils";
  89. import {
  90. onLoad, onShow
  91. } from '@dcloudio/uni-app'
  92. // import {
  93. // getItem
  94. // } from "../../utils/storage";
  95. import {
  96. request
  97. } from "@/utils/network/request.js";
  98. // import {
  99. // IntegerToHexString,
  100. // AsciToHexString,
  101. // } from "../../utils/util/fileData.js";
  102. import {
  103. stringToJson
  104. } from "@/utils/network/encryption.js";
  105. import activeSuccess from "./components/popup-device-active-success";
  106. import * as IFCODE from "@/utils/network/api.js";
  107. const cmd = require("../../../static/etcUtil/cmdConfig.js");
  108. const tools = require("../../../static/etcUtil/tools.js");
  109. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  110. import {
  111. getCodeName
  112. } from "@/datas/queryKey.js";
  113. const state = reactive({
  114. showPopup: false
  115. })
  116. //订单
  117. const orderInfos = reactive({
  118. orderId: "",
  119. ownerName: "",
  120. ownerIdtype: "",
  121. ownerIdnum: "",
  122. vehiclePlate: "",
  123. vehiclePlateColorStr: "",
  124. vehiclePlateColor: "",
  125. vehicleType: "",
  126. cardId: "",
  127. cardStatus: "",
  128. obuId: "",
  129. obuStatus: "",
  130. outlineL: 0,
  131. outlineW: 0,
  132. outlineH: 0,
  133. type: 0,
  134. axleCount: 0,
  135. approvedCount: 0,
  136. vehicleVin: "",
  137. vehicleEngineNum: "",
  138. });
  139. //OBU
  140. const obu = reactive({
  141. obuId: "",
  142. startTime: "",
  143. endTime: "",
  144. version: "",
  145. approvedCount: "",
  146. axleCount: "",
  147. axleDistance: "",
  148. engineNum: "",
  149. type: "",
  150. userType: "",
  151. contractNo: "",
  152. vehiclePlate: "",
  153. vehiclePlateColor: "",
  154. vin: "",
  155. wheelCount: "",
  156. isJH: ""
  157. });
  158. onLoad((option) => {
  159. console.log('======重新激活开始======', option);
  160. //请求订单详情
  161. queryOrderDetail(option.id);
  162. });
  163. onShow((option) => {
  164. uni.$on('bluetoothLink', res => {
  165. console.log(res);
  166. if (res.status) {
  167. // getCardRenewal()
  168. getObuId()
  169. }
  170. //移除监听
  171. console.log('======移除监听======', res)
  172. // uni.$off('bluetoothLink')
  173. })
  174. })
  175. const cancel = () => {
  176. state.showPopup = false;
  177. // navTo("/pages/service/service")
  178. uni.navigateBack({
  179. delta: 2
  180. })
  181. };
  182. const toPage = () => {
  183. navTo("/pages/bluetooth/bluetooth?routeType=5");
  184. };
  185. //获取订单详情
  186. const queryOrderDetail = (id : string) => {
  187. const options = {
  188. type: 2,
  189. data: {
  190. id: id,
  191. },
  192. method: "POST",
  193. showLoading: true,
  194. };
  195. request(IFCODE.orderDetail, options).then((res) => {
  196. let orderInfo = JSON.parse(res.bizContent);
  197. console.log(orderInfo);
  198. orderInfos.orderId = orderInfo.orderId;
  199. orderInfos.ownerName = orderInfo.ownerName;
  200. orderInfos.ownerIdtype = orderInfo.ownerIdtype;
  201. orderInfos.ownerIdnum = orderInfo.ownerIdnum;
  202. orderInfos.vehiclePlate = orderInfo.vehiclePlate;
  203. orderInfos.vehiclePlateColorStr = orderInfo.vehiclePlateColorStr;
  204. orderInfos.vehiclePlateColor = orderInfo.vehiclePlateColor;
  205. orderInfos.vehicleType = orderInfo.vehicleType;
  206. orderInfos.cardId = orderInfo.cardId;
  207. orderInfos.cardStatus = orderInfo.cardStatus;
  208. orderInfos.obuId = orderInfo.obuId;
  209. orderInfos.obuStatus = orderInfo.obuStatus;
  210. let arr = orderInfo.vehicleDimensions.split("x");
  211. orderInfos.outlineL = parseInt(arr[0]); //外廓 长
  212. orderInfos.outlineW = parseInt(arr[1]); //外廓 宽
  213. orderInfos.outlineH = parseInt(arr[2].substring(0, arr[2].length - 2)); //外廓 高
  214. orderInfos.type = orderInfo.type;
  215. orderInfos.axleCount = orderInfo.vehicleAxleCount;
  216. orderInfos.approvedCount = orderInfo.vehicleApprovedCount;
  217. orderInfos.vehicleVin = orderInfo.vehicleVin;
  218. orderInfos.vehicleEngineNum = orderInfo.vehicleEngineNum;
  219. });
  220. };
  221. /**
  222. * 获取OBU号 读OBU
  223. */
  224. const getObuId = () => {
  225. console.log('======获取OBU号======')
  226. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  227. tools.showLoadingAlert("正在执行指令");
  228. bluetoothUtil.transCmd(cmdArray, "20", function (res) {
  229. tools.hideLoadingAlert();
  230. var status = res[1].substring(res[1].length - 4, res[1].length);
  231. console.log('获取OBU号执行结果' + status)
  232. //第一次获取随机数
  233. if (status == "9000") {
  234. obu.obuId = res[1].substring(20, 36);
  235. obu.vin = res[1].substring(18, 20);
  236. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  237. getInstallApply()
  238. // cmdRandNum = res[2].substring(0, res[2].length - 4);
  239. }
  240. });
  241. };
  242. /**
  243. * BDS-安装申请 请求
  244. */
  245. const getInstallApply = () => {
  246. console.log('======安装申请======')
  247. tools.showLoadingAlert("加载中");
  248. let options = {
  249. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  250. data: {
  251. obuId: obu.obuId,
  252. vehicleId: orderInfos.vehiclePlate + "_" + orderInfos.vehiclePlateColor,
  253. orderId: orderInfos.orderId,
  254. agentId: "52010106004",
  255. channelId: "5201010200601130001",
  256. channelType: "1",
  257. staffId: "opId",
  258. terminalId: "999999999",
  259. }, //请求参数
  260. method: "POST", //提交方式(默认POST)
  261. showLoading: true, //是否显示加载中(默认显示)
  262. };
  263. //调用方式
  264. request(IFCODE.installApply, options)
  265. .then(() => {
  266. tools.hideLoadingAlert();
  267. //再次获取随机数
  268. let cmdArr = [cmd.HOME_DIRECTORY, cmd.RANDOM_NUMBER];
  269. bluetoothUtil.transCmd(cmdArr, '20', function (res) {
  270. var str = res[1].substring(res[1].length - 4, res[1].length);
  271. if (str == "9000") {
  272. let cmdRandNum = res[1].substring(0, res[1].length - 4);
  273. getObuActivation(cmdRandNum);
  274. } else {
  275. tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
  276. }
  277. })
  278. })
  279. };
  280. /**
  281. * VFJ-OBU在线激活 请求
  282. */
  283. const getObuActivation = (cmdRandNum : string) => {
  284. console.log('======VFJ-OBU在线激活======')
  285. tools.showLoadingAlert("加载中");
  286. let options = {
  287. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  288. data: {
  289. random: cmdRandNum,
  290. obuSerailNo: obu.obuId,
  291. orderId: orderInfos.orderId,
  292. }, //请求参数
  293. method: "POST", //提交方式(默认POST)
  294. showLoading: true, //是否显示加载中(默认显示)
  295. };
  296. //调用方式
  297. request(IFCODE.obuActivation, options)
  298. .then((res) => {
  299. tools.hideLoadingAlert();
  300. console.log("在线激活 请求");
  301. console.log(stringToJson(res.bizContent));
  302. const datas = stringToJson(res.bizContent);
  303. tools.showLoadingAlert("执行指令");
  304. bluetoothUtil.transCmd([datas.data.APDU], "20", function (res) {
  305. tools.hideLoadingAlert();
  306. console.log(res);
  307. if (res[0] == "9000") {
  308. console.log("在线激活执行指令88888 请求", res);
  309. getObuInstall(0, ""); //status 0 - 安装成功 || 1 - 安装失败
  310. }
  311. });
  312. })
  313. .catch((err) => {
  314. console.log(err);
  315. });
  316. };
  317. /**
  318. * BDS-安装确认 请求
  319. */
  320. const getObuInstall = (status : number, reason : string) => {
  321. console.log('======OBU安装确认======')
  322. tools.showLoadingAlert("加载中");
  323. let options = {
  324. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  325. data: {
  326. installStatus: status,
  327. failReason: reason,
  328. installType: "1",
  329. installChannelId: "5201010200601130001",
  330. obuId: obu.obuId,
  331. orderId: orderInfos.orderId
  332. }, //请求参数
  333. method: "POST", //提交方式(默认POST)
  334. showLoading: true, //是否显示加载中(默认显示)
  335. };
  336. //调用方式
  337. request(IFCODE.obuInstall, options)
  338. .then(() => {
  339. tools.hideLoadingAlert();
  340. state.showPopup = true;
  341. // setTimeout(() => {
  342. // uni.navigateBack({
  343. // delta: 1,
  344. // })
  345. // }, 1000)
  346. });
  347. };
  348. </script>
  349. <style>
  350. page {
  351. width: 100%;
  352. height: 100%;
  353. background-color: #fff;
  354. }
  355. </style>
  356. <style lang="scss" scoped>
  357. .mask {
  358. background: rgba(0, 0, 0, .35);
  359. position: fixed;
  360. left: 0;
  361. top: 0;
  362. bottom: 0;
  363. right: 0;
  364. }
  365. .main {
  366. width: 560rpx;
  367. padding: 25rpx 20rpx 55rpx;
  368. text-align: center;
  369. background: #fff;
  370. position: absolute;
  371. left: 50%;
  372. top: 50%;
  373. transform: translate(-50%, -50%);
  374. border-radius: 20rpx;
  375. .top {
  376. text-align: right;
  377. .icon-close {
  378. width: 48rpx;
  379. height: 48rpx;
  380. }
  381. }
  382. .icon-success {
  383. width: 500rpx;
  384. height: 320rpx;
  385. margin-top: 22rpx;
  386. }
  387. .title {
  388. color: #333333;
  389. font-size: 40rpx;
  390. font-weight: 600;
  391. text-align: center;
  392. margin-top: 55rpx;
  393. }
  394. }
  395. .selectCar-box {
  396. // width: 100%;
  397. // height: 100%;
  398. padding: 30rpx;
  399. .title {
  400. font-size: 30rpx;
  401. font-family: Microsoft YaHei UI;
  402. font-weight: 400;
  403. color: #333333;
  404. margin-bottom: 30rpx;
  405. }
  406. .details {
  407. .title {
  408. font-size: 30rpx;
  409. font-family: Microsoft YaHei UI;
  410. font-weight: 400;
  411. color: #333333;
  412. margin-bottom: 30rpx;
  413. }
  414. .details-item {
  415. display: flex;
  416. font-size: 26rpx;
  417. font-family: Noto Sans S Chinese;
  418. font-weight: 400;
  419. color: #999999;
  420. margin-bottom: 30rpx;
  421. text {
  422. font-size: 26rpx;
  423. font-family: Noto Sans S Chinese;
  424. font-weight: 400;
  425. color: #333333;
  426. }
  427. }
  428. }
  429. .card {
  430. height: 150rpx;
  431. background: #ffffff;
  432. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  433. border-radius: 20rpx;
  434. padding: 30rpx;
  435. display: flex;
  436. justify-content: space-between;
  437. align-items: center;
  438. margin-bottom: 60rpx;
  439. .card-left {
  440. display: flex;
  441. align-items: center;
  442. image {
  443. width: 100rpx;
  444. height: 90rpx;
  445. }
  446. .card-center {
  447. margin-left: 30rpx;
  448. .card-center-head {
  449. font-size: 32rpx;
  450. font-family: Noto Sans S Chinese;
  451. font-weight: 400;
  452. color: #333333;
  453. }
  454. .tips {
  455. font-size: 26rpx;
  456. font-family: Noto Sans S Chinese;
  457. font-weight: 400;
  458. color: #666666;
  459. .tips-card {
  460. width: 70rpx;
  461. height: 40rpx;
  462. background: #d3f2ef;
  463. border-radius: 6rpx;
  464. font-size: 20rpx;
  465. font-family: Noto Sans S Chinese;
  466. font-weight: 400;
  467. color: #0a8f8a;
  468. padding: 5rpx 10rpx;
  469. margin-left: 20rpx;
  470. }
  471. }
  472. }
  473. }
  474. .choose-item {
  475. margin-right: 20rpx;
  476. /* width: 50rpx; */
  477. // height: 50rpx;
  478. /* border: 1rpx solid #00B38B; */
  479. border-radius: 50%;
  480. // display: flex;
  481. // justify-content: center;
  482. // align-items: center;
  483. font-size: 25rpx;
  484. // align-self: end;
  485. .active {
  486. width: 38rpx;
  487. height: 38rpx;
  488. background: #00b38b;
  489. border-radius: 50%;
  490. }
  491. }
  492. }
  493. .remark {
  494. font-size: 26rpx;
  495. font-family: Microsoft YaHei UI;
  496. font-weight: 400;
  497. color: #666666;
  498. text-indent: 30rpx;
  499. margin-bottom: 30rpx;
  500. }
  501. .submit {
  502. margin-top: 100rpx;
  503. width: 670rpx;
  504. height: 80rpx;
  505. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  506. border-radius: 40rpx;
  507. font-size: 32rpx;
  508. font-family: Noto Sans S Chinese;
  509. font-weight: 400;
  510. color: #ffffff;
  511. line-height: 80rpx;
  512. }
  513. }
  514. </style>