|
@@ -4,8 +4,8 @@ import uni from '@/utils/uniHooks';
|
|
|
import { Toast } from 'vant';
|
|
|
import { getPlatform, getAppIdByGroupIdAndMallId, isInWeixinH5 } from '@/utils';
|
|
|
import { initWxJsSdkConfig } from '@/utils/login';
|
|
|
-import { compare } from '@/utils/location.js';
|
|
|
-import { isArray } from 'lodash';
|
|
|
+// import { compare } from '@/utils/location.js';
|
|
|
+// import { isArray } from 'lodash';
|
|
|
// import { v4 as uuidv4 } from 'uuid';
|
|
|
|
|
|
export default {
|
|
@@ -35,6 +35,9 @@ export default {
|
|
|
unLimitWeekendPoints: (state) => state.order.unLimitWeekendPoints, // 新的积分上限, 默认为false(不开启), unLimitWeekendPoints: true # 开启无上限功能; unLimitWeekendPoints: false # 关闭无上限功能;
|
|
|
lbsId: (state) => state.lbsId, // 楼栋ID
|
|
|
groupId: (state) => state.groupId, // 楼盘ID
|
|
|
+ remainCoupons: ( state ) => state.order.remainCoupons, // 仅限杭州当前剩余可选电子券上限
|
|
|
+ parkMallCode: ( state ) => state.order.parkMallCode, // 当前车场的数据
|
|
|
+ maxOneDayCoupons: ( state ) => state.order.maxOneDayCoupons,// 仅限杭州当日电子券可选上限
|
|
|
}),
|
|
|
},
|
|
|
|
|
@@ -139,7 +142,7 @@ export default {
|
|
|
this.setAllDisabled()
|
|
|
this.isDisabledByRule(coupon, index, 'showMsg');
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
// 针对达到优惠的上限制
|
|
|
setAllDisabled() {
|
|
@@ -160,7 +163,6 @@ export default {
|
|
|
if ( oneDayLimitation && parkMallCode !== 5) {
|
|
|
const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
|
|
|
const remainConsumeTimeFee = remainConsumeTime * hourPrice
|
|
|
- console.log(156, remainConsumeTimeFee)
|
|
|
// 计算单日剩余 remainConsumeTime
|
|
|
// 当前使用优惠 state.usingTotalDiscount
|
|
|
// 判断符合上限
|
|
@@ -174,14 +176,12 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
// 单次上限限制
|
|
|
- if ( oneTimeLimitation && parkMallCode !== 5) {
|
|
|
- console.log(170)
|
|
|
+ if ( oneTimeLimitation && parkMallCode !== 5 ) {
|
|
|
const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
|
|
|
- const remainConsumeTimeFee = remainConsumeTime * hourPrice
|
|
|
+ // const remainConsumeTimeFee = remainConsumeTime * hourPrice
|
|
|
// 计算单日剩余 remainConsumeTime
|
|
|
// 当前使用优惠 state.usingTotalDiscount
|
|
|
// 判断符合上限
|
|
|
- console.log(177, remainConsumeTimeFee)
|
|
|
if ( this.remainPrice >= maxOneTimeDiscountFee ) {
|
|
|
this.couponList = this.couponList.map((elm,iemi) => {
|
|
|
if ( !elm.disabled && this.checkedCouponList.indexOf(`coupon${iemi}`) < 0) {
|
|
@@ -191,81 +191,18 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+ // 杭州电子券选择上限判断
|
|
|
+ if ( parkMallCode === 2 && this.checkedCouponList.length === this.remainCoupons ) {
|
|
|
+ this.couponList = this.couponList.map(( elm,iemi ) => {
|
|
|
+ if ( !elm.disabled && this.checkedCouponList.indexOf(`coupon${ iemi }`) < 0 ) {
|
|
|
+ elm.disabled = true
|
|
|
+ }
|
|
|
+ return elm
|
|
|
+ })
|
|
|
+ }
|
|
|
return false
|
|
|
},
|
|
|
// 对不同类型的优惠券进行汇总统计
|
|
|
- /*groupedCouponData() {
|
|
|
- const groupedData = {}; // 所有的电子券按照批次分组;
|
|
|
- let couponList = [...this.couponList]; // 获取目前用户的电子券
|
|
|
- couponList.forEach((elm, index) => {
|
|
|
- // 初始化数据
|
|
|
- const elmName = `coupon${index}`;
|
|
|
- const newElm = { ...elm };
|
|
|
- if (!groupedData[elm.name] || !groupedData[elm.name].hasOwnProperty('noSelectedList')) {
|
|
|
- groupedData[newElm.name] = {
|
|
|
- noSelectedList: [], // 未选择的
|
|
|
- selectedList: [], // 已选择的
|
|
|
- }
|
|
|
- }
|
|
|
- newElm.index = index; // 记录每张电子券的顺序
|
|
|
- // 所有的电子券按照 已选择 和 未选择的分组,存储到同批次下
|
|
|
- if (this.checkedCouponList.indexOf(elmName) > -1) {
|
|
|
- newElm.selected = true;
|
|
|
- groupedData[newElm.name]['selectedList'].push(newElm)
|
|
|
- } else {
|
|
|
- newElm.selected = false;
|
|
|
- groupedData[newElm.name]['noSelectedList'].push(newElm)
|
|
|
- }
|
|
|
- })
|
|
|
- // 对分好组的优惠券进行不同规则处理
|
|
|
- Object.keys(groupedData).forEach(key => {
|
|
|
- const { selectedList, noSelectedList } = groupedData[key]; // 取出已选择的和未选择的
|
|
|
- const { superposition, limitCountPerOrder = 0 } = selectedList.concat(noSelectedList)[0]; // 获取当前批次兑换的类型和可选上限
|
|
|
- switch (superposition) {
|
|
|
- case '1': // 不可叠加
|
|
|
- couponList = couponList.map((item, index) => {
|
|
|
- const elmName = `coupon${index}`;
|
|
|
- // 如果是不可叠加的电子优惠券,设置未选中的为不可选择
|
|
|
- if (item?.superposition === '1') {
|
|
|
- if (selectedList.length) {// 如果存在已选择项,设置未选中的为不可选择
|
|
|
- item.disabled = this.checkedCouponList.indexOf(elmName) < 0;
|
|
|
- /!*
|
|
|
- TODO: 如果不可叠加电子券的选择规则改变为,选中某一项不可叠加券,其他券不可选择,则打开此处注释
|
|
|
- if (item.superposition === '2') {
|
|
|
- item.disabled = selectedList.length > 0
|
|
|
- } *!/
|
|
|
- } else {
|
|
|
- item.disabled = this.checkedCouponList.length > 0;
|
|
|
- }
|
|
|
- }
|
|
|
- /!*
|
|
|
- // TODO: 如果不可叠加电子券的选择规则改变为,选中某一项不可叠加券,其他券不可选择,则打开此处注释
|
|
|
- // 如果存在已选的电子优惠券,将其他类型的优惠券设置为不可选中
|
|
|
- if ( item.superposition === '2' && selectedList.length) {
|
|
|
- item.disabled = true
|
|
|
- } *!/
|
|
|
- return item
|
|
|
- })
|
|
|
- break
|
|
|
- case '2':
|
|
|
- // 统计未选择项是否需要禁用
|
|
|
- noSelectedList.forEach(elm => {
|
|
|
- const _elm = { ...couponList[elm.index] };
|
|
|
- couponList = couponList.map((item, index) => {
|
|
|
- if (index === elm.index && limitCountPerOrder > 0) {
|
|
|
- // elm.disabled = selectedList.length >= limitCountPerOrder;
|
|
|
- _elm.disabled = selectedList.length >= limitCountPerOrder;
|
|
|
- return _elm
|
|
|
- }
|
|
|
- return item
|
|
|
- })
|
|
|
- })
|
|
|
- break
|
|
|
- }
|
|
|
- })
|
|
|
- this.couponList = [...couponList];
|
|
|
- },*/
|
|
|
- // 对不同类型的优惠券进行汇总统计
|
|
|
newGroupedCouponData() {
|
|
|
let couponList = [...this.couponList]; // 获取目前用户的电子券
|
|
|
if (!this.checkedCouponList.length) {
|
|
@@ -275,6 +212,11 @@ export default {
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
+ // 如果杭州的使用券打到上限则不自动计算其余券是否可选
|
|
|
+ if ( this.checkedCouponList.length >= this.remainCoupons && this.parkMallCode === 2 ) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.log(292,this.couponList);
|
|
|
const index = this.item2Number(this.checkedCouponList[0])
|
|
|
const item = this.couponList[index];
|
|
|
const { superposition, limitCountPerOrder = 0, name } = item;
|
|
@@ -286,7 +228,7 @@ export default {
|
|
|
})
|
|
|
break;
|
|
|
case '2': // 同类型可叠加
|
|
|
- // 找到
|
|
|
+ // 找到
|
|
|
couponList = couponList.map((elm, i) => {
|
|
|
// 只有 status === 'available' 的才会赋值为 false
|
|
|
elm.disabled = elm?.status !== 'available'; // 默认可选
|
|
@@ -323,31 +265,14 @@ export default {
|
|
|
icon: 'none',
|
|
|
});
|
|
|
}
|
|
|
- // 杭州电子券使用上限(单位: 张)
|
|
|
- /*if (this.parkMallCode === 2) {
|
|
|
- // 达到上限
|
|
|
- if (
|
|
|
- this.checkedCouponList.length ===
|
|
|
- this.parkFee.parkInfoEntity.useTicketNum -
|
|
|
- this.parkFee.parkInfoEntity.couponcodeNum
|
|
|
- ) {
|
|
|
- this.list.forEach((e, i) => {
|
|
|
- if (this.checkedCouponList.findIndex((c) => c == i) === -1) {
|
|
|
- e.disabled = true;
|
|
|
- } else {
|
|
|
- e.checked = true;
|
|
|
- }
|
|
|
- });
|
|
|
- return uni.showToast({
|
|
|
- title: `电子券每天最多可使用${this.parkFee.parkInfoEntity.useTicketNum}张`,
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.list.forEach((e) => {
|
|
|
- e.disabled = false;
|
|
|
- });
|
|
|
- }
|
|
|
- }*/
|
|
|
+ if ( this.checkedCouponList.length >= this.remainCoupons && this.parkMallCode === 2 ) {
|
|
|
+ if ( showMsg ) return true
|
|
|
+ return Toast({
|
|
|
+ className: 'top300',
|
|
|
+ message: `电子券每天最多可使用${ this.maxOneDayCoupons }张`,
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
// 浦东每次缴费超限控制、沈阳每日超限控制
|
|
|
if ((parkMallCode === 1 || parkMallCode === 4 || parkMallCode === 5 || parkMallCode === 999 || parkMallCode === 6) && this.crossMessage(showMsg)) {
|
|
@@ -385,42 +310,8 @@ export default {
|
|
|
if (parkMallCode === 5) {
|
|
|
if (remainPrice - this.paperDiscountFee > actualPayFee) {
|
|
|
remainPrice = actualPayFee;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- // let totalFee = this.parkDiscountTotal.feeCopy;
|
|
|
- // totalFee += this.totalFee;
|
|
|
- // 电子券优惠金额总计
|
|
|
- // 浦东每次优惠上限
|
|
|
- /*if (
|
|
|
- parkMallCode === 1 &&
|
|
|
- totalFee - this.paperCouponFee >= this.maxonetimediscountFee
|
|
|
- ) {
|
|
|
- // uni.showToast({
|
|
|
- // title: `超出抵扣上限,每次最高可抵扣${this.parkFee.parkInfoEntity.maxonetimediscount}小时`,
|
|
|
- // icon: 'none',
|
|
|
- // });
|
|
|
- return Toast({
|
|
|
- message: `超出抵扣上限,每次最高可抵扣${this.parkFee.parkInfoEntity.maxonetimediscount}小时`,
|
|
|
- icon: 'none',
|
|
|
- });
|
|
|
- return;
|
|
|
- }*/
|
|
|
- // 沈阳超限处理(maxonedaydiscountFee 会员、消费、电子券减免)
|
|
|
- /*if (
|
|
|
- parkMallCode === 4 &&
|
|
|
- totalFee - this.paperCouponFee - this.parkDiscountTotal.bonusfee >=
|
|
|
- this.maxonedaydiscountFee
|
|
|
- ) {
|
|
|
- return Toast({
|
|
|
- message: `(会员等级、消费、电子券)每日最高可抵扣${this.parkFee.parkInfoEntity.maxOneDayHour}小时`,
|
|
|
- icon: 'none',
|
|
|
- });
|
|
|
- // return uni.showToast({
|
|
|
- // title: `(会员等级、消费、电子券)每日最高可抵扣${this.parkFee.parkInfoEntity.maxOneDayHour}小时`,
|
|
|
- // icon: 'none',
|
|
|
- // });
|
|
|
- }*/
|
|
|
// 深圳超限处理
|
|
|
if (parkMallCode === 5 && this.remainPrice >= this.availableDiscountFee) {
|
|
|
if ( showMsg ) return true
|
|
@@ -429,7 +320,7 @@ export default {
|
|
|
icon: 'none',
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 单日上限
|
|
|
if ( oneDayLimitation && parkMallCode !== 5 && this.remainPrice >= maxOneDayDiscountFee) {
|
|
|
if ( showMsg ) return true
|
|
@@ -447,14 +338,6 @@ export default {
|
|
|
icon: 'none',
|
|
|
});
|
|
|
}
|
|
|
- // 浦东,单次上限提示, 后续 usingTotalDiscount 再减去 纸质优惠券的金额
|
|
|
- /*if (parkMallCode === 1 && this.remainPrice - this.paperDiscountFee >= this.availableDiscountFee) {
|
|
|
- if ( showMsg ) return true
|
|
|
- return Toast({
|
|
|
- message: `超出抵扣上限,每次最高可抵扣${maxOneTimeDiscountTime}小时`,
|
|
|
- icon: 'none',
|
|
|
- });
|
|
|
- }*/
|
|
|
return false
|
|
|
},
|
|
|
// 确认
|