parkingFee.js 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  1. import plateNumber from '@/components/plate-number/plateNumber.vue';
  2. import {LICENSE_PLATE_TYPE_ARR, 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 {getUrlParams, isHZ} from '@/utils';
  7. import wxPointsAuth from '@/components/wx-points-auth/wx-points-auth.vue'
  8. const app = {
  9. globalData: {
  10. regSource: '',
  11. },
  12. };
  13. import uni from '@/utils/uniHooks';
  14. import {parkingLots, qrCodes, unlicensedCarCheckIn, getConfValueOfKey, getVehicles, parkingRecord, checkEligibility, addVehicles, getPortalsByLbs} from '@/api/parking';
  15. export default {
  16. components: {
  17. plateNumber,
  18. LoginDom,
  19. 'wx-points-auth': wxPointsAuth,
  20. // blueCom,
  21. // greenCom,
  22. // officeBlueCom,
  23. // purpleCom,
  24. },
  25. data() {
  26. return {
  27. showPointsAuth: true,
  28. vehicleMgt_content_index: -1, //历史车辆选中
  29. carType: 0, //车辆类型
  30. init_ch: false, // 字体超出隐藏显示
  31. search_price: false, //查询按钮隐藏显示
  32. parkInfoEntity: {},
  33. show_chinese: false, //是否显示汉字键盘
  34. show_allBoard: false, //是否显示英文数字键盘
  35. plate_number: '', //车牌号
  36. description: '', // 车场描述
  37. ind: null,
  38. numArr: ['', '', '', '', '', '', ''],
  39. active: null,
  40. carList: [], // 车辆列表
  41. classifyList: ['燃油车牌', '新能源', '特殊车牌'], // 车牌类型
  42. vehicleNumber: '',
  43. localimgPic: '',
  44. hourMoney: '',
  45. showSq: false,
  46. blueHeadBg: 'parkingFee/fee-head-bg.png',
  47. picUrl: this.$picUrl,
  48. colorAry: ['', '-blue', '-green'],
  49. openId: null,
  50. options: null,
  51. preUrl: '',
  52. tabbarActive: 'manualPayment',
  53. supportUnlicensed: false, // 控制当前site,是否使用无牌车
  54. qrCodeHistory: '',
  55. isAlipayClient: isAlipayClient,
  56. // custTypeId: 0,
  57. // 2.19新增内容
  58. eligibility: {}, //
  59. eventId: '',
  60. // 2.22新增内容:https://kerryprops.atlassian.net/browse/KIP-13059
  61. portalsByLbsList: [],
  62. portalsByLbsInfo: {}
  63. };
  64. },
  65. computed: {
  66. disabledBtn() {
  67. return this.numArr.filter((val) => !val).length > 0;
  68. },
  69. ...mapState({
  70. groupId: (state) => state.groupId,
  71. openid: (state) => state.openid,
  72. mallId: (state) => state.mallId,
  73. kipUserId: (state) => state.kipUserId,
  74. userInfo: (state) => state.userInfo,
  75. member: (state) => state.member,
  76. mobile: (state) => state.mobile,
  77. custTypeId: (state) => state.custTypeId,
  78. unlicensedCar: (state) => state.order.unlicensedCar,
  79. // 如果是扫码进入的无牌车
  80. unlicensedInfo: (state) => state.unlicensedInfo,
  81. endlessLoop: (state) => state.endlessLoop,
  82. source: (state) => state.source,
  83. }),
  84. },
  85. created() {
  86. // console.log('二次加载this.$route.query.fromPage', this.$route.query.fromPage, this.$store.state.pageHistory);
  87. // console.log('二次加载', this.$route.query.fromPage && !this.$store.state.pageHistory[this.$route.query.fromPage]);
  88. const fromPage = localStorage.getItem(`${this.$route.query.fromPage}`)
  89. if (this.$route.query?.fromPage && this.$route.query?.fromPage !== 'undefined' && !this.$store.state.pageHistory[this.$route.query.fromPage] && !fromPage) {
  90. // console.log(93939);
  91. this.$store.commit('setPageHistory', {
  92. [this.$route.query.fromPage]: 1
  93. })
  94. localStorage.setItem(`${this.$route.query.fromPage}`, this.$route.query.fromPage)
  95. setTimeout(() => {
  96. this.$router.push({
  97. path: this.$route.query.fromPage, query: {
  98. ...this.$route.query,
  99. loginCount: 1
  100. }
  101. });
  102. }, 200)
  103. }
  104. const {type = '', code = ''} = this.$route.query
  105. // 无牌车流程
  106. if (/unlicensedOut|unlicensedIn/.test(type) && code && !this.$store.state.pageHistory?.unlicensed && !this.endlessLoop) {
  107. this.$store.commit('setPageHistory', {
  108. unlicensed: 1
  109. })
  110. this.$store.commit('SET_UNLICENSED_INFO', {
  111. type, code
  112. });
  113. this.$store.commit('SET_ENDLESS_LOOP', type);
  114. this.$nextTick(() => {
  115. this.qrCodesRule(code);
  116. })
  117. }
  118. },
  119. beforeRouteLeave(to, from, next) {
  120. this.$store.commit('cachedViews/DEL_CACHED_VIEW', to);
  121. next();
  122. },
  123. watch: {
  124. openid() {
  125. if (this.openid) {
  126. this.getParkInfo();
  127. this.showSq = false;
  128. }
  129. },
  130. // unlicensedInfo:{
  131. // handler(){
  132. // // const member = uni.getStorageSync('member');
  133. // // if(!member) return // 如果用户走未登录流程的话
  134. // // 不论是否出入场,都使用此函数获取 gateId(闸口机器的ID)
  135. // if (this.unlicensedInfo?.type && /unlicensedOut|unlicensedIn/.test(this.unlicensedInfo.type) && this.endlessLoop.length === 0) {
  136. // // 此处记录扫码流程执行次数。如果超过一次则不再执行
  137. // this.$store.commit('SET_ENDLESS_LOOP', this.unlicensedInfo.type);
  138. // this.$nextTick(() => {
  139. // this.qrCodesRule(this.unlicensedInfo.code);
  140. // })
  141. // }
  142. // },
  143. // immediate:true //true就表示会立即执行
  144. // }
  145. },
  146. async mounted() {
  147. // console.log(114, 99999999999);
  148. // const platform = getPlatform();
  149. // if (platform === 'micromessenger') {
  150. // await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
  151. // }
  152. this.getVehiclesINTMP()
  153. this.getPortalsByLbs()
  154. const openid = uni.getStorageSync('openid');
  155. // 如果用户未登录的话,返回之后,重新获取数据用户的基础数据
  156. if (openid) {
  157. this.getParkInfo();
  158. this.showSq = false;
  159. } else {
  160. const regSource = REG_SOURCE.PARKING;
  161. app.globalData.regSource = regSource;
  162. if (this.options?.regSource) {
  163. app.globalData.regSource = REG_SOURCE[this.options?.regSource];
  164. }
  165. if (this.options?.tpName) {
  166. app.globalData.tpName = this.options?.tpName;
  167. }
  168. this.showSq = true;
  169. }
  170. try {
  171. const href = window.location.href;
  172. if (!isAlipayClient && !/808[0-9]/.test(href)) {
  173. setTimeout(async () => {
  174. await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
  175. }, 1500)
  176. }
  177. } catch (e) {
  178. console.log(e)
  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. this.vehicleNumber = this.numArr.join('');
  209. },
  210. // 获取停车场信息
  211. getParkInfo: async function () {
  212. uni.showLoading({
  213. title: '加载中',
  214. });
  215. try {
  216. // 加载车场信息
  217. const res = await parkingLots(this.$store.state.lbsId);
  218. // console.log(res);
  219. let reg = /[;;]/g;
  220. if(res?.ruleDescription) {
  221. this.description = res.ruleDescription;
  222. } else {
  223. this.description = res?.description?.replace(reg, '\r\n').replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>');
  224. }
  225. this.supportUnlicensed = res.supportUnlicensed || false
  226. const carList = uni.getStorageSync('carList');
  227. if (carList) {
  228. this.carList = JSON.parse(carList);
  229. }
  230. } catch (e) {
  231. console.log(225225, e);
  232. }
  233. },
  234. //缴费说明隐藏显示
  235. top_display() {
  236. this.init_ch = !this.init_ch;
  237. },
  238. // 唤起键盘
  239. clickShowKeyboard(index) {
  240. if ( index === 7) {
  241. this.carType = 1
  242. this.$refs['k-tab'].changeTab(this.carType)
  243. }
  244. this.ind = index;
  245. this.active = index;
  246. if (index === 0) {
  247. this.$refs['plateKeyboard'].openKeyboardCN();
  248. } else {
  249. this.$refs['plateKeyboard'].closeKeyboardCN();
  250. this.$refs['plateKeyboard'].openKeyboardEN();
  251. }
  252. },
  253. // 接收子组件数据
  254. updateCarno(val) {
  255. this.numArr = [...val.numArr];
  256. this.vehicleNumber = this.numArr.join('');
  257. this.active = val.active;
  258. this.ind = val.ind;
  259. },
  260. // 节流函数
  261. throttle(fc, waitTime = 500, imme = true) {
  262. if (imme) {
  263. if (!this.flag) {
  264. this.flag = true;
  265. typeof fc === 'function' && fc();
  266. this.timer = setTimeout(() => {
  267. this.flag = false;
  268. }, waitTime);
  269. }
  270. } else {
  271. if (!this.flag) {
  272. this.flag = true;
  273. this.timer = setTimeout(() => {
  274. this.flag = false;
  275. typeof fc === 'function' && fc();
  276. }, waitTime);
  277. }
  278. }
  279. },
  280. async checkEligibility(vehicleNumber = this.vehicleNumber) {
  281. try {
  282. /*
  283. * 如果是杭州,并且是登陆情况
  284. * {
  285. "eligible": false, // 是否优惠车
  286. "isBound": false, // 是否绑定
  287. "maxBindingCount": 3, // 绑定数量上限
  288. "maxChangeCount": 5, // 换绑数量上限
  289. "userBindingCount": 3, // 用户当前绑定车牌数量
  290. "userRemainingChangeCount": 5, // 用户剩余换绑次数
  291. "redirectTo": "CHANGE_BINDING" // 跳转页面
  292. }
  293. BIND_NEW //去绑定
  294. CHANGE_BINDING //去换绑
  295. PAY_WITHOUT_DISCOUNT //去无优惠支付或放弃支付
  296. CHECK_OUT //直接去查费,带优惠
  297. *
  298. * */
  299. // 如果是杭州,并且是登陆情况
  300. this.eligibility = await checkEligibility(vehicleNumber)
  301. /*this.eligibility = {
  302. "eligible": false, // 是否优惠车
  303. "isBound": false, // 是否绑定
  304. "maxBindingCount": 3, // 绑定数量上限
  305. "maxChangeCount": 5, // 换绑数量上限
  306. "userBindingCount": 3, // 用户当前绑定车牌数量
  307. "userRemainingChangeCount": 5, // 用户剩余换绑次数
  308. "redirectTo": "CHANGE_BINDING" // 跳转页面
  309. }*/
  310. // 是否优惠车 是否绑定, 或者 直接去查费,带优惠
  311. if(this.eligibility.eligible && this.eligibility.isBound || this.eligibility.redirectTo === 'CHECK_OUT') {
  312. this.toParkingFeeDetail(vehicleNumber)
  313. return
  314. }
  315. // 是否绑定
  316. if(this.eligibility.redirectTo === 'BIND_NEW' && this.eligibility.maxBindingCount > this.eligibility.userBindingCount) {
  317. this.$refs['checkCarPopup'].open({
  318. redirectTo: this.eligibility.redirectTo,
  319. vehicleNo: vehicleNumber,
  320. topBtnFn: async () => {
  321. const res = await addVehicles(this.kipUserId,
  322. {
  323. userId: this.kipUserId,
  324. licensePlateType: LICENSE_PLATE_TYPE_ARR[this.carType].value,
  325. vehicleNo: vehicleNumber,
  326. })
  327. if(res?.id) {
  328. this.toParkingFeeDetail(vehicleNumber)
  329. }
  330. },
  331. bottomBtnFn: () => {
  332. this.toParkingFeeDetail(vehicleNumber)
  333. }
  334. })
  335. return
  336. }
  337. // 是否换绑
  338. if(this.eligibility.redirectTo === 'CHANGE_BINDING' && this.eligibility.userRemainingChangeCount) {
  339. this.$refs['checkCarPopup'].open({
  340. redirectTo: this.eligibility.redirectTo,
  341. vehicleNo: vehicleNumber,
  342. topBtnName: '去换绑(可享停车优惠)',
  343. topBtnFn: async () => {
  344. this.doRouter2()
  345. },
  346. bottomBtnName: '放弃换绑(无停车优惠)',
  347. bottomBtnFn: () => {
  348. this.toParkingFeeDetail(vehicleNumber)
  349. }
  350. })
  351. return
  352. }
  353. // 去无优惠支付或放弃支付,其余场景都是无优惠
  354. /*if(this.eligibility.redirectTo === 'PAY_WITHOUT_DISCOUNT') {
  355. }*/
  356. this.$refs['checkCarPopup'].open({
  357. // redirectTo: this.eligibility.redirectTo,
  358. redirectTo: 'PAY_WITHOUT_DISCOUNT',
  359. vehicleNo: vehicleNumber,
  360. topBtnName: '继续缴费(无停车优惠)',
  361. topBtnFn: () => {
  362. this.toParkingFeeDetail(vehicleNumber)
  363. },
  364. bottomBtnName: '放弃缴费 ',
  365. })
  366. } catch (err) {
  367. }
  368. },
  369. // 校验车牌号
  370. async preHandleSearch() {
  371. if (this.disabledBtn) return
  372. // 不是杭州的车牌 或者 用户拒绝登陆的场景
  373. if (!isHZ(this.mallId) || this.$route.query.isLogin === 'loginDenied') {
  374. this.toParkingFeeDetail()
  375. return
  376. }
  377. // 查询车辆优惠资格并提示跳转页面
  378. await this.checkEligibility()
  379. },
  380. // 去缴费详情
  381. toParkingFeeDetail(vehicleNumber = this.vehicleNumber) {
  382. uni.setStorageSync('carList', [
  383. ...new Set([vehicleNumber, ...this.carList]),
  384. ].slice(0, 6));
  385. this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
  386. name: 'parkingFeeDetail',
  387. });
  388. this.$store.commit('SET_REGRESH_PAGE_KEY')
  389. this.$nextTick(() => {
  390. const query = {
  391. ...this.$route.query,
  392. vehicleNo: vehicleNumber,
  393. }
  394. // fromPage && format && unlicensed
  395. query.fromPage = ''
  396. query.format = ''
  397. query.unlicensed = ''
  398. this.$router.push({
  399. path: 'parkingFeeDetail',
  400. query,
  401. });
  402. })
  403. },
  404. // 历史车牌快速查询
  405. async toHandleSearchBefore(vehicleNo) {
  406. // 不是杭州的车牌 或者 用户拒绝登陆的场景
  407. if (!isHZ(this.mallId) || this.$route.query.isLogin === 'loginDenied') {
  408. this.toHandleSearch(vehicleNo)
  409. return
  410. }
  411. // 查询车辆优惠资格并提示跳转页面
  412. await this.checkEligibility(vehicleNo)
  413. },
  414. toHandleSearch(vehicleNo) {
  415. uni.setStorageSync('carList', [...new Set([vehicleNo, ...this.carList])].slice(0, 6));
  416. this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
  417. name: 'parkingFeeDetail',
  418. });
  419. this.$store.commit('SET_REGRESH_PAGE_KEY')
  420. this.$nextTick(() => {
  421. const query = {
  422. ...this.$route.query,
  423. vehicleNo: vehicleNo,
  424. }
  425. // fromPage && format && unlicensed
  426. query.fromPage = ''
  427. query.format = ''
  428. query.unlicensed = ''
  429. this.$router.push({
  430. path: 'parkingFeeDetail',
  431. query,
  432. });
  433. });
  434. },
  435. // 查询车费信息
  436. async handleSearch(carno, clickEvent = '$ClickQueryAndPayment') {
  437. this.vehicleNumber = carno;
  438. const params = {
  439. carno,
  440. mallid: this.mallId,
  441. openid: this.openid,
  442. vipcode: this.member?.vipcode,
  443. mobile: this.mobile,
  444. groupId: this.groupId,
  445. createuser: 'sys_miniprogram',
  446. };
  447. // 查询缴费按钮埋点
  448. let [carTypeName, redirectUrl, parkTime] = ['ordinary', '', ''];
  449. switch (this.carType) {
  450. case 0:
  451. carTypeName = 'ordinary';
  452. break;
  453. case 1:
  454. carTypeName = 'newEnergy';
  455. break;
  456. case 2:
  457. carTypeName = 'special';
  458. break;
  459. }
  460. this.$md(params);
  461. this.$request({
  462. // url: this.$baseURL + 'api/1.0/park/checkCarIsInPark',
  463. url: this.$baseURL + 'api/1.0/park/checkCarIsInParkAndCarFee',
  464. // url: 'http://172.21.90.87:8083/xcrm-api/api/1.0/park/checkCarIsInParkAndCarFee',
  465. data: params,
  466. method: 'POST',
  467. header: JSON.parse(uni.getStorageSync('handleUser')),
  468. timeout: 60000 * 2, // 120S
  469. showLoading: {
  470. title: '加载中',
  471. duration: 0,
  472. },
  473. })
  474. .then((res) => {
  475. // console.log(555555, res);
  476. // ToastObj.clear();
  477. // uni.hideLoading();
  478. if (res.data.code === 0) {
  479. // 清理旧数据
  480. this.parkingFeeDetailInit();
  481. uni.setStorageSync('isReload', '3');
  482. // this.$destroy();
  483. const query = {
  484. ...this.$route.query,
  485. vehicleNo: carno,
  486. }
  487. // fromPage && format && unlicensed
  488. query.fromPage = ''
  489. query.format = ''
  490. query.unlicensed = ''
  491. this.$router.push({
  492. path: 'parkingFeeDetail',
  493. query,
  494. });
  495. parkTime = res.data?.data?.serviceMin;
  496. redirectUrl = '/pages/parkingFee/parkingFeeDetail.vue';
  497. } else if (res.data.code === 1) {
  498. // 当前车辆没有查到账单
  499. this.$router.push({
  500. path: 'parkingFeePayment',
  501. query: {
  502. ...this.$route.query,
  503. msg: res.data.msg,
  504. carno,
  505. },
  506. });
  507. redirectUrl = '/pages/parkingFee/parkingFeePayment.vue';
  508. } else if (res.data.code === 2) {
  509. // 月租车
  510. this.$router.push({
  511. path: './parkingFeeHint/parkingFeeHint',
  512. query: {
  513. ...this.$route.query,
  514. carno,
  515. },
  516. });
  517. redirectUrl = '/pages/parkingFee/parkingFeeHint/parkingFeeHint.vue';
  518. } else {
  519. uni.showToast({
  520. title: res.data.msg,
  521. duration: 2000,
  522. icon: 'none',
  523. });
  524. }
  525. })
  526. .catch((err) => {
  527. // uni.hideLoading();
  528. uni.showToast({
  529. title: '网络超时请稍后再试',
  530. duration: 2000,
  531. icon: 'none',
  532. });
  533. console.log(err);
  534. });
  535. },
  536. // 页面初始清空缓存
  537. parkingFeeDetailInit() {
  538. console.log('清理数据');
  539. // 优惠减免(首停、会员、消费)
  540. uni.removeStorageSync('checkedList'); // 选中list
  541. uni.removeStorageSync('checkedTotal'); // 选中count数
  542. uni.removeStorageSync('discountTotal'); // 减免信息(时长、费用)
  543. // 停车减免(优惠、积分、停车券)
  544. uni.removeStorageSync('parkFee');
  545. // 电子券优惠信息
  546. uni.removeStorageSync('checkedCouponList'); // 选中list
  547. uni.removeStorageSync('couponInfo'); // 减免信息(时长、费用)
  548. uni.removeStorageSync('list'); // 电子券list
  549. // 总停车优惠信息(时长、费用)
  550. uni.removeStorageSync('parkingTotal');
  551. // 应缴金额
  552. uni.removeStorageSync('servicefee');
  553. // 订单号
  554. uni.removeStorageSync('orderno');
  555. // 纸质优惠券
  556. uni.removeStorageSync('paperCouponInfo');
  557. },
  558. // 缴费记录
  559. doRouter: function () {
  560. const query = {
  561. ...this.$route.query,
  562. // vehicleNo: vehicleNo,
  563. }
  564. // fromPage && format && unlicensed
  565. query.fromPage = ''
  566. query.format = ''
  567. query.loginCount = ''
  568. // uni.setStorageSync('loadData', '');
  569. // if (this.$store.state.isLogin === 'loginDenied') {
  570. // this.$router.push({ path: 'login' });
  571. // return;
  572. // }
  573. this.$store.commit('SET_REGRESH_PAGE_KEY')
  574. this.$router.push({path: 'parkingFeeList', query});
  575. },
  576. // 车牌管理
  577. doRouter2: function () {
  578. this.$store.dispatch('clearUnlicensed');
  579. // window?.toWXSendMsg({
  580. // type: 'uni_func',
  581. // funcName: 'setStorageSync',
  582. // options: {
  583. // key: 'noLoginParkingFeeWebViewPath',
  584. // value: ''
  585. // },
  586. // });
  587. this.$store.commit('SET_REGRESH_PAGE_KEY')
  588. uni.setStorageSync('loadData', '');
  589. // if (this.$store.state.isLogin === 'loginDenied') {
  590. // this.$router.push({ path: 'login' });
  591. // return;
  592. // }
  593. const query = {
  594. ...this.$route.query,
  595. // vehicleNo: vehicleNo,
  596. }
  597. // fromPage && format && unlicensed
  598. query.fromPage = ''
  599. query.format = ''
  600. query.loginCount = ''
  601. uni.removeStorageSync('passLogin');
  602. this.$router.push({path: 'vehicleManagement', query});
  603. },
  604. async jumpToPreJudgmentOfParkingInvoice() {
  605. return new Promise(async (resolve) => {
  606. try {
  607. // 判断是否启用停车发票
  608. uni.showLoading()
  609. // const res = await getAccessH5(`${this.mallId}-invoice`);
  610. const res = await getConfValueOfKey('HEJIInvoiceSwitch')
  611. const lbsId = uni.getStorageSync('lbsId')
  612. if (res?.switch && res.lbsId.length && res.lbsId.indexOf(lbsId) > -1) {
  613. uni.hideLoading();
  614. // console.log(474, this.Dialog);
  615. this.$dialog({
  616. title: '温馨提示',
  617. // message: '小程序“停车开票”功能将从2023年8月10日起提供服务,支持开具3个月内停车记录的发票,如需停车开票,请稍后尝试或咨询服务台',
  618. message: res.message,
  619. confirmButtonColor: this.$theme[this.theme].primaryColor
  620. })
  621. // 提示用户
  622. // uni.showToast({
  623. // title:'尽请期待!'
  624. // })
  625. resolve(true)
  626. }
  627. resolve(false)
  628. } catch (err) {
  629. console.log(err);
  630. resolve(false)
  631. }
  632. })
  633. // return false
  634. },
  635. async jumpToPreJudgmentOfParkingInvoice2() {
  636. return new Promise(async (resolve) => {
  637. try {
  638. // 判断是否启用停车发票
  639. uni.showLoading()
  640. const res = await getConfValueOfKey('nchcInvoiceSwitch')
  641. const lbsId = uni.getStorageSync('lbsId')
  642. if(res?.switch && res.lbsId.length && res.lbsId.indexOf(lbsId) > -1) {
  643. uni.hideLoading();
  644. this.$dialog({
  645. title: '温馨提示',
  646. message: res.message,
  647. confirmButtonColor: this.$theme[this.theme].primaryColor
  648. })
  649. resolve(true)
  650. }
  651. resolve(false)
  652. } catch (err) {
  653. console.log(err);
  654. resolve(false)
  655. }
  656. })
  657. // return false
  658. },
  659. //停车发票
  660. doRouter1: async function () {
  661. const isJump = await this.jumpToPreJudgmentOfParkingInvoice();
  662. if (isJump) return
  663. uni.hideLoading()
  664. uni.removeStorageSync('invoiceindex');
  665. this.$store.dispatch('clearUnlicensed');
  666. this.$store.commit('SET_REGRESH_PAGE_KEY')
  667. // window?.toWXSendMsg({
  668. // type: 'uni_func',
  669. // funcName: 'setStorageSync',
  670. // options: {
  671. // key: 'noLoginParkingFeeWebViewPath',
  672. // value: ''
  673. // },
  674. // });
  675. const query = {
  676. ...this.$route.query,
  677. // vehicleNo: vehicleNo,
  678. }
  679. // fromPage && format && unlicensed
  680. query.fromPage = ''
  681. query.format = ''
  682. query.loginCount = ''
  683. uni.setStorageSync('loadData', '');
  684. // if (this.$store.state.isLogin === 'loginDenied') {
  685. // this.$router.push({ path: 'login' });
  686. // return;
  687. // }
  688. // uni.removeStorageSync('passLogin');
  689. // TODO: 北京停车场开票
  690. /* if (this.parkInfoEntity.parkMallCode === 3) {
  691. uni.navigateToMiniProgram({
  692. appId: this.$etcpAppId,
  693. path: this.$etcpAppInvoicePath,
  694. envVersion: 'release',
  695. })
  696. return
  697. }
  698. */
  699. this.$router.push({path: 'parkingReceipt', query});
  700. },
  701. //停车券兑换
  702. doRouter3: function () {
  703. this.$store.dispatch('clearUnlicensed');
  704. // window?.toWXSendMsg({
  705. // type: 'uni_func',
  706. // funcName: 'setStorageSync',
  707. // options: {
  708. // key: 'noLoginParkingFeeWebViewPath',
  709. // value: ''
  710. // },
  711. // });
  712. uni.setStorageSync('loadData', '');
  713. // window.toWXSendMsg({
  714. // type: 'toPage',
  715. // options: {
  716. // fnName: 'navigateTo',
  717. // url: '/pages/pointsMall/pointsMall?exchangeTypes=2',
  718. // },
  719. // });
  720. wx.miniProgram.navigateTo({
  721. "url": "/pages/pointsMall/pointsMall?exchangeTypes=2" // 去 login 页面 1 去登录
  722. })
  723. },
  724. blueComChange(value) {
  725. console.log('blueComChange', value);
  726. },
  727. tabbarActiveEvent(name) {
  728. this.tabbarActive = name
  729. if (name === 'paymentForUnregisteredVehicle') {
  730. this.$store.dispatch('order/unlicensedRule', (code) => {
  731. // CAR_NOT_FOUND 车场扫描道闸入口,发现无车
  732. if (code === 'CAR_NOT_FOUND') {
  733. }
  734. // CAR_HAS_PLATE 车场扫描道闸入口,发现有牌车
  735. if (code === 'CAR_HAS_PLATE') {
  736. }
  737. })
  738. }
  739. },
  740. // 无牌车闸机扫码
  741. async scanCarCode() {
  742. try {
  743. const runScanFn = (res) => {
  744. if (res.scanType && res.scanType == 'QR_CODE') {
  745. console.log(res.result);
  746. // 获取二维码参数之后,模拟提取参数
  747. const url = res.result;
  748. const {path} = getUrlParams(res.result)
  749. let params = null
  750. if (path) {
  751. params = getUrlParams(decodeURIComponent(path))
  752. }
  753. /*
  754. 微信扫码之后,处理过的参数 {"code": "e41d4d9dd5534f4aa3de88326a2e6f85", "type": "unlicensedIn#wechat-redirect"}
  755. */
  756. if (params?.type.indexOf('wechat-redirect') > -1) {
  757. params.type = params.type.replace('#wechat-redirect', '');
  758. }
  759. console.log('微信扫码之后,处理过的参数', params);
  760. this.$store.commit('SET_UNLICENSED_INFO', params);
  761. this.$nextTick(() => {
  762. this.qrCodesRule(params.code, 'scan');
  763. })
  764. return
  765. }
  766. /*
  767. 针对微信的小程序码进行的兼容改造
  768. 微信扫码结束之后的返回参数 {"errMsg": "scanCode:ok", "scanType": "WX_CODE", "charSet": "ISO8859-1", "rawData": "bGsoP3gyT1Aud3QpbW1JeHRfVHJsUjg4JnR5cGU9dW5saWNlbnNlZElu", "path": "pages/automatic/automaticIndex?scene=code%3D9988%26type%3DunlicensedIn"}
  769. */
  770. if (res.scanType && res.scanType === 'WX_CODE' && res.path) {
  771. const params = getUrlParams(`?${decodeURIComponent(res.path.replace(/.*scene=/g, ''))}`)
  772. this.$store.commit('SET_UNLICENSED_INFO', params);
  773. this.$nextTick(() => {
  774. this.qrCodesRule(params.code, 'scan');
  775. })
  776. }
  777. // 兜底逻辑,如果是其他小程序扫描,则提取rawData,进行解析提取入参
  778. if (res.scanType && res.scanType === 'WX_CODE' && !res?.path) {
  779. let path = atob(res.rawData)
  780. path = path.replace(/.*([a-z0-9]{6}&type)/g, '8b$1')
  781. const regex = /(\w+)&type=(\w+)/;
  782. const match = path.match(regex);
  783. const obj = {code: match[1], type: match[2]};
  784. this.$store.commit('SET_UNLICENSED_INFO', obj);
  785. this.$nextTick(() => {
  786. this.qrCodesRule(obj.code, 'scan');
  787. })
  788. }
  789. };
  790. // 微信小程序
  791. // const platform = getPlatform();
  792. if (isAlipayClient) {
  793. // 判断微信小程序与 h5 是否正常通信
  794. // const isReload = await theCommunicationBetweenWechatAndH5IsNormal()
  795. // if(!isReload) {
  796. // uni.setStorageSync('isReload', 1)
  797. // window.location.reload()
  798. // return
  799. // }
  800. window.toWXSendMsg({
  801. type: 'scanQRCode',
  802. });
  803. // TODO 兼容支付宝无牌车扫码
  804. window.subscribe('scanQRCodeOver', (options) => {
  805. console.log('微信扫码结束之后的返回参数', options);
  806. runScanFn(options.options);
  807. });
  808. } else {
  809. this.$wx.scanQRCode({
  810. onlyFromCamera: false,
  811. // desc: 'scanQRCode desc',
  812. needResult: 0, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  813. // scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  814. success: (res) => {
  815. console.log('H5页面扫码获取到的参数——成功1', res);
  816. // const res = {"resultStr": "lo$Qed.3YuVi*D7vXilrrV0571a1&type=unlicensedIn", "errMsg": "scanQRCode:ok"}
  817. // const test = {"resultStr": "lp$Qed.3YuVi*D7vXilrrV0571a2&type=unlicensedOut", "errMsg": "scanQRCode:ok"}
  818. let path = res.resultStr.replace(/.*([a-z0-9]{6}&type)/g, '8b$1')
  819. const regex = /(\w+)&type=(\w+)/;
  820. const match = path.match(regex);
  821. const obj = {code: match[1], type: match[2]};
  822. this.$store.commit('SET_UNLICENSED_INFO', obj);
  823. this.$nextTick(() => {
  824. this.qrCodesRule(obj.code, 'scan');
  825. })
  826. },
  827. error: (res) => {
  828. console.log('H5页面扫码获取到的参数——失败', res);
  829. },
  830. });
  831. }
  832. } catch (err) {
  833. console.log(624, err);
  834. }
  835. },
  836. // 处理扫码结果: 组装参数,剩余流程,在 缴费支付页面 实现
  837. async qrCodesRule(code, source = '') {
  838. console.log(717, code, source);
  839. // source 是为了避免重复刷新
  840. if (this.$store.state.pageHistory.parkingFeeMsg && !source) {
  841. return
  842. }
  843. try {
  844. if (this.qrCodeHistory && this.qrCodeHistory === code) {
  845. return
  846. }
  847. this.qrCodeHistory = code
  848. const qrCodesres = await qrCodes(code); // 无牌车扫码
  849. // 记录buildingId,确保 buildingId 是最新的数据
  850. window.localStorage.setItem('buildingId', qrCodesres.buildingId);
  851. // 如果是无牌车扫码:出场
  852. // console.log('模拟出场', this.unlicensedInfo.type);
  853. this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
  854. name: 'parkingFeeDetail',
  855. });
  856. console.log(735);
  857. // return
  858. if (this.unlicensedInfo?.type === 'unlicensedOut') {
  859. const query = {
  860. ...this.$route.query,
  861. gateId: qrCodesres.gateId,
  862. vehicleNo: '',
  863. type: this.unlicensedInfo.type
  864. }
  865. // fromPage && format && unlicensed
  866. query.fromPage = ''
  867. query.format = ''
  868. query.unlicensed = ''
  869. query.code = ''
  870. this.$router.push({
  871. path: 'parkingFeeDetail',
  872. query
  873. })
  874. return
  875. }
  876. // 如果是无牌车扫码:入场
  877. const unlicensedCarCheckInres = await unlicensedCarCheckIn({ // 获取无牌车牌
  878. gateId: qrCodesres.gateId
  879. });
  880. const query = {
  881. ...this.$route.query,
  882. type: 'success',
  883. vehicleNo: unlicensedCarCheckInres.vehicleNo
  884. }
  885. // fromPage && format && unlicensed
  886. query.fromPage = ''
  887. query.format = ''
  888. query.unlicensed = ''
  889. query.code = ''
  890. this.$store.commit('setPageHistory', {
  891. parkingFeeMsg: 1
  892. })
  893. // 前往 缴费支付页面
  894. this.$router.push({
  895. path: 'parkingFeeMsg',
  896. query: query
  897. })
  898. } catch (err) {
  899. // 车场扫描道闸入口,发现无车/车场扫描道闸入口,发现有牌车 >>> 停止往下执行,默认提示报错信息
  900. if (/CAR_HAS_PLATE/.test(err.code)) {
  901. return
  902. }
  903. if (/CAR_NOT_FOUND|INOUT_FAILED|UNLICENSED_PLATE_ACQUISITION_FAILED/.test(err.code)) {
  904. const query = {
  905. ...this.$route.query,
  906. type: 'fail'
  907. }
  908. // fromPage && format && unlicensed
  909. query.fromPage = ''
  910. query.format = ''
  911. query.unlicensed = ''
  912. query.code = ''
  913. this.$store.commit('setPageHistory', {
  914. parkingFeeMsg: 1
  915. })
  916. // 如果是其他错误的话,则继续往下执行
  917. this.$router.push({
  918. path: 'parkingFeeMsg',
  919. query
  920. })
  921. }
  922. }
  923. },
  924. // 前往支付
  925. unlicensedToPay() {
  926. // 无牌车这边去支付的时候,属于场内缴费,需要调用场内缴费的接口 /parking/check-out
  927. this.$store.commit('SET_ENDLESS_LOOP', '');
  928. this.toHandleSearch(this.unlicensedCar);
  929. },
  930. // 获取会员绑定的车牌列表
  931. async getVehiclesINTMP() {
  932. /*杭州*/
  933. if (!isHZ(this.mallId)) return
  934. try {
  935. if(this.$route.query.isLogin === 'loginDenied') {
  936. throw new Error('设置默认参数')
  937. }
  938. let vehicles = []
  939. // 获取用户车场在停车辆数据集
  940. vehicles = await parkingRecord({
  941. userId: this.kipUserId,
  942. lbsId: this.mallId
  943. })
  944. // 获取用户的所有车牌
  945. // const userVehicles = await getVehicles(this.kipUserId)
  946. if (!vehicles.length) {
  947. throw new Error('设置默认参数')
  948. // vehicles = userVehicles.content
  949. }
  950. if (vehicles.length) {
  951. // 判断是否存在无牌车
  952. if(vehicles[0].vehicleNo.indexOf('临') > -1) {
  953. this.isUnlicensed(vehicles)
  954. throw new Error('设置默认参数')
  955. }
  956. const vehicleNo = vehicles[0].vehicleNo
  957. // 设置车牌类型
  958. this.setVehicleNoType(vehicleNo, vehicles)
  959. // 赋值
  960. this.numArr = vehicles[0].vehicleNo.split('');
  961. this.vehicleNumber = vehicles[0].vehicleNo;
  962. } else {
  963. throw new Error('设置默认参数')
  964. }
  965. } catch (e) {
  966. // 设置默认参数
  967. this.numArr = '浙,A,,,,,'.split(',')
  968. }
  969. },
  970. setVehicleNoType(vehicleNo, vehicles) {
  971. // const item = vehicles.filter(e => e.vehicleNo === vehicleNo)
  972. const item = vehicles
  973. if(item.length) {
  974. // let label = LICENSE_PLATE_TYPE_ARR.filter(e => e.value == item[0].licensePlateType)
  975. // const index = ['燃油车牌', '新能源', '特殊车牌'].indexOf(label[0].name)
  976. const index = item[0].vehicleNo.length === 8 ? 1 : 0
  977. this.$refs['k-tab'].changeTab(index)
  978. return true
  979. }
  980. return false
  981. },
  982. isUnlicensed(vehicles) {
  983. // debugger
  984. // const unlicensed = vehicles.filter(elm => elm.vehicleNo.indexOf('临') > -1)
  985. if (vehicles.length && vehicles[0].vehicleNo.indexOf('临') > -1) {
  986. this.tabbarActiveEvent('paymentForUnregisteredVehicle');
  987. // this.tabbarActive = 'paymentForUnregisteredVehicle'
  988. }
  989. },
  990. setLicensePlateList(arr) {
  991. var array = []
  992. arr.forEach(element => {
  993. array.push(element.vehicleNo)
  994. });
  995. return array
  996. },
  997. async getPortalsByLbs() {
  998. try {
  999. const res = await getPortalsByLbs(this.groupId, this.mallId);
  1000. if(res.length) {
  1001. this.portalsByLbsList = res[0].displayFunctionList.filter(elm => elm.enabled).map(elm => elm.code)
  1002. this.portalsByLbsInfo = res[0]
  1003. }
  1004. } catch (e) {
  1005. console.log('getPortalsByLbs', e)
  1006. }
  1007. },
  1008. async menuToPage(type) {
  1009. let query = {}
  1010. switch (type){
  1011. case 'PAYMENT_RECORDS': // 缴费记录
  1012. query = {
  1013. ...this.$route.query,
  1014. }
  1015. query.fromPage = ''
  1016. query.format = ''
  1017. query.loginCount = ''
  1018. this.$store.commit('SET_REGRESH_PAGE_KEY')
  1019. this.$router.push({path: 'parkingFeeList', query});
  1020. break
  1021. case 'COUPON_EXCHANGE': // 停车券兑换
  1022. this.$store.dispatch('clearUnlicensed');
  1023. uni.setStorageSync('loadData', '');
  1024. wx.miniProgram.navigateTo({
  1025. "url": "/pages/pointsMall/pointsMall?exchangeTypes=2" // 去 login 页面 1 去登录
  1026. })
  1027. break
  1028. case 'PARKING_INVOICE': // 停车开票
  1029. // const isJump = await this.jumpToPreJudgmentOfParkingInvoice();
  1030. // if (isJump) return
  1031. const isJump2 = await this.jumpToPreJudgmentOfParkingInvoice2();
  1032. if(isJump2) return
  1033. uni.hideLoading()
  1034. uni.removeStorageSync('invoiceindex');
  1035. this.$store.dispatch('clearUnlicensed');
  1036. this.$store.commit('SET_REGRESH_PAGE_KEY')
  1037. query = {
  1038. ...this.$route.query,
  1039. }
  1040. query.fromPage = ''
  1041. query.format = ''
  1042. query.loginCount = ''
  1043. uni.setStorageSync('loadData', '');
  1044. this.$router.push({path: 'parkingReceipt', query});
  1045. break
  1046. case 'VEHICLE_MANAGE': // 车辆管理
  1047. this.$store.dispatch('clearUnlicensed');
  1048. this.$store.commit('SET_REGRESH_PAGE_KEY')
  1049. uni.setStorageSync('loadData', '');
  1050. query = {
  1051. ...this.$route.query,
  1052. }
  1053. query.fromPage = ''
  1054. query.format = ''
  1055. query.loginCount = ''
  1056. uni.removeStorageSync('passLogin');
  1057. this.$router.push({path: 'vehicleManagement', query});
  1058. break
  1059. case 'PARKING_BENEFITS': // 停车权益
  1060. console.log('停车权益', this.portalsByLbsInfo)
  1061. this.$router.push({path: 'parkingRights', query: this.portalsByLbsInfo});
  1062. break
  1063. case 'FIND_CAR': // 反向寻车
  1064. console.log('反向寻车', this.portalsByLbsInfo)
  1065. this.$router.push({path: 'parkingFindCarFirst', query: this.portalsByLbsInfo});
  1066. break
  1067. }
  1068. }
  1069. },
  1070. };