2025-08-13 18:15:04 +08:00
|
|
|
<template>
|
2025-08-19 17:31:28 +08:00
|
|
|
<view id="test">
|
|
|
|
|
<!-- #ifdef h5 -->
|
2025-08-13 18:15:04 +08:00
|
|
|
<web-view :src="url"></web-view>
|
2025-08-19 17:31:28 +08:00
|
|
|
<!-- #endif -->
|
2025-08-13 18:15:04 +08:00
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { ref,onMounted,getCurrentInstance } from 'vue';
|
2025-08-19 17:31:28 +08:00
|
|
|
import { onLoad,onReady,onBackPress } from '@dcloudio/uni-app';
|
2025-08-13 18:15:04 +08:00
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
|
|
|
|
|
|
let windowInfo = ref(null);
|
|
|
|
|
let url = ref('');
|
|
|
|
|
let title = ref('');
|
|
|
|
|
onLoad(async(opt) => {
|
2025-08-19 17:31:28 +08:00
|
|
|
console.log(opt)
|
2025-08-14 14:01:54 +08:00
|
|
|
url.value = opt.url;
|
2025-08-13 18:15:04 +08:00
|
|
|
title.value = opt.title;
|
2025-08-19 17:31:28 +08:00
|
|
|
// #ifdef APP-PLUS
|
|
|
|
|
titleNViewWebview(url.value,title.value);
|
|
|
|
|
// #endif
|
|
|
|
|
// uni.getSystemInfo({
|
|
|
|
|
// success: (res)=> {
|
|
|
|
|
// windowInfo.value = res;
|
|
|
|
|
// createWvAndLoadUrl(url.value,title.value);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
2025-08-13 18:15:04 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
2025-08-19 17:31:28 +08:00
|
|
|
|
|
|
|
|
// 带标题栏控件的Webview窗口
|
|
|
|
|
let webview = null;
|
|
|
|
|
function titleNViewWebview(url,title) {
|
|
|
|
|
webview = plus.webview.create(url, 'test', {
|
|
|
|
|
titleNView: {
|
|
|
|
|
backgroundColor: '#307AF5',
|
|
|
|
|
titleText: title,
|
|
|
|
|
titleColor: '#ffffff',
|
|
|
|
|
autoBackButton: true,
|
|
|
|
|
backgroundImage:'./../../static/images/bg-Blue-header.png',
|
|
|
|
|
buttons:[{onclick:clickButton}]
|
2025-08-13 18:15:04 +08:00
|
|
|
}
|
|
|
|
|
});
|
2025-08-19 17:31:28 +08:00
|
|
|
webview.addEventListener('close', function(){
|
|
|
|
|
webview=null;
|
|
|
|
|
});
|
|
|
|
|
webview.addEventListener('titleUpdate', function(){
|
|
|
|
|
webview.show();
|
|
|
|
|
});
|
|
|
|
|
webview.addEventListener('loading', () => {
|
2025-08-13 18:15:04 +08:00
|
|
|
plus.nativeUI.showWaiting("loading...",{
|
|
|
|
|
width:'110px',
|
|
|
|
|
padding:'10px'
|
|
|
|
|
})
|
|
|
|
|
}, false);
|
|
|
|
|
//plus.nativeUI.showWaiting()
|
2025-08-19 17:31:28 +08:00
|
|
|
webview.addEventListener('loaded', () => {
|
2025-08-13 18:15:04 +08:00
|
|
|
plus.nativeUI.closeWaiting();
|
|
|
|
|
}, false);
|
2025-08-19 17:31:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 左侧按钮返回
|
|
|
|
|
function clickButton(){
|
|
|
|
|
// plus.nativeUI.alert('clicked!');
|
|
|
|
|
webview=null;
|
2025-08-13 18:15:04 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
</style>
|