商品券处理

This commit is contained in:
GaoHao
2024-11-19 13:52:56 +08:00
parent 69151ca3f4
commit d2dbfd5163
6 changed files with 88 additions and 58 deletions

View File

@@ -662,13 +662,7 @@
if (b == '单规格') { //没有规格为空
this.skuidname = []
}
if ( a == "+" && item.cartNumber >= item.limitNumber){
uni.showToast({
title: '当前商品已达到最大赠送数量',
icon: 'none'
})
return;
}
let cartNumber = a == '+' ? item.cartNumber + 1 : item.cartNumber - 1;
@@ -685,13 +679,7 @@
*/
shopAdd(item, index, index1, a, b) {
if (a == "+") {
if ( this.amountcartNumber >= item.limitNumber){
uni.showToast({
title: '当前商品已达到最大赠送数量',
icon: 'none'
})
return;
}
if (this.skuNumber < this.skuSuit && this.amountcartNumber < this.skuSuit) {
this.amountcartNumber = this.amountcartNumber + (this.skuSuit == 0 ? 1 : this.skuSuit);
} else {
@@ -717,13 +705,7 @@
return;
}
let num = 0;
if (item.cartNumber >= item.limitNumber){
uni.showToast({
title: '当前商品已达到最大赠送数量',
icon: 'none'
})
return;
}
if (item.typeEnum == "normal") {
num = item.cartNumber + this.amountcartNumber;
} else {
@@ -984,6 +966,7 @@
let res = await this.api.productqueryProductSku({
code: this.tableCode,
shopId: this.shopId,
"isVip": 0,
productId: item.id, //商品id
spec_tag: this.skuidname.join(","),
})
@@ -996,6 +979,7 @@
"type": c == '+' ? 1 : 0,
"productId": item.id, //商品id
"note": item.note,
"isVip": 0,
"shopId": this.shopId,
"userId": uni.cache.get('userInfo').id,
}

View File

@@ -105,9 +105,10 @@
if (options.payAmount) { this.payAmount = options.payAmount }
if (options.shoppingCart) { this.shoppingCart = JSON.parse(decodeURIComponent(options.shoppingCart)) }
if (options.productList) { this.productList = JSON.parse(decodeURIComponent(options.productList)) }
},
onShow() {
this.getCouponList()
},
methods: {
/**
@@ -133,6 +134,7 @@
if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' ) {
params.orderId = -1;
}
console.log("params",params)
let res = await this.api.conponList(params)
if (res.code == 0) {
console.log(res)

View File

@@ -119,9 +119,9 @@
if ( this.is_type == 'he') {
this.shareHeOpen()
}
this.getByShopId();
},
onShow() {
this.getByShopId();
},
@@ -162,7 +162,7 @@
shareId : this.InviteFriendsData.id,
invitedId : uni.cache.get('userInfo').id,
shopId : this.shopId,
isSuccess : this.isSuccess,
success : this.isSuccess,
}
let res = await this.api.shareRecord(params)
if ( res.code == 0 ) {
@@ -214,6 +214,7 @@
},
tabClick(item) {
this.tabAcitve = item.type;
this.shareRecord();
},

View File

@@ -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 {

View File

@@ -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

View File

@@ -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 @@
})
},
/**
* 去支付
*/