選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

activate.vue 13KB

4ヶ月前
4ヶ月前
11ヶ月前
11ヶ月前
10ヶ月前
4ヶ月前
7ヶ月前
7ヶ月前
1年前
1年前
11ヶ月前
4ヶ月前
1年前
1年前
11ヶ月前
10ヶ月前
10ヶ月前
10ヶ月前
7ヶ月前
10ヶ月前
10ヶ月前
10ヶ月前
7ヶ月前
10ヶ月前
7ヶ月前
10ヶ月前
10ヶ月前
10ヶ月前
10ヶ月前
10ヶ月前
10ヶ月前
10ヶ月前
7ヶ月前
10ヶ月前
7ヶ月前
10ヶ月前
10ヶ月前
10ヶ月前
10ヶ月前
11ヶ月前
10ヶ月前
11ヶ月前
10ヶ月前
7ヶ月前
10ヶ月前
7ヶ月前
1年前
7ヶ月前
11ヶ月前
11ヶ月前
1年前
1年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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. <view v-if="state.showPopup" class="mask">
  41. <piaoyi-progress-bar canvasId="progressCanvas4" :progress="state.progressNum"
  42. progressBackgroundColor="#07C160" :showText="true" textColor="#fff" :textSize="28" :height="22"
  43. :isCircular="true" :diameter="300"></piaoyi-progress-bar>
  44. </view>
  45. </template>
  46. <script setup>
  47. import {
  48. reactive,
  49. ref
  50. } from "vue";
  51. import {
  52. formatTime,
  53. formatTime2,
  54. expireDate,
  55. expireDate2,
  56. getFormatDate,
  57. msg
  58. } from "@/utils/utils";
  59. import {
  60. onLoad
  61. } from '@dcloudio/uni-app'
  62. import {
  63. getItem
  64. } from "@/utils/storage";
  65. import {requestNew} from "@/utils/network/request.js";
  66. import {
  67. IntegerToHexString,
  68. } from "@/utils/util/fileData.js";
  69. import {
  70. issueApply,issueCallback,orderDetailQuery,errorLogAdd
  71. } from "@/utils/network/api";
  72. import {
  73. agentId
  74. } from "@/utils/network/difference";
  75. const cmd = require("../../../static/etcUtil/cmdConfig.js");
  76. const tools = require("../../../static/etcUtil/tools.js");
  77. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  78. import activeSuccess from "./components/popup-device-active-success";
  79. const datas = require("../../../static/etcUtil/datas.js");
  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. transfer: 0, //0 是原来的激活 1 是过户激活
  97. showBtn: true,
  98. disabled: true,
  99. progressNum:0
  100. })
  101. onLoad((option) => {
  102. //读取传入 存储的数据orderInfo
  103. let orderData = getItem("orderInfo");
  104. state.id = orderData.id;
  105. console.log(state);
  106. state.transfer = Number(option.transfer)
  107. //获取订单详情
  108. getOrderDetails(state.id);
  109. console.log("state.transfer", state.transfer, state.transfer == 0, state.transfer == 1,getItem("orderInfo"))
  110. })
  111. const card = reactive({
  112. cardId: "",
  113. netId: "",
  114. cardType: "",
  115. startTime: "",
  116. endTime: "",
  117. userName: "",
  118. idNum: "",
  119. vehiclePlate: "",
  120. vehiclePlateColor: "",
  121. color: "",
  122. version: "",
  123. type: "",
  124. favourable: "",
  125. money: "",
  126. v_userType: "",
  127. });
  128. const obu = reactive({
  129. obuId: "",
  130. startTime: "",
  131. endTime: "",
  132. version: "",
  133. approvedCount: "",
  134. axleCount: "",
  135. axleDistance: "",
  136. engineNum: "",
  137. type: "",
  138. userType: "",
  139. contractNo: "",
  140. vehiclePlate: "",
  141. vehiclePlateColor: "",
  142. vin: "",
  143. wheelCount: 0,
  144. isJH: ""
  145. });
  146. let cmdRandNum = '';
  147. let orderInfo = {};
  148. const fileDataStrings = reactive({
  149. approvedCount: 0, //核载人数
  150. cardId: "", //卡号
  151. obuId: "", //obu号
  152. obuId: "", //obu号
  153. packageNum: "", //套餐编号
  154. axleCount: 0, //轴数
  155. axleDistance: "", //轴距
  156. engineNum: "", //发动机
  157. vehicleVin: "",
  158. vehicleEngineNum: "",
  159. cardStatus: "",
  160. obuStatus: "",
  161. type: 0, //类型
  162. userType: 0, //用户类型
  163. vehiclePlate: "", //车牌
  164. vehiclePlateColor: 0, //车牌颜色
  165. vehicleDimensions: "",
  166. wheelCount: 0, //车轮数
  167. vehicleIdNo: "", //车牌号
  168. vehiclePlateColorStr: "",
  169. customerTel: "",
  170. customerId: "",
  171. orderId: "",
  172. vehicleClassStr: ""
  173. });
  174. function cmdResult1() {
  175. // tools.showLoadingAlert('正在激活,请等待')
  176. const options = {
  177. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  178. showLoading: false,
  179. data: {
  180. orderId: orderInfo.orderNo,
  181. issueType: state.transfer ? 2 : 1, //1正常激活 2 过户激活
  182. cardId:card.cardId,
  183. obuId:obu.obuId
  184. }, //请求参数
  185. method: "POST", //提交方式(默认POST)
  186. };
  187. console.log("options==", options)
  188. //BDS-二发指令申请
  189. requestNew(issueApply, options)
  190. .then((res) => {
  191. console.log("在线激活 请求");
  192. console.log(res);
  193. const datas =res;
  194. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  195. implementCmd(datas.transOrderId, datas.cmd, res.toString(), datas.stepNo)
  196. }, (err) => {
  197. showModals('在线激活异常')
  198. console.log("err",err)
  199. errorLog(datas.cmd,JSON.stringify(err),datas.stepNo)
  200. tools.hideLoadingAlert();
  201. state.showPopup=false
  202. });
  203. })
  204. .catch((err) => {
  205. console.log(err);
  206. tools.hideLoadingAlert();
  207. state.showPopup=false
  208. });
  209. }
  210. function implementCmd(transOrderId, cmd, cmdResult, stepNo) {
  211. state.progressNum=state.progressNum+5
  212. const options = {
  213. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  214. showLoading: false,
  215. data: {
  216. transOrderId, //步骤号
  217. cmd,
  218. cmdResult,
  219. stepNo,
  220. mpOpenId:getItem('mpOpenId')//公众号openid
  221. }, //请求参数
  222. method: "POST", //提交方式(默认POST)
  223. };
  224. console.log("options2222", options)
  225. //BDS-二发指令回传
  226. requestNew(issueCallback, options)
  227. .then((res) => {
  228. console.log("BDS-二发指令回传 ",res);
  229. const datas = res;
  230. console.log("在线激活 请求", datas);
  231. if (datas.stepNo == 100) {
  232. state.disabled = true
  233. tools.hideLoadingAlert();
  234. state.progressNum=100
  235. // msg("激活成功", {
  236. // 'icon': 'success',
  237. // 'duration': 3000
  238. // })
  239. setTimeout(() => {
  240. state.showPopup=false
  241. uni.navigateTo({
  242. url: "/subpackage/after-sale/deviceInfo/deviceInfo",
  243. });
  244. },2000)
  245. } else {
  246. console.log("datas.stepNo", datas.stepNo)
  247. bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) {
  248. implementCmd(transOrderId, datas.cmd, res.toString(), datas.stepNo)
  249. }, (err) => {
  250. console.log("err",err)
  251. state.showPopup=false
  252. errorLog(datas.cmd,JSON.stringify(err),datas.stepNo)
  253. showModals('在线激活异常')
  254. });
  255. }
  256. })
  257. .catch((err) => {
  258. console.log(err);
  259. tools.hideLoadingAlert();
  260. state.showPopup=false
  261. });
  262. }
  263. //开始激活 按钮事件
  264. const btn = () => {
  265. state.disabled = false
  266. state.showPopup=true
  267. console.log('orderInfo参数', orderInfo, state.disabled)
  268. cmdResult1()
  269. };
  270. //获取订单详情
  271. const getOrderDetails = (id) => {
  272. console.log('======获取订单信息======')
  273. const options = {
  274. type: 2,
  275. data: {
  276. id: id,
  277. },
  278. method: "POST",
  279. showLoading: false,
  280. };
  281. state.disabled = false
  282. requestNew(orderDetailQuery, options).then((res) => {
  283. console.log("orderInfo", res);
  284. orderInfo = res.data;
  285. console.log("orderInfores", res);
  286. if (orderInfo) {
  287. fileDataStrings.userType = orderInfo.userType; //用户类型
  288. fileDataStrings.cardId = orderInfo.cardId;
  289. fileDataStrings.packageNum = orderInfo.packageNum;
  290. fileDataStrings.obuId = orderInfo.obuId;
  291. fileDataStrings.customerTel = orderInfo.customerTel;
  292. fileDataStrings.customerId = orderInfo.customerId;
  293. fileDataStrings.orderId = orderInfo.orderNo;
  294. fileDataStrings.vehiclePlateColorStr = getVehiclePlateColor(orderInfo
  295. .vehiclePlateColor);
  296. fileDataStrings.vehiclePlate = orderInfo.vehiclePlate; //车牌
  297. fileDataStrings.vehicleClassStr = orderInfo.vehicleClassStr;
  298. }
  299. });
  300. getObuId();
  301. };
  302. /**
  303. * 获取OBU号 读OBU
  304. */
  305. const getObuId = () => {
  306. console.log('======获取OBU号======')
  307. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  308. bluetoothUtil.transCmd(cmdArray, "20", function(res) {
  309. var status = res[1].substring(res[1].length - 4, res[1].length);
  310. console.log('获取OBU号执行结果' + status, res)
  311. //第一次获取随机数
  312. if (status == "9000") {
  313. state.disabled = true
  314. obu.obuId = res[1].substring(20, 36);
  315. obu.vin = res[1].substring(18, 20);
  316. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  317. cmdRandNum = res[2].substring(0, res[2].length - 4);
  318. getCardId()
  319. } else {
  320. showModals('获取设备信息错误!')
  321. }
  322. }, () => {
  323. showModals('获取设备信息错误')
  324. });
  325. };
  326. function showModals(msg) {
  327. uni.showModal({
  328. title: '提示',
  329. content: msg,
  330. showCancel: false,
  331. success: function(res) {
  332. if (res.confirm) {
  333. uni.navigateBack()
  334. console.log('用户点击确定1');
  335. } else if (res.cancel) {
  336. console.log('用户点击取消1');
  337. }
  338. }
  339. });
  340. }
  341. const back = () => {
  342. uni.switchTab({
  343. url: "/pages/index/index"
  344. });
  345. }
  346. const getCardId = () => {
  347. //执行0015文件
  348. tools.showLoadingAlert("执行指令");
  349. let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY, cmd.CMD_GETBALANCE];
  350. console.log(cmdArr);
  351. console.log(bluetoothUtil);
  352. bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU
  353. console.log("5201",res)
  354. let str = res[2].substring(res[2].length - 4, res[2].length); //判断是否为9000
  355. let str3 = res[3].substring(res[3].length - 4, res[3].length); //判断是否为9000
  356. if (str == "9000" || str3 == "9000") {
  357. if (res[2].length > 86 || res[3] >= 12) {
  358. card.cardId = res[2].substring(20, 40);
  359. tools.hideLoadingAlert();
  360. state.showBtn = true
  361. } else {
  362. alertF("CMD_READBINARY指令长度不符" + res[2]);
  363. }
  364. return;
  365. }
  366. alertF("CMD_READBINARY指令长度不符" + res[2]);
  367. })
  368. };
  369. //获取订单详情
  370. const errorLog = (cmd,error,step) => {
  371. console.log('======获取订单信息======')
  372. const options = {
  373. type: 2,
  374. data: {
  375. cardId:card.cardId,
  376. obuId:obu.obuId,
  377. orderType:"1",
  378. factory:datas.getData("deviceName")+"_"+datas.getData("deviceNameZW"),
  379. orderNo:orderInfo.orderNo,
  380. cmd,
  381. error,
  382. step
  383. },
  384. method: "POST",
  385. showLoading: false,
  386. };
  387. requestNew(errorLogAdd, options).then((res) => {
  388. console.log("错误提交成功", res);
  389. });
  390. };
  391. </script>
  392. <style>
  393. .containers {
  394. height: 100%;
  395. display: flex;
  396. flex-direction: column;
  397. align-items: center;
  398. justify-content: space-between;
  399. box-sizing: border-box;
  400. }
  401. .sec_info {
  402. width: 90%;
  403. height: auto;
  404. margin: 0 auto;
  405. box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.2);
  406. margin-top: 50rpx;
  407. border-radius: 20rpx;
  408. }
  409. .info_txt {
  410. width: 100%;
  411. height: 120rpx;
  412. line-height: 120rpx;
  413. text-align: center;
  414. color: #000;
  415. font-size: 36rpx;
  416. margin-bottom: 20rpx;
  417. }
  418. .info_plate {
  419. display: flex;
  420. flex-direction: row;
  421. width: 94%;
  422. height: 100rpx;
  423. margin: 0 auto;
  424. border-bottom: 2rpx solid #f2f2f2;
  425. }
  426. .info_plate text:nth-child(1) {
  427. height: 100rpx;
  428. text-align: left;
  429. line-height: 100rpx;
  430. font-size: 32rpx;
  431. color: #999;
  432. }
  433. .info_plate text:nth-child(2) {
  434. flex: 1;
  435. height: 100rpx;
  436. line-height: 100rpx;
  437. font-size: 32rpx;
  438. color: #333;
  439. margin-left: 50rpx;
  440. text-align: right;
  441. }
  442. /*提交按钮样式*/
  443. .up_btn {
  444. width: 85%;
  445. height: 100rpx;
  446. margin: 0 auto;
  447. margin-top: 50rpx;
  448. margin-bottom: 100rpx;
  449. }
  450. .up_btn button {
  451. width: 100%;
  452. height: 80rpx;
  453. line-height: 80rpx;
  454. color: white;
  455. font-size: 32rpx;
  456. text-align: center;
  457. background: linear-gradient(to right,#01243A,#004576);
  458. border-radius: 40rpx;
  459. outline: none;
  460. border: #4cd95f;
  461. }
  462. .button {
  463. width: 100%;
  464. height: 80rpx;
  465. line-height: 80rpx;
  466. color: white;
  467. font-size: 32rpx;
  468. text-align: center;
  469. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  470. border-radius: 40rpx;
  471. outline: none;
  472. border: #4cd95f;
  473. }
  474. .hui {
  475. width: 100%;
  476. height: 80rpx;
  477. line-height: 80rpx;
  478. color: white;
  479. font-size: 32rpx;
  480. text-align: center;
  481. background: linear-gradient(to left, #b9b9b9 0%, #e7e7e7 100%) !important;
  482. border-radius: 40rpx;
  483. outline: none;
  484. border: #4cd95f;
  485. }
  486. .up_btn button[disabled] {
  487. background-color: rgba(0, 191, 112, 0.5);
  488. color: white;
  489. font-size: 34rpx;
  490. border-radius: 20rpx;
  491. }
  492. .mask{
  493. width: 100%;
  494. height:100vh;
  495. background:rgba(0,0,0,0.63);
  496. position: fixed;
  497. left: 0;
  498. top: 0;
  499. right: 0;
  500. bottom: 0;
  501. z-index: 999;
  502. display: flex;
  503. align-items: center;
  504. justify-content: center;
  505. }
  506. </style>