2026-01-13 04:12:48 +00:00
|
|
|
<template>
|
|
|
|
|
<view class="webview-page">
|
2026-03-09 03:37:41 +00:00
|
|
|
<view class="header-fixed-wrapper" :style="{ height: headerHeight + 'px' }">
|
|
|
|
|
<NavHeader title="网页" />
|
|
|
|
|
</view>
|
|
|
|
|
<view class="main-wrap" :style="{ paddingTop: headerHeight + 'px' }">
|
2026-01-13 04:12:48 +00:00
|
|
|
<view class="webview-container">
|
|
|
|
|
<!-- #ifdef MP-WEIXIN -->
|
|
|
|
|
<web-view :src="webviewUrl"></web-view>
|
|
|
|
|
<!-- #endif -->
|
|
|
|
|
|
|
|
|
|
<!-- #ifndef MP-WEIXIN -->
|
|
|
|
|
<view class="unsupported-tip">
|
|
|
|
|
<text>当前平台不支持 WebView</text>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- #endif -->
|
|
|
|
|
</view>
|
2026-03-09 03:37:41 +00:00
|
|
|
</view>
|
2026-01-13 04:12:48 +00:00
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import NavHeader from "@/components/NavHeader/NavHeader.vue";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
NavHeader
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2026-03-09 03:37:41 +00:00
|
|
|
statusBarHeight: 0,
|
2026-01-13 04:12:48 +00:00
|
|
|
webviewUrl: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-03-09 03:37:41 +00:00
|
|
|
computed: {
|
|
|
|
|
headerHeight() {
|
|
|
|
|
return this.statusBarHeight + 44;
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-01-13 04:12:48 +00:00
|
|
|
onLoad(options) {
|
2026-03-09 03:37:41 +00:00
|
|
|
const systemInfo = uni.getSystemInfoSync();
|
|
|
|
|
this.statusBarHeight = systemInfo.statusBarHeight || 0;
|
2026-01-13 04:12:48 +00:00
|
|
|
// 从路由参数获取要加载的 URL
|
|
|
|
|
if (options.url) {
|
|
|
|
|
this.webviewUrl = decodeURIComponent(options.url);
|
|
|
|
|
} else {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '缺少网页地址',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.navigateBack();
|
|
|
|
|
}, 1500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.webview-page {
|
|
|
|
|
height: 100vh;
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-09 03:37:41 +00:00
|
|
|
.header-fixed-wrapper {
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
z-index: 100;
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.main-wrap {
|
|
|
|
|
flex: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
min-height: 0;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-13 04:12:48 +00:00
|
|
|
.webview-container {
|
|
|
|
|
flex: 1;
|
|
|
|
|
height: 0; // 配合 flex: 1 使用
|
|
|
|
|
|
|
|
|
|
.unsupported-tip {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
|
|
text {
|
|
|
|
|
font-family: PingFang-SC, PingFang-SC;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #999999;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-01-14 10:55:42 +00:00
|
|
|
|
2026-03-02 07:32:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|