fix(webview&form): 适配小程序webview跳转场景

1. 给h5和小程序端webview页面分别处理src参数,小程序端添加from=mp-webview参数
2. 新增isFromMpWebView标识,从跳转参数判断是否来自小程序webview
3. 非小程序webview场景下才设置页面导航栏标题
This commit is contained in:
2026-05-28 16:07:38 +08:00
parent 00870e4554
commit a6189a5f9e
2 changed files with 16 additions and 4 deletions

View File

@@ -38,7 +38,8 @@ export default {
isRepeat: false,
complete: false,
scroll: true,
uniacid: 0
uniacid: 0,
isFromMpWebView: false, // 是否是从微信小程序的WebView跳转过来的
}
},
computed: {
@@ -67,6 +68,7 @@ export default {
this.uniacid = options.uniacid
this.id = options.id || 0
this.isFromMpWebView = options.from === 'mp-webview';
if (options.scene) {
const scene = decodeURIComponent(options.scene)
@@ -98,9 +100,13 @@ export default {
if (res.code == 0 && res.data) {
this.detail = res.data
console.log(`form data =>`, this.detail)
uni.setNavigationBarTitle({
title: res.data.form_name
})
// 非H5的情况下,设置标题
if (!this.isFromMpWebView) {
uni.setNavigationBarTitle({
title: res.data.form_name
})
}
}
this.$refs.loadingCover && this.$refs.loadingCover.hide()
},

View File

@@ -18,7 +18,13 @@ export default {
};
},
onLoad(option) {
// #ifdef H5
this.src = decodeEntity(decodeURIComponent(option.src));
// #endif
// #ifndef H5
this.src = decodeEntity(decodeURIComponent(`${option.src}&from=mp-webview`));
// #endif
},
methods: {
navigateBack() {