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-SH.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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">
  18. <text>卡号</text>
  19. <text>{{ fileDataStrings.newCardId }}</text>
  20. </view>
  21. <view class="info_plate">
  22. <text>OBU号</text>
  23. <text>{{ fileDataStrings.newObuId }}</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 {
  64. request, requestNew
  65. } from "@/utils/network/request.js";
  66. import {
  67. IntegerToHexString,
  68. } from "@/utils/util/fileData.js";
  69. import * as IFCODE from "@/utils/network/api.js";
  70. import {
  71. changeCardObuCommandApply,changeCardObuCommandCallback,changeCardObuView
  72. } from "@/utils/network/api";
  73. import {
  74. agentId
  75. } from "@/utils/network/difference";
  76. const cmd = require("../../../static/etcUtil/cmdConfig.js");
  77. const tools = require("../../../static/etcUtil/tools.js");
  78. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  79. import activeSuccess from "./components/popup-device-active-success";
  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. showBtn: true,
  97. disabled: true,
  98. })
  99. let snums = 0
  100. onLoad((option) => {
  101. //读取传入 存储的数据orderInfo
  102. let orderData = getItem("orderInfo");
  103. state.id = orderData.id;
  104. state.orderId = orderData.orderId;
  105. console.log("state售后激活",option,orderData);
  106. //获取订单详情
  107. getOrderDetails(state.id);
  108. })
  109. const card = reactive({
  110. cardId: "",
  111. netId: "",
  112. cardType: "",
  113. startTime: "",
  114. endTime: "",
  115. userName: "",
  116. idNum: "",
  117. vehiclePlate: "",
  118. vehiclePlateColor: "",
  119. color: "",
  120. version: "",
  121. type: "",
  122. favourable: "",
  123. money: "",
  124. v_userType: "",
  125. });
  126. const obu = reactive({
  127. obuId: "",
  128. startTime: "",
  129. endTime: "",
  130. version: "",
  131. approvedCount: "",
  132. axleCount: "",
  133. axleDistance: "",
  134. engineNum: "",
  135. type: "",
  136. userType: "",
  137. contractNo: "",
  138. vehiclePlate: "",
  139. vehiclePlateColor: "",
  140. vin: "",
  141. wheelCount: 0,
  142. isJH: ""
  143. });
  144. let cmdRandNum = '';
  145. let orderInfo = {};
  146. const fileDataStrings = reactive({
  147. approvedCount: 0, //核载人数
  148. cardId: "", //卡号
  149. obuId: "", //obu号
  150. obuId: "", //obu号
  151. packageNum: "", //套餐编号
  152. axleCount: 0, //轴数
  153. axleDistance: "", //轴距
  154. engineNum: "", //发动机
  155. vehicleVin: "",
  156. vehicleEngineNum: "",
  157. cardStatus: "",
  158. obuStatus: "",
  159. type: 0, //类型
  160. userType: 0, //用户类型
  161. vehiclePlate: "", //车牌
  162. vehiclePlateColor: 0, //车牌颜色
  163. vehicleDimensions: "",
  164. wheelCount: 0, //车轮数
  165. vehicleIdNo: "", //车牌号
  166. vehiclePlateColorStr: "",
  167. customerTel: "",
  168. customerId: "",
  169. orderId: "",
  170. vehicleClassStr: "",
  171. newCardId:"",
  172. newObuId:""
  173. });
  174. //开始激活 按钮事件
  175. const btn = () => {
  176. state.disabled = false
  177. console.log('orderInfo参数', orderInfo, state.disabled)
  178. // 售后激活
  179. cmdResultSH()
  180. };
  181. function cmdResultSH() {
  182. tools.showLoadingAlert('正在激活,请等待')
  183. const options = {
  184. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  185. showLoading: false,
  186. data: {
  187. id: orderInfo.id,
  188. }, //请求参数
  189. method: "POST", //提交方式(默认POST)
  190. };
  191. console.log("options==", options)
  192. //BDS-二发指令申请
  193. requestNew(changeCardObuCommandApply, options)
  194. .then((res) => {
  195. console.log("在线激活 请求");
  196. console.log(res);
  197. const datas =res;
  198. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  199. implementCmdSH(datas.transOrderId, datas.cmd, res.toString(), datas.stepNo)
  200. }, () => {
  201. showModals('在线激活异常')
  202. tools.hideLoadingAlert();
  203. });
  204. })
  205. .catch((err) => {
  206. console.log(err);
  207. tools.hideLoadingAlert();
  208. });
  209. }
  210. function implementCmdSH(transOrderId, cmd, cmdResult, stepNo) {
  211. const options = {
  212. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  213. showLoading: false,
  214. data: {
  215. transOrderId, //步骤号
  216. cmd,
  217. cmdResult,
  218. stepNo
  219. }, //请求参数
  220. method: "POST", //提交方式(默认POST)
  221. };
  222. console.log("options2222", options)
  223. //BDS-二发指令回传
  224. requestNew(changeCardObuCommandCallback, options)
  225. .then((res) => {
  226. console.log("BDS-二发指令回传 ",res);
  227. const datas = res;
  228. console.log("在线激活 请求", datas);
  229. if (datas.stepNo == 100) {
  230. state.disabled = true
  231. tools.hideLoadingAlert();
  232. msg("激活成功", {
  233. 'icon': 'success',
  234. 'duration': 3000
  235. })
  236. setTimeout(() => {
  237. uni.navigateTo({
  238. url: "/subpackage/after-sale/deviceInfo/deviceInfo",
  239. });
  240. }, 3000)
  241. } else {
  242. console.log("datas.stepNo", datas.stepNo)
  243. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  244. implementCmdSH(transOrderId, datas.cmd, res.toString(), datas.stepNo)
  245. }, () => {
  246. showModals('在线激活异常')
  247. });
  248. }
  249. })
  250. .catch((err) => {
  251. console.log(err);
  252. tools.hideLoadingAlert();
  253. });
  254. }
  255. //获取订单详情
  256. const getOrderDetails = (id) => {
  257. console.log('======获取订单信息======')
  258. const options = {
  259. type: 2,
  260. data: {
  261. id: id,
  262. },
  263. method: "POST",
  264. showLoading: false,
  265. };
  266. state.disabled = false
  267. requestNew(changeCardObuView, options).then((res) => {
  268. console.log("orderInfo", res);
  269. orderInfo = res;
  270. console.log("orderInfores", res);
  271. if (orderInfo) {
  272. fileDataStrings.userType = orderInfo.userType; //用户类型
  273. fileDataStrings.cardId = orderInfo.cardId;
  274. fileDataStrings.packageNum = orderInfo.packageNum;
  275. fileDataStrings.obuId = orderInfo.obuId;
  276. fileDataStrings.customerTel = orderInfo.customerTel;
  277. fileDataStrings.customerId = orderInfo.customerId;
  278. fileDataStrings.orderId = orderInfo.orderNo;
  279. fileDataStrings.vehiclePlateColorStr = getVehiclePlateColor(orderInfo
  280. .vehiclePlateColor);
  281. fileDataStrings.vehiclePlate = orderInfo.vehiclePlate; //车牌
  282. fileDataStrings.vehicleClassStr = orderInfo.vehicleClassStr;
  283. fileDataStrings.newCardId = orderInfo.newCardId;
  284. fileDataStrings.newObuId = orderInfo.newObuId;
  285. }
  286. });
  287. getObuId();
  288. };
  289. /**
  290. * 获取OBU号 读OBU
  291. */
  292. const getObuId = () => {
  293. console.log('======获取OBU号======')
  294. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  295. // tools.showLoadingAlert("正在执行指令");
  296. bluetoothUtil.transCmd(cmdArray, "20", function(res) {
  297. // tools.hideLoadingAlert();
  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. state.showBtn = true
  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. </script>
  336. <style>
  337. .containers {
  338. height: 100%;
  339. display: flex;
  340. flex-direction: column;
  341. align-items: center;
  342. justify-content: space-between;
  343. box-sizing: border-box;
  344. }
  345. .sec_info {
  346. width: 90%;
  347. height: auto;
  348. margin: 0 auto;
  349. box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.2);
  350. margin-top: 50rpx;
  351. border-radius: 20rpx;
  352. }
  353. .info_txt {
  354. width: 100%;
  355. height: 120rpx;
  356. line-height: 120rpx;
  357. text-align: center;
  358. color: #000;
  359. font-size: 36rpx;
  360. margin-bottom: 20rpx;
  361. }
  362. .info_plate {
  363. display: flex;
  364. flex-direction: row;
  365. width: 94%;
  366. height: 100rpx;
  367. margin: 0 auto;
  368. border-bottom: 2rpx solid #f2f2f2;
  369. }
  370. .info_plate text:nth-child(1) {
  371. height: 100rpx;
  372. text-align: left;
  373. line-height: 100rpx;
  374. font-size: 32rpx;
  375. color: #999;
  376. }
  377. .info_plate text:nth-child(2) {
  378. flex: 1;
  379. height: 100rpx;
  380. line-height: 100rpx;
  381. font-size: 32rpx;
  382. color: #333;
  383. margin-left: 50rpx;
  384. text-align: right;
  385. }
  386. /*提交按钮样式*/
  387. .up_btn {
  388. width: 85%;
  389. height: 100rpx;
  390. margin: 0 auto;
  391. margin-top: 50rpx;
  392. margin-bottom: 100rpx;
  393. }
  394. .up_btn button {
  395. width: 100%;
  396. height: 80rpx;
  397. line-height: 80rpx;
  398. color: white;
  399. font-size: 32rpx;
  400. text-align: center;
  401. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  402. border-radius: 40rpx;
  403. outline: none;
  404. border: #4cd95f;
  405. }
  406. .button {
  407. width: 100%;
  408. height: 80rpx;
  409. line-height: 80rpx;
  410. color: white;
  411. font-size: 32rpx;
  412. text-align: center;
  413. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  414. border-radius: 40rpx;
  415. outline: none;
  416. border: #4cd95f;
  417. }
  418. .hui {
  419. width: 100%;
  420. height: 80rpx;
  421. line-height: 80rpx;
  422. color: white;
  423. font-size: 32rpx;
  424. text-align: center;
  425. background: linear-gradient(to left, #b9b9b9 0%, #e7e7e7 100%) !important;
  426. border-radius: 40rpx;
  427. outline: none;
  428. border: #4cd95f;
  429. }
  430. .up_btn button[disabled] {
  431. background-color: rgba(0, 191, 112, 0.5);
  432. color: white;
  433. font-size: 34rpx;
  434. border-radius: 20rpx;
  435. }
  436. </style>