hookehuyr

feat(index): 优化首页产品跳转逻辑

- 热卖产品点击"产品资料"跳转到产品详情页并传递产品ID
- 产品详情页使用useLoad接收ID参数,为后续API调用做准备
- 本周热门资料"查看更多"跳转到资料列表页(material-list)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
67 plain 67 plain
68 color="#2563EB" 68 color="#2563EB"
69 class="flex-1 !h-[64rpx] !rounded-[16rpx] !text-[26rpx] !m-0 !border-blue-600" 69 class="flex-1 !h-[64rpx] !rounded-[16rpx] !text-[26rpx] !m-0 !border-blue-600"
70 - @tap="go('/pages/knowledge-base/index')" 70 + @tap="goToProductDetail(1)"
71 > 71 >
72 产品资料 72 产品资料
73 </nut-button> 73 </nut-button>
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
100 plain 100 plain
101 color="#2563EB" 101 color="#2563EB"
102 class="flex-1 !h-[64rpx] !rounded-[16rpx] !text-[26rpx] !m-0 !border-blue-600" 102 class="flex-1 !h-[64rpx] !rounded-[16rpx] !text-[26rpx] !m-0 !border-blue-600"
103 - @tap="go('/pages/knowledge-base/index')" 103 + @tap="goToProductDetail(2)"
104 > 104 >
105 产品资料 105 产品资料
106 </nut-button> 106 </nut-button>
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
119 <view class="bg-white rounded-[32rpx] shadow-sm p-[32rpx] mb-[48rpx]"> 119 <view class="bg-white rounded-[32rpx] shadow-sm p-[32rpx] mb-[48rpx]">
120 <view class="flex justify-between items-center mb-[24rpx]"> 120 <view class="flex justify-between items-center mb-[24rpx]">
121 <text class="text-gray-900 text-[32rpx] font-bold">本周热门资料</text> 121 <text class="text-gray-900 text-[32rpx] font-bold">本周热门资料</text>
122 - <view class="flex items-center text-blue-600" @tap="go('/pages/knowledge-base/index')"> 122 + <view class="flex items-center text-blue-600" @tap="go('/pages/material-list/index')">
123 <text class="text-[26rpx] mr-[4rpx]">查看更多</text> 123 <text class="text-[26rpx] mr-[4rpx]">查看更多</text>
124 <IconFont name="RectRight" size="12" /> 124 <IconFont name="RectRight" size="12" />
125 </view> 125 </view>
...@@ -208,6 +208,13 @@ const handleGridNav = (item) => { ...@@ -208,6 +208,13 @@ const handleGridNav = (item) => {
208 go(item.route); 208 go(item.route);
209 }; 209 };
210 210
211 +// 跳转到产品详情页
212 +const goToProductDetail = (productId) => {
213 + go('/pages/product-detail/index', {
214 + id: productId
215 + });
216 +};
217 +
211 // Open webview with URL 218 // Open webview with URL
212 const openWebView = (url) => { 219 const openWebView = (url) => {
213 go('/pages/webview/index', { 220 go('/pages/webview/index', {
......
...@@ -117,7 +117,51 @@ import { ref } from 'vue' ...@@ -117,7 +117,51 @@ import { ref } from 'vue'
117 import NavHeader from '@/components/NavHeader.vue' 117 import NavHeader from '@/components/NavHeader.vue'
118 import TabBar from '@/components/TabBar.vue' 118 import TabBar from '@/components/TabBar.vue'
119 import IconFont from '@/components/IconFont.vue' 119 import IconFont from '@/components/IconFont.vue'
120 -import Taro from '@tarojs/taro' 120 +import Taro, { useLoad } from '@tarojs/taro'
121 +
122 +// 接收页面参数
123 +const productId = ref(null)
124 +
125 +useLoad((options) => {
126 + console.log('产品详情页参数:', options)
127 +
128 + if (options.id) {
129 + productId.value = options.id
130 + console.log('产品ID:', productId.value)
131 +
132 + // TODO: 根据 productId 获取产品详情数据
133 + // 这里可以调用 API 获取对应产品的数据
134 + fetchProductDetail(options.id)
135 + } else {
136 + console.warn('未接收到产品ID')
137 + Taro.showToast({
138 + title: '产品ID不存在',
139 + icon: 'none',
140 + duration: 2000
141 + })
142 + }
143 +})
144 +
145 +// 根据 ID 获取产品详情(模拟)
146 +const fetchProductDetail = async (id) => {
147 + console.log('正在获取产品ID', id, '的详情...')
148 +
149 + // TODO: 实际调用 API
150 + // const res = await getProductDetailAPI({ i: id })
151 + // if (res.code === 1) {
152 + // // 更新产品数据
153 + // }
154 +
155 + // 模拟根据不同ID显示不同产品
156 + const productNames = {
157 + '1': '家庭财富传承保障计划(分红)',
158 + '2': '儿童教育金储备方案(分红)'
159 + }
160 +
161 + if (productNames[id]) {
162 + console.log('产品名称:', productNames[id])
163 + }
164 +}
121 165
122 // Random banner image 166 // Random banner image
123 const bannerImage = `https://picsum.photos/seed/${Math.floor(Math.random() * 1000)}/750/420` 167 const bannerImage = `https://picsum.photos/seed/${Math.floor(Math.random() * 1000)}/750/420`
......