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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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. //请求订单详情
  160. queryOrderDetail(option.id);
  161. });
  162. onShow((option) => {
  163. uni.$on('bluetoothLink', res => {
  164. console.log(res);
  165. if (res.status) {
  166. // getCardRenewal()
  167. getObuId()
  168. }
  169. //移除监听
  170. uni.$off('bluetoothLink')
  171. })
  172. })
  173. const cancel = ()=>{
  174. state.showPopup = false;
  175. // navTo("/pages/service/service")
  176. uni.navigateBack({
  177. delta:2
  178. })
  179. };
  180. const toPage = () => {
  181. navTo("/pages/bluetooth/bluetooth?routeType=5");
  182. };
  183. //获取订单详情
  184. const queryOrderDetail = (id: string) => {
  185. const options = {
  186. type: 2,
  187. data: {
  188. id: "cebc78a8aa024a0c96c0d1b0da3752e5",
  189. },
  190. method: "POST",
  191. showLoading: true,
  192. };
  193. request(IFCODE.orderDetail, options).then((res) => {
  194. let orderInfo = JSON.parse(res.bizContent);
  195. console.log(orderInfo);
  196. orderInfos.orderId = orderInfo.orderId;
  197. orderInfos.ownerName = orderInfo.ownerName;
  198. orderInfos.ownerIdtype = orderInfo.ownerIdtype;
  199. orderInfos.ownerIdnum = orderInfo.ownerIdnum;
  200. orderInfos.vehiclePlate = orderInfo.vehiclePlate;
  201. orderInfos.vehiclePlateColorStr = orderInfo.vehiclePlateColorStr;
  202. orderInfos.vehiclePlateColor = orderInfo.vehiclePlateColor;
  203. orderInfos.vehicleType = orderInfo.vehicleType;
  204. orderInfos.cardId = orderInfo.cardId;
  205. orderInfos.cardStatus = orderInfo.cardStatus;
  206. orderInfos.obuId = orderInfo.obuId;
  207. orderInfos.obuStatus = orderInfo.obuStatus;
  208. let arr = orderInfo.vehicleDimensions.split("x");
  209. orderInfos.outlineL = parseInt(arr[0]); //外廓 长
  210. orderInfos.outlineW = parseInt(arr[1]); //外廓 宽
  211. orderInfos.outlineH = parseInt(arr[2].substring(0, arr[2].length - 2)); //外廓 高
  212. orderInfos.type=orderInfo.type;
  213. orderInfos.axleCount=orderInfo.vehicleAxleCount;
  214. orderInfos.approvedCount=orderInfo.vehicleApprovedCount;
  215. orderInfos.vehicleVin=orderInfo.vehicleVin;
  216. orderInfos.vehicleEngineNum=orderInfo.vehicleEngineNum;
  217. });
  218. };
  219. /**
  220. * 获取OBU号 读OBU
  221. */
  222. const getObuId = () => {
  223. console.log('======获取OBU号======')
  224. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  225. tools.showLoadingAlert("正在执行指令");
  226. bluetoothUtil.transCmd(cmdArray, "20", function(res) {
  227. tools.hideLoadingAlert();
  228. var status = res[1].substring(res[1].length - 4, res[1].length);
  229. console.log('获取OBU号执行结果' + status)
  230. //第一次获取随机数
  231. if (status == "9000") {
  232. obu.obuId = res[1].substring(20, 36);
  233. obu.vin = res[1].substring(18, 20);
  234. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  235. getInstallApply()
  236. // cmdRandNum = res[2].substring(0, res[2].length - 4);
  237. }
  238. });
  239. };
  240. /**
  241. * BDS-安装申请 请求
  242. */
  243. const getInstallApply = () => {
  244. console.log('======安装申请======')
  245. tools.showLoadingAlert("加载中");
  246. let options = {
  247. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  248. data: {
  249. obuId: obu.obuId,
  250. vehicleId: orderInfos.vehiclePlate + "_" + orderInfos.vehiclePlateColor,
  251. orderId: orderInfos.orderId,
  252. agentId: "52010106004",
  253. channelId: "5201010200601130001",
  254. channelType: "1",
  255. staffId: "opId",
  256. terminalId: "999999999",
  257. }, //请求参数
  258. method: "POST", //提交方式(默认POST)
  259. showLoading: true, //是否显示加载中(默认显示)
  260. };
  261. //调用方式
  262. request(IFCODE.installApply, options)
  263. .then(() => {
  264. tools.hideLoadingAlert();
  265. //再次获取随机数
  266. let cmdArr = [cmd.HOME_DIRECTORY, cmd.RANDOM_NUMBER];
  267. bluetoothUtil.transCmd(cmdArr, '20', function(res) {
  268. var str = res[1].substring(res[1].length - 4, res[1].length);
  269. if (str == "9000") {
  270. let cmdRandNum = res[1].substring(0, res[1].length - 4);
  271. getObuActivation(cmdRandNum);
  272. } else {
  273. tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
  274. }
  275. })
  276. })
  277. };
  278. /**
  279. * VFJ-OBU在线激活 请求
  280. */
  281. const getObuActivation = (cmdRandNum:string) => {
  282. console.log('======VFJ-OBU在线激活======')
  283. tools.showLoadingAlert("加载中");
  284. let options = {
  285. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  286. data: {
  287. random: cmdRandNum,
  288. obuSerailNo: obu.obuId,
  289. orderId: orderInfos.orderId,
  290. }, //请求参数
  291. method: "POST", //提交方式(默认POST)
  292. showLoading: true, //是否显示加载中(默认显示)
  293. };
  294. //调用方式
  295. request(IFCODE.obuActivation, options)
  296. .then((res) => {
  297. tools.hideLoadingAlert();
  298. console.log("在线激活 请求");
  299. console.log(stringToJson(res.bizContent));
  300. const datas = stringToJson(res.bizContent);
  301. tools.showLoadingAlert("执行指令");
  302. bluetoothUtil.transCmd([datas.data.APDU], "20", function(res) {
  303. tools.hideLoadingAlert();
  304. console.log(res);
  305. if (res[0] == "9000") {
  306. console.log("在线激活执行指令88888 请求", res);
  307. getObuInstall(0, ""); //status 0 - 安装成功 || 1 - 安装失败
  308. }
  309. });
  310. })
  311. .catch((err) => {
  312. console.log(err);
  313. });
  314. };
  315. /**
  316. * BDS-安装确认 请求
  317. */
  318. const getObuInstall = (status:number, reason:string) => {
  319. console.log('======OBU安装确认======')
  320. tools.showLoadingAlert("加载中");
  321. let options = {
  322. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  323. data: {
  324. installStatus: status,
  325. failReason: reason,
  326. installType: "1",
  327. installChannelId: "5201010200601130001",
  328. obuId: obu.obuId,
  329. orderId: orderInfos.orderId
  330. }, //请求参数
  331. method: "POST", //提交方式(默认POST)
  332. showLoading: true, //是否显示加载中(默认显示)
  333. };
  334. //调用方式
  335. request(IFCODE.obuInstall, options)
  336. .then(() => {
  337. tools.hideLoadingAlert();
  338. state.showPopup = true;
  339. });
  340. };
  341. </script>
  342. <style>
  343. page {
  344. width: 100%;
  345. height: 100%;
  346. background-color: #fff;
  347. }
  348. </style>
  349. <style lang="scss" scoped>
  350. .mask{
  351. background: rgba(0, 0, 0, .35);
  352. position: fixed;
  353. left: 0;
  354. top: 0;
  355. bottom: 0;
  356. right: 0;
  357. }
  358. .main{
  359. width: 560rpx;
  360. padding: 25rpx 20rpx 55rpx;
  361. text-align: center;
  362. background: #fff;
  363. position: absolute;
  364. left: 50%;
  365. top: 50%;
  366. transform: translate(-50%,-50%);
  367. border-radius: 20rpx;
  368. .top{
  369. text-align: right;
  370. .icon-close{
  371. width: 48rpx;
  372. height: 48rpx;
  373. }
  374. }
  375. .icon-success{
  376. width: 500rpx;
  377. height: 320rpx;
  378. margin-top: 22rpx;
  379. }
  380. .title{
  381. color: #333333;
  382. font-size: 40rpx;
  383. font-weight: 600;
  384. text-align: center;
  385. margin-top: 55rpx;
  386. }
  387. }
  388. .selectCar-box {
  389. // width: 100%;
  390. // height: 100%;
  391. padding: 30rpx;
  392. .title {
  393. font-size: 30rpx;
  394. font-family: Microsoft YaHei UI;
  395. font-weight: 400;
  396. color: #333333;
  397. margin-bottom: 30rpx;
  398. }
  399. .details {
  400. .title {
  401. font-size: 30rpx;
  402. font-family: Microsoft YaHei UI;
  403. font-weight: 400;
  404. color: #333333;
  405. margin-bottom: 30rpx;
  406. }
  407. .details-item {
  408. display: flex;
  409. font-size: 26rpx;
  410. font-family: Noto Sans S Chinese;
  411. font-weight: 400;
  412. color: #999999;
  413. margin-bottom: 30rpx;
  414. text {
  415. font-size: 26rpx;
  416. font-family: Noto Sans S Chinese;
  417. font-weight: 400;
  418. color: #333333;
  419. }
  420. }
  421. }
  422. .card {
  423. height: 150rpx;
  424. background: #ffffff;
  425. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  426. border-radius: 20rpx;
  427. padding: 30rpx;
  428. display: flex;
  429. justify-content: space-between;
  430. align-items: center;
  431. margin-bottom: 60rpx;
  432. .card-left {
  433. display: flex;
  434. align-items: center;
  435. image {
  436. width: 100rpx;
  437. height: 90rpx;
  438. }
  439. .card-center {
  440. margin-left: 30rpx;
  441. .card-center-head {
  442. font-size: 32rpx;
  443. font-family: Noto Sans S Chinese;
  444. font-weight: 400;
  445. color: #333333;
  446. }
  447. .tips {
  448. font-size: 26rpx;
  449. font-family: Noto Sans S Chinese;
  450. font-weight: 400;
  451. color: #666666;
  452. .tips-card {
  453. width: 70rpx;
  454. height: 40rpx;
  455. background: #d3f2ef;
  456. border-radius: 6rpx;
  457. font-size: 20rpx;
  458. font-family: Noto Sans S Chinese;
  459. font-weight: 400;
  460. color: #0a8f8a;
  461. padding: 5rpx 10rpx;
  462. margin-left: 20rpx;
  463. }
  464. }
  465. }
  466. }
  467. .choose-item {
  468. margin-right: 20rpx;
  469. /* width: 50rpx; */
  470. // height: 50rpx;
  471. /* border: 1rpx solid #00B38B; */
  472. border-radius: 50%;
  473. // display: flex;
  474. // justify-content: center;
  475. // align-items: center;
  476. font-size: 25rpx;
  477. // align-self: end;
  478. .active {
  479. width: 38rpx;
  480. height: 38rpx;
  481. background: #00b38b;
  482. border-radius: 50%;
  483. }
  484. }
  485. }
  486. .remark {
  487. font-size: 26rpx;
  488. font-family: Microsoft YaHei UI;
  489. font-weight: 400;
  490. color: #666666;
  491. text-indent: 30rpx;
  492. margin-bottom: 30rpx;
  493. }
  494. .submit {
  495. margin-top: 100rpx;
  496. width: 670rpx;
  497. height: 80rpx;
  498. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  499. border-radius: 40rpx;
  500. font-size: 32rpx;
  501. font-family: Noto Sans S Chinese;
  502. font-weight: 400;
  503. color: #ffffff;
  504. line-height: 80rpx;
  505. }
  506. }
  507. </style>