fix(webview&form): 适配小程序webview跳转场景
1. 给h5和小程序端webview页面分别处理src参数,小程序端添加from=mp-webview参数 2. 新增isFromMpWebView标识,从跳转参数判断是否来自小程序webview 3. 非小程序webview场景下才设置页面导航栏标题
This commit is contained in:
@@ -38,7 +38,8 @@ export default {
|
|||||||
isRepeat: false,
|
isRepeat: false,
|
||||||
complete: false,
|
complete: false,
|
||||||
scroll: true,
|
scroll: true,
|
||||||
uniacid: 0
|
uniacid: 0,
|
||||||
|
isFromMpWebView: false, // 是否是从微信小程序的WebView跳转过来的
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -67,6 +68,7 @@ export default {
|
|||||||
|
|
||||||
this.uniacid = options.uniacid
|
this.uniacid = options.uniacid
|
||||||
this.id = options.id || 0
|
this.id = options.id || 0
|
||||||
|
this.isFromMpWebView = options.from === 'mp-webview';
|
||||||
|
|
||||||
if (options.scene) {
|
if (options.scene) {
|
||||||
const scene = decodeURIComponent(options.scene)
|
const scene = decodeURIComponent(options.scene)
|
||||||
@@ -98,9 +100,13 @@ export default {
|
|||||||
if (res.code == 0 && res.data) {
|
if (res.code == 0 && res.data) {
|
||||||
this.detail = res.data
|
this.detail = res.data
|
||||||
console.log(`form data =>`, this.detail)
|
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()
|
this.$refs.loadingCover && this.$refs.loadingCover.hide()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,7 +18,13 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
|
// #ifdef H5
|
||||||
this.src = decodeEntity(decodeURIComponent(option.src));
|
this.src = decodeEntity(decodeURIComponent(option.src));
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifndef H5
|
||||||
|
this.src = decodeEntity(decodeURIComponent(`${option.src}&from=mp-webview`));
|
||||||
|
// #endif
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
navigateBack() {
|
navigateBack() {
|
||||||
|
|||||||
Reference in New Issue
Block a user