商品券处理
This commit is contained in:
@@ -149,6 +149,9 @@
|
||||
listinfo:{
|
||||
type: Object
|
||||
},
|
||||
amountVIP:{
|
||||
type: Object
|
||||
},
|
||||
},
|
||||
watch :{
|
||||
listinfo:{
|
||||
@@ -160,14 +163,13 @@
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
console.log(this.listinfo.shopId)
|
||||
uni.$on('couponItem',this.changeCoupon)
|
||||
this.getCalcUsablePoints()
|
||||
},
|
||||
onShow() {
|
||||
// uni.$on('couponItem',this.changeCoupon)
|
||||
},
|
||||
methods: {
|
||||
childOnShow() {
|
||||
console.log(222)
|
||||
uni.$on('couponItem',this.changeCoupon)
|
||||
this.getCalcUsablePoints()
|
||||
},
|
||||
/**
|
||||
* 监听优惠券/商品券选择
|
||||
* @param {Object} data
|
||||
@@ -180,7 +182,7 @@
|
||||
if ( couponData.type == 1 ) { //满减优惠券
|
||||
let couponList = _this.userCouponInfos.filter(v => v.type == 1);
|
||||
//不包含优惠券的金额
|
||||
let currentPayAmount = (couponList.length > 0 ? _this.listinfo.payAmount + couponList[0].discountAmount : _this.listinfo.payAmount)
|
||||
let currentPayAmount = (couponList.length > 0 ? Number(_this.listinfo.payAmount) + couponList[0].discountAmount : _this.listinfo.payAmount)
|
||||
// 判断优惠金额不能大于支付金额
|
||||
if ( couponData.discountAmount < currentPayAmount) {
|
||||
_this.listinfo.payAmount = ( currentPayAmount - couponData.discountAmount).toFixed(2)
|
||||
@@ -203,11 +205,12 @@
|
||||
num: couponData.type == 1 ? 1 : couponData.num,
|
||||
})
|
||||
}
|
||||
console.log(currentPayAmount)
|
||||
console.log(_this.listinfo.payAmount)
|
||||
// if ( _this.isPointsChecked ) {
|
||||
if ( _this.isPointsChecked ) {
|
||||
_this.pointsChange()
|
||||
_this.getCalcUsablePoints()
|
||||
// }
|
||||
}
|
||||
this.$emit("setPayAmount",_this.listinfo.payAmount)
|
||||
} else {
|
||||
uni.showToast({
|
||||
@@ -230,15 +233,23 @@
|
||||
productTicketList.map((item,index) => {
|
||||
productTicketNum += item.num
|
||||
})
|
||||
console.log(productTicketList)
|
||||
console.log(minCouponList)
|
||||
minCouponList.map((item,index) => {
|
||||
productNumber += item.number
|
||||
if ( productNum > 0 && productNumber > productTicketNum) {
|
||||
let num = productNum >= item.number ? item.number : productNum
|
||||
productNum = (productNum - item.number) >= 0 ? (productNum - item.number) : 0;
|
||||
console.log(num)
|
||||
console.log(item.salePrice)
|
||||
productPayAmount = productPayAmount + (num*(item.memberPrice > 0 ? item.memberPrice : item.salePrice))
|
||||
// productNumber += item.num
|
||||
if ( productNum > 0) {
|
||||
item.num = (item.num - productTicketNum) <= 0 ? 0 : (item.num - productTicketNum)
|
||||
productTicketNum = (item.num - productTicketNum) <= 0 ? (productTicketNum - item.num) : item.num - productTicketNum
|
||||
console.log(productTicketNum)
|
||||
}
|
||||
if ( productNum > 0 && item.num > 0) {
|
||||
let num = productNum >= item.num ? item.num : productNum
|
||||
productNum = (productNum - item.num) >= 0 ? (productNum - item.num) : 0;
|
||||
productPayAmount = productPayAmount + (num*(item.memberPrice > 0 ? item.memberPrice : item.price))
|
||||
// let num = productNum >= item.num ? item.num : productNum
|
||||
// productNum = (productNum - item.num) >= 0 ? (productNum - item.num) : 0;
|
||||
|
||||
// productNum = num <= productNum ? num : productNum;
|
||||
}
|
||||
})
|
||||
_this.userCouponInfos.push({
|
||||
@@ -257,15 +268,39 @@
|
||||
num: productNum == 0 ? couponData.num : (couponData.num - productNum),
|
||||
})
|
||||
console.log(productNum)
|
||||
console.log(_this.favorable)
|
||||
// if ( _this.isPointsChecked) {
|
||||
console.log(productNum == 0 ? couponData.num : productNum)
|
||||
if ( _this.isPointsChecked) {
|
||||
_this.pointsChange()
|
||||
_this.getCalcUsablePoints()
|
||||
// }
|
||||
this.$emit("setPayAmount",_this.listinfo.payAmount)
|
||||
}
|
||||
this.setPayAmount()
|
||||
}
|
||||
uni.$off('couponItem')
|
||||
},
|
||||
setPayAmount ( cartLists ) {
|
||||
let tableFee;
|
||||
// this.storeInfo.registerType == 'munchies'
|
||||
|
||||
|
||||
if ( this.userCouponInfos.length > 0 ) {
|
||||
console.log(this.userCouponInfos)
|
||||
this.userCouponInfos.forEach(item => {
|
||||
if ( item.type == 1 ) {
|
||||
if ( item.discountAmount && item.discountAmount > 0 ) {
|
||||
this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2)
|
||||
}
|
||||
} else {
|
||||
if ( item.discountAmount && item.discountAmount > 0 ) {
|
||||
this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
this.isPointsChecked = false;
|
||||
this.getCalcUsablePoints()
|
||||
this.$emit("setPayAmount",this.listinfo.payAmount)
|
||||
},
|
||||
/**
|
||||
* 积分状态监听
|
||||
*/
|
||||
@@ -282,7 +317,8 @@
|
||||
this.freeDisabled = false
|
||||
this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2);
|
||||
}
|
||||
this.$emit("setPayAmount",_this.listinfo.payAmount)
|
||||
console.log(this.listinfo.payAmount)
|
||||
this.$emit("setPayAmount",this.listinfo.payAmount)
|
||||
},
|
||||
goUrl(item){
|
||||
switch (item.type){
|
||||
@@ -661,6 +697,7 @@
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.info {
|
||||
|
||||
Reference in New Issue
Block a user