From 8537f196df21e3bc49bec2f42088e84c3b67af97 Mon Sep 17 00:00:00 2001 From: minimaxagent1 Date: Tue, 5 Aug 2025 17:47:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=94=AF=E6=8C=81=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E5=8F=82=E6=95=B0page=E5=92=8Caid=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=B7=B3=E8=BD=AC=E5=92=8C=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 7 + pages/article/article-detail.vue | 229 +++++++++++++++++++++++++++++++ pages/nearbystores/index.vue | 75 +++++++++- 3 files changed, 308 insertions(+), 3 deletions(-) create mode 100644 pages/article/article-detail.vue diff --git a/pages.json b/pages.json index d9004c3..6f22756 100644 --- a/pages.json +++ b/pages.json @@ -95,6 +95,13 @@ } }, { + "path": "pages/article/article-detail", + "style": { + "navigationBarTitleText": "文章详情", + "enablePullDownRefresh": false, + "navigationStyle": "custom" + } + }, { "path": "pages/institutionalStructure/donationRecord", "style": { "navigationBarTitleText": "", diff --git a/pages/article/article-detail.vue b/pages/article/article-detail.vue new file mode 100644 index 0000000..6859b9f --- /dev/null +++ b/pages/article/article-detail.vue @@ -0,0 +1,229 @@ + + + + + \ No newline at end of file diff --git a/pages/nearbystores/index.vue b/pages/nearbystores/index.vue index 1308df6..576a3af 100644 --- a/pages/nearbystores/index.vue +++ b/pages/nearbystores/index.vue @@ -368,9 +368,78 @@ import { getArticleById } from "../../api/article/article.js"; } }, - // 页面跳转方法 - 使用路由仓库 - navigateToPage(pageType) { - navigateToPage(pageType); + // 兼容两种跳转方式:page路由跳转 或 aid文章详情跳转 + async navigateToPage(item, index) { + try { + console.log('导航项信息:', item); + console.log('导航项索引:', index); + + // 优先使用page字段进行路由跳转 + if (item.page) { + console.log('使用page字段进行路由跳转:', item.page); + // 导入路由工具 + const { navigateToPage: routerNavigate } = await import("../../utils/router.js"); + routerNavigate(item.page); + return; + } + + // 如果没有page字段,则使用aid进行文章详情跳转 + if (item.aid) { + console.log('使用aid字段获取文章详情:', item.aid); + + // 显示加载提示 + uni.showLoading({ + title: '加载中...', + mask: true + }); + + // 调用API获取文章详情 + const response = await getArticleById(item.aid); + + // 隐藏加载提示 + uni.hideLoading(); + + if (response.code === 200 && response.data) { + console.log('获取文章详情成功:', response.data); + + // 将文章数据存储到本地,供目标页面使用 + uni.setStorageSync('currentArticle', response.data); + + // 直接跳转到文章详情页面 + uni.navigateTo({ + url: '/pages/article/article-detail', + fail: (err) => { + console.error('跳转到文章详情页面失败:', err); + uni.showToast({ + title: '页面跳转失败', + icon: 'none' + }); + } + }); + } else { + console.error('获取文章详情失败:', response); + uni.showToast({ + title: '获取内容失败', + icon: 'none' + }); + } + } else { + console.error('导航项既没有page字段也没有aid字段:', item); + uni.showToast({ + title: '配置错误', + icon: 'none' + }); + } + } catch (error) { + // 隐藏加载提示 + uni.hideLoading(); + + console.error('导航跳转出错:', error); + uni.showToast({ + title: '网络错误', + icon: 'none' + }); + } } } }