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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. console.log('activateSHBTN', orderInfo, state.disabled);
  177. state.disabled = false
  178. console.log('orderInfo参数', orderInfo, state.disabled)
  179. // 售后激活
  180. cmdResultSH()
  181. };
  182. function cmdResultSH() {
  183. tools.showLoadingAlert('正在激活,请等待')
  184. const options = {
  185. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  186. showLoading: false,
  187. data: {
  188. id: orderInfo.id,
  189. }, //请求参数
  190. method: "POST", //提交方式(默认POST)
  191. };
  192. console.log("options==", options)
  193. //BDS-二发指令申请
  194. requestNew(changeCardObuCommandApply, options)
  195. .then((res) => {
  196. console.log("在线激活 请求");
  197. console.log(res);
  198. const datas =res;
  199. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  200. implementCmdSH(datas.transOrderId, datas.cmd, res.toString(), datas.stepNo)
  201. }, () => {
  202. showModals('在线激活异常')
  203. tools.hideLoadingAlert();
  204. });
  205. })
  206. .catch((err) => {
  207. console.log(err);
  208. tools.hideLoadingAlert();
  209. });
  210. }
  211. function implementCmdSH(transOrderId, cmd, cmdResult, stepNo) {
  212. const options = {
  213. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  214. showLoading: false,
  215. data: {
  216. transOrderId, //步骤号
  217. cmd,
  218. cmdResult,
  219. stepNo
  220. }, //请求参数
  221. method: "POST", //提交方式(默认POST)
  222. };
  223. console.log("options2222", options)
  224. //BDS-二发指令回传
  225. requestNew(changeCardObuCommandCallback, options)
  226. .then((res) => {
  227. console.log("BDS-二发指令回传 ",res);
  228. const datas = res;
  229. console.log("在线激活 请求", datas);
  230. if (datas.stepNo == 100) {
  231. state.disabled = true
  232. tools.hideLoadingAlert();
  233. msg("激活成功", {
  234. 'icon': 'success',
  235. 'duration': 3000
  236. })
  237. setTimeout(() => {
  238. uni.navigateTo({
  239. url: "/subpackage/after-sale/deviceInfo/deviceInfo",
  240. });
  241. }, 3000)
  242. } else {
  243. console.log("datas.stepNo", datas.stepNo)
  244. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  245. implementCmdSH(transOrderId, datas.cmd, res.toString(), datas.stepNo)
  246. }, () => {
  247. showModals('在线激活异常')
  248. });
  249. }
  250. })
  251. .catch((err) => {
  252. console.log(err);
  253. tools.hideLoadingAlert();
  254. });
  255. }
  256. //获取订单详情
  257. const getOrderDetails = (id) => {
  258. console.log('======获取订单信息======')
  259. const options = {
  260. type: 2,
  261. data: {
  262. id: id,
  263. },
  264. method: "POST",
  265. showLoading: false,
  266. };
  267. state.disabled = false
  268. requestNew(changeCardObuView, options).then((res) => {
  269. console.log("orderInfo", res);
  270. orderInfo = res;
  271. console.log("orderInfores", res);
  272. if (orderInfo) {
  273. fileDataStrings.userType = orderInfo.userType; //用户类型
  274. fileDataStrings.cardId = orderInfo.cardId;
  275. fileDataStrings.packageNum = orderInfo.packageNum;
  276. fileDataStrings.obuId = orderInfo.obuId;
  277. fileDataStrings.customerTel = orderInfo.customerTel;
  278. fileDataStrings.customerId = orderInfo.customerId;
  279. fileDataStrings.orderId = orderInfo.orderNo;
  280. fileDataStrings.vehiclePlateColorStr = getVehiclePlateColor(orderInfo
  281. .vehiclePlateColor);
  282. fileDataStrings.vehiclePlate = orderInfo.vehiclePlate; //车牌
  283. fileDataStrings.vehicleClassStr = orderInfo.vehicleClassStr;
  284. fileDataStrings.newCardId = orderInfo.newCardId;
  285. fileDataStrings.newObuId = orderInfo.newObuId;
  286. }
  287. });
  288. getObuId();
  289. };
  290. /**
  291. * 获取OBU号 读OBU
  292. */
  293. const getObuId = () => {
  294. console.log('======获取OBU号======')
  295. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  296. // tools.showLoadingAlert("正在执行指令");
  297. bluetoothUtil.transCmd(cmdArray, "20", function(res) {
  298. // tools.hideLoadingAlert();
  299. var status = res[1].substring(res[1].length - 4, res[1].length);
  300. console.log('获取OBU号执行结果' + status, res)
  301. //第一次获取随机数
  302. if (status == "9000") {
  303. state.disabled = true
  304. obu.obuId = res[1].substring(20, 36);
  305. obu.vin = res[1].substring(18, 20);
  306. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  307. cmdRandNum = res[2].substring(0, res[2].length - 4);
  308. state.showBtn = true
  309. } else {
  310. showModals('获取设备信息错误!')
  311. }
  312. }, () => {
  313. showModals('获取设备信息错误')
  314. });
  315. };
  316. function showModals(msg) {
  317. uni.showModal({
  318. title: '提示',
  319. content: msg,
  320. showCancel: false,
  321. success: function(res) {
  322. if (res.confirm) {
  323. uni.navigateBack()
  324. console.log('用户点击确定1');
  325. } else if (res.cancel) {
  326. console.log('用户点击取消1');
  327. }
  328. }
  329. });
  330. }
  331. const back = () => {
  332. uni.switchTab({
  333. url: "/pages/index/index"
  334. });
  335. }
  336. </script>
  337. <style>
  338. .containers {
  339. height: 100%;
  340. display: flex;
  341. flex-direction: column;
  342. align-items: center;
  343. justify-content: space-between;
  344. box-sizing: border-box;
  345. }
  346. .sec_info {
  347. width: 90%;
  348. height: auto;
  349. margin: 0 auto;
  350. box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.2);
  351. margin-top: 50rpx;
  352. border-radius: 20rpx;
  353. }
  354. .info_txt {
  355. width: 100%;
  356. height: 120rpx;
  357. line-height: 120rpx;
  358. text-align: center;
  359. color: #000;
  360. font-size: 36rpx;
  361. margin-bottom: 20rpx;
  362. }
  363. .info_plate {
  364. display: flex;
  365. flex-direction: row;
  366. width: 94%;
  367. height: 100rpx;
  368. margin: 0 auto;
  369. border-bottom: 2rpx solid #f2f2f2;
  370. }
  371. .info_plate text:nth-child(1) {
  372. height: 100rpx;
  373. text-align: left;
  374. line-height: 100rpx;
  375. font-size: 32rpx;
  376. color: #999;
  377. }
  378. .info_plate text:nth-child(2) {
  379. flex: 1;
  380. height: 100rpx;
  381. line-height: 100rpx;
  382. font-size: 32rpx;
  383. color: #333;
  384. margin-left: 50rpx;
  385. text-align: right;
  386. }
  387. /*提交按钮样式*/
  388. .up_btn {
  389. width: 85%;
  390. height: 100rpx;
  391. margin: 0 auto;
  392. margin-top: 50rpx;
  393. margin-bottom: 100rpx;
  394. }
  395. .up_btn button {
  396. width: 100%;
  397. height: 80rpx;
  398. line-height: 80rpx;
  399. color: white;
  400. font-size: 32rpx;
  401. text-align: center;
  402. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  403. border-radius: 40rpx;
  404. outline: none;
  405. border: #4cd95f;
  406. }
  407. .button {
  408. width: 100%;
  409. height: 80rpx;
  410. line-height: 80rpx;
  411. color: white;
  412. font-size: 32rpx;
  413. text-align: center;
  414. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  415. border-radius: 40rpx;
  416. outline: none;
  417. border: #4cd95f;
  418. }
  419. .hui {
  420. width: 100%;
  421. height: 80rpx;
  422. line-height: 80rpx;
  423. color: white;
  424. font-size: 32rpx;
  425. text-align: center;
  426. background: linear-gradient(to left, #b9b9b9 0%, #e7e7e7 100%) !important;
  427. border-radius: 40rpx;
  428. outline: none;
  429. border: #4cd95f;
  430. }
  431. .up_btn button[disabled] {
  432. background-color: rgba(0, 191, 112, 0.5);
  433. color: white;
  434. font-size: 34rpx;
  435. border-radius: 20rpx;
  436. }
  437. </style>