您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

activate-SH.vue 11KB

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