Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

activate.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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 class="info_plate">
  26. <text>收费车型</text>
  27. <text>{{ fileDataStrings.vehicleClassStr }}</text>
  28. </view>
  29. </view>
  30. <view class="up_btn" v-if="state.showBtn">
  31. <button aria-disabled="true" @click="btn" v-if="!state.isSuccess" :class="state.disabled?'button':'hui'">
  32. 点击开始激活
  33. </button>
  34. <button aria-disabled="true" @click="back" v-else>
  35. 点击返回首页
  36. </button>
  37. </view>
  38. </view>
  39. <!-- 激活成功popup -->
  40. <u-popup v-model="state.showPopup" mode="center">
  41. <active-success @cancel="state.showPopup = false"></active-success>
  42. </u-popup>
  43. </template>
  44. <script setup>
  45. import {
  46. reactive,
  47. ref
  48. } from "vue";
  49. import {
  50. formatTime,
  51. formatTime2,
  52. expireDate,
  53. expireDate2,
  54. getFormatDate,
  55. msg
  56. } from "@/utils/utils";
  57. import {
  58. onLoad
  59. } from '@dcloudio/uni-app'
  60. import {
  61. getItem
  62. } from "@/utils/storage";
  63. import {
  64. request, requestNew
  65. } from "@/utils/network/request.js";
  66. import {
  67. IntegerToHexString,
  68. } from "@/utils/util/fileData.js";
  69. import {
  70. stringToJson
  71. } from "@/utils/network/encryption.js";
  72. import * as IFCODE from "@/utils/network/api.js";
  73. import {
  74. issueApply,issueCallback
  75. } from "@/utils/network/api";
  76. import {
  77. agentId
  78. } from "@/utils/network/difference";
  79. const cmd = require("../../../static/etcUtil/cmdConfig.js");
  80. const tools = require("../../../static/etcUtil/tools.js");
  81. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  82. import activeSuccess from "./components/popup-device-active-success";
  83. import {
  84. getVehiclePlateColor
  85. } from "@/datas/vehiclePlateColor";
  86. import {
  87. searchVehicleInfoQuery
  88. } from "@/subpackage/after-sale/js/publicRequest";
  89. import {
  90. channelId
  91. } from "@/utils/network/difference";
  92. import {
  93. orderDetailQuery
  94. } from "@/utils/network/api.js";
  95. const state = reactive({
  96. orderId: "",
  97. id: "",
  98. cardStatus: "",
  99. obuStatus: "",
  100. isSuccess: false, //是否激活成功
  101. showPopup: false,
  102. transfer: 0, //0 是原来的激活 1 是过户激活
  103. showBtn: true,
  104. disabled: true
  105. })
  106. let snums = 0
  107. onLoad((option) => {
  108. //读取传入 存储的数据orderInfo
  109. let orderData = getItem("orderInfo");
  110. state.id = orderData.id;
  111. state.orderId = orderData.orderId;
  112. console.log(state);
  113. state.transfer = Number(option.transfer)
  114. //获取订单详情
  115. getOrderDetails(state.id);
  116. console.log("state.transfer", state.transfer, state.transfer == 0, state.transfer == 1)
  117. })
  118. const card = reactive({
  119. cardId: "",
  120. netId: "",
  121. cardType: "",
  122. startTime: "",
  123. endTime: "",
  124. userName: "",
  125. idNum: "",
  126. vehiclePlate: "",
  127. vehiclePlateColor: "",
  128. color: "",
  129. version: "",
  130. type: "",
  131. favourable: "",
  132. money: "",
  133. v_userType: "",
  134. });
  135. const obu = reactive({
  136. obuId: "",
  137. startTime: "",
  138. endTime: "",
  139. version: "",
  140. approvedCount: "",
  141. axleCount: "",
  142. axleDistance: "",
  143. engineNum: "",
  144. type: "",
  145. userType: "",
  146. contractNo: "",
  147. vehiclePlate: "",
  148. vehiclePlateColor: "",
  149. vin: "",
  150. wheelCount: 0,
  151. isJH: ""
  152. });
  153. let cmdRandNum = '';
  154. let orderInfo = {};
  155. const fileDataStrings = reactive({
  156. approvedCount: 0, //核载人数
  157. cardId: "", //卡号
  158. obuId: "", //obu号
  159. obuId: "", //obu号
  160. packageNum: "", //套餐编号
  161. axleCount: 0, //轴数
  162. axleDistance: "", //轴距
  163. engineNum: "", //发动机
  164. vehicleVin: "",
  165. vehicleEngineNum: "",
  166. cardStatus: "",
  167. obuStatus: "",
  168. type: 0, //类型
  169. userType: 0, //用户类型
  170. vehiclePlate: "", //车牌
  171. vehiclePlateColor: 0, //车牌颜色
  172. vehicleDimensions: "",
  173. wheelCount: 0, //车轮数
  174. vehicleIdNo: "", //车牌号
  175. vehiclePlateColorStr: "",
  176. customerTel: "",
  177. customerId: "",
  178. orderId: "",
  179. vehicleClassStr: ""
  180. });
  181. // 卡签版本校验接口
  182. function versionVerification(transOrderId, cmd, cmdResult, stepNo){
  183. tools.showLoadingAlert('正在激活,请等待')
  184. const options = {
  185. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  186. showLoading: false,
  187. data: {
  188. transOrderId, //步骤号
  189. cmd,
  190. cmdResult,
  191. stepNo
  192. }, //请求参数
  193. method: "POST", //提交方式(默认POST)
  194. };
  195. console.log("options2222", options)
  196. //卡签版本校验接口
  197. request(IFCODE.versionVerificationApi, options)
  198. .then((res) => {
  199. console.log(stringToJson(res.bizContent));
  200. const datas = stringToJson(res.bizContent).data;
  201. console.log("在线激活 请求", datas,datas.stepNo == 100);
  202. if (datas.stepNo == 100) {
  203. console.log("陈工")
  204. cmdResult1()
  205. } else {
  206. console.log("datas.stepNo", datas.stepNo)
  207. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  208. versionVerification(datas.transOrderId, datas.cmd, res.toString(), datas.stepNo)
  209. }, () => {
  210. tools.hideLoadingAlert();
  211. });
  212. }
  213. })
  214. .catch((err) => {
  215. console.log(err);
  216. tools.hideLoadingAlert();
  217. });
  218. }
  219. function cmdResult1() {
  220. tools.showLoadingAlert('正在激活,请等待')
  221. const options = {
  222. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  223. showLoading: false,
  224. data: {
  225. orderId: orderInfo.orderNo,
  226. issueType: state.transfer ? 2 : 1 //1正常激活 2 过户激活
  227. }, //请求参数
  228. method: "POST", //提交方式(默认POST)
  229. };
  230. console.log("options==", options)
  231. //BDS-二发指令申请
  232. requestNew(issueApply, options)
  233. .then((res) => {
  234. console.log("在线激活 请求");
  235. console.log(res);
  236. const datas =res;
  237. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  238. implementCmd(datas.transOrderId, datas.cmd, res.toString(), datas.stepNo)
  239. }, () => {
  240. showModals('在线激活异常')
  241. tools.hideLoadingAlert();
  242. });
  243. })
  244. .catch((err) => {
  245. console.log(err);
  246. tools.hideLoadingAlert();
  247. });
  248. }
  249. function implementCmd(transOrderId, cmd, cmdResult, stepNo) {
  250. const options = {
  251. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  252. showLoading: false,
  253. data: {
  254. transOrderId, //步骤号
  255. cmd,
  256. cmdResult,
  257. stepNo
  258. }, //请求参数
  259. method: "POST", //提交方式(默认POST)
  260. };
  261. console.log("options2222", options)
  262. //BDS-二发指令回传
  263. requestNew(issueCallback, options)
  264. .then((res) => {
  265. console.log("BDS-二发指令回传 ",res);
  266. const datas = res;
  267. console.log("在线激活 请求", datas);
  268. if (datas.stepNo == 100) {
  269. state.disabled = true
  270. tools.hideLoadingAlert();
  271. msg("激活成功", {
  272. 'icon': 'success',
  273. 'duration': 3000
  274. })
  275. setTimeout(() => {
  276. uni.navigateTo({
  277. url: "/subpackage/after-sale/deviceInfo/deviceInfo",
  278. });
  279. }, 3000)
  280. } else {
  281. console.log("datas.stepNo", datas.stepNo)
  282. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  283. implementCmd(transOrderId, datas.cmd, res.toString(), datas.stepNo)
  284. }, () => {
  285. showModals('在线激活异常')
  286. });
  287. }
  288. })
  289. .catch((err) => {
  290. console.log(err);
  291. tools.hideLoadingAlert();
  292. });
  293. }
  294. //开始激活 按钮事件
  295. const btn = () => {
  296. state.disabled = false
  297. console.log('orderInfo参数', orderInfo, state.disabled)
  298. cmdResult1()
  299. };
  300. //获取订单详情
  301. const getOrderDetails = (id) => {
  302. console.log('======获取订单信息======')
  303. const options = {
  304. type: 2,
  305. data: {
  306. id: id,
  307. },
  308. method: "POST",
  309. showLoading: false,
  310. };
  311. state.disabled = false
  312. requestNew(orderDetailQuery, options).then((res) => {
  313. console.log("orderInfo", res);
  314. orderInfo = res.data;
  315. console.log("orderInfores", res);
  316. if (orderInfo) {
  317. fileDataStrings.userType = orderInfo.userType; //用户类型
  318. fileDataStrings.cardId = orderInfo.cardId;
  319. fileDataStrings.packageNum = orderInfo.packageNum;
  320. fileDataStrings.obuId = orderInfo.obuId;
  321. fileDataStrings.customerTel = orderInfo.customerTel;
  322. fileDataStrings.customerId = orderInfo.customerId;
  323. fileDataStrings.orderId = orderInfo.orderNo;
  324. fileDataStrings.vehiclePlateColorStr = getVehiclePlateColor(orderInfo
  325. .vehiclePlateColor);
  326. fileDataStrings.vehiclePlate = orderInfo.vehiclePlate; //车牌
  327. fileDataStrings.vehicleClassStr = orderInfo.vehicleClassStr;
  328. }
  329. });
  330. getObuId();
  331. };
  332. /**
  333. * 获取OBU号 读OBU
  334. */
  335. const getObuId = () => {
  336. console.log('======获取OBU号======')
  337. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  338. // tools.showLoadingAlert("正在执行指令");
  339. bluetoothUtil.transCmd(cmdArray, "20", function(res) {
  340. // tools.hideLoadingAlert();
  341. var status = res[1].substring(res[1].length - 4, res[1].length);
  342. console.log('获取OBU号执行结果' + status, res)
  343. //第一次获取随机数
  344. if (status == "9000") {
  345. state.disabled = true
  346. obu.obuId = res[1].substring(20, 36);
  347. obu.vin = res[1].substring(18, 20);
  348. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  349. cmdRandNum = res[2].substring(0, res[2].length - 4);
  350. state.showBtn = true
  351. } else {
  352. showModals('获取设备信息错误!')
  353. }
  354. }, () => {
  355. showModals('获取设备信息错误')
  356. });
  357. };
  358. function showModals(msg) {
  359. uni.showModal({
  360. title: '提示',
  361. content: msg,
  362. showCancel: false,
  363. success: function(res) {
  364. if (res.confirm) {
  365. uni.navigateBack()
  366. console.log('用户点击确定1');
  367. } else if (res.cancel) {
  368. console.log('用户点击取消1');
  369. }
  370. }
  371. });
  372. }
  373. const back = () => {
  374. uni.switchTab({
  375. url: "/pages/index/index"
  376. });
  377. }
  378. </script>
  379. <style>
  380. .containers {
  381. height: 100%;
  382. display: flex;
  383. flex-direction: column;
  384. align-items: center;
  385. justify-content: space-between;
  386. box-sizing: border-box;
  387. }
  388. .sec_info {
  389. width: 90%;
  390. height: auto;
  391. margin: 0 auto;
  392. box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.2);
  393. margin-top: 50rpx;
  394. border-radius: 20rpx;
  395. }
  396. .info_txt {
  397. width: 100%;
  398. height: 120rpx;
  399. line-height: 120rpx;
  400. text-align: center;
  401. color: #000;
  402. font-size: 36rpx;
  403. margin-bottom: 20rpx;
  404. }
  405. .info_plate {
  406. display: flex;
  407. flex-direction: row;
  408. width: 94%;
  409. height: 100rpx;
  410. margin: 0 auto;
  411. border-bottom: 2rpx solid #f2f2f2;
  412. }
  413. .info_plate text:nth-child(1) {
  414. height: 100rpx;
  415. text-align: left;
  416. line-height: 100rpx;
  417. font-size: 32rpx;
  418. color: #999;
  419. }
  420. .info_plate text:nth-child(2) {
  421. flex: 1;
  422. height: 100rpx;
  423. line-height: 100rpx;
  424. font-size: 32rpx;
  425. color: #333;
  426. margin-left: 50rpx;
  427. text-align: right;
  428. }
  429. /*提交按钮样式*/
  430. .up_btn {
  431. width: 85%;
  432. height: 100rpx;
  433. margin: 0 auto;
  434. margin-top: 50rpx;
  435. margin-bottom: 100rpx;
  436. }
  437. .up_btn button {
  438. width: 100%;
  439. height: 80rpx;
  440. line-height: 80rpx;
  441. color: white;
  442. font-size: 32rpx;
  443. text-align: center;
  444. background: linear-gradient(to right,#01243A,#004576);
  445. border-radius: 40rpx;
  446. outline: none;
  447. border: #4cd95f;
  448. }
  449. .button {
  450. width: 100%;
  451. height: 80rpx;
  452. line-height: 80rpx;
  453. color: white;
  454. font-size: 32rpx;
  455. text-align: center;
  456. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  457. border-radius: 40rpx;
  458. outline: none;
  459. border: #4cd95f;
  460. }
  461. .hui {
  462. width: 100%;
  463. height: 80rpx;
  464. line-height: 80rpx;
  465. color: white;
  466. font-size: 32rpx;
  467. text-align: center;
  468. background: linear-gradient(to left, #b9b9b9 0%, #e7e7e7 100%) !important;
  469. border-radius: 40rpx;
  470. outline: none;
  471. border: #4cd95f;
  472. }
  473. .up_btn button[disabled] {
  474. background-color: rgba(0, 191, 112, 0.5);
  475. color: white;
  476. font-size: 34rpx;
  477. border-radius: 20rpx;
  478. }
  479. </style>