修改广告跳转页面异常的问题

This commit is contained in:
赵毅 2025-08-05 09:39:45 +08:00
parent d64fa80c13
commit f52d8cbcc6

View File

@ -427,26 +427,27 @@ export default {
headerServerClick(e) { headerServerClick(e) {
console.log("当前点击内容", e); console.log("当前点击内容", e);
if (!e.link_url) { if (!e.target_page) {
this.NotOpen(); this.NotOpen();
return; return;
} }
if (e.link_url) { if (e.target_page) {
// #ifdef APP-PLUS // #ifdef APP-PLUS
uni.navigateTo({ uni.navigateTo({
url: "/pages/webview/webview?url=" + encodeURIComponent(e.link_url), url:
"/pages/webview/webview?url=" + encodeURIComponent(e.target_page),
}); });
// #endif // #endif
// #ifdef H5 // #ifdef H5
window.open(e.link_url, "_blank"); window.open(e.target_page, "_blank");
// #endif // #endif
// #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU // #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU
if (e.appid) { if (e.appid) {
uni.navigateToMiniProgram({ uni.navigateToMiniProgram({
appId: e.appid, appId: e.appid,
path: e.link_url, path: e.target_page,
//需要传递给目标小程序的数据 //需要传递给目标小程序的数据
extraData: { extraData: {
data1: "test", data1: "test",
@ -456,18 +457,23 @@ export default {
}, },
}); });
} else { } else {
NavgateTo(e.link_url); // 确保路径是绝对路径
let targetPage = e.target_page;
if (!targetPage.startsWith("/")) {
targetPage = "/" + targetPage;
}
NavgateTo(targetPage);
// NavgateTo('/packages/localLife/index/index') // NavgateTo('/packages/localLife/index/index')
} }
// 小程序中可能需要用户手动复制链接或使用web-view // 小程序中可能需要用户手动复制链接或使用web-view
// uni.showModal({ // uni.showModal({
// title: '提示', // title: '提示',
// content: '即将打开外部链接,请复制后在浏览器中打开: ' + e.link_url, // content: '即将打开外部链接,请复制后在浏览器中打开: ' + e.target_page,
// confirmText: '复制链接', // confirmText: '复制链接',
// success(res) { // success(res) {
// if (res.confirm) { // if (res.confirm) {
// uni.setClipboardData({ // uni.setClipboardData({
// data: e.link_url, // data: e.target_page,
// success() { // success() {
// uni.showToast({ // uni.showToast({
// title: '复制成功', // title: '复制成功',