Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

activate-SH.vue 11KB

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