Explorar o código

✨ feat(index): 实现商品点击跳转详情页功能

- 修改商品点击事件处理函数,支持跳转到商品详情页
- 使用Taro.navigateTo实现页面跳转,携带商品id参数
- 移除原有的console.log调试代码
yourname hai 1 mes
pai
achega
fe31438040
Modificáronse 1 ficheiros con 10 adicións e 4 borrados
  1. 10 4
      mini/src/pages/index/index.tsx

+ 10 - 4
mini/src/pages/index/index.tsx

@@ -9,6 +9,7 @@ import { goodsClient, advertisementClient } from '@/api'
 import { InferResponseType } from 'hono'
 import './index.css'
 import { Carousel } from '@/components/ui/carousel'
+import Taro from '@tarojs/taro'
 
 type GoodsResponse = InferResponseType<typeof goodsClient.$get, 200>
 type Goods = GoodsResponse['data'][0]
@@ -103,10 +104,15 @@ const HomePage: React.FC = () => {
     }
   }
 
-
-  // 商品点击
-  const handleGoodsClick = (goods: GoodsData, index: number) => {
-    console.log('点击商品:', goods, index)
+  // // 商品点击
+  // const handleGoodsClick = (goods: GoodsData, index: number) => {
+  //   console.log('点击商品:', goods, index)
+  // }
+  // 跳转到商品详情
+  const handleGoodsClick = (goods: Goods) => {
+    Taro.navigateTo({
+      url: `/pages/goods-detail/index?id=${goods.id}`
+    })
   }
 
   // 添加购物车