f
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
<!-- 支付方式选择 -->
|
||||
<div class="">
|
||||
<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>
|
||||
<van-icon size="24" name="wechat-pay" color="#1AAD19" class="mr-2" />
|
||||
</template>
|
||||
@@ -48,18 +48,8 @@
|
||||
</template>
|
||||
</van-cell>
|
||||
|
||||
<!-- 开发环境:测试支付(仅开发环境显示) -->
|
||||
<van-cell v-if="isDev" title="测试支付(开发)" clickable @click="selectedPaymentMethod = 'test'">
|
||||
<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'">
|
||||
<!-- 支付宝支付(非微信环境;或微信内但隐藏微信支付时,如代理推广页) -->
|
||||
<van-cell v-if="showAlipayPay" title="支付宝支付" clickable @click="selectedPaymentMethod = 'alipay'">
|
||||
<template #icon>
|
||||
<van-icon size="24" name="alipay" color="#00A1E9" class="mr-2" />
|
||||
</template>
|
||||
@@ -77,7 +67,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, defineProps } from "vue";
|
||||
import { ref, computed, watch, onMounted } from "vue";
|
||||
import { showConfirmDialog } from "vant";
|
||||
const { isWeChat } = useEnv();
|
||||
const isDev = import.meta.env.DEV;
|
||||
@@ -95,20 +85,40 @@ const props = defineProps({
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
/** 为 true 时不展示微信支付(例如 /agent/promotionInquire/ 代理推广查询) */
|
||||
hideWechat: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
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 router = useRouter();
|
||||
const discountPrice = ref(false); // 是否应用折扣
|
||||
|
||||
Reference in New Issue
Block a user