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.

activate.vue 12KB

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