Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

activate.vue 12KB

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