123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940 |
- import { mapState } from 'vuex';
- import uni from '@/utils/uniHooks';
- import {
- backLbsHome,
- getPlatform,
- isAlipay,
- } from '@/utils';
- import {debounce, } from 'lodash'
- import { Dialog, Toast } from 'vant';
- import { ordersAndPrepay } from '@/api/parking';
- import store from "@/store";
- // import newMemberPoints from '@/components/newMemberPoints/index.vue'
- import newMemberPointsItem from '@/components/newMemberPoints/item.vue'
- export default {
- name: 'parkingFeeDetail',
- components: { newMemberPointsItem },
- data() {
- this.toPay = debounce(this.toPay, 5000, {
- leading: true,
- trailing: false
- })
- return {
- hasDiscount: false,
- parkFee: {},
- refreshTime: 180, // 停车场重置费用倒计时3分钟
- // 微服务接口字段
- isShowDescription: true, // 缴费说明true:显示全部 false:显示部分
- btnLoading: false,
- isPay: false,
- popup: false,
- msData: {},
- orderTimeEvent: null,
- orderTime: null
- };
- },
- beforeRouteLeave(to, from, next) {
- // 设置下一个路由的 meta
- if (/index|home/.test(to.name)) {
- // 不在缓存列表中,从cachedViews缓存列表中移除
- this.$store.commit('cachedViews/DEL_CACHED_VIEW', from);
- }
- next();
- },
- async created() {
- // console.log('如果本地不存在', this.$route.query);
- const {fromPage = '', format = '', unlicensed = ''} = this.$route.query
- // licensedVehicle
- // format
- /* unlicensed: unlicensedVehicle(无牌车), licensedVehicle(有牌车)
- * format: success, fail
- * fromPage: 'parkingFeeDetail'
- */
- if(fromPage && format && unlicensed && !this.$store.state.pageHistory?.parkingFeeDetailPaystatus) {
- this.$store.commit('setPageHistory', {
- parkingFeeDetailPaystatus: 1
- })
- const query = {
- ...this.$route.query,
- }
- query.fromPage = ''
- query.format = ''
- query.unlicensed = ''
- // 无牌车失败跳转
- // 有牌车失败跳转
- if (format === 'success') {
- // 无牌车成功跳转, 有牌车成功跳转
- this.$router.replace({
- // path: 'parkingFeeSuccess?vehicleNo=' + this.$route.query.vehicleNo,
- path: this.getPagePath(),
- query: {
- ...this.$route.query,
- }
- });
- return
- }
- // 如果失败的话,刷新当前页面,则不做任何处理
- if(format === 'fail') {
- await Dialog.alert({
- title: '提示',
- message: '支付失败',
- confirmButtonColor: '#333',
- })
- // await this.pageInit();
- // return
- }
- }
- // 如果本地不存在
- // setTimeout(() => {
- // uni.setNavigationBarTitle({
- // title: '停车支付',
- // });
- // }, 300);
- // setTimeout(() => {
- // window?.toWXSendMsg({
- // type: 'uni_func',
- // funcName: 'setNavigationBarColor',
- // options: {
- // frontColor: '#000000',
- // backgroundColor: '#FBFCFF',
- // },
- // });
- // }, 500)
- setTimeout(async () => {
- // 如果从小程序来的用户已经登录。但是本地的 member 数据是空的,则从后端重新获取,如果获取失败则提示用户
- if(this.isLogin === 'haveLoggedIn' && (this.isNoLogin || !this.member?.vipcode)) {
- const res = await this.$store.dispatch('memberInit',{
- unionId: this.$store.state.sourceId,
- openid: this.$store.state.openid,
- isError: true
- })
- if(res) {
- backLbsHome()
- return;
- }
- }
- await this.pageInit();
- }, 300)
- },
- mounted() {
- // this.reloadPage()
- // console.log(7878, this.$route)
- },
- computed: {
- ...mapState({
- orderDetail: (state) => state.order.orderDetail,
- discountDesc: (state) => state.order.discountDesc,
- enableNewMemberPoints: (state) => state.order.enableNewMemberPoints,
- enablePoints: (state) => state.order.enablePoints,
- integralDesc: (state) => state.order.integralDesc,
- enableCoupon: (state) => state.order.enableCoupon,
- maxOneDayCoupons: (state) => state.order.maxOneDayCoupons,
- coupons: (state) => state.order.coupons,
- couponDesc: (state) => state.order.couponDesc,
- enablePaperCoupons: (state) => state.order.enablePaperCoupons,
- custTypeId: (state) => state.custTypeId,
- usingTotalDiscount: (state) => state.order.usingTotalDiscount,
- actualPayFee: (state) => state.order.actualPayFee,
- available: (state) => state.order.available,
- member: (state) => state.member,
- maxPointsTime: (state) => state.order.maxPointsTime,
- pointsTime: (state) => state.order.pointsTime,
- pointsPerHour: (state) => state.order.pointsPerHour,
- usePoints: (state) => state.order.usePoints,
- usePointsTime: (state) => state.order.usePointsTime,
- enableConsume: (state) => state.order.enableConsume,
- memberLevelDiscount: (state) => state.order.memberLevelDiscount,
- unitAmount: (state) => state.order.unitAmount,
- unlicensedInfo: state => state.unlicensedInfo,
- endlessLoop: (state) => state.endlessLoop,
- appId: state => state.appId,
- source: state => state.source,
- parkMallCode: (state) => state.order.parkMallCode,
- isLogin: (state) => state.isLogin,
- mallId: (state) => state.mallId,
- }),
- isNoLogin() {
- return JSON.stringify(this.member) === '{}' || !this.member
- },
- // 支付按钮状态
- payBtnDisabled() {
- // 当存在待支付金额 或者 用户登陆
- return !this.orderDetail?.parkingRecord?.totalFeeInYuan || (JSON.stringify(this.member) !== '{}' && !this.orderDetail.parkInfo);
- },
- // integralDesc() {
- // if (this.pointsTime > 0) {
- // // 深圳特殊处理(单位:金额)
- // if (this.orderDetail.parkInfo.parkMallCode === 5 || this.orderDetail.parkInfo.parkMallCode === 999) {
- // return `已选择兑换${this.pointsTime}元`;
- // }
- // return `已选择兑换${this.pointsTime}小时`;
- // }
- // if (this.bonusCopy < this.integral) {
- // return `${this.integral}积分可停车1小时`;
- // }
- // if (this.orderDetail.parkInfo.parkMallCode === 3 && app.globalData.member?.currnentintegral >= this.integral && !this.bonus) {
- // return `今日已达上限`;
- // }
- // return `${this.available}积分可减免`;
- // },
- },
- filters: {
- parkingTime(val) {
- const days = parseInt(val / 60 / 24)
- const hours = parseInt((val / 60) % 24)
- const minutes = parseInt(val % 60)
- if (days > 0) {
- return `${days}天 ${hours}小时 ${minutes}分钟`
- }
- if (hours > 0) {
- return `${hours}小时 ${minutes}分钟`
- }
- return `${minutes}分钟`
- },
- },
- methods: {
- // 刷新管理
- reloadPage() {
- setTimeout(() => {
- const fullPath = window.location.href.indexOf('parkingFeePaperCoupon') > -1 ? '/parkingFeeDetail/' : this.$route.fullPath
- window?.toWXSendMsg({
- type: 'nowRoute',
- options: {
- fullPath: fullPath
- },
- });
- window.subscribe('reload',( ) => {
- // 如果是纸质券页面,发起的扫码动作,不做任何刷新动作
- if (window.location.href.indexOf('parkingFeePaperCoupon') > -1) {
- this.reloadPage()
- return
- }
- // 如果当前路由不是支付页面,则回退到当前页面再刷新页面
- if(this.$route.name !== 'parkingFeeDetail') {
- this.$router.back()
- }
- setTimeout(() => {
- window.location.reload();
- }, 100)
- });
- }, 700)
- },
- // 前往支付
- async toPay() {
- // if (!isAlipayClient) {
- // // 判断微信小程序与 h5 是否正常通信
- // const isReload = await theCommunicationBetweenWechatAndH5IsNormal()
- // if(!isReload) {
- // uni.setStorageSync('isReload', 1)
- // window.location.reload()
- // return
- // }
- // }
- if (this.btnLoading) return
- this.btnLoading = true
- setTimeout(() => {
- if ( this.btnLoading && !this.isPay ) {
- const toast1 = Toast({
- message: '网络连接失败,请重试',
- duration: 3000,
- onClose: () => {
- this.clearOrderTimeEvent()
- this.$router.replace({
- // path: 'parkingFeeSuccess?carno=' + this.parkInfo.carno,
- path: 'home',
- query: {
- ...this.$route.query,
- }
- });
- }
- });
- this.btnLoading = false
- }
- }, 10000)
- const { parkingRecord, discountInfo = {}, parkingRule = {}} = this.orderDetail;
- const { coupons, points, memberGrade = [], paperCoupons = [], consume = [], newMemberPoints= {} } = discountInfo
- const { hourPrice } = parkingRule
- try {
- const params = {
- // vehicleNo: '', // 车牌号
- // points
- payChannel: isAlipay() ? 'MINI_PROGRAM' : 'OFFICIAL_ACCOUNT',
- payOption: isAlipay() ? 'ALIPAY' : 'WECHATPAY',
- parkingRecord: {
- ...parkingRecord,
- vehicleNo: parkingRecord.vehicleNo,
- enterTime: parkingRecord.enterTime,
- serviceMin: parkingRecord.serviceMin,
- totalFee: parkingRecord.totalFeeInYuan, //应缴
- actualPayFee: this.actualPayFee, //应付金额
- },
- discountInfo: {
- usingTotalDiscount: discountInfo?.usingTotalDiscount || 0, //优惠金额"
- actualUsedDiscount: discountInfo?.usingTotalDiscount || 0, //实际优惠金额
- },
- };
- // 会员等级减免
- if ( memberGrade?.length && memberGrade[0].discountFee > 0 && memberGrade[0].hasOwnProperty('selected')? memberGrade[0]?.selected : memberGrade[0]?.defaultSelected) {
- const selected = memberGrade[0].hasOwnProperty('selected') ? memberGrade[0].selected : memberGrade[0].defaultSelected;
- let discountTime = 0
- let discountFee = 0
- if(selected) {
- discountTime = memberGrade[0].hasOwnProperty('discountTime') ? memberGrade[0].discountTime : memberGrade[0].defaultDiscountTime;
- discountFee = memberGrade[0].hasOwnProperty('discountFee') ? memberGrade[0].discountFee : discountTime * hourPrice;
- }
- params.discountInfo.memberLevel = {
- "discountTime": discountTime * 60, // 小时转成分钟
- "discountFee": discountFee,
- "memberGrade": memberGrade[0].memberGrade
- }
- }
- // 消费减免
- if ( consume?.length && consume[0].discountFee > 0 && consume[0].hasOwnProperty('selected')? consume[0]?.selected : consume[0]?.defaultSelected) {
- const { redeemSalesAmount, defaultDiscountTime, couponCodes = ''} = consume[0]
- const selected = consume[0].hasOwnProperty('selected') ? consume[0].selected : consume[0].defaultSelected;
- let discountTime = 0
- let discountFee = 0
- if(selected) {
- discountFee = consume[0].hasOwnProperty('discountFee') ? consume[0].discountFee : memberGrade[0].defaultDiscountTime * hourPrice;
- discountTime = discountFee / hourPrice * 60;
- }
- params.discountInfo.consume = {
- ...consume[0],
- "defaultSelected": selected,
- "discountTime": discountTime,
- "discountFee": discountFee,
- // 杭州,沈阳,天津,福州,重新计算 redeemSalesAmount
- "redeemSalesAmount": ([2,4,6,8].indexOf(this.parkMallCode) > -1) ? (redeemSalesAmount / defaultDiscountTime) * ( discountFee / hourPrice) : redeemSalesAmount
- }
- // 浦东,重新计算 couponCodes
- if( this.parkMallCode == 1 && couponCodes) {
- params.discountInfo.consume.couponCodes = couponCodes.split('#').slice(0,discountFee / hourPrice).toString().replace(/,/g, '#')
- }
- }
-
- // 积分
- if (points?.length && points[0].discountFee > 0) {
- // 15 兑换 5元
- const { pointsPerUnit, unitAmount, discountFee, available } = points[0]
- params.discountInfo.points = {
- "discountTime": discountFee / hourPrice * 60,
- "discountFee": discountFee,
- "discountPoints": discountFee / hourPrice * pointsPerUnit
- }
- }
- // 优惠券
- if (coupons?.length) {
- const selectedCoupons = coupons.filter(elm => {
- const selected = elm.hasOwnProperty('selected') ? elm.selected : elm.defaultSelected;
- return selected
- }).map(elm => {
- elm.discountTime = elm.discountFee / hourPrice * 60
- return elm
- })
- if (selectedCoupons.length) {
- params.discountInfo.coupons = selectedCoupons
- }
- }
- // 纸质优惠券
- if ( paperCoupons?.length ) {
- params.discountInfo.paperCoupons = paperCoupons.filter(elm => {
- if ( !elm.discountFee ) {
- return false
- }
- return {
- ...elm,
- "discountFee": elm.discountFee,
- // discountTime: elm.discountFee / hourPrice * 60
- }
- })
- }
- // 新会员积分, 默认带上了,然后不加也不影响
- // if ( newMemberPoints?.discountFee ) {
- // params.discountInfo.paperCoupons = paperCoupons.filter(elm => {
- // if ( !elm.discountFee ) {
- // return false
- // }
- // return {
- // ...elm,
- // "discountFee": elm.discountFee,
- // // discountTime: elm.discountFee / hourPrice * 60
- // }
- // })
- // }
- console.log('下单时的参数', params);
- const unlicensed = this.$route.query?.vehicleNo ? this.$route.query?.vehicleNo.indexOf('临') > -1 : false; // true: 临时车牌;false:燃油车牌
- const res = await ordersAndPrepay(params, unlicensed);
- // console.log('orderDetail', res);
- if (res?.paymentType === 'NO_FEE_PAY') {
- this.btnLoading = false;
- this.isPay = false
- this.clearOrderTimeEvent()
- this.$router.replace({
- path: this.getPagePath(),
- query:{
- ...this.$route.query,
- }
- });
- // 支付成功
- return
- }
- // 如果是北京的ETCP
- if (this.isBKC() && !isAlipay()) {
- wx.miniProgram.navigateTo({
- url: `/pages/package-parkingFee/etcpPayment?token=${encodeURIComponent(
- res.token + '$'
- )}&syncId=${encodeURIComponent(
- res.syncId + '$'
- )}&CarNumber=${encodeURIComponent(
- res.vehicleNo + '$'
- )}`,
- });
- this.$router.back()
- return
- }
- if(res?.sessionId) {
- this.kerryPayment(res.sessionId, {unlicensed});
- return
- }
- // 如果接口返回异常,重置当前页面数据
- this.reCreateParkOrder()
- } catch (err) {
- // 网络异常返回首页
- if(err ==='ERR_NETWORK') {
- setTimeout(() => {
- this.clearOrderTimeEvent()
- this.$router.replace({
- // path: 'parkingFeeSuccess?carno=' + this.parkInfo.carno,
- path: 'home',
- query:{
- ...this.$route.query,
- }
- });
- }, 2900)
- } else {
- // 如果接口返回异常,重置当前页面数据
- console.log('err::::', err)
- if (err.code !=='NO_FEE_NEED_TO_PAY') {
- this.reCreateParkOrder()
- } else {
- Dialog.alert({
- title: '提示',
- message: '当前无需缴费',
- confirmButtonColor: '#333',
- }).then(() => {
- this.$router.replace({
- // path: 'parkingFeeSuccess?carno=' + this.parkInfo.carno,
- path: 'home',
- });
- // this.createParkOrder();
- });
- }
- this.btnLoading = false
- this.isPay = false
- }
- console.log(err);
- }
- },
- isBKC() {
- const lbsList = ['8a8884e77cc9e70a017cca4003590008','8a8485067ce4da2d017ce555e9b20000','8aaa80b47c784020017c78b205ba0023']
- return lbsList.indexOf(this.mallId) > -1
- },
- kerryPayment(session = '', payParams) {
- if(!session) return
- const platform = getPlatform();
- // console.log('platform:::', platform)
- let appId = uni.getStorageSync('appid');
- let openId = uni.getStorageSync('openid') || this.openid;
- if (platform === 'miniprogram') {
- // appId = 'wx92c3e55fbef6b2af';
- // appId = 'wxd830fe4d1e04988e';
- appId = this.appId;
- }
- // console.log('支付宝::', isAlipay())
- const params = {
- region: 'cn',
- payChannel: isAlipay() ? 'MINI_PROGRAM' : 'OFFICIAL_ACCOUNT',
- // payChannel: 'MOBILE_WEB',
- payOption: isAlipay() ? 'ALIPAY' : 'WECHATPAY',
- appId: appId,
- // openId: 'oudWQ5SCDElfn-IQH6eBR5JesOz4', // 下的appid: wxd830fe4d1e04988e
- openId,
- };
- // console.log(1854, params);
- this.$md(params);
- // let path = `/profileApi/payment/v1/services/session/${session}/transactions`;
- let path = `${window.profileApi}/payment/v1/services/session/${session}/transactions`;
- this.$request({
- url: path,
- data: params,
- method: 'POST',
- header: JSON.parse(uni.getStorageSync('handleUser')),
- })
- .then(async (res) => {
- // this.Toastloading.clear();
- // console.log(1795, res);
- if (res.data?.code == '000000') {
- const prepayJson = res.data.data.params;
- // console.log('prepayJson::', res.data)
- // const platform = getPlatform();
- this.isPay = true
- // TODO: h5环境判断
- // if (platform === 'micromessenger') {
- // const weixinH5PayRes = await this.weixinH5Pay(prepayJson);
- // // 微信支付完成,判断结果
- // // console.log(1784, weixinH5PayRes);
- // // errMsg: 'requestPayment:ok'
- // if (weixinH5PayRes?.errMsg === 'requestPayment:ok') {
- // this.btnLoading = false
- // this.isPay = false
- // this.clearOrderTimeEvent()
- // this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
- // name: 'parkingFeeDetail',
- // });
- // this.$router.replace({
- // // path: 'parkingFeeSuccess?carno=' + this.parkInfo.carno,
- // path: this.getPagePath(),
- // query: {...this.$route.query}
- // });
- // } else {
- // this.reCreateParkOrder();
- // }
- // } else {
- let options = {}
- // if (isAlipay()) {
- // options = {
- // provider: 'alipay',
- // orderInfo: prepayJson.trade_no,
- // }
- // } else {
- options = {
- provider: 'wxpay',
- timeStamp: prepayJson.timeStamp,
- nonceStr: prepayJson.nonceStr,
- package: prepayJson.package,
- signType: prepayJson.signType,
- paySign: prepayJson.paySign,
- }
- // }
- // console.log(430, options)
- const data = {
- ...options,
- unlicensed: payParams.unlicensed,
- vehicleNo: this.$route.query.vehicleNo,
- };
- const timeStamp = data.timeStamp + '$';
- const nonceStr = data.nonceStr + '$';
- const packageStr = data.package + '$';
- const signType = data.signType + '$';
- const paySign = data.paySign + '$';
- const vehicleNo = this.orderDetail.parkingRecord.vehicleNo + '$';
- const unlicensed = this.orderDetail.unlicensed ? 'unlicensedVehicle' + '$': 'licensedVehicle' + '$';
- // console.log(486, this.orderDetail);
- // return
- wx.miniProgram.redirectTo({
- url: `/pages/package-parkingFee/payment?timeStamp=${encodeURIComponent(
- timeStamp
- )}&nonceStr=${encodeURIComponent(
- nonceStr
- )}&package=${encodeURIComponent(
- packageStr
- )}&signType=${encodeURIComponent(
- signType
- )}&paySign=${encodeURIComponent(paySign)}&activityRecordId=${
- res.signUpRecordId
- }&orderNo=${res.orderNo}&unlicensed=${
- unlicensed
- }&vehicleNo=${
- vehicleNo
- }`,
- });
- // return
- // window?.toWXSendMsg({
- // type: 'nowRoute',
- // options: {
- // fullPath: '1'
- // },
- // });
- // window.toWXSendMsg({
- // type: 'openWxPay',
- // options: options,
- // });
- // window.subscribe('wxPayOver', (options) => {
- // if(isAlipayClient) {
- // options.wxPayOver = options.options.wxPayOver
- // }
- // // this.Toastloading.clear();
- // // console.log('微信支付结束之后的返回参数', options);
- // // T-ODO: 在 qa 新发版前,只提示支付成功的信息(已处理成功信息)
- // if (options?.wxPayOver === 'fail') {
- // console.log('支付失败');
- // this.reCreateParkOrder();
- // } else {
- // this.btnLoading = false;
- // this.isPay = false
- // this.clearOrderTimeEvent()
- // this.$router.replace({
- // // path: 'parkingFeeSuccess?vehicleNo=' + this.$route.query.vehicleNo,
- // path: this.getPagePath(),
- // query:{
- // ...this.$route.query,
- // }
- // });
- // }
- // });
- // }
- } else {
- this.reCreateParkOrder();
- }
- })
- .catch((err) => {
- if(err.code === "ERR_NETWORK") {
- this.btnLoading = true;
- uni.showToast({ title: '网络连接失败,请重试', duration: 3000, icon: 'fail' });
- setTimeout(() => {
- this.clearOrderTimeEvent()
- this.$router.replace({
- // path: 'parkingFeeSuccess?carno=' + this.parkInfo.carno,
- path: 'home',
- query:{
- ...this.$route.query,
- }
- });
- }, 2900)
- return
- }
- this.reCreateParkOrder();
- });
- },
- // 支付失败后返还优惠券
- failedParkOrder() {
- // this.Toastloading.clear();
- const param = {
- orderno: this.parkInfo.orderno,
- };
- this.$md(param);
- uni
- .request({
- url: this.$baseURL + 'api/1.0/park/failedParkOrder',
- data: param,
- method: 'POST',
- header: JSON.parse(uni.getStorageSync('handleUser')),
- })
- .then((res) => {
- this.reCreateParkOrder();
- })
- .catch((err) => {
- this.reCreateParkOrder();
- });
- },
- // 支付失败弹框 重新创建订单
- reCreateParkOrder() {
- // console.log('支付失败弹框 重新创建订单');
- Dialog.alert({
- title: '提示',
- message: '支付失败',
- confirmButtonColor: '#333',
- }).then(() => {
- this.$refs.countDown.reset(); // 停车场重置费用倒计时3分钟
- this.$store.dispatch('order/orderInit', {
- gateId: this.$route.query?.gateId,
- vehicleNo: this.$route.query?.vehicleNo,
- endlessLoop: this.endlessLoop,
- callback: (res) => {
- this.orderInitCallBack(res)
- },
- })
- this.btnLoading = false;
- this.isPay = false
- // this.createParkOrder();
- });
- // uni.showModal({
- // showCancel: false,
- // title: '提示',
- // content: '支付失败',
- // complete: (r) => {
- // this.createParkOrder();
- // },
- // });
- },
- // 初始化
- async pageInit() {
- // console.log(247, checkOutResponse);
- // this.msData.detail = checkOutResponse
- // 停车优惠
- // this.discounts(this.msData.detail)
- // 积分减免
- // 优惠券
- // 纸质优惠券
- // 优惠金额
- // 应付金额
- // this.$store.commit('order/SET_ORDER_DETAIL', checkOutResponse);
- try {
- console.log('无牌车扫码出场', this.unlicensedInfo, this.endlessLoop);
- this.btnLoading = false
- this.isPay = false
- // return
- this.$store.dispatch('order/orderInit', {
- vehicleNo: this.$route.query.vehicleNo,
- gateId: this.$route.query?.gateId,
- endlessLoop: this.endlessLoop,
- callback: (res) => {
- this.orderInitCallBack(res)
- },
- enquiryFarePolling: () => {
- this.orderTimeEvent = setInterval(() => {
- if(!this.orderTime) {
- this.orderTime = new Date().getTime()
- }
- const nowTime = new Date().getTime()
- if(nowTime - this.orderTime >= 2.8 * 60 * 1000) {
- if(this.$route.name !== 'parkingFeeDetail') {
- this.$router.back()
- }
- setTimeout(() => {
- this.orderTime = new Date().getTime()
- this.resetCountDown()
- }, 250)
- }
- // console.log(509, (nowTime - this.orderTime) / 1000);
- }, 1100);
- }
- });
- setTimeout(() => {
- this.$store.dispatch('clearUnlicensed');
- }, 1200);
- } catch (err) {
- // console.log('查询车辆是否在场的报错信息?', err, err.code === "INTERNAL_SERVER_ERROR");
- // 如果网络异常(这里是因为订单页面存在空白场景,才需要单独处理报错交互)
- if (err.code === "INTERNAL_SERVER_ERROR") {
- this.clearOrderTimeEvent()
- this.$router.back()
- }
- }
- },
- // 停车优惠
- discounts() {
- // totalFee 为零的时候不做跳转
- if (this.orderDetail.parkingRecord.totalFeeInYuan === 0) return;
- if (!this.enableConsume && !this.memberLevelDiscount && this.orderDetail.parkInfo.parkMallCode !== 2) {
- return Toast({
- message: '暂无可用优惠',
- });
- }
- if( this.discountDesc !== '暂无可用优惠') {
- this.$router.push({
- path: 'parkingFeeDiscounts',
- });
- }
- },
- setColor() {
- window?.toWXSendMsg({
- type: 'uni_func',
- funcName: 'setNavigationBarColor',
- options: {
- frontColor: '#000000',
- backgroundColor: '#2151C5',
- },
- });
- // uni.setNavigationBarColor({
- // frontColor: '#000000',
- // backgroundColor: '#FAFBFF',
- // });
- },
- // 是否展示优惠信息
- // isShowDiscounts(params) {
- // console.log(277, params?.parkingRule?.enableCoupon);
- // return params?.parkingRule?.enableCoupon
- // },
- //
- // 计算优惠信息
- discountssss(params) {
- // console.log(275, params);
- // console.log(275, params.discountInfo);
- // console.log(275, params.discountInfo.consume);
- return 1;
- },
- coupon() {
- // totalFee 为零的时候不做跳转
- if (this.orderDetail.parkingRecord.totalFeeInYuan === 0) return;
- // 如果没有电子券的话,提示用户
- if (this.coupons.length === 0 && this.source !== 'KIP') {
- uni.showToast({
- title: '暂无可使用的优惠券,请前往积分商城兑换优惠券'
- })
- return
- }
- this.$router.push({
- path: 'parkingFeeCoupon',
- });
- },
- paperCoupon() {
- if(!this.actualPayFee) {
- Toast('当前无需追加优惠')
- return;
- }
- // totalFee 为零的时候不做跳转
- if (this.orderDetail.parkingRecord.totalFeeInYuan === 0) return;
- this.$router.push({
- path: 'parkingFeePaperCoupon',
- query:{
- vehicleNo: this.$route.query.vehicleNo
- }
- });
- },
- duration() { },
- couponCount() { },
- // 重置倒计时
- resetCountDown() {
- this.$refs?.countDown?.reset();
- this.btnLoading = false;
- this.isPay = false;
- this.popup = false;
- this.$store.dispatch('order/orderInit', {
- gateId: this.$route.query?.gateId,
- vehicleNo: this.$route.query?.vehicleNo,
- endlessLoop: this.endlessLoop,
- callback: (res) => {
- this.orderInitCallBack(res)
- },
- })
- // 重新创建订单
- // this.createParkOrder();
- },
- //缴费说明隐藏显示
- togglePayinstruction() {
- this.isShowDescription = !this.isShowDescription;
- },
- // 积分修改框
- showPointsMathPopup() {
- // totalFee 为零的时候不做跳转
- if (this.orderDetail.parkingRecord.totalFeeInYuan === 0) return;
- if(this.integralDesc === '暂无可用积分'){
- return
- }
- this.popup = true;
- },
- cancelPointsMathPopup() {
- this.$store.dispatch('order/cancelPointsMath', () => {
- this.popup = false;
- });
- },
- savePointsMathPopup() {
- this.$store.dispatch('order/savePointsMath', () => {
- this.popup = false;
- });
- },
- // 获取成功缴费之后前往的页面
- getPagePath() {
- const { vehicleNo = '', unlicensed = '' } = this.$route.query
- // unlicensed: unlicensedVehicle(无牌车), licensedVehicle(有牌车)
- let pagePath = 'parkingFeeSuccess?vehicleNo=' + this.$route.query.vehicleNo
- // console.log('临时车流程', this.endlessLoop);
- if (vehicleNo.indexOf('临') > -1 && unlicensed === 'unlicensedVehicle') {
- pagePath = 'parkingFeeMsg?type=pay'
- }
- return pagePath
- },
- pointsMathCallback({type, message}) {
- // console.log(465, type);
- Toast({
- message: message,
- icon: 'none',
- });
- },
- //
- setDescription() {
- if ( this?.orderDetail?.parkInfo?.description.length > 0 ) {
- let reg = /[;;]/g;
- return this.orderDetail.parkInfo.description.replace(reg, '\r\n').replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>');
- }
- return ''
- },
- clearOrderTimeEvent() {
- if(this.orderTimeEvent) {
- clearInterval(this.orderTimeEvent);
- this.orderTime = null
- }
- },
- orderInitCallBack(res) {
- console.log('orderInitCallBack', res);
- try {
- setTimeout(() => {
- this.$store.dispatch('clearUnlicensed');
- }, 700);
- // 如果 无牌车扫码出场扫码 无需缴费,直接展示无需缴费页面
- if(/unlicensedOut/.test(res.code) && res?.unlicensed) {
- this.clearOrderTimeEvent()
- // console.log('818', {
- // type: 'pay',
- // ...this.$route.query,
- // });
- console.log('822822822822822', this.$route.query);
- this.$router.replace({
- path: 'parkingFeeMsg',
- query: {
- ...this.$route.query,
- type: 'pay',
- }
- });
- return
- }
- // 如果是无需缴费的话,提示用户无需缴费
- if (res?.orderDetail?.parkingRecord?.totalFee <= 0) {
- this.$store.dispatch('order/orderInitRule', res.orderDetail);
- setTimeout(() => {
- Dialog.alert({
- message: '当前无需缴费',
- confirmButtonColor: '#333',
- }).then(() => {
- this.clearOrderTimeEvent()
- this.$router.back()
- });
- }, 1000)
- return
- }
- if ( /CAR_NOT_FOUND|INOUT_FAILED/.test(res.code) ) {
- setTimeout(() => {
- this.clearOrderTimeEvent()
- this.$router.replace({
- path: 'parkingFeeMsg',
- query: {
- ...this.$route.query,
- type: 'outFail'
- }
- })
- }, 300)
- return;
- }
- if (/NOT_FOUND|PARKING_RECORD_NOT_FOUND/.test(res.code)) {
- // 当前车辆没有查到账单
- this.clearOrderTimeEvent()
- setTimeout(() => {
- this.$router.replace({
- path: 'parkingFeePayment',
- query: {
- ...this.$route.query,
- msg: res.langMessage,
- vehicleNo: this.$route.query.vehicleNo,
- },
- });
- }, 300)
- return
- }
- if (/LOCAL_PARK_ERROR|INTERNAL_SERVER_ERROR|VALIDATION_FAILED|PLEASE_SCAN_QRCODE/g.test(res.code)) {
- setTimeout(() => {
- this.clearOrderTimeEvent()
- this.$router.back()
- }, 3000)
- }
- } catch (err) {
- console.log('查费接口返回异常', err);
- }
- }
- },
- destroyed() {
- this.clearOrderTimeEvent()
- }
- };
|