2025-10-24
多商品支付页面修改
This commit is contained in:
@@ -56,12 +56,11 @@
|
||||
<view class="u-m-t-10" style="font-weight: 500;font-size: 20rpx;">选择优惠券后自动换算扣除</view>
|
||||
</view>
|
||||
|
||||
<view class="box-bg pay-method u-m-t-20" v-if="dataInfo.items?.length && dataInfo.items.length!=0">
|
||||
<view class="box-bg pay-method u-m-t-20" v-if="supportMethod.length!=0">
|
||||
<view class="title u-m-b-20">
|
||||
支付方式
|
||||
</view>
|
||||
<view class="item" v-if="dataInfo?.items[0].payment_methods.includes('rongdou')"
|
||||
@click="handleChangeMethod(0)">
|
||||
<view class="item" v-if="supportMethod.includes('rongdou')" @click="handleChangeMethod(0)">
|
||||
<view class="title">
|
||||
融豆
|
||||
</view>
|
||||
@@ -69,8 +68,7 @@
|
||||
<u-checkbox v-model="rongdouChecked" shape="circle" active-color="#305def"></u-checkbox>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" v-if="dataInfo?.items[0].payment_methods.includes('points')"
|
||||
@click="handleChangeMethod(1)">
|
||||
<view class="item" v-if="supportMethod.includes('points')" @click="handleChangeMethod(1)">
|
||||
<view class="title">
|
||||
积分
|
||||
</view>
|
||||
@@ -78,8 +76,7 @@
|
||||
<u-checkbox v-model="pointsChecked" shape="circle" active-color="#305def"></u-checkbox>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" v-if="dataInfo?.items[0].payment_methods.includes('mixed')"
|
||||
@click="handleChangeMethod(2)">
|
||||
<view class="item" v-if="supportMethod.includes('mixed')" @click="handleChangeMethod(2)">
|
||||
<view class="title">
|
||||
融豆+积分
|
||||
</view>
|
||||
@@ -87,8 +84,7 @@
|
||||
<u-checkbox v-model="rpChecked" shape="circle" active-color="#305def"></u-checkbox>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" v-if="dataInfo?.items[0].payment_methods.includes('alipay')"
|
||||
@click="handleChangeMethod(3)">
|
||||
<view class="item" v-if="supportMethod.includes('alipay')" @click="handleChangeMethod(3)">
|
||||
<view class="title">
|
||||
支付宝
|
||||
</view>
|
||||
@@ -96,8 +92,7 @@
|
||||
<u-checkbox v-model="alipayChecked" shape="circle" active-color="#305def"></u-checkbox>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" v-if="dataInfo?.items[0].payment_methods.includes('wechatpay')"
|
||||
@click="handleChangeMethod(4)">
|
||||
<view class="item" v-if="supportMethod.includes('wechatpay')" @click="handleChangeMethod(4)">
|
||||
<view class="title">
|
||||
微信
|
||||
</view>
|
||||
@@ -113,8 +108,8 @@
|
||||
<view class="text">
|
||||
实际支付:
|
||||
<image v-if="rpChecked || pointsChecked" src="/static/icon/jifen.png" class="icon" mode=""></image>
|
||||
<image v-else-if="rongdouChecked || wechatpayChecked || alipayChecked" src="/static/icon/rongdou.png"
|
||||
class="icon" mode=""></image>
|
||||
<image v-else-if="rongdouChecked" src="/static/icon/rongdou.png" class="icon" mode=""></image>
|
||||
<span v-else>¥</span>
|
||||
{{allPayNum}}
|
||||
</view>
|
||||
<view class="btn">
|
||||
@@ -267,8 +262,11 @@
|
||||
|
||||
// 计算实际支付
|
||||
const calculateAllPay = () => {
|
||||
allPayNum.value = 0
|
||||
if (rongdouChecked.value) { // 融豆
|
||||
allPayNum.value = dataInfo.value.items[0].rongdou_price * dataInfo.value.items[0].quantity
|
||||
dataInfo.value.items.forEach(item => {
|
||||
allPayNum.value += item.rongdou_price * item.quantity
|
||||
})
|
||||
// 选择优惠券
|
||||
if (couponRecordId.value) {
|
||||
let couponInfo = couponList.value.filter(item => item.couponInfo.id == couponRecordId.value)[0]
|
||||
@@ -276,7 +274,9 @@
|
||||
handle1to1(couponInfo)
|
||||
}
|
||||
} else if (pointsChecked.value) { // 积分
|
||||
allPayNum.value = dataInfo.value.items[0].points_price * dataInfo.value.items[0].quantity
|
||||
dataInfo.value.items.forEach(item => {
|
||||
allPayNum.value += item.points_price * item.quantity
|
||||
})
|
||||
// 选择优惠券
|
||||
if (couponRecordId.value) {
|
||||
let couponInfo = couponList.value.filter(item => item.couponInfo.id == couponRecordId.value)[0]
|
||||
@@ -284,7 +284,9 @@
|
||||
handle1to10000(couponInfo)
|
||||
}
|
||||
} else if (rpChecked.value) { // 融豆+积分
|
||||
allPayNum.value = dataInfo.value.items[0].points_price * dataInfo.value.items[0].quantity
|
||||
dataInfo.value.items.forEach(item => {
|
||||
allPayNum.value += item.points_price * item.quantity
|
||||
})
|
||||
// 选择优惠券
|
||||
if (couponRecordId.value) {
|
||||
let couponInfo = couponList.value.filter(item => item.couponInfo.id == couponRecordId.value)[0]
|
||||
@@ -292,7 +294,9 @@
|
||||
handle1to10000(couponInfo)
|
||||
}
|
||||
} else if (alipayChecked.value) { // 支付宝
|
||||
allPayNum.value = dataInfo.value.items[0].price * dataInfo.value.items[0].quantity
|
||||
dataInfo.value.items.forEach(item => {
|
||||
allPayNum.value += item.price * item.quantity
|
||||
})
|
||||
// 选择优惠券
|
||||
if (couponRecordId.value) {
|
||||
let couponInfo = couponList.value.filter(item => item.couponInfo.id == couponRecordId.value)[0]
|
||||
@@ -300,7 +304,9 @@
|
||||
handle1to1(couponInfo)
|
||||
}
|
||||
} else if (wechatpayChecked.value) { // 微信
|
||||
allPayNum.value = dataInfo.value.items[0].price * dataInfo.value.items[0].quantity
|
||||
dataInfo.value.items.forEach(item => {
|
||||
allPayNum.value += item.price * item.quantity
|
||||
})
|
||||
// 选择优惠券
|
||||
if (couponRecordId.value) {
|
||||
let couponInfo = couponList.value.filter(item => item.couponInfo.id == couponRecordId.value)[0]
|
||||
@@ -311,6 +317,7 @@
|
||||
if (allPayNum.value < 0) allPayNum.value = 0
|
||||
}
|
||||
|
||||
// 折扣计算
|
||||
const handle1to1 = (couponInfo) => {
|
||||
if (couponInfo.type == 'discount_for_a_amount') { // 满减
|
||||
if (allPayNum.value > couponInfo.for_a_amount) {
|
||||
@@ -323,6 +330,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 折扣计算
|
||||
const handle1to10000 = (couponInfo) => {
|
||||
if (couponInfo.type == 'discount_for_a_amount') { // 满减
|
||||
if (allPayNum.value > (couponInfo.for_a_amount * 10000)) {
|
||||
@@ -411,6 +419,19 @@
|
||||
|
||||
const dataInfo = ref({})
|
||||
const couponList = ref({})
|
||||
const supportMethod = ref([])
|
||||
|
||||
function getCommonPaymentMethods(data) {
|
||||
if (!data.items || data.items.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return data.items
|
||||
.map(item => item.payment_methods)
|
||||
.reduce((common, current) =>
|
||||
common.filter(method => current.includes(method))
|
||||
);
|
||||
}
|
||||
|
||||
const loadData = async () => {
|
||||
// 订单信息
|
||||
@@ -420,6 +441,7 @@
|
||||
if (item.payment_methods.includes('rongdou') && item.payment_methods.includes(
|
||||
'points')) item.payment_methods.push('mixed')
|
||||
})
|
||||
supportMethod.value = getCommonPaymentMethods(dataInfo.value)
|
||||
})
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
|
||||
@@ -165,8 +165,7 @@
|
||||
if (response.success) {
|
||||
// 进入支付页面
|
||||
uni.navigateTo({
|
||||
url: '/pages/home/pay?preOrderId=' + response.data
|
||||
.preOrderId
|
||||
url: '/pages/home/pay?preOrderId=' + response.data.preOrderId
|
||||
})
|
||||
} else {
|
||||
msgRef.value.show({
|
||||
|
||||
Reference in New Issue
Block a user