parkingFeeDetail.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. import moment from 'moment';
  2. import { mapState } from 'vuex';
  3. import log from '@/utils/log.js';
  4. import { compare } from '@/utils/location.js';
  5. import uni from '@/utils/uniHooks';
  6. import { initWxJsSdkConfig } from '@/utils/login';
  7. import { getPlatform, isAlipay, theCommunicationBetweenWechatAndH5IsNormal } from '@/utils';
  8. import { Dialog, Toast } from 'vant';
  9. import { ordersAndPrepay } from '@/api/parking';
  10. // import checkOutResponse from '@/api/mockData/checkout.hz.response'
  11. export default {
  12. name: 'parkingFeeDetail',
  13. data() {
  14. return {
  15. hasDiscount: false,
  16. parkFee: {},
  17. refreshTime: 180, // 停车场重置费用倒计时3分钟
  18. // 微服务接口字段
  19. isShowDescription: true, // 缴费说明true:显示全部 false:显示部分
  20. btnLoading: false,
  21. isPay: false,
  22. popup: false,
  23. msData: {},
  24. orderTimeEvent: null,
  25. orderTime: null
  26. };
  27. },
  28. beforeRouteLeave(to, from, next) {
  29. // 设置下一个路由的 meta
  30. if (/index|home/.test(to.name)) {
  31. // 不在缓存列表中,从cachedViews缓存列表中移除
  32. this.$store.commit('cachedViews/DEL_CACHED_VIEW', from);
  33. }
  34. next();
  35. },
  36. created() {
  37. setTimeout(() => {
  38. uni.setNavigationBarTitle({
  39. title: '停车支付',
  40. });
  41. }, 300);
  42. setTimeout(() => {
  43. window?.toWXSendMsg({
  44. type: 'uni_func',
  45. funcName: 'setNavigationBarColor',
  46. options: {
  47. frontColor: '#000000',
  48. backgroundColor: '#FBFCFF',
  49. },
  50. });
  51. }, 500)
  52. setTimeout(() => {
  53. window?.toWXSendMsg({
  54. type: 'nowRoute',
  55. options: {
  56. fullPath: this.$route.fullPath
  57. },
  58. });
  59. window.subscribe('reload',( ) => {
  60. // 如果是纸质券页面,发起的扫码动作,不做任何刷新动作
  61. if (window.location.href.indexOf('parkingFeePaperCoupon') > -1) {
  62. return
  63. }
  64. // 如果当前路由不是支付页面,则回退到当前页面再刷新页面
  65. if(this.$route.name !== 'parkingFeeDetail') {
  66. this.$router.back()
  67. }
  68. setTimeout(() => {
  69. window.location.reload();
  70. }, 100)
  71. });
  72. }, 700)
  73. setTimeout(() => {
  74. this.pageInit();
  75. }, 300)
  76. },
  77. computed: {
  78. ...mapState({
  79. orderDetail: (state) => state.order.orderDetail,
  80. discountDesc: (state) => state.order.discountDesc,
  81. enableNewMemberPoints: (state) => state.order.enableNewMemberPoints,
  82. enablePoints: (state) => state.order.enablePoints,
  83. integralDesc: (state) => state.order.integralDesc,
  84. enableCoupon: (state) => state.order.enableCoupon,
  85. maxOneDayCoupons: (state) => state.order.maxOneDayCoupons,
  86. coupons: (state) => state.order.coupons,
  87. couponDesc: (state) => state.order.couponDesc,
  88. enablePaperCoupons: (state) => state.order.enablePaperCoupons,
  89. custTypeId: (state) => state.custTypeId,
  90. usingTotalDiscount: (state) => state.order.usingTotalDiscount,
  91. actualPayFee: (state) => state.order.actualPayFee,
  92. available: (state) => state.order.available,
  93. member: (state) => state.member,
  94. maxPointsTime: (state) => state.order.maxPointsTime,
  95. pointsTime: (state) => state.order.pointsTime,
  96. pointsPerHour: (state) => state.order.pointsPerHour,
  97. usePoints: (state) => state.order.usePoints,
  98. usePointsTime: (state) => state.order.usePointsTime,
  99. enableConsume: (state) => state.order.enableConsume,
  100. memberLevelDiscount: (state) => state.order.memberLevelDiscount,
  101. unitAmount: (state) => state.order.unitAmount,
  102. unlicensedInfo: state => state.unlicensedInfo,
  103. endlessLoop: (state) => state.endlessLoop,
  104. appId: state => state.appId,
  105. source: state => state.source,
  106. parkMallCode: (state) => state.order.parkMallCode,
  107. }),
  108. isNoLogin() {
  109. return JSON.stringify(this.member) === '{}' || !this.member
  110. },
  111. // 支付按钮状态
  112. payBtnDisabled() {
  113. // 当存在待支付金额 或者 用户登陆
  114. return !this.orderDetail?.parkingRecord?.totalFeeInYuan || (JSON.stringify(this.member) !== '{}' && !this.orderDetail.parkInfo);
  115. },
  116. // integralDesc() {
  117. // if (this.pointsTime > 0) {
  118. // // 深圳特殊处理(单位:金额)
  119. // if (this.orderDetail.parkInfo.parkMallCode === 5 || this.orderDetail.parkInfo.parkMallCode === 999) {
  120. // return `已选择兑换${this.pointsTime}元`;
  121. // }
  122. // return `已选择兑换${this.pointsTime}小时`;
  123. // }
  124. // if (this.bonusCopy < this.integral) {
  125. // return `${this.integral}积分可停车1小时`;
  126. // }
  127. // if (this.orderDetail.parkInfo.parkMallCode === 3 && app.globalData.member?.currnentintegral >= this.integral && !this.bonus) {
  128. // return `今日已达上限`;
  129. // }
  130. // return `${this.available}积分可减免`;
  131. // },
  132. },
  133. filters: {
  134. parkingTime(val) {
  135. const days = parseInt(val / 60 / 24)
  136. const hours = parseInt((val / 60) % 24)
  137. const minutes = parseInt(val % 60)
  138. if (days > 0) {
  139. return `${days}天 ${hours}小时 ${minutes}分钟`
  140. }
  141. if (hours > 0) {
  142. return `${hours}小时 ${minutes}分钟`
  143. }
  144. return `${minutes}分钟`
  145. },
  146. },
  147. methods: {
  148. // 前往支付
  149. async toPay() {
  150. // 判断微信小程序与 h5 是否正常通信
  151. const isReload = await theCommunicationBetweenWechatAndH5IsNormal()
  152. if(!isReload) {
  153. uni.setStorageSync('isReload', 1)
  154. window.location.reload()
  155. return
  156. }
  157. if (this.btnLoading) return
  158. this.btnLoading = true
  159. setTimeout(() => {
  160. if ( this.btnLoading && !this.isPay ) {
  161. const toast1 = Toast({
  162. message: '网络连接失败,请重试',
  163. duration: 3000,
  164. onClose: () => {
  165. this.clearOrderTimeEvent()
  166. this.$router.replace({
  167. // path: 'parkingFeeSuccess?carno=' + this.parkInfo.carno,
  168. path: 'home',
  169. });
  170. }
  171. });
  172. this.btnLoading = false
  173. }
  174. }, 10000)
  175. const { parkingRecord, discountInfo = {}, parkingRule = {}} = this.orderDetail;
  176. const { coupons, points, memberGrade = [], paperCoupons = [], consume = [] } = discountInfo
  177. const { hourPrice } = parkingRule
  178. try {
  179. const params = {
  180. // vehicleNo: '', // 车牌号
  181. // points
  182. parkingRecord: {
  183. ...parkingRecord,
  184. vehicleNo: parkingRecord.vehicleNo,
  185. enterTime: parkingRecord.enterTime,
  186. serviceMin: parkingRecord.serviceMin,
  187. totalFee: parkingRecord.totalFeeInYuan, //应缴
  188. actualPayFee: this.actualPayFee, //应付金额
  189. },
  190. discountInfo: {
  191. usingTotalDiscount: discountInfo?.usingTotalDiscount || 0, //优惠金额"
  192. actualUsedDiscount: discountInfo?.usingTotalDiscount || 0, //实际优惠金额
  193. },
  194. };
  195. // 会员等级减免
  196. if ( memberGrade?.length && memberGrade[0].discountFee > 0 && memberGrade[0].hasOwnProperty('selected')? memberGrade[0]?.selected : memberGrade[0]?.defaultSelected) {
  197. const selected = memberGrade[0].hasOwnProperty('selected') ? memberGrade[0].selected : memberGrade[0].defaultSelected;
  198. let discountTime = 0
  199. let discountFee = 0
  200. if(selected) {
  201. discountTime = memberGrade[0].hasOwnProperty('discountTime') ? memberGrade[0].discountTime : memberGrade[0].defaultDiscountTime;
  202. discountFee = memberGrade[0].hasOwnProperty('discountFee') ? memberGrade[0].discountFee : discountTime * hourPrice;
  203. }
  204. params.discountInfo.memberLevel = {
  205. "discountTime": discountTime * 60, // 小时转成分钟
  206. "discountFee": discountFee,
  207. "memberGrade": memberGrade[0].memberGrade
  208. }
  209. }
  210. // 消费减免
  211. if ( consume?.length && consume[0].discountFee > 0 && consume[0].hasOwnProperty('selected')? consume[0]?.selected : consume[0]?.defaultSelected) {
  212. const { redeemSalesAmount, defaultDiscountTime} = consume[0]
  213. const selected = consume[0].hasOwnProperty('selected') ? consume[0].selected : consume[0].defaultSelected;
  214. let discountTime = 0
  215. let discountFee = 0
  216. if(selected) {
  217. discountFee = consume[0].hasOwnProperty('discountFee') ? consume[0].discountFee : memberGrade[0].defaultDiscountTime * hourPrice;
  218. discountTime = discountFee / hourPrice * 60;
  219. }
  220. params.discountInfo.consume = {
  221. ...consume[0],
  222. "defaultSelected": selected,
  223. "discountTime": discountTime,
  224. "discountFee": discountFee,
  225. // 杭州,沈阳,天津,福州,重新计算 redeemSalesAmount
  226. "redeemSalesAmount": ([2,4,6,8].indexOf(this.parkMallCode) > -1) ? (redeemSalesAmount / defaultDiscountTime) * ( discountFee / hourPrice) : redeemSalesAmount
  227. }
  228. }
  229. // 积分
  230. if (points?.length && points[0].discountFee > 0) {
  231. // 15 兑换 5元
  232. const { pointsPerUnit, unitAmount, discountFee, available } = points[0]
  233. params.discountInfo.points = {
  234. "discountTime": discountFee / hourPrice * 60,
  235. "discountFee": discountFee,
  236. "discountPoints": discountFee / hourPrice * pointsPerUnit
  237. }
  238. }
  239. // 优惠券
  240. if (coupons?.length) {
  241. const selectedCoupons = coupons.filter(elm => {
  242. const selected = elm.hasOwnProperty('selected') ? elm.selected : elm.defaultSelected;
  243. return selected
  244. }).map(elm => {
  245. elm.discountTime = elm.discountFee / hourPrice * 60
  246. return elm
  247. })
  248. if (selectedCoupons.length) {
  249. params.discountInfo.coupons = selectedCoupons
  250. }
  251. }
  252. // 纸质优惠券
  253. if ( paperCoupons?.length ) {
  254. params.discountInfo.paperCoupons = paperCoupons.filter(elm => {
  255. if ( !elm.discountFee ) {
  256. return false
  257. }
  258. return {
  259. ...elm,
  260. "discountFee": elm.discountFee,
  261. // discountTime: elm.discountFee / hourPrice * 60
  262. }
  263. })
  264. }
  265. console.log('下单时的参数', params);
  266. const res = await ordersAndPrepay(params);
  267. // console.log('orderDetail', res);
  268. if (res?.paymentType === 'NO_FEE_PAY') {
  269. this.btnLoading = false;
  270. this.isPay = false
  271. this.clearOrderTimeEvent()
  272. this.$router.replace({
  273. path: this.getPagePath(),
  274. });
  275. // 支付成功
  276. return
  277. }
  278. this.kerryPayment(res.sessionId);
  279. } catch (err) {
  280. if(err ==='ERR_NETWORK') {
  281. setTimeout(() => {
  282. this.clearOrderTimeEvent()
  283. this.$router.replace({
  284. // path: 'parkingFeeSuccess?carno=' + this.parkInfo.carno,
  285. path: 'home',
  286. });
  287. }, 2900)
  288. } else {
  289. this.btnLoading = false
  290. this.isPay = false
  291. }
  292. console.log(err);
  293. }
  294. },
  295. kerryPayment(session = '011cad54-735f-4e92-8f1b-f22bdfe073cd', payParams) {
  296. const platform = getPlatform();
  297. // console.log('platform:::', platform)
  298. let appId = uni.getStorageSync('appid');
  299. let openId = uni.getStorageSync('openid') || this.openid;
  300. if (platform === 'miniprogram') {
  301. // appId = 'wx92c3e55fbef6b2af';
  302. // appId = 'wxd830fe4d1e04988e';
  303. appId = this.appId;
  304. }
  305. // console.log('支付宝::', isAlipay())
  306. const params = {
  307. region: 'cn',
  308. payChannel: isAlipay() ? 'MINI_PROGRAM' : 'OFFICIAL_ACCOUNT',
  309. // payChannel: 'MOBILE_WEB',
  310. payOption: isAlipay() ? 'ALIPAY' : 'WECHATPAY',
  311. appId: appId,
  312. // openId: 'oudWQ5SCDElfn-IQH6eBR5JesOz4', // 下的appid: wxd830fe4d1e04988e
  313. openId,
  314. };
  315. // console.log(1854, params);
  316. this.$md(params);
  317. // let path = `/profileApi/payment/v1/services/session/${session}/transactions`;
  318. let path = `${window.profileApi}/payment/v1/services/session/${session}/transactions`;
  319. this.$request({
  320. url: path,
  321. data: params,
  322. method: 'POST',
  323. header: JSON.parse(uni.getStorageSync('handleUser')),
  324. })
  325. .then(async (res) => {
  326. // this.Toastloading.clear();
  327. // console.log(1795, res);
  328. if (res.data?.code == '000000') {
  329. const prepayJson = res.data.data.params;
  330. console.log('prepayJson::', res.data)
  331. const platform = getPlatform();
  332. this.isPay = true
  333. // TODO: h5环境判断
  334. if (platform === 'micromessenger') {
  335. const weixinH5PayRes = await this.weixinH5Pay(prepayJson);
  336. // 微信支付完成,判断结果
  337. console.log(1784, weixinH5PayRes);
  338. // errMsg: 'requestPayment:ok'
  339. if (weixinH5PayRes?.errMsg === 'requestPayment:ok') {
  340. this.btnLoading = false
  341. this.isPay = false
  342. this.clearOrderTimeEvent()
  343. this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
  344. name: 'parkingFeeDetail'
  345. });
  346. this.$router.replace({
  347. // path: 'parkingFeeSuccess?carno=' + this.parkInfo.carno,
  348. path: this.getPagePath(),
  349. });
  350. } else {
  351. this.reCreateParkOrder();
  352. }
  353. } else {
  354. let options = {}
  355. if (isAlipay()) {
  356. options = {
  357. provider: 'alipay',
  358. orderInfo: prepayJson.trade_no,
  359. }
  360. } else {
  361. options = {
  362. provider: 'wxpay',
  363. timeStamp: prepayJson.timeStamp,
  364. nonceStr: prepayJson.nonceStr,
  365. package: prepayJson.package,
  366. signType: prepayJson.signType,
  367. paySign: prepayJson.paySign,
  368. }
  369. }
  370. window.toWXSendMsg({
  371. type: 'openWxPay',
  372. options: options,
  373. });
  374. window.subscribe('wxPayOver', (options) => {
  375. // this.Toastloading.clear();
  376. // console.log('微信支付结束之后的返回参数', options);
  377. // T-ODO: 在 qa 新发版前,只提示支付成功的信息(已处理成功信息)
  378. if (options?.wxPayOver === 'fail') {
  379. console.log('支付失败');
  380. this.reCreateParkOrder();
  381. } else {
  382. this.btnLoading = false;
  383. this.isPay = false
  384. this.clearOrderTimeEvent()
  385. this.$router.replace({
  386. // path: 'parkingFeeSuccess?vehicleNo=' + this.$route.query.vehicleNo,
  387. path: this.getPagePath(),
  388. });
  389. }
  390. });
  391. }
  392. } else {
  393. this.reCreateParkOrder();
  394. }
  395. })
  396. .catch((err) => {
  397. if(err.code === "ERR_NETWORK") {
  398. this.btnLoading = true;
  399. uni.showToast({ title: '网络连接失败,请重试', duration: 3000, icon: 'fail' });
  400. setTimeout(() => {
  401. this.clearOrderTimeEvent()
  402. this.$router.replace({
  403. // path: 'parkingFeeSuccess?carno=' + this.parkInfo.carno,
  404. path: 'home',
  405. });
  406. }, 2900)
  407. return
  408. }
  409. this.reCreateParkOrder();
  410. });
  411. },
  412. // 支付失败后返还优惠券
  413. failedParkOrder() {
  414. // this.Toastloading.clear();
  415. const param = {
  416. orderno: this.parkInfo.orderno,
  417. };
  418. this.$md(param);
  419. uni
  420. .request({
  421. url: this.$baseURL + 'api/1.0/park/failedParkOrder',
  422. data: param,
  423. method: 'POST',
  424. header: JSON.parse(uni.getStorageSync('handleUser')),
  425. })
  426. .then((res) => {
  427. this.reCreateParkOrder();
  428. })
  429. .catch((err) => {
  430. this.reCreateParkOrder();
  431. });
  432. },
  433. // 支付失败弹框 重新创建订单
  434. reCreateParkOrder() {
  435. // console.log('支付失败弹框 重新创建订单');
  436. Dialog.alert({
  437. title: '提示',
  438. message: '支付失败',
  439. confirmButtonColor: '#333',
  440. }).then(() => {
  441. this.$refs.countDown.reset(); // 停车场重置费用倒计时3分钟
  442. this.$store.dispatch('order/orderInit', {
  443. gateId: this.$route.query?.gateId,
  444. vehicleNo: this.$route.query?.vehicleNo,
  445. endlessLoop: this.endlessLoop
  446. })
  447. this.btnLoading = false;
  448. this.isPay = false
  449. // this.createParkOrder();
  450. });
  451. // uni.showModal({
  452. // showCancel: false,
  453. // title: '提示',
  454. // content: '支付失败',
  455. // complete: (r) => {
  456. // this.createParkOrder();
  457. // },
  458. // });
  459. },
  460. // 初始化
  461. async pageInit() {
  462. // console.log(247, checkOutResponse);
  463. // this.msData.detail = checkOutResponse
  464. // 停车优惠
  465. // this.discounts(this.msData.detail)
  466. // 积分减免
  467. // 优惠券
  468. // 纸质优惠券
  469. // 优惠金额
  470. // 应付金额
  471. // this.$store.commit('order/SET_ORDER_DETAIL', checkOutResponse);
  472. try {
  473. console.log('无牌车扫码出场', this.unlicensedInfo, this.endlessLoop);
  474. this.btnLoading = false
  475. this.isPay = false
  476. // return
  477. this.$store.dispatch('order/orderInit', {
  478. vehicleNo: this.$route.query.vehicleNo,
  479. gateId: this.$route.query?.gateId,
  480. endlessLoop: this.endlessLoop,
  481. callback: (res) => {
  482. setTimeout(() => {
  483. this.$store.dispatch('clearUnlicensed');
  484. }, 700);
  485. // 如果 无牌车扫码出场扫码 无需缴费,直接展示无需缴费页面
  486. if(/unlicensedOut/.test(res.code) && res?.unlicensed) {
  487. this.clearOrderTimeEvent()
  488. this.$router.replace({
  489. path: 'parkingFeeMsg?type=pay',
  490. });
  491. return
  492. }
  493. // 如果是无需缴费的话,提示用户无需缴费
  494. if (res?.orderDetail?.parkingRecord?.totalFee <= 0) {
  495. this.$store.dispatch('order/orderInitRule', res.orderDetail);
  496. setTimeout(() => {
  497. Dialog.alert({
  498. message: '当前无需缴费',
  499. confirmButtonColor: '#333',
  500. }).then(() => {
  501. this.clearOrderTimeEvent()
  502. this.$router.back()
  503. });
  504. }, 1000)
  505. return
  506. }
  507. if ( /CAR_NOT_FOUND|INOUT_FAILED/.test(res.code) ) {
  508. setTimeout(() => {
  509. this.clearOrderTimeEvent()
  510. this.$router.replace({
  511. path: 'parkingFeeMsg',
  512. query: {
  513. type: 'outFail'
  514. }
  515. })
  516. }, 300)
  517. return;
  518. }
  519. if (/NOT_FOUND|PARKING_RECORD_NOT_FOUND/.test(res.code)) {
  520. // 当前车辆没有查到账单
  521. this.clearOrderTimeEvent()
  522. this.$router.replace({
  523. path: 'parkingFeePayment',
  524. query: {
  525. msg: res.langMessage,
  526. vehicleNo: this.$route.query.vehicleNo,
  527. },
  528. });
  529. return
  530. }
  531. if (/LOCAL_PARK_ERROR|INTERNAL_SERVER_ERROR|VALIDATION_FAILED|PLEASE_SCAN_QRCODE/g.test(res.code)) {
  532. setTimeout(() => {
  533. this.clearOrderTimeEvent()
  534. this.$router.back()
  535. }, 3000)
  536. }
  537. },
  538. enquiryFarePolling: () => {
  539. this.orderTimeEvent = setInterval(() => {
  540. if(!this.orderTime) {
  541. this.orderTime = new Date().getTime()
  542. }
  543. const nowTime = new Date().getTime()
  544. if(nowTime - this.orderTime >= 2.8 * 60 * 1000) {
  545. if(this.$route.name !== 'parkingFeeDetail') {
  546. this.$router.back()
  547. }
  548. setTimeout(() => {
  549. this.orderTime = new Date().getTime()
  550. this.resetCountDown()
  551. }, 250)
  552. }
  553. // console.log(509, (nowTime - this.orderTime) / 1000);
  554. }, 1100);
  555. }
  556. });
  557. setTimeout(() => {
  558. this.$store.dispatch('clearUnlicensed');
  559. }, 1200);
  560. } catch (err) {
  561. console.log('查询车辆是否在场的报错信息?', err, err.code === "INTERNAL_SERVER_ERROR");
  562. // 如果网络异常(这里是因为订单页面存在空白场景,才需要单独处理报错交互)
  563. if (err.code === "INTERNAL_SERVER_ERROR") {
  564. this.clearOrderTimeEvent()
  565. this.$router.back()
  566. }
  567. }
  568. },
  569. // 停车优惠
  570. discounts() {
  571. // totalFee 为零的时候不做跳转
  572. if (this.orderDetail.parkingRecord.totalFeeInYuan === 0) return;
  573. if (!this.enableConsume && !this.memberLevelDiscount && this.orderDetail.parkInfo.parkMallCode !== 2) {
  574. return Toast({
  575. message: '暂无可用优惠',
  576. });
  577. }
  578. if( this.discountDesc !== '暂无可用优惠') {
  579. this.$router.push({
  580. path: 'parkingFeeDiscounts',
  581. });
  582. }
  583. },
  584. setColor() {
  585. window?.toWXSendMsg({
  586. type: 'uni_func',
  587. funcName: 'setNavigationBarColor',
  588. options: {
  589. frontColor: '#000000',
  590. backgroundColor: '#2151C5',
  591. },
  592. });
  593. // uni.setNavigationBarColor({
  594. // frontColor: '#000000',
  595. // backgroundColor: '#FAFBFF',
  596. // });
  597. },
  598. // 是否展示优惠信息
  599. // isShowDiscounts(params) {
  600. // console.log(277, params?.parkingRule?.enableCoupon);
  601. // return params?.parkingRule?.enableCoupon
  602. // },
  603. //
  604. // 计算优惠信息
  605. discountssss(params) {
  606. // console.log(275, params);
  607. // console.log(275, params.discountInfo);
  608. // console.log(275, params.discountInfo.consume);
  609. return 1;
  610. },
  611. coupon() {
  612. // totalFee 为零的时候不做跳转
  613. if (this.orderDetail.parkingRecord.totalFeeInYuan === 0) return;
  614. // 如果没有电子券的话,提示用户
  615. if (this.coupons.length === 0 && this.source !== 'KIP') {
  616. uni.showToast({
  617. title: '暂无可使用的优惠券,请前往积分商城兑换优惠券'
  618. })
  619. return
  620. }
  621. this.$router.push({
  622. path: 'parkingFeeCoupon',
  623. });
  624. },
  625. paperCoupon() {
  626. // totalFee 为零的时候不做跳转
  627. if (this.orderDetail.parkingRecord.totalFeeInYuan === 0) return;
  628. this.$router.push({
  629. path: 'parkingFeePaperCoupon',
  630. query:{
  631. vehicleNo: this.$route.query.vehicleNo
  632. }
  633. });
  634. },
  635. duration() { },
  636. couponCount() { },
  637. // 重置倒计时
  638. resetCountDown() {
  639. this.$refs?.countDown?.reset();
  640. this.btnLoading = false;
  641. this.isPay = false;
  642. this.popup = false;
  643. this.$store.dispatch('order/orderInit', {
  644. gateId: this.$route.query?.gateId,
  645. vehicleNo: this.$route.query?.vehicleNo,
  646. endlessLoop: this.endlessLoop
  647. })
  648. // 重新创建订单
  649. // this.createParkOrder();
  650. },
  651. //缴费说明隐藏显示
  652. togglePayinstruction() {
  653. this.isShowDescription = !this.isShowDescription;
  654. },
  655. // 积分修改框
  656. showPointsMathPopup() {
  657. // totalFee 为零的时候不做跳转
  658. if (this.orderDetail.parkingRecord.totalFeeInYuan === 0) return;
  659. if(this.integralDesc === '暂无可用积分'){
  660. return
  661. }
  662. this.popup = true;
  663. },
  664. cancelPointsMathPopup() {
  665. this.$store.dispatch('order/cancelPointsMath', () => {
  666. this.popup = false;
  667. });
  668. },
  669. savePointsMathPopup() {
  670. this.$store.dispatch('order/savePointsMath', () => {
  671. this.popup = false;
  672. });
  673. },
  674. // 获取成功缴费之后前往的页面
  675. getPagePath() {
  676. let pagePath = 'parkingFeeSuccess?vehicleNo=' + this.$route.query.vehicleNo
  677. console.log('临时车流程', this.endlessLoop);
  678. if (this.$route.query.vehicleNo.indexOf('临') > -1 && this.endlessLoop || this.$route.query.gateId) {
  679. pagePath = 'parkingFeeMsg?type=pay'
  680. }
  681. return pagePath
  682. },
  683. pointsMathCallback({type, message}) {
  684. // console.log(465, type);
  685. Toast({
  686. message: message,
  687. icon: 'none',
  688. });
  689. },
  690. //
  691. setDescription() {
  692. if ( this?.orderDetail?.parkInfo?.description.length > 0 ) {
  693. let reg = /[;;]/g;
  694. return this.orderDetail.parkInfo.description.replace(reg, '\r\n').replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>');
  695. }
  696. return ''
  697. },
  698. clearOrderTimeEvent() {
  699. if(this.orderTimeEvent) {
  700. clearInterval(this.orderTimeEvent);
  701. this.orderTime = null
  702. }
  703. }
  704. },
  705. destroyed() {
  706. this.clearOrderTimeEvent()
  707. }
  708. };