From 9d4e22931288a249c0db2ad174de22fb242f57e7 Mon Sep 17 00:00:00 2001 From: ISFP_T <68358856@qq.com> Date: Mon, 15 Dec 2025 17:37:52 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=AD=A3=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=A6=96=E9=A1=B5=E3=80=81=E4=B8=AA=E4=BA=BA=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E9=A1=B5=E9=9D=A2=E5=B9=BF=E5=91=8A=E5=9B=BEurl?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/MapComponent.vue | 10 ----- config/url.js | 4 +- locale/en-US.js | 1 + locale/zh-CN.js | 1 + pages.json | 8 ++++ pages/index/index.vue | 62 ++++++++++++++++++++++++----- pages/my/index.vue | 62 +++++++++++++++++++++++++---- pages/webview/index.vue | 78 +++++++++++++++++++++++++++++++++++++ 8 files changed, 197 insertions(+), 29 deletions(-) create mode 100644 pages/webview/index.vue diff --git a/components/MapComponent.vue b/components/MapComponent.vue index dfa3a5a..1bfe736 100644 --- a/components/MapComponent.vue +++ b/components/MapComponent.vue @@ -247,14 +247,12 @@ // 监听广告图片变化,启动或停止轮播 watch(() => props.bannerImages, (newImages, oldImages) => { - console.log('广告图片变化:', newImages?.length, '张') // 先停止旧的轮播 stopBannerRotation() currentBannerIndex.value = 0 // 如果有多张图片,启动新的轮播 if (newImages && newImages.length > 1) { - console.log('启动广告轮播,共', newImages.length, '张图片') // 使用 nextTick 确保 DOM 已更新 nextTick(() => { startBannerRotation() @@ -384,29 +382,23 @@ const handleSearch = () => { // 处理广告点击 const handleBannerTap = () => { - console.log('点击地图广告:', currentBannerIndex.value, currentBannerImage.value) // 触发父组件处理点击事件 emit('bannerClick', currentBannerIndex.value) - // 默认跳转到合作加盟页面 - handleJoinTap() } // 启动广告轮播 const startBannerRotation = () => { // 如果只有一张或没有图片,不需要轮播 if (!props.bannerImages || props.bannerImages.length <= 1) { - console.log('图片数量不足,不启动轮播') return } // 清除旧的定时器 stopBannerRotation() - console.log('开始广告轮播定时器') // 每3秒切换一次 bannerTimer = setInterval(() => { const nextIndex = (currentBannerIndex.value + 1) % props.bannerImages.length - console.log('轮播切换:', currentBannerIndex.value, '->', nextIndex) currentBannerIndex.value = nextIndex }, 3000) } @@ -414,7 +406,6 @@ const handleSearch = () => { // 停止广告轮播 const stopBannerRotation = () => { if (bannerTimer) { - console.log('停止广告轮播') clearInterval(bannerTimer) bannerTimer = null } @@ -450,7 +441,6 @@ const handleSearch = () => { // 初始化广告轮播 if (props.bannerImages && props.bannerImages.length > 1) { - console.log('onMounted: 初始化广告轮播') startBannerRotation() } }) diff --git a/config/url.js b/config/url.js index e0d18e3..914ef91 100644 --- a/config/url.js +++ b/config/url.js @@ -1,6 +1,6 @@ // export const URL = "https://my.gxfs123.com/api" //正式服务器-弃用 -// export const URL = "https://manager.fdzpower.com/api" //正式服务器 -export const URL = "https://fansdev.gxfs123.com/api" //测试服务器 +export const URL = "https://manager.fdzpower.com/api" //正式服务器 +// export const URL = "https://fansdev.gxfs123.com/api" //测试服务器 // export const URL = "http://192.168.5.30:8080" //本地调试 // export const URL = "http://127.0.0.1:8080" //本地调试 diff --git a/locale/en-US.js b/locale/en-US.js index 1b7cb3f..2324a62 100644 --- a/locale/en-US.js +++ b/locale/en-US.js @@ -11,6 +11,7 @@ export default { filling: 'Filling...', save: 'Save', loadFailed: 'Load failed', + invalidUrl: 'Invalid URL', statusCode: 'Status Code', message: 'Message', none: 'None', diff --git a/locale/zh-CN.js b/locale/zh-CN.js index 6ad80cf..fc903bb 100644 --- a/locale/zh-CN.js +++ b/locale/zh-CN.js @@ -11,6 +11,7 @@ export default { filling: '补填中', save: '保存', loadFailed: '加载失败', + invalidUrl: '无效的链接', statusCode: '状态码', message: '消息', none: '无', diff --git a/pages.json b/pages.json index b5700e1..dfb941f 100644 --- a/pages.json +++ b/pages.json @@ -240,6 +240,14 @@ "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black" } + }, + { + "path": "pages/webview/index", + "style": { + "navigationBarTitleText": "", + "navigationBarBackgroundColor": "#ffffff", + "navigationBarTextStyle": "black" + } } ], "globalStyle": { diff --git a/pages/index/index.vue b/pages/index/index.vue index 321098b..0ceab82 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -292,6 +292,7 @@ const noticeText = ref('') const bannerImages = ref([]) // 首页广告图片列表 + const bannerImageList = ref([]) // 完整的广告配置列表(包含链接信息) // 将语言代码转换为后端接受的格式 const convertLanguageCode = (lang) => { @@ -373,11 +374,12 @@ console.log('首页广告响应:', res) if (res.statusCode === 200 && res.data.code === 200 && res.data.data) { - // 使用 files 字段(图片列表) - const files = res.data.data.files || [] - if (files.length > 0) { - bannerImages.value = files - console.log('首页广告加载成功,图片数量:', files.length) + // 使用 imageList 字段(包含图片和链接信息) + const imageList = res.data.data.imageList || [] + if (imageList.length > 0) { + bannerImageList.value = imageList + // 提取图片URL用于展示 + bannerImages.value = imageList.map(item => item.imageUrl) } else { console.warn('未获取到广告图片') } @@ -391,10 +393,52 @@ // 处理首页广告点击 const handleBannerClick = (index) => { - console.log('点击首页广告:', index, bannerImages.value[index]) - // 可以根据需要添加跳转逻辑 - // 例如跳转到合作加盟页面 - uni.navigateTo({ url: '/pages/join/index' }) + if (!bannerImageList.value || !bannerImageList.value[index]) { + console.warn('未找到对应的广告配置') + return + } + + const config = bannerImageList.value[index] + console.log('点击首页广告:', index, config) + + // 根据链接类型进行跳转 + if (config.linkType === 'miniapp' && config.appId) { + // 跳转到外部小程序 + // #ifdef MP-WEIXIN + uni.navigateToMiniProgram({ + appId: config.appId, + path: config.linkUrl || '', + success: () => { + console.log('跳转小程序成功') + }, + fail: (err) => { + console.error('跳转小程序失败:', err) + uni.showToast({ + title: '跳转失败', + icon: 'none' + }) + } + }) + // #endif + // #ifndef MP-WEIXIN + uni.showToast({ + title: '请在微信小程序中使用', + icon: 'none' + }) + // #endif + } else if (config.linkType === 'external' && config.linkUrl) { + // 跳转到外部链接(H5页面) + uni.navigateTo({ + url: `/pages/webview/index?url=${encodeURIComponent(config.linkUrl)}` + }) + } else if (config.linkType === 'internal' && config.linkUrl) { + // 跳转到内部页面 + uni.navigateTo({ + url: config.linkUrl + }) + } else { + console.log('无有效的跳转配置') + } } // 查询最近的活动 diff --git a/pages/my/index.vue b/pages/my/index.vue index 30fc32a..5a26c2f 100644 --- a/pages/my/index.vue +++ b/pages/my/index.vue @@ -159,6 +159,7 @@ import { const showMenuItem = ref(false) const bannerImages = ref([]) // 广告图片列表 + const bannerImageList = ref([]) // 完整的广告配置列表(包含链接信息) // 将语言代码转换为后端接受的格式 const convertLanguageCode = (lang) => { @@ -192,11 +193,13 @@ import { console.log('个人中心广告响应:', res) if (res.statusCode === 200 && res.data.code === 200 && res.data.data) { - // 使用 files 字段(图片列表) - const files = res.data.data.files || [] - if (files.length > 0) { - bannerImages.value = files - console.log('个人中心广告加载成功,图片数量:', files.length) + // 使用 imageList 字段(包含图片和链接信息) + const imageList = res.data.data.imageList || [] + if (imageList.length > 0) { + bannerImageList.value = imageList + // 提取图片URL用于展示 + bannerImages.value = imageList.map(item => item.imageUrl) + console.log('个人中心广告加载成功,图片数量:', imageList.length) } } else { console.warn('获取个人中心广告失败:', res.data?.msg || '未知错误') @@ -208,9 +211,52 @@ import { // 处理广告点击 const handleBannerClick = (index) => { - console.log('点击广告:', index) - // 可以根据需要添加跳转逻辑 - // 例如:navigateTo('/pages/join/index') + if (!bannerImageList.value || !bannerImageList.value[index]) { + console.warn('未找到对应的广告配置') + return + } + + const config = bannerImageList.value[index] + console.log('点击广告:', index, config) + + // 根据链接类型进行跳转 + if (config.linkType === 'miniapp' && config.appId) { + // 跳转到外部小程序 + // #ifdef MP-WEIXIN + uni.navigateToMiniProgram({ + appId: config.appId, + path: config.linkUrl || '', + success: () => { + console.log('跳转小程序成功') + }, + fail: (err) => { + console.error('跳转小程序失败:', err) + uni.showToast({ + title: '跳转失败', + icon: 'none' + }) + } + }) + // #endif + // #ifndef MP-WEIXIN + uni.showToast({ + title: '请在微信小程序中使用', + icon: 'none' + }) + // #endif + } else if (config.linkType === 'external' && config.linkUrl) { + // 跳转到外部链接(H5页面) + uni.navigateTo({ + url: `/pages/webview/index?url=${encodeURIComponent(config.linkUrl)}` + }) + } else if (config.linkType === 'internal' && config.linkUrl) { + // 跳转到内部页面 + uni.navigateTo({ + url: config.linkUrl + }) + } else { + console.log('无有效的跳转配置') + } } // 页面加载时初始化 diff --git a/pages/webview/index.vue b/pages/webview/index.vue new file mode 100644 index 0000000..5ac4ee9 --- /dev/null +++ b/pages/webview/index.vue @@ -0,0 +1,78 @@ + + + + + + +