|
@@ -1,3 +1,4 @@
|
|
|
+import { Toast } from "vant";
|
|
|
import { mapState } from 'vuex';
|
|
|
import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue';
|
|
|
import { cloneDeep } from 'lodash'
|
|
@@ -7,7 +8,7 @@ export default {
|
|
|
components: {uniNumberBox},
|
|
|
created() {
|
|
|
// 超限提示
|
|
|
- this.crossMessage();
|
|
|
+ // this.crossMessage();
|
|
|
},
|
|
|
// beforeRouteLeave(to, from, next) {
|
|
|
// console.log(251251251251251251, to, from,);
|
|
@@ -30,6 +31,7 @@ export default {
|
|
|
enableConsumeSplit: false,
|
|
|
maxReduceDiscount: 0,
|
|
|
reduceHours: 0,
|
|
|
+ remainPrice: 0
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -46,6 +48,32 @@ export default {
|
|
|
paperDiscountTime: state => state.order.paperDiscountTime,
|
|
|
paperDiscountFee: state => state.order.paperDiscountTime,
|
|
|
}),
|
|
|
+ // maxReduceDiscount() {
|
|
|
+ // const {maxOneDayCoupons,maxConsumeTime,maxonedaydiscountFee,maxOneTimeDiscountTime,remainConsumeTime,hourPrice,availableDiscountFee,oneTimeLimitation,oneDayLimitation,maxOneDayDiscountFee} = this.orderDetail.parkingRule;
|
|
|
+ // let newMaxConsumeTime = maxConsumeTime
|
|
|
+ // const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
|
|
|
+ // console.log(52, this.remainPrice)
|
|
|
+ // if ( this.remainPrice + (newMaxConsumeTime * hourPrice) > maxOneTimeDiscountFee ) {
|
|
|
+ // newMaxConsumeTime = (maxOneTimeDiscountFee - this.remainPrice) / hourPrice
|
|
|
+ // }
|
|
|
+ // return maxConsumeTime
|
|
|
+ // },
|
|
|
+ // remainPrice() {
|
|
|
+ // let remainPrice = this.usingTotalDiscount
|
|
|
+ // const {maxOneDayCoupons,maxConsumeTime,maxonedaydiscountFee,maxOneTimeDiscountTime,remainConsumeTime,hourPrice,availableDiscountFee,oneTimeLimitation,oneDayLimitation,maxOneDayDiscountFee} = this.orderDetail.parkingRule;
|
|
|
+ // let newMaxConsumeTime = maxConsumeTime
|
|
|
+ // if ( this.checkedList.indexOf('member') > -1) {
|
|
|
+ // remainPrice = remainPrice + this.memberGrade.discountFee
|
|
|
+ // }
|
|
|
+ // if ( this.checkedList.indexOf('reduces') > -1) {
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // return remainPrice
|
|
|
+ // }
|
|
|
},
|
|
|
mounted() {
|
|
|
try {
|
|
@@ -57,41 +85,191 @@ export default {
|
|
|
this.$router.back();
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ remainPrice() {
|
|
|
+ const {maxOneDayCoupons,maxonedaydiscountFee,maxOneTimeDiscountTime,remainConsumeTime,hourPrice,availableDiscountFee,oneTimeLimitation,oneDayLimitation,maxOneDayDiscountFee} = this.orderDetail.parkingRule;
|
|
|
+ const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
|
|
|
+ // console.log('hourPrice + this.remainPrice',this.remainPrice)
|
|
|
+ // 单日上限
|
|
|
+ // if ( oneDayLimitation && this.remainPrice >= maxOneDayDiscountFee ) {
|
|
|
+ // return Toast({
|
|
|
+ // message: `每日最高可抵扣${ maxOneDayDiscountFee }元`,
|
|
|
+ // icon: 'none',
|
|
|
+ // });
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // 单次上限限制
|
|
|
+ if ( oneTimeLimitation ) {
|
|
|
+ if( this.remainPrice <= maxOneTimeDiscountFee ) {
|
|
|
+ if ( this.isMember ) {
|
|
|
+ this.isMember = !this.isMember
|
|
|
+ }
|
|
|
+ if ( this.isReduces ) {
|
|
|
+ this.isReduces = false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.isMember = this.checkedList.indexOf('member') < 0
|
|
|
+ this.isReduces = this.checkedList.indexOf('reduces') < 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkedList() {
|
|
|
+ // const {hourPrice} = this.orderDetail.parkingRule;
|
|
|
+ // if ( this.checkedList.indexOf('reduces') > -1 ) {
|
|
|
+ // this.remainPrice = this.reduceHours * hourPrice + this.remainPrice
|
|
|
+ // } else {
|
|
|
+ // this.remainPrice = this.remainPrice - this.reduceHours * hourPrice
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
pageInit() {
|
|
|
+ this.remainPrice = this.usingTotalDiscount
|
|
|
if ( this.orderDetail?.parkingRule?.enableConsumeSplit ) {
|
|
|
this.enableConsumeSplit = this.orderDetail.parkingRule.enableConsumeSplit
|
|
|
}
|
|
|
-
|
|
|
this.checkedList = []
|
|
|
const {memberGrade = [],consume = [],memberLevelDiscount} = this.orderDetail.discountInfo;
|
|
|
+ const {maxConsumeTime} = this.orderDetail.parkingRule
|
|
|
this.memberGrade = {...memberGrade[0]}
|
|
|
this.consume = {...consume[0]}
|
|
|
- if ( JSON.stringify(this.memberGrade) !== '{}' && this.memberGrade.hasOwnProperty('selected') ? this.memberGrade.selected : this.memberGrade.defaultSelected) {
|
|
|
+ if ( JSON.stringify(this.memberGrade) !== '{}' && this.memberGrade.hasOwnProperty('selected') ? this.memberGrade.selected : this.memberGrade.defaultSelected ) {
|
|
|
this.checkedList.push('member')
|
|
|
this.isMember = false
|
|
|
}
|
|
|
- if ( JSON.stringify(this.consume) !== '{}' && this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected) {
|
|
|
+ if ( JSON.stringify(this.consume) !== '{}' && this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected ) {
|
|
|
this.checkedList.push('reduces')
|
|
|
this.isReduces = false
|
|
|
// 如果存在拆分逻辑的话
|
|
|
// this.consume.
|
|
|
}
|
|
|
- if ( this?.consume?.defaultDiscountTime ) {
|
|
|
- this.reduceHours = this.consume.hasOwnProperty('discountTime') ? this.consume.discountTime : this.consume.defaultDiscountTime
|
|
|
- }
|
|
|
- if ( this?.consume?.maxDiscountTime ) {
|
|
|
- this.maxReduceDiscount = this.consume.maxDiscountTime
|
|
|
+ this.reduceHours = this.consume.hasOwnProperty('discountFee') ? this.consume.discountFee / this.orderDetail.parkingRule.hourPrice : this.consume.defaultDiscountTime
|
|
|
+ if ( maxConsumeTime ) {
|
|
|
+ this.maxReduceDiscount = maxConsumeTime
|
|
|
}
|
|
|
this.oldCheckedList = [...this.checkedList]
|
|
|
},
|
|
|
setIsMemberDiscountDisabled() {
|
|
|
this.todayReduceDiscountMessage = '当日'
|
|
|
},
|
|
|
+ checkboxChange() {},
|
|
|
+ onReduceHoursChange( type ) {
|
|
|
+ if ( this.checkedList.indexOf('reduces') < 0 ) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const {maxOneDayCoupons,maxonedaydiscountFee,maxOneTimeDiscountTime,remainConsumeTime,hourPrice,availableDiscountFee,oneTimeLimitation,oneDayLimitation,maxOneDayDiscountFee} = this.orderDetail.parkingRule;
|
|
|
+ // console.log(133,this.reduceHours)
|
|
|
+ if ( type === 'plus') {
|
|
|
+ this.remainPrice = this.remainPrice + hourPrice
|
|
|
+ this.reduceHours = this.reduceHours + 1
|
|
|
+ const [isCrossMessage = false,maxReduceDiscount = this.maxReduceDiscount] = this.crossMessage()
|
|
|
+ if ( isCrossMessage ) {
|
|
|
+ this.remainPrice = this.remainPrice - hourPrice
|
|
|
+ this.reduceHours = this.reduceHours - 1
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if ( type === 'minus' ) {
|
|
|
+ this.reduceHours = this.reduceHours - 1
|
|
|
+ this.remainPrice = this.remainPrice - hourPrice
|
|
|
+ return
|
|
|
+ }
|
|
|
+ },
|
|
|
+ memberClick() {
|
|
|
+ const {maxConsumeTime} = this.orderDetail.parkingRule;
|
|
|
+ if ( this.checkedList.indexOf('member') > -1 ) {
|
|
|
+ this.remainPrice = this.memberGrade.discountFee + this.remainPrice
|
|
|
+ } else if ( !this.isMember ) {
|
|
|
+ this.remainPrice = this.remainPrice - this.memberGrade.discountFee
|
|
|
+ this.maxReduceDiscount = maxConsumeTime
|
|
|
+ }
|
|
|
+ const [isCrossMessage = false,maxReduceDiscount = this.maxReduceDiscount] = this.crossMessage()
|
|
|
+ if ( isCrossMessage ) {
|
|
|
+ this.checkedList = this.checkedList.filter(elm => elm !== 'member')
|
|
|
+ this.remainPrice = this.remainPrice - this.memberGrade.discountFee
|
|
|
+ this.isMember = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ reducesClick() {
|
|
|
+ const {maxOneTimeDiscountTime,hourPrice,oneTimeLimitation,maxConsumeTime,oneDayLimitation,maxOneDayDiscountFee} = this.orderDetail.parkingRule;
|
|
|
+ const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
|
|
|
+ /*if ( oneTimeLimitation && this.remainPrice >= maxOneTimeDiscountFee ) {
|
|
|
+ this.checkedList = this.checkedList.filter(elm => elm !== 'reduces')
|
|
|
+ Toast({
|
|
|
+ message: `超出抵扣上限,每次最高可抵扣${ maxOneTimeDiscountTime }小时`,
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ return false
|
|
|
+ }*/
|
|
|
+ const reduceHours = ( maxOneTimeDiscountFee - this.remainPrice ) / hourPrice
|
|
|
+ if ( this.checkedList.indexOf('reduces') > -1 ) {
|
|
|
+ this.remainPrice = hourPrice + this.remainPrice
|
|
|
+ this.maxReduceDiscount = maxConsumeTime
|
|
|
+ } else {
|
|
|
+ this.remainPrice = this.remainPrice - hourPrice
|
|
|
+ this.maxReduceDiscount = maxConsumeTime
|
|
|
+ this.reduceHours = maxConsumeTime
|
|
|
+ }
|
|
|
+ const [isCrossMessage = false,maxReduceDiscount = 0] = this.crossMessage()
|
|
|
+ if ( isCrossMessage ) {
|
|
|
+ // console.log(215, maxReduceDiscount)
|
|
|
+ // console.log(207, this.reduceHours)
|
|
|
+ // this.maxReduceDiscount = maxReduceDiscount ? 0 : maxReduceDiscount * -1
|
|
|
+ // console.log(217, this.maxReduceDiscount)
|
|
|
+ this.remainPrice = this.remainPrice - maxReduceDiscount * hourPrice
|
|
|
+ //
|
|
|
+ // this.reduceHours = this.maxReduceDiscount
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 超限提示
|
|
|
+ crossMessage() {
|
|
|
+ const {maxOneTimeDiscountTime,hourPrice,oneTimeLimitation,oneDayLimitation,maxOneDayDiscountFee} = this.orderDetail.parkingRule;
|
|
|
+ const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
|
|
|
+ // 单日上限
|
|
|
+ if ( oneDayLimitation && this.remainPrice >= maxOneDayDiscountFee ) {
|
|
|
+ Toast({
|
|
|
+ message: `每日最高可抵扣${ maxOneDayDiscountFee }元`,
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ return [true,( maxOneDayDiscountFee - (this.reduceHours - 1) * hourPrice ) / hourPrice]
|
|
|
+ }
|
|
|
+ // 单次上限限制
|
|
|
+ console.log(234, this.remainPrice, maxOneTimeDiscountFee,);
|
|
|
+ if ( oneTimeLimitation && this.remainPrice >= maxOneTimeDiscountFee ) {
|
|
|
+ Toast({
|
|
|
+ message: `超出抵扣上限,每次最高可抵扣${ maxOneTimeDiscountTime }小时`,
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ // return [true,( maxOneTimeDiscountFee - (this.reduceHours - 1) * hourPrice ) / hourPrice]
|
|
|
+ return [true, ( this.remainPrice - maxOneTimeDiscountFee) / hourPrice]
|
|
|
+ }
|
|
|
+ return [false,0]
|
|
|
+ },
|
|
|
+ // 验证当前的选项是否可选择
|
|
|
+ isCheck( callback ) {
|
|
|
+ if ( !this?.orderDetail?.parkingRule ) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // const {parkInfo,parkingRule,discountInfo} = this.orderDetail
|
|
|
+ const {maxOneTimeDiscountTime,maxOneDayDiscountFee,oneTimeLimitation,oneDayLimitation,hourPrice,remainConsumeTime} = this.orderDetail.parkingRule
|
|
|
+ // 浦东
|
|
|
+ if ( this.parkMallCode === 1 ) {
|
|
|
+ const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
|
|
|
+ const remainConsumeTimeFee = remainConsumeTime * hourPrice
|
|
|
+
|
|
|
+ // TODO: 统计纸质优惠券的总金额, usingTotalDiscount - 纸质优惠券的总金额,才是用户当前订单使用的优惠总数
|
|
|
+ this.isMember = !( this.usingTotalDiscount - this.paperDiscountFee < ( oneTimeLimitation ? maxOneTimeDiscountFee : maxOneDayDiscountFee ) && this.memberLevelDiscount )
|
|
|
+ this.isReduces = !( this.usingTotalDiscount - this.paperDiscountFee < ( oneTimeLimitation ? maxOneTimeDiscountFee : maxOneDayDiscountFee ) && this.enableConsume )
|
|
|
+ }
|
|
|
+ if ( callback ) callback()
|
|
|
+ },
|
|
|
+ reducesChange( value ) {
|
|
|
+ // console.log(149,value)
|
|
|
+ },
|
|
|
async confirm() {
|
|
|
let orderDetail = cloneDeep(this.orderDetail)
|
|
|
// 如果初次进来操作的跟原来的不一样则重新计算优惠
|
|
|
- if ( this.checkedList.length !== this.checkedTotal ) {
|
|
|
+ if ( this.checkedList.length !== this.checkedTotal || true ) {
|
|
|
['member','reduces'].forEach(key => {
|
|
|
if ( key === 'member' ) {
|
|
|
this.memberGrade = {
|
|
@@ -115,42 +293,6 @@ export default {
|
|
|
this.$router.back();
|
|
|
}
|
|
|
},
|
|
|
- checkboxChange() {},
|
|
|
- // todayReduceDiscountMessage() {},
|
|
|
- // 验证当前的选项是否可选择
|
|
|
- isCheck( callback ) {
|
|
|
- const {parkInfo,parkingRule,discountInfo} = this.orderDetail
|
|
|
- const {maxOneTimeDiscountTime,maxOneDayDiscountFee,oneTimeLimitation,oneDayLimitation,hourPrice,remainConsumeTime} = parkingRule
|
|
|
- console.log(129,this.parkMallCode)
|
|
|
- // 浦东
|
|
|
- if ( this.parkMallCode === 1 ) {
|
|
|
- const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
|
|
|
- const remainConsumeTimeFee = remainConsumeTime * hourPrice
|
|
|
- console.log(133,this.usingTotalDiscount,remainConsumeTimeFee,maxOneTimeDiscountFee)
|
|
|
- console.log('this.isMember',{
|
|
|
- usingTotalDiscount: this.usingTotalDiscount,remainConsumeTimeFee,maxOneTimeDiscountFee,memberLevelDiscount: this.memberLevelDiscount
|
|
|
- })
|
|
|
-
|
|
|
- // TODO: 统计纸质优惠券的总金额, usingTotalDiscount - 纸质优惠券的总金额,才是用户当前订单使用的优惠总数
|
|
|
- this.isMember = !( this.usingTotalDiscount - this.paperDiscountFee < ( oneTimeLimitation ? maxOneTimeDiscountFee : maxOneDayDiscountFee ) && this.memberLevelDiscount )
|
|
|
- this.isReduces = !( this.usingTotalDiscount - this.paperDiscountFee < ( oneTimeLimitation ? maxOneTimeDiscountFee : maxOneDayDiscountFee ) && this.enableConsume )
|
|
|
- }
|
|
|
- // if ( this.checkedTotal === 2 ) {
|
|
|
- // if ( this.checkedList.indexOf(type) > -1 ) {
|
|
|
- //
|
|
|
- // } else {
|
|
|
- // // 未选中
|
|
|
- //
|
|
|
- // }
|
|
|
- // }
|
|
|
- if ( callback ) callback()
|
|
|
- },
|
|
|
- reducesChange( value ) {
|
|
|
- console.log(value)
|
|
|
- },
|
|
|
- crossMessage() {
|
|
|
-
|
|
|
- }
|
|
|
},
|
|
|
|
|
|
};
|