This commit is contained in:
Mrx
2026-05-09 15:28:23 +08:00
parent e48a8ee4ed
commit a67094f90a
2 changed files with 37 additions and 26 deletions

View File

@@ -440,7 +440,8 @@
</div> </div>
<!-- 支付组件 --> <!-- 支付组件 -->
<Payment v-model="showPayment" :data="featureData" :id="queryId" type="query" @close="showPayment = false" /> <Payment v-model="showPayment" :data="featureData" :id="queryId" type="query"
:hide-wechat="props.type === 'promotion'" @close="showPayment = false" />
<BindPhoneDialog @bind-success="handleBindSuccess" /> <BindPhoneDialog @bind-success="handleBindSuccess" />
<LoginDialog @login-success="handleLoginSuccess" /> <LoginDialog @login-success="handleLoginSuccess" />

View File

@@ -29,7 +29,7 @@
<!-- 支付方式选择 --> <!-- 支付方式选择 -->
<div class=""> <div class="">
<van-cell-group inset> <van-cell-group inset>
<van-cell v-if="isWeChat" title="微信支付" clickable @click="selectedPaymentMethod = 'wechat'"> <van-cell v-if="showWechatPay" title="微信支付" clickable @click="selectedPaymentMethod = 'wechat'">
<template #icon> <template #icon>
<van-icon size="24" name="wechat-pay" color="#1AAD19" class="mr-2" /> <van-icon size="24" name="wechat-pay" color="#1AAD19" class="mr-2" />
</template> </template>
@@ -48,18 +48,8 @@
</template> </template>
</van-cell> </van-cell>
<!-- 开发环境测试支付仅开发环境显示 --> <!-- 支付宝支付非微信环境或微信内但隐藏微信支付如代理推广页 -->
<van-cell v-if="isDev" title="测试支付(开发)" clickable @click="selectedPaymentMethod = 'test'"> <van-cell v-if="showAlipayPay" title="支付宝支付" clickable @click="selectedPaymentMethod = 'alipay'">
<template #icon>
<van-icon size="24" name="passed" color="#07c160" class="mr-2" />
</template>
<template #right-icon>
<van-radio v-model="selectedPaymentMethod" name="test" />
</template>
</van-cell>
<!-- 支付宝支付 -->
<van-cell v-if="!isWeChat" title="支付宝支付" clickable @click="selectedPaymentMethod = 'alipay'">
<template #icon> <template #icon>
<van-icon size="24" name="alipay" color="#00A1E9" class="mr-2" /> <van-icon size="24" name="alipay" color="#00A1E9" class="mr-2" />
</template> </template>
@@ -77,7 +67,7 @@
</template> </template>
<script setup> <script setup>
import { ref, defineProps } from "vue"; import { ref, computed, watch, onMounted } from "vue";
import { showConfirmDialog } from "vant"; import { showConfirmDialog } from "vant";
const { isWeChat } = useEnv(); const { isWeChat } = useEnv();
const isDev = import.meta.env.DEV; const isDev = import.meta.env.DEV;
@@ -95,20 +85,40 @@ const props = defineProps({
type: String, type: String,
required: true, required: true,
}, },
/** 为 true 时不展示微信支付(例如 /agent/promotionInquire/ 代理推广查询) */
hideWechat: {
type: Boolean,
default: false,
},
}); });
const show = defineModel(); const show = defineModel();
const selectedPaymentMethod = ref(
isDev ? "test" : isWeChat.value ? "wechat" : "alipay" const showWechatPay = computed(() => isWeChat.value && !props.hideWechat);
const showAlipayPay = computed(() => !isWeChat.value || props.hideWechat);
function defaultPaymentMethod() {
if (isDev) return "test";
if (showWechatPay.value) return "wechat";
return "alipay";
}
const selectedPaymentMethod = ref(defaultPaymentMethod());
function syncSelectedPaymentMethod() {
selectedPaymentMethod.value = defaultPaymentMethod();
}
onMounted(syncSelectedPaymentMethod);
watch(
[showWechatPay, showAlipayPay, show],
() => {
if (show.value) {
syncSelectedPaymentMethod();
}
},
{ flush: "post" }
); );
onMounted(() => {
if (isDev) {
selectedPaymentMethod.value = "test";
} else if (isWeChat.value) {
selectedPaymentMethod.value = "wechat";
} else {
selectedPaymentMethod.value = "alipay";
}
});
const orderNo = ref(""); const orderNo = ref("");
const router = useRouter(); const router = useRouter();
const discountPrice = ref(false); // 是否应用折扣 const discountPrice = ref(false); // 是否应用折扣