商品券处理
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 {
|
||||
|
||||
@@ -403,7 +403,8 @@
|
||||
},
|
||||
setPayAmount ( cartLists ) {
|
||||
let tableFee;
|
||||
if ( this.is_type == 0 ) {
|
||||
// this.storeInfo.registerType == 'munchies'
|
||||
if ( this.is_type == 0 && this.storeInfo.registerType == 'munchies') {
|
||||
tableFee = this.shopTableInfo?(this.shopTableInfo.seatNum*this.storeInfo.tableFee):0
|
||||
} else{
|
||||
tableFee = 0
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 先下单后支付 -->
|
||||
<orderInfoAfter ref="orderInfoAfter" :listinfo="listinfo" @setPayAmount="setPayAmount" v-if="listinfo.useType == 'dine-in-after'"></orderInfoAfter>
|
||||
<orderInfoAfter ref="orderInfoAfterRef" :amountVIP="amountVIP" :listinfo="listinfo" @setPayAmount="setPayAmount" v-if="listinfo.useType == 'dine-in-after'"></orderInfoAfter>
|
||||
<!-- 先支付后下单 -->
|
||||
<orderInfoBefore ref="orderInfoBefore" :listinfo="listinfo" v-else></orderInfoBefore>
|
||||
<!-- 积分兑换订单详情 -->
|
||||
@@ -96,11 +96,16 @@
|
||||
};
|
||||
},
|
||||
onLoad(e) {
|
||||
console.log(e)
|
||||
this.orderId = e.orderId
|
||||
this.orderorderInfo()
|
||||
},
|
||||
onShow() {
|
||||
this.orderorderInfo()
|
||||
if ( this.listinfo.useType == "dine-in-after") {
|
||||
this.$nextTick(()=>{
|
||||
this.$refs.orderInfoAfterRef.childOnShow();
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
onUnload() {
|
||||
this.ispws = false
|
||||
@@ -116,8 +121,10 @@
|
||||
},
|
||||
methods: {
|
||||
setPayAmount(payAmount) {
|
||||
console.log("payAmount===",payAmount)
|
||||
this.listinfo.payAmount = payAmount
|
||||
this.$forceUpdate()
|
||||
// this.$set(this.listinfo,"payAmount",payAmount)
|
||||
// this.$forceUpdate()
|
||||
},
|
||||
saveImage (url) {
|
||||
uni.saveImage({
|
||||
@@ -157,17 +164,19 @@
|
||||
})
|
||||
if (res.code == 0) {
|
||||
this.listinfo = res.data;
|
||||
console.log(this.listinfo.orderInfo.couponInfoList)
|
||||
if ( this.listinfo.orderInfo.couponInfoList ) {
|
||||
this.listinfo.orderInfo.couponInfoList = JSON.parse(this.listinfo.orderInfo.couponInfoList)
|
||||
// this.listinfo.orderInfo.couponInfoList = eval('(' + jsonString + ')')
|
||||
}
|
||||
this.listinfoid = res.data.orderId;
|
||||
this.shopId = res.data.shopId;
|
||||
if (this.listinfo.useType == " ") {
|
||||
//堂食先付费
|
||||
}
|
||||
console.log(this.listinfo)
|
||||
if ( this.listinfo.useType == "dine-in-after") {
|
||||
this.$nextTick(()=>{
|
||||
this.$refs.orderInfoAfterRef.childOnShow();
|
||||
})
|
||||
}
|
||||
this.getAount();
|
||||
}
|
||||
},
|
||||
@@ -181,10 +190,6 @@
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 去支付
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user