parkingFee.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. import plateNumber from '@/components/plate-number/plateNumber.vue';
  2. import { REG_SOURCE } from '@/constants';
  3. import LoginDom from '@/components/Login/Login.vue';
  4. import { mapState } from 'vuex';
  5. import { initWxJsSdkConfig } from '@/utils/login';
  6. import { getPlatform,requestInit } from '@/utils/index';
  7. import { wxToLoginCallback, getUrlParams } from '@/utils';
  8. import {getAccessH5} from '@/utils/api-crm-member'
  9. const app = {
  10. globalData: {
  11. regSource: '',
  12. },
  13. };
  14. import uni from '@/utils/uniHooks';
  15. // import blueCom from '../components/blue/home.vue';
  16. // import greenCom from '../components/green/home.vue';
  17. // import officeBlueCom from '../components/officeBlue/home.vue';
  18. // import purpleCom from '../components/purple/home.vue';
  19. import { parkingLots, qrCodes, unlicensedCarCheckIn } from '@/api/parking';
  20. import { reject } from 'lodash';
  21. export default {
  22. components: {
  23. plateNumber,
  24. LoginDom,
  25. // blueCom,
  26. // greenCom,
  27. // officeBlueCom,
  28. // purpleCom,
  29. },
  30. data() {
  31. return {
  32. vehicleMgt_content_index: -1, //历史车辆选中
  33. carType: 0, //车辆类型
  34. init_ch: false, // 字体超出隐藏显示
  35. search_price: false, //查询按钮隐藏显示
  36. parkInfoEntity: {},
  37. show_chinese: false, //是否显示汉字键盘
  38. show_allBoard: false, //是否显示英文数字键盘
  39. plate_number: '', //车牌号
  40. description: '', // 车场描述
  41. ind: null,
  42. numArr: ['', '', '', '', '', '', ''],
  43. active: null,
  44. carList: [], // 车辆列表
  45. classifyList: ['燃油车牌', '新能源', '特殊车牌'], // 车牌类型
  46. vehicleNumber: '',
  47. localimgPic: '',
  48. hourMoney: '',
  49. showSq: false,
  50. blueHeadBg: 'parkingFee/fee-head-bg.png',
  51. picUrl: this.$picUrl,
  52. colorAry: ['', '-blue', '-green'],
  53. openId: null,
  54. options: null,
  55. preUrl: '',
  56. tabbarActive: '手动缴费',
  57. supportUnlicensed: false, // 控制当前site,是否使用无牌车
  58. qrCodeHistory: ''
  59. // custTypeId: 0,
  60. };
  61. },
  62. computed: {
  63. disabledBtn() {
  64. return this.numArr.filter((val) => !val).length > 0;
  65. },
  66. ...mapState({
  67. groupId: (state) => state.groupId,
  68. openid: (state) => state.openid,
  69. mallId: (state) => state.mallId,
  70. kipUserId: (state) => state.kipUserId,
  71. userInfo: (state) => state.userInfo,
  72. member: (state) => state.member,
  73. mobile: (state) => state.mobile,
  74. custTypeId: (state) => state.custTypeId,
  75. unlicensedCar: (state) => state.order.unlicensedCar,
  76. // 如果是扫码进入的无牌车
  77. unlicensedInfo: (state) => state.unlicensedInfo,
  78. endlessLoop: (state) => state.endlessLoop,
  79. source: (state) => state.source,
  80. }),
  81. },
  82. beforeRouteLeave(to, from, next) {
  83. this.$store.commit('cachedViews/DEL_CACHED_VIEW', to);
  84. next();
  85. },
  86. watch: {
  87. openid() {
  88. if (this.openid) {
  89. this.getParkInfo();
  90. this.showSq = false;
  91. }
  92. },
  93. unlicensedInfo:{
  94. handler(){
  95. // const member = uni.getStorageSync('member');
  96. // if(!member) return // 如果用户走未登录流程的话
  97. // 不论是否出入场,都使用此函数获取 gateId(闸口机器的ID)
  98. if (this.unlicensedInfo?.type && /unlicensedOut|unlicensedIn/.test(this.unlicensedInfo.type) && this.endlessLoop.length === 0) {
  99. // 此处记录扫码流程执行次数。如果超过一次则不再执行
  100. this.$store.commit('SET_ENDLESS_LOOP', this.unlicensedInfo.type);
  101. this.$nextTick(() => {
  102. this.qrCodesRule(this.unlicensedInfo.code);
  103. })
  104. }
  105. },
  106. immediate:true //true就表示会立即执行
  107. }
  108. },
  109. async mounted() {
  110. setTimeout(() => {
  111. uni.setNavigationBarTitle({
  112. title: '停车缴费',
  113. });
  114. }, 300);
  115. setTimeout(() => {
  116. window?.toWXSendMsg({
  117. type: 'uni_func',
  118. funcName: 'setNavigationBarColor',
  119. options: {
  120. frontColor: '#000000',
  121. backgroundColor: '#FBFCFF',
  122. },
  123. });
  124. }, 500)
  125. const platform = getPlatform();
  126. if (platform === 'micromessenger') {
  127. await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
  128. }
  129. const member = uni.getStorageSync('member');
  130. const openid= uni.getStorageSync('openid');
  131. // console.log(openid)
  132. // 如果用户未登录的话,返回之后,重新获取数据用户的基础数据
  133. if (!member && window?.toWXSendMsg) {
  134. /*wxToLoginCallback('parkingFee', (options) => {
  135. console.log('用户是扫码进来的125', this.unlicensedInfo);
  136. console.log('用户是扫码进来的126', options);
  137. this.$store.commit('SET_IS_INIT', false);
  138. // 请求 projectId
  139. window.toWXSendMsg({
  140. type: 'getProjectId',
  141. options: {},
  142. });
  143. window.subscribe('projectId', (newOptions) => {
  144. console.log('用户是扫码进来的134', newOptions);
  145. this.$store.dispatch('baseInit', {
  146. options: newOptions,
  147. callback: () => {
  148. this.$nextTick(( ) => {
  149. requestInit();
  150. this.getParkInfo();
  151. this.$store.commit('SET_IS_INIT', true);
  152. this.$nextTick(() => {
  153. // 如果是无牌车的扫码出入场
  154. if(options?.options?.type && /unlicensedIn|unlicensedOut/.test(options.options.type)) {
  155. this.$store.commit('SET_UNLICENSED_INFO', options.options);
  156. this.qrCodesRule(options.options.code);
  157. }
  158. })
  159. })
  160. },
  161. });
  162. });
  163. });*/
  164. }
  165. // console.log(136, this.openid);
  166. if (openid) {
  167. this.getParkInfo();
  168. this.showSq = false;
  169. } else {
  170. const regSource = REG_SOURCE.PARKING;
  171. app.globalData.regSource = regSource;
  172. if (this.options?.regSource) {
  173. app.globalData.regSource = REG_SOURCE[this.options?.regSource];
  174. }
  175. if (this.options?.tpName) {
  176. app.globalData.tpName = this.options?.tpName;
  177. }
  178. this.showSq = true;
  179. }
  180. },
  181. methods: {
  182. toggleType(carType) {
  183. this.ind = 0;
  184. this.active = 0;
  185. this.carType = carType;
  186. if (carType === 1) {
  187. this.numArr = [
  188. this.numArr[0],
  189. this.numArr[1],
  190. this.numArr[2],
  191. this.numArr[3],
  192. this.numArr[4],
  193. this.numArr[5],
  194. this.numArr[6],
  195. this.numArr[7],
  196. ];
  197. } else {
  198. this.numArr = [
  199. this.numArr[0],
  200. this.numArr[1],
  201. this.numArr[2],
  202. this.numArr[3],
  203. this.numArr[4],
  204. this.numArr[5],
  205. this.numArr[6],
  206. ];
  207. }
  208. },
  209. // 获取停车场信息
  210. getParkInfo: async function () {
  211. uni.showLoading({
  212. title: '加载中',
  213. });
  214. try {
  215. console.log('加载车场信息', this.$store.state.lbsId);
  216. // const res = await parkingLots('8aaa82ea804d07cd0180516ff03b0008'); // TODO: 临时写死
  217. const res = await parkingLots(this.$store.state.lbsId); // TODO: 临时写死
  218. console.log(res);
  219. let reg = /[;;]/g;
  220. this.description = res?.description?.replace(reg, '\r\n').replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>');
  221. this.supportUnlicensed = res.supportUnlicensed || false
  222. const carList = uni.getStorageSync('carList');
  223. if (carList) {
  224. this.carList = JSON.parse(carList);
  225. }
  226. } catch (e) {
  227. console.log(225225, e);
  228. }
  229. },
  230. //缴费说明隐藏显示
  231. top_display() {
  232. this.init_ch = !this.init_ch;
  233. },
  234. // 唤起键盘
  235. clickShowKeyboard(index) {
  236. if ( this.carType !== 1 && index === 7) return
  237. this.ind = index;
  238. this.active = index;
  239. if (index === 0) {
  240. this.$refs['plateKeyboard'].openKeyboardCN();
  241. } else {
  242. this.$refs['plateKeyboard'].closeKeyboardCN();
  243. this.$refs['plateKeyboard'].openKeyboardEN();
  244. }
  245. },
  246. // 接收子组件数据
  247. updateCarno(val) {
  248. this.numArr = [...val.numArr];
  249. this.vehicleNumber = this.numArr.join('');
  250. this.active = val.active;
  251. this.ind = val.ind;
  252. },
  253. // 节流函数
  254. throttle(fc, waitTime = 500, imme = true) {
  255. if (imme) {
  256. if (!this.flag) {
  257. this.flag = true;
  258. typeof fc === 'function' && fc();
  259. this.timer = setTimeout(() => {
  260. this.flag = false;
  261. }, waitTime);
  262. }
  263. } else {
  264. if (!this.flag) {
  265. this.flag = true;
  266. this.timer = setTimeout(() => {
  267. this.flag = false;
  268. typeof fc === 'function' && fc();
  269. }, waitTime);
  270. }
  271. }
  272. },
  273. // 校验车牌号
  274. preHandleSearch() {
  275. if (this.disabledBtn) return
  276. uni.setStorageSync('carList', [
  277. ...new Set([this.vehicleNumber, ...this.carList]),
  278. ].slice(0, 6));
  279. this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
  280. name: 'parkingFeeDetail',
  281. });
  282. this.$nextTick(() => {
  283. this.$router.push({
  284. path: 'parkingFeeDetail',
  285. query: {
  286. vehicleNo: this.vehicleNumber,
  287. },
  288. });
  289. })
  290. },
  291. // 历史车牌快速查询
  292. toHandleSearch(vehicleNo) {
  293. uni.setStorageSync('carList', [...new Set([vehicleNo, ...this.carList])].slice(0, 6));
  294. this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
  295. name: 'parkingFeeDetail',
  296. });
  297. this.$nextTick(() => {
  298. this.$router.push({
  299. path: 'parkingFeeDetail',
  300. query: {
  301. vehicleNo,
  302. },
  303. });
  304. });
  305. },
  306. // 查询车费信息
  307. async handleSearch(carno, clickEvent = '$ClickQueryAndPayment') {
  308. this.vehicleNumber = carno;
  309. const params = {
  310. carno,
  311. mallid: this.mallId,
  312. openid: this.openid,
  313. vipcode: this.member?.vipcode,
  314. mobile: this.mobile,
  315. groupId: this.groupId,
  316. createuser: 'sys_miniprogram',
  317. };
  318. // 查询缴费按钮埋点
  319. let [carTypeName, redirectUrl, parkTime] = ['ordinary', '', ''];
  320. switch (this.carType) {
  321. case 0:
  322. carTypeName = 'ordinary';
  323. break;
  324. case 1:
  325. carTypeName = 'newEnergy';
  326. break;
  327. case 2:
  328. carTypeName = 'special';
  329. break;
  330. }
  331. this.$md(params);
  332. this.$request({
  333. // url: this.$baseURL + 'api/1.0/park/checkCarIsInPark',
  334. url: this.$baseURL + 'api/1.0/park/checkCarIsInParkAndCarFee',
  335. // url: 'http://172.21.90.87:8083/xcrm-api/api/1.0/park/checkCarIsInParkAndCarFee',
  336. data: params,
  337. method: 'POST',
  338. header: JSON.parse(uni.getStorageSync('handleUser')),
  339. timeout: 60000 * 2, // 120S
  340. showLoading: {
  341. title: '加载中',
  342. duration: 0,
  343. },
  344. })
  345. .then((res) => {
  346. // console.log(555555, res);
  347. // ToastObj.clear();
  348. // uni.hideLoading();
  349. if (res.data.code === 0) {
  350. // 清理旧数据
  351. this.parkingFeeDetailInit();
  352. uni.setStorageSync('isReload', '3');
  353. // this.$destroy();
  354. this.$router.push({
  355. path: 'parkingFeeDetail',
  356. query: {
  357. vehicleNo: carno,
  358. },
  359. });
  360. parkTime = res.data?.data?.serviceMin;
  361. redirectUrl = '/pages/parkingFee/parkingFeeDetail.vue';
  362. } else if (res.data.code === 1) {
  363. // 当前车辆没有查到账单
  364. this.$router.push({
  365. path: 'parkingFeePayment',
  366. query: {
  367. msg: res.data.msg,
  368. carno,
  369. },
  370. });
  371. redirectUrl = '/pages/parkingFee/parkingFeePayment.vue';
  372. } else if (res.data.code === 2) {
  373. // 月租车
  374. this.$router.push({
  375. path: './parkingFeeHint/parkingFeeHint',
  376. query: {
  377. carno,
  378. },
  379. });
  380. redirectUrl = '/pages/parkingFee/parkingFeeHint/parkingFeeHint.vue';
  381. } else {
  382. uni.showToast({
  383. title: res.data.msg,
  384. duration: 2000,
  385. icon: 'none',
  386. });
  387. }
  388. })
  389. .catch((err) => {
  390. // uni.hideLoading();
  391. uni.showToast({
  392. title: '网络超时请稍后再试',
  393. duration: 2000,
  394. icon: 'none',
  395. });
  396. console.log(err);
  397. });
  398. },
  399. // 页面初始清空缓存
  400. parkingFeeDetailInit() {
  401. console.log('清理数据');
  402. // 优惠减免(首停、会员、消费)
  403. uni.removeStorageSync('checkedList'); // 选中list
  404. uni.removeStorageSync('checkedTotal'); // 选中count数
  405. uni.removeStorageSync('discountTotal'); // 减免信息(时长、费用)
  406. // 停车减免(优惠、积分、停车券)
  407. uni.removeStorageSync('parkFee');
  408. // 电子券优惠信息
  409. uni.removeStorageSync('checkedCouponList'); // 选中list
  410. uni.removeStorageSync('couponInfo'); // 减免信息(时长、费用)
  411. uni.removeStorageSync('list'); // 电子券list
  412. // 总停车优惠信息(时长、费用)
  413. uni.removeStorageSync('parkingTotal');
  414. // 应缴金额
  415. uni.removeStorageSync('servicefee');
  416. // 订单号
  417. uni.removeStorageSync('orderno');
  418. // 纸质优惠券
  419. uni.removeStorageSync('paperCouponInfo');
  420. },
  421. // 缴费记录
  422. doRouter: function () {
  423. this.$store.dispatch('clearUnlicensed');
  424. window?.toWXSendMsg({
  425. type: 'uni_func',
  426. funcName: 'setStorageSync',
  427. options: {
  428. key: 'noLoginParkingFeeWebViewPath',
  429. value: ''
  430. },
  431. });
  432. uni.setStorageSync('loadData', '');
  433. if (this.$store.state.isLogin === '3') {
  434. this.$router.push({ path: 'login' });
  435. return;
  436. }
  437. this.$router.push({ path: 'parkingFeeList' });
  438. },
  439. // 车牌管理
  440. doRouter2: function () {
  441. this.$store.dispatch('clearUnlicensed');
  442. window?.toWXSendMsg({
  443. type: 'uni_func',
  444. funcName: 'setStorageSync',
  445. options: {
  446. key: 'noLoginParkingFeeWebViewPath',
  447. value: ''
  448. },
  449. });
  450. uni.setStorageSync('loadData', '');
  451. if (this.$store.state.isLogin === '3') {
  452. this.$router.push({ path: 'login' });
  453. return;
  454. }
  455. uni.removeStorageSync('passLogin');
  456. this.$router.push({ path: 'vehicleManagement' });
  457. },
  458. async jumpToPreJudgmentOfParkingInvoice() {
  459. return new Promise(async (resolve) => {
  460. try {
  461. // 判断是否启用停车发票
  462. uni.showLoading()
  463. const res = await getAccessH5(`${this.mallId}-invoice`);
  464. if(res?.data === 1) {
  465. uni.hideLoading();
  466. // console.log(474, this.Dialog);
  467. this.$dialog({
  468. title: '温馨提示',
  469. message: '小程序“停车开票”功能将从2023年8月10日起提供服务,支持开具3个月内停车记录的发票,如需停车开票,请稍后尝试或咨询服务台',
  470. confirmButtonColor: this.$theme[this.theme].primaryColor
  471. })
  472. // 提示用户
  473. // uni.showToast({
  474. // title:'尽请期待!'
  475. // })
  476. resolve(true)
  477. }
  478. resolve(false)
  479. } catch (err) {
  480. console.log(err);
  481. resolve(false)
  482. }
  483. })
  484. // return false
  485. },
  486. //停车发票
  487. doRouter1: async function () {
  488. const isJump = await this.jumpToPreJudgmentOfParkingInvoice();
  489. if(isJump) return
  490. uni.hideLoading()
  491. uni.removeStorageSync('invoiceindex');
  492. this.$store.dispatch('clearUnlicensed');
  493. window?.toWXSendMsg({
  494. type: 'uni_func',
  495. funcName: 'setStorageSync',
  496. options: {
  497. key: 'noLoginParkingFeeWebViewPath',
  498. value: ''
  499. },
  500. });
  501. uni.setStorageSync('loadData', '');
  502. if (this.$store.state.isLogin === '3') {
  503. this.$router.push({ path: 'login' });
  504. return;
  505. }
  506. // uni.removeStorageSync('passLogin');
  507. // TODO: 北京停车场开票
  508. /* if (this.parkInfoEntity.parkMallCode === 3) {
  509. uni.navigateToMiniProgram({
  510. appId: this.$etcpAppId,
  511. path: this.$etcpAppInvoicePath,
  512. envVersion: 'release',
  513. })
  514. return
  515. }
  516. */
  517. this.$router.push({ path: 'parkingReceipt' });
  518. },
  519. //停车券兑换
  520. doRouter3: function () {
  521. this.$store.dispatch('clearUnlicensed');
  522. window?.toWXSendMsg({
  523. type: 'uni_func',
  524. funcName: 'setStorageSync',
  525. options: {
  526. key: 'noLoginParkingFeeWebViewPath',
  527. value: ''
  528. },
  529. });
  530. uni.setStorageSync('loadData', '');
  531. window.toWXSendMsg({
  532. type: 'toPage',
  533. options: {
  534. fnName: 'navigateTo',
  535. url: '/pages/pointsMall/pointsMall?exchangeTypes=2',
  536. },
  537. });
  538. },
  539. blueComChange(value) {
  540. console.log('blueComChange', value);
  541. },
  542. tabbarActiveEvent(name) {
  543. this.tabbarActive = name
  544. if (name === '无牌缴费') {
  545. this.$store.dispatch('order/unlicensedRule', (code) => {
  546. // CAR_NOT_FOUND 车场扫描道闸入口,发现无车
  547. if (code === 'CAR_NOT_FOUND') {
  548. }
  549. // CAR_HAS_PLATE 车场扫描道闸入口,发现有牌车
  550. if (code === 'CAR_HAS_PLATE') {
  551. }
  552. })
  553. }
  554. },
  555. // 无牌车闸机扫码
  556. async scanCarCode() {
  557. try {
  558. const runScanFn = (res) => {
  559. if (res.scanType && res.scanType == 'QR_CODE') {
  560. console.log(res.result);
  561. // 获取二维码参数之后,模拟提取参数
  562. const url = res.result;
  563. const {path} = getUrlParams(res.result)
  564. let params = null
  565. if(path) {
  566. params = getUrlParams(decodeURIComponent(path))
  567. }
  568. /*
  569. 微信扫码之后,处理过的参数 {"code": "e41d4d9dd5534f4aa3de88326a2e6f85", "type": "unlicensedIn#wechat-redirect"}
  570. */
  571. if (params?.type.indexOf('wechat-redirect') > -1) {
  572. params.type = params.type.replace('#wechat-redirect', '');
  573. }
  574. console.log('微信扫码之后,处理过的参数', params);
  575. this.$store.commit('SET_UNLICENSED_INFO', params);
  576. this.$nextTick(() => {
  577. this.qrCodesRule(params.code);
  578. })
  579. return
  580. }
  581. /*
  582. 针对微信的小程序码进行的兼容改造
  583. 微信扫码结束之后的返回参数 {"errMsg": "scanCode:ok", "scanType": "WX_CODE", "charSet": "ISO8859-1", "rawData": "bGsoP3gyT1Aud3QpbW1JeHRfVHJsUjg4JnR5cGU9dW5saWNlbnNlZElu", "path": "pages/automatic/automaticIndex?scene=code%3D9988%26type%3DunlicensedIn"}
  584. */
  585. if(res.scanType && res.scanType === 'WX_CODE' && res.path) {
  586. const params = getUrlParams(`?${decodeURIComponent(res.path.replace(/.*scene=/g, ''))}`)
  587. this.$store.commit('SET_UNLICENSED_INFO', params);
  588. this.$nextTick(() => {
  589. this.qrCodesRule(params.code);
  590. })
  591. }
  592. // 兜底逻辑,如果是其他小程序扫描,则提取rawData,进行解析提取入参
  593. if(res.scanType && res.scanType === 'WX_CODE' && !res?.path){
  594. let path = atob(res.rawData)
  595. path = path.replace(/.*([a-z0-9]{6}&type)/g, '8b$1')
  596. const regex = /(\w+)&type=(\w+)/;
  597. const match = path.match(regex);
  598. const obj = { code: match[1], type: match[2] };
  599. this.$store.commit('SET_UNLICENSED_INFO', obj);
  600. this.$nextTick(() => {
  601. this.qrCodesRule(obj.code);
  602. })
  603. }
  604. };
  605. // 微信小程序
  606. const platform = getPlatform();
  607. if (platform === 'miniprogram') {
  608. window.toWXSendMsg({
  609. type: 'scanQRCode',
  610. });
  611. window.subscribe('scanQRCodeOver', (options) => {
  612. console.log('微信扫码结束之后的返回参数', options);
  613. runScanFn(options);
  614. });
  615. } else {
  616. this.$wx.scanQRCode({
  617. desc: 'scanQRCode desc',
  618. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  619. // scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  620. success: (res) => {
  621. console.log('H5页面扫码获取到的参数——成功', res);
  622. runScanFn(res);
  623. // this.formMsg.deviceCode = res.resultStr;
  624. },
  625. error: (res) => {
  626. console.log('H5页面扫码获取到的参数——失败', res);
  627. // console.log(242, res);
  628. },
  629. });
  630. }
  631. } catch (err) {
  632. console.log(624, err);
  633. }
  634. },
  635. // 处理扫码结果: 组装参数,剩余流程,在 缴费支付页面 实现
  636. async qrCodesRule(code) {
  637. try {
  638. if ( this.qrCodeHistory && this.qrCodeHistory === code ) {
  639. return
  640. }
  641. this.qrCodeHistory = code
  642. const qrCodesres = await qrCodes(code); // 无牌车扫码
  643. // 记录buildingId,确保 buildingId 是最新的数据
  644. window.localStorage.setItem('buildingId', qrCodesres.buildingId);
  645. // 如果是无牌车扫码:出场
  646. console.log('模拟出场', this.unlicensedInfo.type);
  647. this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
  648. name: 'parkingFeeDetail',
  649. });
  650. // return
  651. if (this.unlicensedInfo?.type === 'unlicensedOut') {
  652. this.$router.push({
  653. path: 'parkingFeeDetail',
  654. query: {
  655. gateId: qrCodesres.gateId,
  656. vehicleNo: '',
  657. type: this.unlicensedInfo.type
  658. }
  659. })
  660. return
  661. }
  662. // 如果是无牌车扫码:入场
  663. const unlicensedCarCheckInres = await unlicensedCarCheckIn({ // 获取无牌车牌
  664. gateId: qrCodesres.gateId
  665. });
  666. // 前往 缴费支付页面
  667. this.$router.push({
  668. path: 'parkingFeeMsg',
  669. query: {
  670. type: 'success',
  671. vehicleNo: unlicensedCarCheckInres.vehicleNo
  672. }
  673. })
  674. } catch (err) {
  675. // 车场扫描道闸入口,发现无车/车场扫描道闸入口,发现有牌车 >>> 停止往下执行,默认提示报错信息
  676. if (/CAR_HAS_PLATE/.test(err.code)) {
  677. return
  678. }
  679. if (/CAR_NOT_FOUND|INOUT_FAILED|UNLICENSED_PLATE_ACQUISITION_FAILED/.test(err.code)) {
  680. // 如果是其他错误的话,则继续往下执行
  681. this.$router.push({
  682. path: 'parkingFeeMsg',
  683. query: {
  684. type: 'fail'
  685. }
  686. })
  687. }
  688. }
  689. },
  690. // 前往支付
  691. unlicensedToPay() {
  692. // 无牌车这边去支付的时候,属于场内缴费,需要调用场内缴费的接口 /parking/check-out
  693. this.$store.commit('SET_ENDLESS_LOOP', '');
  694. this.toHandleSearch(this.unlicensedCar);
  695. }
  696. },
  697. };