|
@@ -1,20 +1,29 @@
|
|
|
-import {Toast} from "vant";
|
|
|
-import {mapState} from 'vuex';
|
|
|
+import { Toast } from "vant";
|
|
|
+import { mapState } from 'vuex';
|
|
|
import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue';
|
|
|
-import {cloneDeep} from 'lodash'
|
|
|
+import { cloneDeep } from 'lodash'
|
|
|
import baseMixins from '../mixins/base';
|
|
|
-import {waitByTime} from '@/utils'
|
|
|
-import uni from '@/utils/uniHooks';
|
|
|
+// import uni from '@/utils/uniHooks';
|
|
|
// const app = getApp()
|
|
|
export default {
|
|
|
mixins: [baseMixins],
|
|
|
- components: {uniNumberBox},
|
|
|
+ components: { uniNumberBox },
|
|
|
+ created() {
|
|
|
+ // 超限提示
|
|
|
+ // this.crossMessage();
|
|
|
+ },
|
|
|
+ // beforeRouteLeave(to, from, next) {
|
|
|
+ // console.log(251251251251251251, to, from,);
|
|
|
+ // // 设置下一个路由的 meta
|
|
|
+ // to.meta.keepAlive = true; // 让 A 不缓存,即刷新
|
|
|
+ // next();
|
|
|
+ // },
|
|
|
data() {
|
|
|
return {
|
|
|
checkedList: [], // 已选优惠列表
|
|
|
oldCheckedList: [], // 已选优惠列表备份
|
|
|
- isMember: false, // member
|
|
|
- isReduces: false, // reduces
|
|
|
+ isMember: true, // member
|
|
|
+ isReduces: true, // reduces
|
|
|
memberLevelReduce: [],
|
|
|
memberGrade: {},
|
|
|
consume: {},
|
|
@@ -25,12 +34,7 @@ export default {
|
|
|
maxReduceDiscount: 0,
|
|
|
reduceHours: 0,
|
|
|
remainPrice: 0,
|
|
|
- reduceFee: 0, // 消费减免金额
|
|
|
isInit: 1,
|
|
|
- isDiscountDisabled: false,
|
|
|
- remainReduceTime: 0,
|
|
|
- //
|
|
|
- usingTotalDiscount: 0
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -40,14 +44,13 @@ export default {
|
|
|
groupId: (state) => state.groupId,
|
|
|
enableConsume: (state) => state.order.enableConsume,
|
|
|
actualPayFee: (state) => state.order.actualPayFee,
|
|
|
- // usingTotalDiscount: (state) => state.order.usingTotalDiscount,
|
|
|
+ usingTotalDiscount: (state) => state.order.usingTotalDiscount,
|
|
|
memberLevelDiscount: (state) => state.order.memberLevelDiscount,
|
|
|
checkedTotal: (state) => state.order.checkedTotal,
|
|
|
parkMallCode: (state) => state.order.parkMallCode,
|
|
|
paperDiscountTime: (state) => state.order.paperDiscountTime,
|
|
|
- // paperDiscountFee: (state) => state.order.paperDiscountTime,
|
|
|
+ paperDiscountFee: (state) => state.order.paperDiscountTime,
|
|
|
availableDiscountFee: (state) => state.order.availableDiscountFee,
|
|
|
- paperDiscountFee: (state) => state.order.paperDiscountFee, // 纸质优惠券
|
|
|
}),
|
|
|
enableConsumeNonSplit() {
|
|
|
return this.orderDetail.parkingRule.enableConsumeNonSplit
|
|
@@ -57,13 +60,55 @@ export default {
|
|
|
if (this.parkMallCode === 7 || this.enableConsumeNonSplit) {
|
|
|
return this.reduceHours || 0
|
|
|
}
|
|
|
- // 如果不存消费减免,默认展示 0
|
|
|
+ // 如果不存消费减免,默认展示0
|
|
|
if (JSON.stringify(this.consume) === '{}') {
|
|
|
return 0
|
|
|
}
|
|
|
// 如果存在消费减免并且是可拆分的,则设置最低拆分单位是 1
|
|
|
return 1
|
|
|
},
|
|
|
+ stepperMax() {
|
|
|
+ if (this.parkMallCode === 4 || this.parkMallCode === 6) {
|
|
|
+ // 如果存在消费减免并且是可拆分的,则设置最低拆分单位是 1
|
|
|
+ return this.maxReduceDiscount
|
|
|
+ }
|
|
|
+ // 如果是合集车场,不存在拆分,默认返回用户可使用的消费抵扣时间
|
|
|
+ if (this.parkMallCode === 7 || this.enableConsumeNonSplit) {
|
|
|
+ return this.reduceHours || 0
|
|
|
+ }
|
|
|
+ // 如果不存消费减免,默认展示0
|
|
|
+ if (JSON.stringify(this.consume) === '{}') {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ // 如果存在消费减免并且是可拆分的,则设置最低拆分单位是 1
|
|
|
+ return this.maxReduceDiscount
|
|
|
+ },
|
|
|
+ // 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
|
|
|
+ // }
|
|
|
// 消费减免(拆分部分)提示文本
|
|
|
reduceSplitMessage() {
|
|
|
// console.log(106, this.reduceHours);
|
|
@@ -94,12 +139,12 @@ export default {
|
|
|
|
|
|
// 静安存在消费减免时
|
|
|
if (this.parkMallCode === 0) {
|
|
|
- return `今日可减免${this.consume.remainConsumeTime}小时`;
|
|
|
+ return `今日可减免${this.consume.defaultDiscountTime}小时`;
|
|
|
}
|
|
|
|
|
|
// 沈阳提示信息
|
|
|
if (this.parkMallCode === 4 || this.parkMallCode === 6) {
|
|
|
- return `未达上限时今日可减免${this.orderDetail.parkingRule.remainConsumeTime}小时`;
|
|
|
+ return `未达上限时今日可减免${this.stepperMax}小时`;
|
|
|
}
|
|
|
if (this.consume.defaultDiscountTime > this.orderDetail.parkingRule.remainConsumeTime) {
|
|
|
return `消费已满${this.consume.redeemSalesAmount}元,减免${this.consume.defaultDiscountTime}小时。超出优惠上限,可减免${this.maxReduceDiscount}小时,${this.reduceSplitMessage}可优惠${this.reducesDiscountFee}元`
|
|
@@ -107,221 +152,409 @@ export default {
|
|
|
return `消费已满${this.consume.redeemSalesAmount}元,减免${this.consume.defaultDiscountTime}小时。${this.reduceSplitMessage}可优惠${this.reducesDiscountFee}元`
|
|
|
}
|
|
|
},
|
|
|
- async mounted() {
|
|
|
+ mounted() {
|
|
|
try {
|
|
|
- await waitByTime(200);
|
|
|
-
|
|
|
- const {usingTotalDiscount, memberGrade = [], consume = []} = this.orderDetail.discountInfo;
|
|
|
- if (memberGrade.length) {
|
|
|
- this.memberGrade = memberGrade[0]
|
|
|
- }
|
|
|
- if (consume.length) {
|
|
|
- this.consume = consume[0]
|
|
|
- }
|
|
|
- // 开始初始化
|
|
|
- this.pageInit()
|
|
|
+ this.isCheck(() => this.pageInit()); // 验证是否可选
|
|
|
} catch (err) {
|
|
|
- this.$router.back()
|
|
|
+ // console.log(err);
|
|
|
+ this.$router.back();
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+ watch: {
|
|
|
+ remainPrice() {
|
|
|
+ const { maxOneDayCoupons, maxonedaydiscountFee, maxOneTimeDiscountTime, remainConsumeTime, hourPrice, 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;
|
|
|
+ // console.log(109);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.isMember = this.checkedList.indexOf('member') < 0;
|
|
|
+ this.isReduces = this.checkedList.indexOf('reduces') < 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkedList(newVal, oldVal) {
|
|
|
+ // console.log(190, { newVal, oldVal });
|
|
|
+ if ((this.parkMallCode === 4 || this.parkMallCode === 6) && this.isInit > 1) {
|
|
|
+ const { maxOneDayCoupons, maxonedaydiscountFee, maxOneTimeDiscountTime, remainConsumeTime, hourPrice, oneTimeLimitation, oneDayLimitation, maxOneDayDiscountFee } = this.orderDetail.parkingRule;
|
|
|
+ // 会员等级选中了
|
|
|
+ if (newVal.indexOf('member') > -1 && oldVal.indexOf('member') < 0) {
|
|
|
+ // console.log(193, '会员等级选中了');
|
|
|
+ // this.remainPrice = this.remainPrice + this.memberGrade.discountFee;
|
|
|
+ // this.maxReduceDiscountInit();
|
|
|
+ }
|
|
|
+ if (oldVal.indexOf('member') > -1 && newVal.indexOf('member') < 0) {
|
|
|
+ // 会员等级未选中了
|
|
|
+ // console.log(193, '会员等级未选中了');
|
|
|
+ // this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
|
|
|
+ // this.maxReduceDiscountInit();
|
|
|
+ }
|
|
|
+ // 消费减免选中了
|
|
|
+ if (newVal.indexOf('reduces') > -1 && oldVal.indexOf('reduces') < 0) {
|
|
|
+ // console.log(193, '消费减免选中了');
|
|
|
+ this.consume.discountFee = this.reduceHours * hourPrice
|
|
|
+ this.remainPrice = this.remainPrice + this.consume.discountFee;
|
|
|
+ }
|
|
|
+ if (oldVal.indexOf('reduces') > -1 && newVal.indexOf('reduces') < 0) {
|
|
|
+ // 消费减免未选中了
|
|
|
+ // console.log(193, '消费减免未选中了');
|
|
|
+ this.consume.discountFee = this.reduceHours * hourPrice
|
|
|
+ this.remainPrice = this.remainPrice - this.consume.discountFee;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 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: {
|
|
|
- async pageInit() {
|
|
|
- await waitByTime(200);
|
|
|
- const {hourPrice = 0, remainConsumeTime = 0, maxOneTimeDiscountTime = 0} = this.orderDetail.parkingRule;
|
|
|
- const {usingTotalDiscount} = this.orderDetail.discountInfo;
|
|
|
- this.usingTotalDiscount = usingTotalDiscount
|
|
|
- /*页面的默认展示*/
|
|
|
- /*会员等级减免是否选中*/
|
|
|
+ pageInit() {
|
|
|
+ if (this.orderDetail?.parkingRule?.enableConsumeSplit) {
|
|
|
+ this.enableConsumeSplit = this.orderDetail.parkingRule.enableConsumeSplit;
|
|
|
+ }
|
|
|
+ this.checkedList = [];
|
|
|
+ const { memberGrade = [{}], consume = [], memberLevelDiscount, points = [{}] } = this.orderDetail.discountInfo;
|
|
|
+ const { maxConsumeTime, remainConsumeTime, hourPrice } = this.orderDetail.parkingRule;
|
|
|
+ // 如果积分存在的话,则移除积分的优惠
|
|
|
+ if (JSON.stringify(points) !== {}) {
|
|
|
+ this.remainPrice = this.parkMallCode !== 1 ? this.usingTotalDiscount - points[0].discountFee : this.usingTotalDiscount;
|
|
|
+ }
|
|
|
+ this.memberGrade = { ...memberGrade[0] };
|
|
|
+ this.consume = { ...consume[0] };
|
|
|
if (JSON.stringify(this.memberGrade) !== '{}' && this.memberGrade && this.memberGrade.hasOwnProperty('selected') ? this.memberGrade.selected : this.memberGrade.defaultSelected) {
|
|
|
this.checkedList.push('member');
|
|
|
}
|
|
|
- /*消费减免是否选中*/
|
|
|
+ this.isMember = JSON.stringify(this.memberGrade) === '{}';
|
|
|
+ // console.log(140, this.consume, this.consume.hasOwnProperty('selected'), JSON.stringify(this.consume) !== '{}' && this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected, this.consume.defaultSelected)
|
|
|
+ // console.log(143, JSON.stringify(this.consume) !== '{}' && this.consume.hasOwnProperty('selected') ? this.consume.selected !== undefined : this.consume.defaultSelected !== undefined);
|
|
|
if (JSON.stringify(this.consume) !== '{}' && this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected !== undefined) {
|
|
|
this.checkedList.push('reduces');
|
|
|
+ // this.isReduces = false;
|
|
|
+ // 如果存在拆分逻辑的话
|
|
|
+ // this.consume.
|
|
|
+ }
|
|
|
+ this.isReduces = this.consume.hasOwnProperty('selected') || this.consume.hasOwnProperty('defaultSelected') ? false : true;
|
|
|
+ this.reduceHours = this.consume.hasOwnProperty('discountFee') ? this.consume.discountFee / this.orderDetail.parkingRule.hourPrice : this.consume.defaultDiscountTime;
|
|
|
+ if (JSON.stringify(this.consume) !== '{}') {
|
|
|
+ const isSelected = this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected;
|
|
|
+ this.maxReduceDiscount = this.consume.hasOwnProperty('discountFee') ? this.consume.discountFee / hourPrice : this.consume.defaultDiscountTime;
|
|
|
+ // const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee) / hourPrice
|
|
|
+ // if (remainingLimitToIncrease) {
|
|
|
+ // this.maxReduceDiscountInit();
|
|
|
+ // }
|
|
|
+ this.maxReduceDiscountInit();
|
|
|
+
|
|
|
+ }
|
|
|
+ this.oldCheckedList = [...this.checkedList];
|
|
|
+ // 如果是杭州、沈阳可以选择
|
|
|
+ // if (this.parkMallCode === 2 || this.parkMallCode === 4 || this.parkMallCode === 7) {
|
|
|
+ // this.isReduces = JSON.stringify(this.consume) === '{}';
|
|
|
+ // }
|
|
|
+ // https://kerryprops.atlassian.net/browse/SCRM-4016?focusedCommentId=117842: 只要存在消费减免情况,都允许用户进行操作
|
|
|
+ this.isReduces = JSON.stringify(this.consume) === '{}';
|
|
|
+ this.discountInit()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isInit = this.isInit + 1
|
|
|
+
|
|
|
+ }, 300)
|
|
|
+ },
|
|
|
+ discountInit() {
|
|
|
+ if(this.parkMallCode === 4 || this.parkMallCode === 6 ) {
|
|
|
+ const { maxConsumeTime, remainConsumeTime, hourPrice } = this.orderDetail.parkingRule;
|
|
|
+ const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee) / hourPrice
|
|
|
+ if(!remainingLimitToIncrease) {
|
|
|
+ this.isMember = this.memberGrade.hasOwnProperty('selected')? !this.memberGrade.selected : !this.memberGrade.defaultSelected
|
|
|
+ this.isReduces = this.consume.hasOwnProperty('selected')? !this.consume.selected : !this.consume.defaultSelected
|
|
|
+ }
|
|
|
}
|
|
|
- // 已用优惠时长 已经拿到了 usingTotalDiscount
|
|
|
- // 剩余可用优惠时长 remainConsumeTime
|
|
|
- /*
|
|
|
- 1、浦东每次上限处理
|
|
|
- 如果 剩余可用优惠时长 > 当前可用上限时间
|
|
|
- 则
|
|
|
- 剩余可用优惠时长 = 当前可用上限时间
|
|
|
- */
|
|
|
- if (this.parkMallCode === 1 && remainConsumeTime > maxOneTimeDiscountTime) {
|
|
|
- this.remainConsumeTime = maxOneTimeDiscountTime;
|
|
|
- }
|
|
|
- if (this.parkMallCode === 1 && remainConsumeTime > maxOneTimeDiscountTime) {
|
|
|
- this.remainConsumeTime = maxOneTimeDiscountTime;
|
|
|
- }
|
|
|
- // 沈阳、天津上限处理
|
|
|
- if (this.parkMallCode === 4 || this.parkMallCode === 6) {
|
|
|
- this.remainReduceTime = this.consume.maxDiscountTime;
|
|
|
+ },
|
|
|
+ maxReduceDiscountInit() {
|
|
|
+ const {maxDiscountTime, couponCodes, defaultDiscountTime} = this.consume
|
|
|
+ if(JSON.stringify(this.consume) === '{}' || !this.consume.hasOwnProperty('redeemSalesAmount')) {
|
|
|
+ return
|
|
|
}
|
|
|
-
|
|
|
- // 消费减免可拆分上限
|
|
|
- this.maxReduceDiscount = this.consume.defaultDiscountTime;
|
|
|
- if (this.maxReduceDiscount > remainConsumeTime) {
|
|
|
- this.maxReduceDiscount = remainConsumeTime;
|
|
|
+ const { maxConsumeTime, remainConsumeTime, hourPrice, maxOneTimeDiscountTime } = this.orderDetail.parkingRule;
|
|
|
+
|
|
|
+ const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee || 0) / hourPrice;
|
|
|
+ // 如果是浦东的话, 重新计算优惠
|
|
|
+ if (this.parkMallCode === 1) {
|
|
|
+ /*
|
|
|
+ * 消费减免真实可用优惠的计算逻辑
|
|
|
+ * 消费减免可能选择的情况: X
|
|
|
+ * 其余已使用的优惠:W
|
|
|
+ * 当前可使用优惠的上限:B
|
|
|
+ * 当前消费减免最高可用优惠:D = B - ( W - X )
|
|
|
+ * 当前消费减免用户可用优惠上限:Z
|
|
|
+ * 消费减免真实可用优惠: D > Z ? Z : D
|
|
|
+ * */
|
|
|
+ const isSelected = this.checkedList.indexOf('reduces') > -1;
|
|
|
+ // const reduceHours = isSelected ? this.reduceHours : 0
|
|
|
+ const remainHour = this.remainPrice / hourPrice
|
|
|
+ // 当前订单的总可用余额: remainConsumeTime
|
|
|
+ const couponCodesLength = couponCodes?.split('#')?.length || 0; // 上限
|
|
|
+ // const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
|
|
|
+ // 实际上限
|
|
|
+ // remainConsumeTime - this.reduceHours 剩余优惠
|
|
|
+ // couponCodesLength - this.reduceHours 剩余上限
|
|
|
+ // 实际上限 = 剩余优惠 <= 剩余上限
|
|
|
+ // this.maxReduceDiscount = remainConsumeTime - this.reduceHours <= couponCodesLength - this.reduceHours
|
|
|
+ // 转化公式之后
|
|
|
+ // this.maxReduceDiscount = remainConsumeTime > couponCodesLength ? couponCodesLength : remainConsumeTime
|
|
|
+ // console.log(319, this.remainPrice >= maxOneTimeDiscountFee)
|
|
|
+ // this.maxReduceDiscount = couponCodesLength > defaultDiscountTime ? defaultDiscountTime> remainHour > defaultDiscountTime ? defaultDiscountTime : remainHour : remainHour > couponCodesLength?couponCodesLength:remainHour;
|
|
|
+ this.maxReduceDiscount = defaultDiscountTime;
|
|
|
+ // 323323323 3 2 2 2
|
|
|
+ // 323323323 3 1 2 1
|
|
|
+ // console.log('323323323', couponCodesLength, remainHour, defaultDiscountTime, this.reduceHours )
|
|
|
+
|
|
|
+ // this.reduceHours = this.maxReduceDiscount
|
|
|
+ !isSelected && remainConsumeTime - remainHour > 0 && defaultDiscountTime && (this.reduceHours = 1)
|
|
|
+ // remainConsumeTime - remainHour > 0 && defaultDiscountTime && (this.reduceHours = 1)
|
|
|
+ return
|
|
|
+ // 如果超过限制就置灰
|
|
|
+ // const maxOneTimeDiscountTimeFee = (couponCodes.split('#').length) * hourPrice
|
|
|
+ // const isSelected = this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected;
|
|
|
+ // const isCheckedListSelected = this.checkedList.indexOf('consume') > -1;
|
|
|
+ // if(maxOneTimeDiscountTimeFee > this.remainPrice) {
|
|
|
+ // // 优惠计算公式: 剩余可用优惠 + 已经选择的优惠 = 总的消费减免的优惠(小时)
|
|
|
+ // const maxReduceDiscount = (maxOneTimeDiscountTimeFee - this.remainPrice) / hourPrice + (isSelected ? this.reduceHours : 0)
|
|
|
+ // this.maxReduceDiscount = maxReduceDiscount > maxOneTimeDiscountTime ? maxOneTimeDiscountTime: maxReduceDiscount
|
|
|
+ // !isSelected && (this.reduceHours = this.maxReduceDiscount)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // if(maxOneTimeDiscountTimeFee == this.remainPrice && !isSelected && isCheckedListSelected) {
|
|
|
+ // this.maxReduceDiscount = 0
|
|
|
+ // this.reduceHours = this.maxReduceDiscount
|
|
|
+ // return
|
|
|
+ // } else {
|
|
|
+ // this.maxReduceDiscount = this.reduceHours
|
|
|
+ // }
|
|
|
+ return
|
|
|
}
|
|
|
- this.reduceHours = this.maxReduceDiscount;
|
|
|
-
|
|
|
- // 反显处理
|
|
|
- if (this.consume.discountFee) {
|
|
|
- this.reduceHours = (this.consume.discountFee / hourPrice) || 0;
|
|
|
+ if (!remainingLimitToIncrease) {
|
|
|
+ // if(!this.consume.selected) {
|
|
|
+ // this.isReduces = true
|
|
|
+ // }
|
|
|
+ return
|
|
|
}
|
|
|
-
|
|
|
- // 浦东上限控制
|
|
|
- if (this.parkMallCode === 1 || this.parkMallCode === 4 || this.parkMallCode === 6) {
|
|
|
- if (this.memberGrade.discountFee) {
|
|
|
- this.maxReduceDiscount = remainConsumeTime - (this.memberGrade.discountFee / hourPrice);
|
|
|
- if ((this.parkMallCode === 4 || this.parkMallCode === 6) && this.maxReduceDiscount > this.consume.defaultDiscountTime) {
|
|
|
- this.maxReduceDiscount = this.consume.defaultDiscountTime;
|
|
|
- }
|
|
|
- }
|
|
|
- // this.reduceHours = this.maxReduceDiscount;
|
|
|
- if (this.crossMessage()) {
|
|
|
- if (this.isCheck('reduces')) {
|
|
|
- this.maxReduceDiscount = this.reduceHours;
|
|
|
- } else {
|
|
|
- this.maxReduceDiscount = 0;
|
|
|
- this.reduceHours = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!this.isCheck('reduces')) {
|
|
|
- this.reduceHours = this.maxReduceDiscount;
|
|
|
- }
|
|
|
- }
|
|
|
+ this.isReduces = false
|
|
|
+ if (this.remainPrice >= this.availableDiscountFee) {
|
|
|
+ // console.log('过大', this.maxReduceDiscount, remainingLimitToIncrease);
|
|
|
+ this.maxReduceDiscount = this.maxReduceDiscount - remainingLimitToIncrease > maxDiscountTime ? maxDiscountTime : this.maxReduceDiscount - remainingLimitToIncrease
|
|
|
+ this.consume.discountFee = this.consume.discountFee - (remainingLimitToIncrease * hourPrice)
|
|
|
+ this.remainPrice = this.remainPrice - (remainingLimitToIncrease * hourPrice);
|
|
|
+ this.reduceHours = this.maxReduceDiscount
|
|
|
+ }
|
|
|
+ if(this.checkedList.indexOf('reduces') < 0) {
|
|
|
+ // 如果没被选中
|
|
|
+ this.maxReduceDiscount = remainingLimitToIncrease > maxDiscountTime ? maxDiscountTime : remainingLimitToIncrease
|
|
|
+ this.reduceHours = this.maxReduceDiscount
|
|
|
+ this.consume.discountFee = remainingLimitToIncrease * hourPrice
|
|
|
+ return
|
|
|
}
|
|
|
- },
|
|
|
- discountInit() {
|
|
|
-
|
|
|
- },
|
|
|
- maxReduceDiscountInit() {
|
|
|
+ // 如果被选中
|
|
|
+ // console.log('过小?', this.consume.discountFee, remainingLimitToIncrease);
|
|
|
+ const maxReduceDiscount = this.consume.discountFee / hourPrice + remainingLimitToIncrease
|
|
|
+ // console.log('过小', maxReduceDiscount);
|
|
|
+ this.maxReduceDiscount = maxReduceDiscount <= remainConsumeTime ? maxReduceDiscount : remainConsumeTime
|
|
|
+ this.maxReduceDiscount = this.maxReduceDiscount > maxDiscountTime ? maxDiscountTime: this.maxReduceDiscount
|
|
|
},
|
|
|
setIsMemberDiscountDisabled() {
|
|
|
this.todayReduceDiscountMessage = '当日';
|
|
|
},
|
|
|
- async checkboxChange() {
|
|
|
- const {hourPrice = 0, remainConsumeTime = 0, maxOneTimeDiscountTime = 0} = this.orderDetail.parkingRule;
|
|
|
- // const {usingTotalDiscount} = this.orderDetail.discountInfo;
|
|
|
- // 浦东上限控制
|
|
|
- if (this.parkMallCode === 1) {
|
|
|
- if (this.isCheck('member')) {
|
|
|
- this.maxReduceDiscount = remainConsumeTime - ((this.usingTotalDiscount - this.paperDiscountFee - this.memberGrade?.discountFee || 0) / hourPrice)
|
|
|
- this.usingTotalDiscount -= this.reduceHours * hourPrice
|
|
|
- await waitByTime()
|
|
|
- this.reduceHours = this.maxReduceDiscount
|
|
|
- this.usingTotalDiscount += this.reduceHours * hourPrice
|
|
|
- } else {
|
|
|
- if (this.isCheck('reduces')) {
|
|
|
- this.maxReduceDiscount = remainConsumeTime - ((this.usingTotalDiscount - this.paperDiscountFee - this.reduceFee) / hourPrice);
|
|
|
- this.reduceHours = this.maxReduceDiscount;
|
|
|
- this.usingTotalDiscount += this.reduceHours * hourPrice
|
|
|
- } else {
|
|
|
- this.usingTotalDiscount -= this.reduceHours * hourPrice
|
|
|
- this.maxReduceDiscount = remainConsumeTime - ((this.usingTotalDiscount - this.paperDiscountFee) / hourPrice);
|
|
|
- this.reduceHours = this.maxReduceDiscount;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- await waitByTime()
|
|
|
- // 沈阳、天津上限控制
|
|
|
- if (this.parkMallCode === 4 || this.parkMallCode === 6) {
|
|
|
- if (this.isCheck('member')) {
|
|
|
- this.usingTotalDiscount += this.memberGrade.discountFee
|
|
|
- } else {
|
|
|
- this.usingTotalDiscount -= this.memberGrade.discountFee
|
|
|
- this.maxReduceDiscount = this.consume?.defaultDiscountTime;
|
|
|
- }
|
|
|
- }
|
|
|
- console.log(2525, this.reduceHours, this.maxReduceDiscount)
|
|
|
- // 超限设置
|
|
|
- this.crossMessage();
|
|
|
- },
|
|
|
+ checkboxChange() { },
|
|
|
onReduceHoursChange(type) {
|
|
|
- if (this.isCheck('reduces')) {
|
|
|
- return
|
|
|
- }
|
|
|
- const {hourPrice = 0, remainConsumeTime = 0, maxOneTimeDiscountTime = 0} = this.orderDetail.parkingRule;
|
|
|
- if (type === 'minus') {
|
|
|
- this.reduceHours = this.reduceHours - 1
|
|
|
- this.usingTotalDiscount -= hourPrice
|
|
|
- console.log(276, this.reduceHours)
|
|
|
+ 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)
|
|
|
+ // console.log(166, this.maxReduceDiscount);
|
|
|
+ if (type === 'plus') {
|
|
|
+ const [isCrossMessage = false, maxReduceDiscount = this.maxReduceDiscount] = this.crossMessage('onReduceHoursChange');
|
|
|
+ if (isCrossMessage) {
|
|
|
+ // this.remainPrice = this.remainPrice - hourPrice;
|
|
|
+ // this.reduceHours = this.reduceHours - 1;
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.remainPrice = this.remainPrice + hourPrice;
|
|
|
+ this.reduceHours = this.reduceHours + 1;
|
|
|
+ this.consume.discountFee = this.reduceHours * hourPrice
|
|
|
+ return;
|
|
|
}
|
|
|
- if (type === 'plus' && !this.crossMessage()) {
|
|
|
- this.reduceHours++
|
|
|
- this.usingTotalDiscount += hourPrice
|
|
|
+ if (type === 'minus' && this.reduceHours > 1) {
|
|
|
+ this.reduceHours = this.reduceHours - 1;
|
|
|
+ this.remainPrice = this.remainPrice - hourPrice;
|
|
|
+ this.consume.discountFee = this.reduceHours * hourPrice
|
|
|
+ return;
|
|
|
}
|
|
|
},
|
|
|
- memberClick(e) {
|
|
|
- if((!this.isCheck('member') && this.isDiscountDisabled) || !this.memberGrade.discountFee) {
|
|
|
- return
|
|
|
+ memberClick() {
|
|
|
+ const { maxConsumeTime, remainConsumeTime, availableDiscountFee, hourPrice } = this.orderDetail.parkingRule;
|
|
|
+ if (this.checkedList.indexOf('member') > -1) {
|
|
|
+ /* 浦东 */
|
|
|
+ if(this.parkMallCode === 1) {
|
|
|
+ const [isCrossMessage = false, maxReduceDiscount = this.maxReduceDiscount] = this.crossMessage();
|
|
|
+ if (!isCrossMessage) {
|
|
|
+ this.remainPrice = this.memberGrade.discountFee + this.remainPrice;
|
|
|
+ } else {
|
|
|
+ this.checkedList = this.checkedList.filter((elm) => elm !== 'member');
|
|
|
+ // this.remainPrice = this.remainPrice - this.memberGrade.discountFee
|
|
|
+ this.isMember = false;
|
|
|
+ }
|
|
|
+ this.maxReduceDiscountInit();
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.remainPrice = this.memberGrade.discountFee + this.remainPrice;
|
|
|
+ // 沈阳
|
|
|
+ if (this.parkMallCode === 4 || this.parkMallCode === 6) {
|
|
|
+ this.maxReduceDiscountInit();
|
|
|
+ }
|
|
|
+ } else if (!this.isMember) {
|
|
|
+ // 浦东单独处理
|
|
|
+ if(this.parkMallCode === 1) {
|
|
|
+ this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
|
|
|
+ this.maxReduceDiscountInit();
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
|
|
|
+ // 如果不是沈阳,重新计算优惠
|
|
|
+ if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
|
|
|
+ this.maxReduceDiscount = remainConsumeTime;
|
|
|
+ }
|
|
|
+ // 如果不是沈阳,重新计算优惠
|
|
|
+ if (this.parkMallCode === 4 || this.parkMallCode === 6) {
|
|
|
+ this.maxReduceDiscountInit();
|
|
|
+ }
|
|
|
}
|
|
|
- if (!this.isCheck('member')) {
|
|
|
- this.checkedList = [...this.checkedList, 'member']
|
|
|
- } else {
|
|
|
- this.checkedList = this.checkedList.filter(elm => elm !== 'member')
|
|
|
+ // 如果不是沈阳
|
|
|
+ if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
- this.checkboxChange()
|
|
|
},
|
|
|
reducesClick() {
|
|
|
- if((!this.isCheck('reduces') && this.isDiscountDisabled) || !this.consume.defaultDiscountTime) {
|
|
|
- return
|
|
|
- }
|
|
|
- // && !this.crossMessage()
|
|
|
- if (!this.isCheck('reduces')) {
|
|
|
- this.checkedList = [...this.checkedList, 'reduces']
|
|
|
+ // 浦东
|
|
|
+ if(this.parkMallCode === 1 && (this.isReduces || !this.maxReduceDiscount) ) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const { maxOneTimeDiscountTime, hourPrice, oneTimeLimitation, maxConsumeTime, remainConsumeTime, oneDayLimitation, maxOneDayDiscountFee, availableDiscountFee } = this.orderDetail.parkingRule;
|
|
|
+ const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
|
|
|
+ if (this.checkedList.indexOf('reduces') > -1) {
|
|
|
+ if(this.parkMallCode === 1) {
|
|
|
+ const [isCrossMessage = false, maxReduceDiscount = this.maxReduceDiscount] = this.crossMessage();
|
|
|
+ if(isCrossMessage) {
|
|
|
+ this.checkedList = this.checkedList.filter((elm) => elm !== 'reduces');
|
|
|
+ // this.remainPrice = this.remainPrice - this.memberGrade.discountFee
|
|
|
+ // this.isReduces = false;
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 如果还有剩余优惠的话,给一个默认值
|
|
|
+ const {defaultDiscountTime} = this.consume
|
|
|
+ const remainHour = this.remainPrice / hourPrice
|
|
|
+ if(remainConsumeTime - remainHour > 0 && defaultDiscountTime){
|
|
|
+ this.reduceHours = 1
|
|
|
+ this.remainPrice = this.remainPrice + hourPrice
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
|
|
|
+ // 如果不是沈阳,重新计算计算最大上限
|
|
|
+ this.remainPrice = hourPrice + this.remainPrice;
|
|
|
+ this.maxReduceDiscount = remainConsumeTime > maxOneTimeDiscountFee / hourPrice ? maxOneTimeDiscountFee / hourPrice : remainConsumeTime;
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.checkedList = this.checkedList.filter(elm => elm !== 'reduces')
|
|
|
+ // this.remainPrice = this.remainPrice - hourPrice;
|
|
|
+ // 如果不是沈阳,重新计算计算最大上限
|
|
|
+ if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
|
|
|
+ this.remainPrice = this.remainPrice - hourPrice;
|
|
|
+ this.maxReduceDiscount = remainConsumeTime > maxOneTimeDiscountFee / hourPrice ? maxOneTimeDiscountFee / hourPrice : remainConsumeTime;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
|
|
|
+ const [isCrossMessage = false, maxReduceDiscount = 0] = this.crossMessage();
|
|
|
+ if (isCrossMessage) {
|
|
|
+ this.remainPrice = this.remainPrice - maxReduceDiscount * hourPrice;
|
|
|
+ }
|
|
|
}
|
|
|
- this.checkboxChange()
|
|
|
},
|
|
|
// 超限提示
|
|
|
crossMessage(type) {
|
|
|
- const {
|
|
|
- hourPrice = 0,
|
|
|
- remainConsumeTime = 0,
|
|
|
- maxOneTimeDiscountFee = 0,
|
|
|
- oneTimeLimitation,
|
|
|
- oneDayLimitation,
|
|
|
- maxOneTimeDiscountTime,
|
|
|
- maxOneDayDiscountFee
|
|
|
- } = this.orderDetail.parkingRule;
|
|
|
- // const {usingTotalDiscount} = this.orderDetail.discountInfo;
|
|
|
- this.isDiscountDisabled = false;
|
|
|
- // 浦东每次总优惠上限
|
|
|
- if (oneTimeLimitation && (this.usingTotalDiscount - this.paperDiscountFee) / hourPrice >= maxOneTimeDiscountTime) {
|
|
|
- this.isDiscountDisabled = true;
|
|
|
- uni.showToast({
|
|
|
- title: `超出抵扣上限,每次最高可抵扣${maxOneTimeDiscountTime}小时`,
|
|
|
- icon: 'none'
|
|
|
+ const { maxOneTimeDiscountTime, hourPrice, oneTimeLimitation, oneDayLimitation, maxOneDayDiscountFee, remainConsumeTime } = this.orderDetail.parkingRule;
|
|
|
+ const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
|
|
|
+ // console.log(373, this.remainPrice, this.availableDiscountFee);
|
|
|
+ // 单日上限
|
|
|
+ if (oneDayLimitation && this.remainPrice >= this.availableDiscountFee) {
|
|
|
+
|
|
|
+ Toast({
|
|
|
+ message: `每日最高可抵扣${maxOneDayDiscountFee}元`,
|
|
|
+ icon: 'none',
|
|
|
});
|
|
|
- return true
|
|
|
- }
|
|
|
- // 沈阳、天津
|
|
|
- if (oneDayLimitation && this.usingTotalDiscount - this.paperDiscountFee >= maxOneDayDiscountFee) {
|
|
|
- this.isDiscountDisabled = true;
|
|
|
- uni.showToast({
|
|
|
- title: `超出抵扣上限,每次最高可抵扣${maxOneDayDiscountFee / hourPrice}小时`,
|
|
|
- icon: 'none'
|
|
|
+ return [true, (maxOneDayDiscountFee - (this.reduceHours - 1) * hourPrice) / hourPrice];
|
|
|
+ }
|
|
|
+ // 单次上限限制
|
|
|
+ if (oneTimeLimitation && this.remainPrice >= maxOneTimeDiscountFee) {
|
|
|
+ Toast({
|
|
|
+ message: `超出抵扣上限,每次最高可抵扣${maxOneTimeDiscountTime}小时`,
|
|
|
+ icon: 'none',
|
|
|
});
|
|
|
- return true
|
|
|
- }
|
|
|
- // 消费每天优惠上限(非浦东、沈阳)
|
|
|
- if (this.parkMallCode !== 1 && this.parkMallCode !== 4 && this.parkMallCode !== 6 && this.reduceHours * hourPrice >= remainConsumeTime) {
|
|
|
- this.reduces = remainConsumeTime;
|
|
|
- uni.showToast({
|
|
|
- title: `超出抵扣上限,消费减免每天最高可抵扣${this.parkInfoEntity.dateReduceUpperliLimit}小时,可使用${this.parkInfoEntity.remainReduceTime}小时`,
|
|
|
- icon: 'none'
|
|
|
+ // return [true,( maxOneTimeDiscountFee - (this.reduceHours - 1) * hourPrice ) / hourPrice]
|
|
|
+ return [true, (this.remainPrice - maxOneTimeDiscountFee) / hourPrice];
|
|
|
+ }
|
|
|
+ // 单次上限限制 浦东
|
|
|
+ const remainHour = this.remainPrice / hourPrice
|
|
|
+ if (oneTimeLimitation && remainConsumeTime - remainHour < 1) {
|
|
|
+ Toast({
|
|
|
+ message: `超出抵扣上限,每次最高可抵扣${maxOneTimeDiscountTime}小时`,
|
|
|
+ icon: 'none',
|
|
|
});
|
|
|
- return true
|
|
|
+ return [true, (this.remainPrice - maxOneTimeDiscountFee) / hourPrice];
|
|
|
}
|
|
|
- return false
|
|
|
+ return [false, 0];
|
|
|
},
|
|
|
// 验证当前的选项是否可选择
|
|
|
- isCheck(val) {
|
|
|
- return this.checkedList.findIndex(e => e == val) > -1;
|
|
|
+ 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 < (oneTimeLimitation ? maxOneTimeDiscountFee : maxOneDayDiscountFee) && this.memberLevelDiscount);
|
|
|
+ this.isReduces = !(this.usingTotalDiscount < (oneTimeLimitation ? maxOneTimeDiscountFee : maxOneDayDiscountFee) && this.enableConsume);
|
|
|
+ }
|
|
|
+ if (callback) callback();
|
|
|
+ },
|
|
|
+ reducesChange(value) {
|
|
|
+ // console.log(149,value)
|
|
|
},
|
|
|
async confirm() {
|
|
|
let orderDetail = cloneDeep(this.orderDetail);
|
|
@@ -345,7 +578,7 @@ export default {
|
|
|
orderDetail.discountInfo.consume = [this.consume];
|
|
|
}
|
|
|
});
|
|
|
- await this.$store.dispatch('order/saveDiscounts', {orderDetail, callback: () => this.$router.back()});
|
|
|
+ await this.$store.dispatch('order/saveDiscounts', { orderDetail, callback: () => this.$router.back() });
|
|
|
} else {
|
|
|
this.$router.back();
|
|
|
}
|