Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

activate.vue 12KB

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