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 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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. const options = {
  177. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  178. showLoading: false,
  179. data: {
  180. orderId: orderInfo.orderNo,
  181. issueType: state.transfer ? 2 : 1, //1正常激活 2 过户激活
  182. cardId:card.cardId,
  183. obuId:obu.obuId
  184. }, //请求参数
  185. method: "POST", //提交方式(默认POST)
  186. };
  187. console.log("options==", options)
  188. //BDS-二发指令申请
  189. requestNew(issueApply, options)
  190. .then((res) => {
  191. console.log("在线激活 请求");
  192. console.log(res);
  193. const datas =res;
  194. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  195. implementCmd(datas.transOrderId, datas.cmd, res.toString(), datas.stepNo)
  196. }, (err) => {
  197. showModals('在线激活异常')
  198. console.log("err",err)
  199. errorLog(datas.cmd,JSON.stringify(err),datas.stepNo)
  200. tools.hideLoadingAlert();
  201. state.showPopup=false
  202. });
  203. })
  204. .catch((err) => {
  205. console.log(err);
  206. tools.hideLoadingAlert();
  207. state.showPopup=false
  208. });
  209. }
  210. function implementCmd(transOrderId, cmd, cmdResult, stepNo) {
  211. state.progressNum=state.progressNum+5
  212. const options = {
  213. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  214. showLoading: false,
  215. data: {
  216. transOrderId, //步骤号
  217. cmd,
  218. cmdResult,
  219. stepNo,
  220. mpOpenId:getItem('mpOpenId')//公众号openid
  221. }, //请求参数
  222. method: "POST", //提交方式(默认POST)
  223. };
  224. console.log("options2222", options)
  225. //BDS-二发指令回传
  226. requestNew(issueCallback, options)
  227. .then((res) => {
  228. console.log("BDS-二发指令回传 ",res);
  229. const datas = res;
  230. console.log("在线激活 请求", datas);
  231. if (datas.stepNo == 100) {
  232. state.disabled = true
  233. tools.hideLoadingAlert();
  234. state.progressNum=100
  235. setTimeout(() => {
  236. state.showPopup=false
  237. },1000)
  238. setTimeout(() => {
  239. msg("激活成功", {
  240. 'icon': 'success',
  241. 'duration': 3000
  242. })
  243. },2000)
  244. setTimeout(() => {
  245. uni.navigateTo({
  246. url: "/subpackage/after-sale/deviceInfo/deviceInfo",
  247. });
  248. },5000)
  249. } else {
  250. console.log("datas.stepNo", datas.stepNo)
  251. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  252. implementCmd(transOrderId, datas.cmd, res.toString(), datas.stepNo)
  253. }, (err) => {
  254. console.log("err",err)
  255. state.showPopup=false
  256. errorLog(datas.cmd,JSON.stringify(err),datas.stepNo)
  257. showModals('在线激活异常')
  258. });
  259. }
  260. })
  261. .catch((err) => {
  262. console.log(err);
  263. tools.hideLoadingAlert();
  264. state.showPopup=false
  265. });
  266. }
  267. //开始激活 按钮事件
  268. const btn = () => {
  269. state.disabled = false
  270. state.showPopup=true
  271. console.log('orderInfo参数', orderInfo, state.disabled)
  272. cmdResult1()
  273. };
  274. //获取订单详情
  275. const getOrderDetails = (id) => {
  276. console.log('======获取订单信息======')
  277. const options = {
  278. type: 2,
  279. data: {
  280. id: id,
  281. },
  282. method: "POST",
  283. showLoading: false,
  284. };
  285. state.disabled = false
  286. requestNew(orderDetailQuery, options).then((res) => {
  287. console.log("orderInfo", res);
  288. orderInfo = res.data;
  289. console.log("orderInfores", res);
  290. if (orderInfo) {
  291. fileDataStrings.userType = orderInfo.userType; //用户类型
  292. fileDataStrings.cardId = orderInfo.cardId;
  293. fileDataStrings.packageNum = orderInfo.packageNum;
  294. fileDataStrings.obuId = orderInfo.obuId;
  295. fileDataStrings.customerTel = orderInfo.customerTel;
  296. fileDataStrings.customerId = orderInfo.customerId;
  297. fileDataStrings.orderId = orderInfo.orderNo;
  298. fileDataStrings.vehiclePlateColorStr = getVehiclePlateColor(orderInfo
  299. .vehiclePlateColor);
  300. fileDataStrings.vehiclePlate = orderInfo.vehiclePlate; //车牌
  301. fileDataStrings.vehicleClassStr = orderInfo.vehicleClassStr;
  302. }
  303. });
  304. getObuId();
  305. };
  306. /**
  307. * 获取OBU号 读OBU
  308. */
  309. const getObuId = () => {
  310. console.log('======获取OBU号======')
  311. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  312. bluetoothUtil.transCmd(cmdArray, "20", function(res) {
  313. var status = res[1].substring(res[1].length - 4, res[1].length);
  314. console.log('获取OBU号执行结果' + status, res)
  315. //第一次获取随机数
  316. if (status == "9000") {
  317. state.disabled = true
  318. obu.obuId = res[1].substring(20, 36);
  319. obu.vin = res[1].substring(18, 20);
  320. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  321. cmdRandNum = res[2].substring(0, res[2].length - 4);
  322. getCardId()
  323. } else {
  324. showModals('获取设备信息错误!')
  325. }
  326. }, () => {
  327. showModals('获取设备信息错误')
  328. });
  329. };
  330. function showModals(msg) {
  331. uni.showModal({
  332. title: '提示',
  333. content: msg,
  334. showCancel: false,
  335. success: function(res) {
  336. if (res.confirm) {
  337. uni.navigateBack()
  338. console.log('用户点击确定1');
  339. } else if (res.cancel) {
  340. console.log('用户点击取消1');
  341. }
  342. }
  343. });
  344. }
  345. const back = () => {
  346. uni.switchTab({
  347. url: "/pages/index/index"
  348. });
  349. }
  350. const getCardId = () => {
  351. //执行0015文件
  352. tools.showLoadingAlert("执行指令");
  353. let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY, cmd.CMD_GETBALANCE];
  354. console.log(cmdArr);
  355. console.log(bluetoothUtil);
  356. bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU
  357. console.log("5201",res)
  358. let str = res[2].substring(res[2].length - 4, res[2].length); //判断是否为9000
  359. let str3 = res[3].substring(res[3].length - 4, res[3].length); //判断是否为9000
  360. if (str == "9000" || str3 == "9000") {
  361. if (res[2].length > 86 || res[3] >= 12) {
  362. card.cardId = res[2].substring(20, 40);
  363. tools.hideLoadingAlert();
  364. state.showBtn = true
  365. } else {
  366. alertF("CMD_READBINARY指令长度不符" + res[2]);
  367. }
  368. return;
  369. }
  370. alertF("CMD_READBINARY指令长度不符" + res[2]);
  371. })
  372. };
  373. //获取订单详情
  374. const errorLog = (cmd,error,step) => {
  375. console.log('======获取订单信息======')
  376. const options = {
  377. type: 2,
  378. data: {
  379. cardId:card.cardId,
  380. obuId:obu.obuId,
  381. orderType:"1",
  382. factory:datas.getData("deviceName")+"_"+datas.getData("deviceNameZW"),
  383. orderNo:orderInfo.orderNo,
  384. cmd,
  385. error,
  386. step
  387. },
  388. method: "POST",
  389. showLoading: false,
  390. };
  391. requestNew(errorLogAdd, options).then((res) => {
  392. console.log("错误提交成功", res);
  393. });
  394. };
  395. </script>
  396. <style>
  397. .containers {
  398. height: 100%;
  399. display: flex;
  400. flex-direction: column;
  401. align-items: center;
  402. justify-content: space-between;
  403. box-sizing: border-box;
  404. }
  405. .sec_info {
  406. width: 90%;
  407. height: auto;
  408. margin: 0 auto;
  409. box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.2);
  410. margin-top: 50rpx;
  411. border-radius: 20rpx;
  412. }
  413. .info_txt {
  414. width: 100%;
  415. height: 120rpx;
  416. line-height: 120rpx;
  417. text-align: center;
  418. color: #000;
  419. font-size: 36rpx;
  420. margin-bottom: 20rpx;
  421. }
  422. .info_plate {
  423. display: flex;
  424. flex-direction: row;
  425. width: 94%;
  426. height: 100rpx;
  427. margin: 0 auto;
  428. border-bottom: 2rpx solid #f2f2f2;
  429. }
  430. .info_plate text:nth-child(1) {
  431. height: 100rpx;
  432. text-align: left;
  433. line-height: 100rpx;
  434. font-size: 32rpx;
  435. color: #999;
  436. }
  437. .info_plate text:nth-child(2) {
  438. flex: 1;
  439. height: 100rpx;
  440. line-height: 100rpx;
  441. font-size: 32rpx;
  442. color: #333;
  443. margin-left: 50rpx;
  444. text-align: right;
  445. }
  446. /*提交按钮样式*/
  447. .up_btn {
  448. width: 85%;
  449. height: 100rpx;
  450. margin: 0 auto;
  451. margin-top: 50rpx;
  452. margin-bottom: 100rpx;
  453. }
  454. .up_btn button {
  455. width: 100%;
  456. height: 80rpx;
  457. line-height: 80rpx;
  458. color: white;
  459. font-size: 32rpx;
  460. text-align: center;
  461. background: linear-gradient(to right,#01243A,#004576);
  462. border-radius: 40rpx;
  463. outline: none;
  464. border: #4cd95f;
  465. }
  466. .button {
  467. width: 100%;
  468. height: 80rpx;
  469. line-height: 80rpx;
  470. color: white;
  471. font-size: 32rpx;
  472. text-align: center;
  473. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  474. border-radius: 40rpx;
  475. outline: none;
  476. border: #4cd95f;
  477. }
  478. .hui {
  479. width: 100%;
  480. height: 80rpx;
  481. line-height: 80rpx;
  482. color: white;
  483. font-size: 32rpx;
  484. text-align: center;
  485. background: linear-gradient(to left, #b9b9b9 0%, #e7e7e7 100%) !important;
  486. border-radius: 40rpx;
  487. outline: none;
  488. border: #4cd95f;
  489. }
  490. .up_btn button[disabled] {
  491. background-color: rgba(0, 191, 112, 0.5);
  492. color: white;
  493. font-size: 34rpx;
  494. border-radius: 20rpx;
  495. }
  496. .mask{
  497. width: 100%;
  498. height:100vh;
  499. background:rgba(0,0,0,0.63);
  500. position: fixed;
  501. left: 0;
  502. top: 0;
  503. right: 0;
  504. bottom: 0;
  505. z-index: 999;
  506. display: flex;
  507. align-items: center;
  508. justify-content: center;
  509. }
  510. </style>