Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

activate.vue 12KB

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