2025-07-01 16:17:13 +08:00
|
|
|
<template>
|
|
|
|
|
<view class="wh-full">
|
|
|
|
|
<web-view :src="payUrl"></web-view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { onLoad } from "@dcloudio/uni-app";
|
|
|
|
|
import { useWebSocket } from '@/utils/webSocket/webSocket'
|
|
|
|
|
import { useUserStore } from "@/store/modules/user";
|
|
|
|
|
const { getUser } = useUserStore();
|
|
|
|
|
|
|
|
|
|
const payUrl = ref("");
|
|
|
|
|
const ws = useWebSocket(`/zhxy/webSocket/${getUser.userId}`, (type: string, data: any) => {
|
|
|
|
|
console.log('收到WebSocket消息:', type, data);
|
|
|
|
|
if (type === 'pay') {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '支付成功',
|
|
|
|
|
icon: 'success',
|
|
|
|
|
})
|
|
|
|
|
// 跳转到支付成功页面
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: "/pages/base/course-selection/payment-success",
|
|
|
|
|
});
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
onLoad((options: any) => {
|
|
|
|
|
if (options.payUrl) {
|
|
|
|
|
payUrl.value = decodeURIComponent(options.payUrl);
|
|
|
|
|
ws.reconnect();
|
|
|
|
|
} else {
|
|
|
|
|
uni.showToast({ title: '缺少支付地址', icon: 'none' })
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.navigateBack()
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-07-01 17:22:38 +08:00
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
ws.closeConnect();
|
|
|
|
|
});
|
2025-07-01 16:17:13 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|