refactor: 优化webview页面和util.js中链接处理逻辑
将链接参数拼接逻辑移至util.js中处理,统一各端链接处理方式
This commit is contained in:
@@ -693,18 +693,17 @@ export default {
|
|||||||
title: link?.title ?? '',
|
title: link?.title ?? '',
|
||||||
enable_set_title: link?.enable_set_title ? 1 : 0
|
enable_set_title: link?.enable_set_title ? 1 : 0
|
||||||
}
|
}
|
||||||
|
let url = this.normalizeUrl(decodeEntity(link.wap_url));
|
||||||
|
url = this.appendQueryParams(url, params);
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
let url = this.normalizeUrl(decodeEntity(link.wap_url));
|
|
||||||
url = this.appendQueryParams(url, params);
|
|
||||||
// console.log(`url ---->`, url, link)
|
// console.log(`url ---->`, url, link)
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
this.redirectTo('/pages_tool/webview/webview', {
|
this.redirectTo('/pages_tool/webview/webview', {
|
||||||
src: encodeURIComponent(link.wap_url),
|
src: encodeURIComponent(url)
|
||||||
...params
|
|
||||||
});
|
});
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,15 +14,10 @@ import { decodeEntity } from '@/common/js/util.js';
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
src: '',
|
src: ''
|
||||||
title: '', // 标题栏标题
|
|
||||||
enableSetTitle: false, // 是否强制设置标题,用来替换Webview中的默认标题
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
this.title = option?.title ?? '';
|
|
||||||
this.enableSetTitle = option?.enable_set_title == 1;
|
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
this.src = decodeEntity(decodeURIComponent(option.src));
|
this.src = decodeEntity(decodeURIComponent(option.src));
|
||||||
// #endif
|
// #endif
|
||||||
@@ -31,32 +26,11 @@ export default {
|
|||||||
this.src = decodeEntity(decodeURIComponent(`${option.src}&from=mp-webview`));
|
this.src = decodeEntity(decodeURIComponent(`${option.src}&from=mp-webview`));
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
onReady() {
|
|
||||||
this.updateNavbarTitle();
|
|
||||||
},
|
|
||||||
onShow() {
|
|
||||||
this.updateNavbarTitle();
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
title(newVal) {
|
|
||||||
this.updateNavbarTitle(newVal);
|
|
||||||
},
|
|
||||||
enableSetTitle() {
|
|
||||||
this.updateNavbarTitle();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
navigateBack() {
|
navigateBack() {
|
||||||
uni.navigateBack({
|
uni.navigateBack({
|
||||||
delta: 1
|
delta: 1
|
||||||
});
|
});
|
||||||
},
|
|
||||||
updateNavbarTitle(newTitle) {
|
|
||||||
if (this.enableSetTitle) {
|
|
||||||
uni.setNavigationBarTitle({
|
|
||||||
title: newTitle ?? this.title
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user