diff --git a/api/gift.js b/api/gift.js index 1963088..3f33c62 100644 --- a/api/gift.js +++ b/api/gift.js @@ -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 + }) +} diff --git a/pkg_user/views/gift/gift.vue b/pkg_user/views/gift/gift.vue index c306cd4..ffc34d5 100644 --- a/pkg_user/views/gift/gift.vue +++ b/pkg_user/views/gift/gift.vue @@ -81,7 +81,7 @@ {{ isGroupBuy ? goodsInfo.price : computedResult.totalPrice }} - + 平台折扣: - @@ -89,7 +89,7 @@ {{ computedResult.discountPrice }} - + 优惠券: @@ -111,7 +111,7 @@ 合计: - {{ isGroupBuy ? goodsInfo.price : computedResult.payPrice }} + {{ computedResult.payPrice }} @@ -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) } }) }