parkingFeeDetail.js 26 KB

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