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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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
  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. import {
  87. orderDetailQuery
  88. } from "@/utils/network/api.js";
  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. })
  100. onLoad((option) => {
  101. //读取传入 存储的数据orderInfo
  102. let orderData = getItem("orderInfo");
  103. state.id = orderData.id;
  104. console.log(state);
  105. state.transfer = Number(option.transfer)
  106. //获取订单详情
  107. getOrderDetails(state.id);
  108. console.log("state.transfer", state.transfer, state.transfer == 0, state.transfer == 1,getItem("orderInfo"))
  109. })
  110. const card = reactive({
  111. cardId: "",
  112. netId: "",
  113. cardType: "",
  114. startTime: "",
  115. endTime: "",
  116. userName: "",
  117. idNum: "",
  118. vehiclePlate: "",
  119. vehiclePlateColor: "",
  120. color: "",
  121. version: "",
  122. type: "",
  123. favourable: "",
  124. money: "",
  125. v_userType: "",
  126. });
  127. const obu = reactive({
  128. obuId: "",
  129. startTime: "",
  130. endTime: "",
  131. version: "",
  132. approvedCount: "",
  133. axleCount: "",
  134. axleDistance: "",
  135. engineNum: "",
  136. type: "",
  137. userType: "",
  138. contractNo: "",
  139. vehiclePlate: "",
  140. vehiclePlateColor: "",
  141. vin: "",
  142. wheelCount: 0,
  143. isJH: ""
  144. });
  145. let cmdRandNum = '';
  146. let orderInfo = {};
  147. const fileDataStrings = reactive({
  148. approvedCount: 0, //核载人数
  149. cardId: "", //卡号
  150. obuId: "", //obu号
  151. obuId: "", //obu号
  152. packageNum: "", //套餐编号
  153. axleCount: 0, //轴数
  154. axleDistance: "", //轴距
  155. engineNum: "", //发动机
  156. vehicleVin: "",
  157. vehicleEngineNum: "",
  158. cardStatus: "",
  159. obuStatus: "",
  160. type: 0, //类型
  161. userType: 0, //用户类型
  162. vehiclePlate: "", //车牌
  163. vehiclePlateColor: 0, //车牌颜色
  164. vehicleDimensions: "",
  165. wheelCount: 0, //车轮数
  166. vehicleIdNo: "", //车牌号
  167. vehiclePlateColorStr: "",
  168. customerTel: "",
  169. customerId: "",
  170. orderId: "",
  171. vehicleClassStr: ""
  172. });
  173. function cmdResult1() {
  174. tools.showLoadingAlert('正在激活,请等待')
  175. const options = {
  176. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  177. showLoading: false,
  178. data: {
  179. orderId: orderInfo.orderNo,
  180. issueType: state.transfer ? 2 : 1 //1正常激活 2 过户激活
  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. }, () => {
  194. showModals('在线激活异常')
  195. tools.hideLoadingAlert();
  196. });
  197. })
  198. .catch((err) => {
  199. console.log(err);
  200. tools.hideLoadingAlert();
  201. });
  202. }
  203. function implementCmd(transOrderId, cmd, cmdResult, stepNo) {
  204. const options = {
  205. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  206. showLoading: false,
  207. data: {
  208. transOrderId, //步骤号
  209. cmd,
  210. cmdResult,
  211. stepNo
  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. // tools.showLoadingAlert("正在执行指令");
  293. bluetoothUtil.transCmd(cmdArray, "20", function(res) {
  294. // tools.hideLoadingAlert();
  295. var status = res[1].substring(res[1].length - 4, res[1].length);
  296. console.log('获取OBU号执行结果' + status, res)
  297. //第一次获取随机数
  298. if (status == "9000") {
  299. state.disabled = true
  300. obu.obuId = res[1].substring(20, 36);
  301. obu.vin = res[1].substring(18, 20);
  302. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  303. cmdRandNum = res[2].substring(0, res[2].length - 4);
  304. state.showBtn = true
  305. } else {
  306. showModals('获取设备信息错误!')
  307. }
  308. }, () => {
  309. showModals('获取设备信息错误')
  310. });
  311. };
  312. function showModals(msg) {
  313. uni.showModal({
  314. title: '提示',
  315. content: msg,
  316. showCancel: false,
  317. success: function(res) {
  318. if (res.confirm) {
  319. uni.navigateBack()
  320. console.log('用户点击确定1');
  321. } else if (res.cancel) {
  322. console.log('用户点击取消1');
  323. }
  324. }
  325. });
  326. }
  327. const back = () => {
  328. uni.switchTab({
  329. url: "/pages/index/index"
  330. });
  331. }
  332. </script>
  333. <style>
  334. .containers {
  335. height: 100%;
  336. display: flex;
  337. flex-direction: column;
  338. align-items: center;
  339. justify-content: space-between;
  340. box-sizing: border-box;
  341. }
  342. .sec_info {
  343. width: 90%;
  344. height: auto;
  345. margin: 0 auto;
  346. box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.2);
  347. margin-top: 50rpx;
  348. border-radius: 20rpx;
  349. }
  350. .info_txt {
  351. width: 100%;
  352. height: 120rpx;
  353. line-height: 120rpx;
  354. text-align: center;
  355. color: #000;
  356. font-size: 36rpx;
  357. margin-bottom: 20rpx;
  358. }
  359. .info_plate {
  360. display: flex;
  361. flex-direction: row;
  362. width: 94%;
  363. height: 100rpx;
  364. margin: 0 auto;
  365. border-bottom: 2rpx solid #f2f2f2;
  366. }
  367. .info_plate text:nth-child(1) {
  368. height: 100rpx;
  369. text-align: left;
  370. line-height: 100rpx;
  371. font-size: 32rpx;
  372. color: #999;
  373. }
  374. .info_plate text:nth-child(2) {
  375. flex: 1;
  376. height: 100rpx;
  377. line-height: 100rpx;
  378. font-size: 32rpx;
  379. color: #333;
  380. margin-left: 50rpx;
  381. text-align: right;
  382. }
  383. /*提交按钮样式*/
  384. .up_btn {
  385. width: 85%;
  386. height: 100rpx;
  387. margin: 0 auto;
  388. margin-top: 50rpx;
  389. margin-bottom: 100rpx;
  390. }
  391. .up_btn button {
  392. width: 100%;
  393. height: 80rpx;
  394. line-height: 80rpx;
  395. color: white;
  396. font-size: 32rpx;
  397. text-align: center;
  398. background: linear-gradient(to right,#01243A,#004576);
  399. border-radius: 40rpx;
  400. outline: none;
  401. border: #4cd95f;
  402. }
  403. .button {
  404. width: 100%;
  405. height: 80rpx;
  406. line-height: 80rpx;
  407. color: white;
  408. font-size: 32rpx;
  409. text-align: center;
  410. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  411. border-radius: 40rpx;
  412. outline: none;
  413. border: #4cd95f;
  414. }
  415. .hui {
  416. width: 100%;
  417. height: 80rpx;
  418. line-height: 80rpx;
  419. color: white;
  420. font-size: 32rpx;
  421. text-align: center;
  422. background: linear-gradient(to left, #b9b9b9 0%, #e7e7e7 100%) !important;
  423. border-radius: 40rpx;
  424. outline: none;
  425. border: #4cd95f;
  426. }
  427. .up_btn button[disabled] {
  428. background-color: rgba(0, 191, 112, 0.5);
  429. color: white;
  430. font-size: 34rpx;
  431. border-radius: 20rpx;
  432. }
  433. </style>