Merge branch 'main' of http://1.117.67.95:3000/team/tyc-webview-v2
This commit is contained in:
@@ -38,8 +38,28 @@
|
|||||||
</template>
|
</template>
|
||||||
</van-cell>
|
</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="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-else title="支付宝支付" clickable @click="selectedPaymentMethod = 'alipay'">
|
<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>
|
||||||
@@ -60,6 +80,7 @@
|
|||||||
import { ref, defineProps } from "vue";
|
import { ref, defineProps } from "vue";
|
||||||
import { showConfirmDialog } from "vant";
|
import { showConfirmDialog } from "vant";
|
||||||
const { isWeChat } = useEnv();
|
const { isWeChat } = useEnv();
|
||||||
|
const isDev = import.meta.env.DEV;
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
@@ -76,9 +97,13 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const show = defineModel();
|
const show = defineModel();
|
||||||
const selectedPaymentMethod = ref(isWeChat.value ? "wechat" : "alipay");
|
const selectedPaymentMethod = ref(
|
||||||
|
isDev ? "test" : isWeChat.value ? "wechat" : "alipay"
|
||||||
|
);
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (isWeChat.value) {
|
if (isDev) {
|
||||||
|
selectedPaymentMethod.value = "test";
|
||||||
|
} else if (isWeChat.value) {
|
||||||
selectedPaymentMethod.value = "wechat";
|
selectedPaymentMethod.value = "wechat";
|
||||||
} else {
|
} else {
|
||||||
selectedPaymentMethod.value = "alipay";
|
selectedPaymentMethod.value = "alipay";
|
||||||
@@ -87,13 +112,6 @@ onMounted(() => {
|
|||||||
const orderNo = ref("");
|
const orderNo = ref("");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const discountPrice = ref(false); // 是否应用折扣
|
const discountPrice = ref(false); // 是否应用折扣
|
||||||
onMounted(() => {
|
|
||||||
if (isWeChat.value) {
|
|
||||||
selectedPaymentMethod.value = "wechat";
|
|
||||||
} else {
|
|
||||||
selectedPaymentMethod.value = "alipay";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
async function getPayment() {
|
async function getPayment() {
|
||||||
showConfirmDialog({
|
showConfirmDialog({
|
||||||
@@ -111,10 +129,23 @@ async function getPayment() {
|
|||||||
.json();
|
.json();
|
||||||
|
|
||||||
if (data.value && !error.value) {
|
if (data.value && !error.value) {
|
||||||
|
const prepayId = data.value.data.prepay_id ?? data.value.data.prepayId;
|
||||||
|
const orderNoFromApi = data.value.data.order_no;
|
||||||
|
orderNo.value = orderNoFromApi;
|
||||||
|
|
||||||
|
// 开发环境测试支付:直接跳转结果页
|
||||||
|
if (selectedPaymentMethod.value === "test" && prepayId === "test_payment_success") {
|
||||||
|
router.push({
|
||||||
|
path: "/payment/result",
|
||||||
|
query: { orderNo: orderNoFromApi },
|
||||||
|
});
|
||||||
|
show.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedPaymentMethod.value === "alipay") {
|
if (selectedPaymentMethod.value === "alipay") {
|
||||||
orderNo.value = data.value.data.order_no;
|
|
||||||
// 存储订单ID以便支付宝返回时获取
|
// 存储订单ID以便支付宝返回时获取
|
||||||
const prepayUrl = data.value.data.prepay_id;
|
const prepayUrl = prepayId;
|
||||||
const paymentForm = document.createElement("form");
|
const paymentForm = document.createElement("form");
|
||||||
paymentForm.method = "POST";
|
paymentForm.method = "POST";
|
||||||
paymentForm.action = prepayUrl;
|
paymentForm.action = prepayUrl;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ export default defineConfig({
|
|||||||
strictPort: true, // 如果端口被占用则抛出错误而不是使用下一个可用端口
|
strictPort: true, // 如果端口被占用则抛出错误而不是使用下一个可用端口
|
||||||
proxy: {
|
proxy: {
|
||||||
"/api/v1": {
|
"/api/v1": {
|
||||||
target: "http://127.0.0.1:8888", // 本地接口地址
|
// target: "http://127.0.0.1:8888", // 本地接口地址
|
||||||
// target: "https://www.tianyuancha.cn", // 本地接口地址
|
target: "https://www.tianyuancha.cn", // 本地接口地址
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user