Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

activate.vue 13KB

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