Files
gym-manage/gym-manage-uniapp/pages/webview/webview.vue
T

41 lines
911 B
Vue

<template>
<view class="webview-container">
<web-view :src="url" @message="handleMessage"></web-view>
</view>
</template>
<script setup>
import { ref } from 'vue'
const url = ref('')
onLoad((options) => {
if (options.url) {
url.value = decodeURIComponent(options.url)
}
})
function handleMessage(e) {
console.log('[webview] 收到消息:', e.detail)
// 处理支付回调消息
const data = e.detail.data
if (data && data.payResult) {
if (data.payResult === 'success') {
// 支付成功
uni.showToast({ title: '支付成功', icon: 'success' })
setTimeout(() => {
uni.navigateBack()
}, 1500)
} else {
uni.showToast({ title: '支付失败', icon: 'none' })
}
}
}
</script>
<style scoped>
.webview-container {
width: 100%;
height: 100vh;
}
</style>