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