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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  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. uni.navigateBack({
  342. delta: 1,
  343. })
  344. });
  345. };
  346. </script>
  347. <style>
  348. page {
  349. width: 100%;
  350. height: 100%;
  351. background-color: #fff;
  352. }
  353. </style>
  354. <style lang="scss" scoped>
  355. .mask{
  356. background: rgba(0, 0, 0, .35);
  357. position: fixed;
  358. left: 0;
  359. top: 0;
  360. bottom: 0;
  361. right: 0;
  362. }
  363. .main{
  364. width: 560rpx;
  365. padding: 25rpx 20rpx 55rpx;
  366. text-align: center;
  367. background: #fff;
  368. position: absolute;
  369. left: 50%;
  370. top: 50%;
  371. transform: translate(-50%,-50%);
  372. border-radius: 20rpx;
  373. .top{
  374. text-align: right;
  375. .icon-close{
  376. width: 48rpx;
  377. height: 48rpx;
  378. }
  379. }
  380. .icon-success{
  381. width: 500rpx;
  382. height: 320rpx;
  383. margin-top: 22rpx;
  384. }
  385. .title{
  386. color: #333333;
  387. font-size: 40rpx;
  388. font-weight: 600;
  389. text-align: center;
  390. margin-top: 55rpx;
  391. }
  392. }
  393. .selectCar-box {
  394. // width: 100%;
  395. // height: 100%;
  396. padding: 30rpx;
  397. .title {
  398. font-size: 30rpx;
  399. font-family: Microsoft YaHei UI;
  400. font-weight: 400;
  401. color: #333333;
  402. margin-bottom: 30rpx;
  403. }
  404. .details {
  405. .title {
  406. font-size: 30rpx;
  407. font-family: Microsoft YaHei UI;
  408. font-weight: 400;
  409. color: #333333;
  410. margin-bottom: 30rpx;
  411. }
  412. .details-item {
  413. display: flex;
  414. font-size: 26rpx;
  415. font-family: Noto Sans S Chinese;
  416. font-weight: 400;
  417. color: #999999;
  418. margin-bottom: 30rpx;
  419. text {
  420. font-size: 26rpx;
  421. font-family: Noto Sans S Chinese;
  422. font-weight: 400;
  423. color: #333333;
  424. }
  425. }
  426. }
  427. .card {
  428. height: 150rpx;
  429. background: #ffffff;
  430. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  431. border-radius: 20rpx;
  432. padding: 30rpx;
  433. display: flex;
  434. justify-content: space-between;
  435. align-items: center;
  436. margin-bottom: 60rpx;
  437. .card-left {
  438. display: flex;
  439. align-items: center;
  440. image {
  441. width: 100rpx;
  442. height: 90rpx;
  443. }
  444. .card-center {
  445. margin-left: 30rpx;
  446. .card-center-head {
  447. font-size: 32rpx;
  448. font-family: Noto Sans S Chinese;
  449. font-weight: 400;
  450. color: #333333;
  451. }
  452. .tips {
  453. font-size: 26rpx;
  454. font-family: Noto Sans S Chinese;
  455. font-weight: 400;
  456. color: #666666;
  457. .tips-card {
  458. width: 70rpx;
  459. height: 40rpx;
  460. background: #d3f2ef;
  461. border-radius: 6rpx;
  462. font-size: 20rpx;
  463. font-family: Noto Sans S Chinese;
  464. font-weight: 400;
  465. color: #0a8f8a;
  466. padding: 5rpx 10rpx;
  467. margin-left: 20rpx;
  468. }
  469. }
  470. }
  471. }
  472. .choose-item {
  473. margin-right: 20rpx;
  474. /* width: 50rpx; */
  475. // height: 50rpx;
  476. /* border: 1rpx solid #00B38B; */
  477. border-radius: 50%;
  478. // display: flex;
  479. // justify-content: center;
  480. // align-items: center;
  481. font-size: 25rpx;
  482. // align-self: end;
  483. .active {
  484. width: 38rpx;
  485. height: 38rpx;
  486. background: #00b38b;
  487. border-radius: 50%;
  488. }
  489. }
  490. }
  491. .remark {
  492. font-size: 26rpx;
  493. font-family: Microsoft YaHei UI;
  494. font-weight: 400;
  495. color: #666666;
  496. text-indent: 30rpx;
  497. margin-bottom: 30rpx;
  498. }
  499. .submit {
  500. margin-top: 100rpx;
  501. width: 670rpx;
  502. height: 80rpx;
  503. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  504. border-radius: 40rpx;
  505. font-size: 32rpx;
  506. font-family: Noto Sans S Chinese;
  507. font-weight: 400;
  508. color: #ffffff;
  509. line-height: 80rpx;
  510. }
  511. }
  512. </style>