Feat:团购礼品支持优惠券

This commit is contained in:
linxi
2025-11-22 15:15:13 +08:00
parent cdf1f24b74
commit efd70ae003
2 changed files with 45 additions and 14 deletions
+12
View File
@@ -112,3 +112,15 @@ export function fetchSojoumGroupBuyGiftCarousel(params) {
login: true
})
}
/**
* 计算旅居团购礼品订单价格
* @param {*} params
* @returns
*/
export function computedSojoumGroupBuyGiftOrderPrice(params) {
return request.post("/travel/giftCardOrder/computed/" + params.key, params, {
login: true
})
}
+33 -14
View File
@@ -81,7 +81,7 @@
<text class="v12-dark-text v12-font-30">{{ isGroupBuy ? goodsInfo.price : computedResult.totalPrice }}</text>
</view>
</view>
<view class="v12-justify-between v12-align-center v12-font-28 v12-mt-1" v-if="!isGroupBuy">
<view class="v12-justify-between v12-align-center v12-font-28 v12-mt-1">
<view class="v12-font-24 v12-dark-text">平台折扣</view>
<view>
-
@@ -89,7 +89,7 @@
<text class="v12-dark-text v12-font-30">{{ computedResult.discountPrice }}</text>
</view>
</view>
<view class="v12-justify-between v12-align-center v12-font-28 v12-mt-1" v-if="!isGroupBuy">
<view class="v12-justify-between v12-align-center v12-font-28 v12-mt-1">
<view class="v12-font-24 v12-dark-text v12-align-center">
<view class="">
优惠券
@@ -111,7 +111,7 @@
<view class="v12-font-bold">合计</view>
<view class="">
<text class="v12-primary-text v12-font-bold v12-font-22"></text>
<text class="v12-primary-text v12-font-bold v12-font-28">{{ isGroupBuy ? goodsInfo.price : computedResult.payPrice }}</text>
<text class="v12-primary-text v12-font-bold v12-font-28">{{ computedResult.payPrice }}</text>
</view>
</view>
</view>
@@ -146,7 +146,7 @@
ref='payPwdPop'
showMoney
v-if="isShowPayPwdPop"
:money="isGroupBuy ? goodsInfo.price : payPrice"
:money="payPrice"
:show="isShowPayPwdPop"
@close="isShowPayPwdPop = false"
@finish="pwdPopFinish"
@@ -186,7 +186,8 @@ import {
getGiftCardResend,
createGroupBuyGift,
createSojoumGroupBuyGift,
fetchSojoumGroupBuyGiftCarousel
fetchSojoumGroupBuyGiftCarousel,
computedSojoumGroupBuyGiftOrderPrice
} from '@/api/gift'
import { weappPay } from "@/libs/wechat";
import {mapGetters} from "vuex";
@@ -249,7 +250,11 @@ export default {
async couponId(value) {
this.couponIndex = this.couponList['usable']?.findIndex(item => item.id === +value)
this.couponTitle = this.couponList['usable']?.[this.couponIndex]?.couponTitle
await this.computedPrice(this.goodsInfo.cartNum, 1)
if(this.isGroupBuy) {
await this.computedTravelGroupPrice(true)
} else {
await this.computedPrice(this.goodsInfo.cartNum, 1)
}
}
},
onLoad(opts) {
@@ -284,14 +289,23 @@ export default {
imageUrl: this.shareImage
}
},
// onReady() {
// this.$nextTick(() => {
// this.$refs.textarea.setFormatter(val => {
// return val.length > 30 ? val.substring(0, 30) : val
// })
// })
// },
methods: {
// 团购价计算
computedTravelGroupPrice(useDefaultCouponId) {
const params = {
key: this.orderKey,
couponId: this.couponId
}
computedSojoumGroupBuyGiftOrderPrice(params).then(res => {
this.computedResult = res.data.result
this.couponList = res.data.result.couponList
this.payPrice = res.data.result.payPrice
this.$forceUpdate()
if(useDefaultCouponId) {
this.couponId = res.data.result.defaultCouponId || 0
}
})
},
handleShowCover() {
this.showCoverPicker = true
},
@@ -310,7 +324,11 @@ export default {
if(!item.id) {
this.couponId = 0
this.couponTitle = ''
this.computedPrice(this.goodsInfo.cartNum, 1)
if(this.isGroupBuy) {
this.computedTravelGroupPrice(false)
} else {
this.computedPrice(this.goodsInfo.cartNum, 1)
}
return
}
this.couponId = item.id
@@ -576,6 +594,7 @@ export default {
}
}
this.giftNotice = res.data.giftCardGiftNotice
this.computedTravelGroupPrice(true)
}
})
}