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

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