From d2816a7f7860480770ebe856bea0c63ac70bb187 Mon Sep 17 00:00:00 2001 From: dzl <786316265@qq.com> Date: Fri, 17 Oct 2025 14:29:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Pay.vue | 50 +++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/src/views/Pay.vue b/src/views/Pay.vue index 4552e08..52c61c7 100644 --- a/src/views/Pay.vue +++ b/src/views/Pay.vue @@ -229,7 +229,7 @@
@@ -276,6 +277,7 @@ class="payment-option" :class="{ active: selectedPaymentMethod === 'wechat_h5' }" @click="selectPaymentMethod('wechat_h5')" + v-if="shouldShowPaymentMethod('wechatpay')" >
@@ -414,6 +416,8 @@ const paymentData = ref({ items: [] // 添加商品列表 }) +const items = ref([]) + const couponList = ref([]) const selectedCoupon = ref() @@ -652,30 +656,19 @@ const isPaymentMethodAvailable = (method) => { // 检查支付方式是否应该显示 const shouldShowPaymentMethod = (method) => { - // 基于折后金额判断显示 - const totalRMBBase = totalRongdouPrice.value - const discountedRMB = applyCouponToRMB(totalRMBBase) - const totalPointsPrice = Math.ceil(discountedRMB * EXCHANGE_RATE) - - switch (method) { - case 'beans': - // 当总积分大于等于10000且用户融豆足够支付总积分价值时显示融豆支付选项 - if (totalPointsPrice < 10000) { - return false + // console.log(12345,method,items.value) + const can = ref(false) + // 检查商品是否支持所选支付方式 + items.value.forEach(item => { + item.paymentMethod.map(itemMethod => itemMethod === 'rongdou' ? 'beans' : itemMethod).forEach(itemMethod => { + // console.log(1234,itemMethod,method) + if (itemMethod === method) { + can.value = true } - const requiredBeans = Math.ceil(totalPointsPrice / EXCHANGE_RATE) - return totalPointsPrice > 0 && userBalance.value.beans >= requiredBeans - case 'points': - // 当用户积分足够支付时显示积分支付选项 - return totalPointsPrice > 0 && userBalance.value.points >= totalPointsPrice - case 'mixed': - // 当用户积分不够但积分+融豆换算足够时显示混合支付选项,且用户积分必须大于等于10000 - const pointsNotEnough = totalPointsPrice > 0 && userBalance.value.points < totalPointsPrice - const hasEnoughPoints = userBalance.value.points >= 10000 - return pointsNotEnough && hasEnoughPoints && isPaymentMethodAvailable('mixed') - default: - return false - } + }) + }) + // console.log(111,can.value) + return can.value } const fetchPaymentData = async () => { @@ -699,7 +692,7 @@ const fetchPaymentData = async () => { if (response.data.success) { const data = response.data.data - const items = (data.items || []).map(item => ({ + items.value = (data.items || []).map(item => ({ id: item.id, productId: item.product_id, name: item.product_name, @@ -710,12 +703,13 @@ const fetchPaymentData = async () => { rongdouPrice: item.rongdou_price, quantity: item.quantity, description: item.description, - specInfo: item.spec_info + specInfo: item.spec_info, + paymentMethod: item.payment_methods })) // 计算总积分价格和总融豆价格 - const totalPointsPrice = items.reduce((sum, item) => sum + (item.points * item.quantity), 0) - const totalBeansPrice = items.reduce((sum, item) => sum + (item.rongdouPrice * item.quantity), 0) + const totalPointsPrice = items.value.reduce((sum, item) => sum + (item.points * item.quantity), 0) + const totalBeansPrice = items.value.reduce((sum, item) => sum + (item.rongdouPrice * item.quantity), 0) paymentData.value = { totalAmount: 0, // 初始不设置总金额,等用户选择支付方式后再设置