This commit is contained in:
zoujiandong
2025-12-03 17:31:08 +08:00
parent f4c8df1950
commit 22104881f1
13 changed files with 104 additions and 65 deletions
+14 -7
View File
@@ -134,9 +134,11 @@ onLoad((query) => {
summary.value = shareTitle.value;
}
// #ifdef APP-PLUS
const resInfo = uni.getSystemInfoSync(); // 或者使用 uni.getSystemInfo({...}).then(res => {...})
let statusBarHeight = resInfo.statusBarHeight;
let wv = plus.webview.create("", "custom-webview", {
top: "140rpx",
bottom:"0rpx",
top: (statusBarHeight+44) + "px",
bottom:"0rpx",
});
wv.loadURL( safeUrl.value);
@@ -148,7 +150,7 @@ onLoad((query) => {
currentWebview.append(wv);
setTimeout(function () {
wv = currentWebview.children()[0];
wv.setStyle({ top: 80,height: height- 80,bottom:0,scalable:true, videoFullscreen: 'landscape',zIndex:-1});
wv.setStyle({ top: (statusBarHeight+44)+"px",height: height- 80,bottom:0,scalable:true, videoFullscreen: 'landscape',zIndex:-1});
}, 300); //如果是页面初始化调用时,需要延时一下
wv.onloaded = (e) => {
@@ -165,7 +167,7 @@ onLoad((query) => {
console.log('键盘高度',res.height);
setTimeout(function() {
wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
top:80,
top:(statusBarHeight+44)+"px",
videoFullscreen: 'landscape',
height: height-res.size.windowHeight+100,
scalable: true, //webview的页面是否可以缩放,双指放大缩小
@@ -178,7 +180,7 @@ onLoad((query) => {
} else {
setTimeout(function() {
wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
top:80,
top:(statusBarHeight+44)+"px",
height:height-80,
videoFullscreen: 'landscape',
scalable: true, //webview的页面是否可以缩放,双指放大缩小
@@ -346,11 +348,16 @@ function createNativePopup() {
console.log(`图标 ${idx} (${it.text}): left=${left}, itemW=${itemW.toFixed(2)}, iconLeft=${iconLeftPx}, iconTop=${iconTopPx}, iconSize=${iconSizePx}`);
// 构建图标本地路径
// 说明:
// - 在 Android 上使用 convertLocalFileSystemURL 可以得到 file:// 路径;
// - 但在 iOS 上,plus.nativeObj.View.drawBitmap 对 file:// 路径兼容性较差,
// 更推荐直接使用 "_www" 相对路径。
// 这里统一使用 "_www/static/xxx.png" 相对路径,兼容 Android 和 iOS。
let iconPath = null;
try {
// 直接使用静态资源路径
const iconFile = iconFiles[idx];
iconPath = plus.io.convertLocalFileSystemURL('_www/static/' + iconFile);
// 使用 _www 相对路径,避免 iOS 下 file:// 路径导致图片不显示
iconPath = '_www/static/' + iconFile;
console.log(`图标 ${it.text} 路径: ${iconPath}`);
} catch (e) {
console.log('构建图标路径失败:', e);