Browse Source

Merge branch 'mini-starter/mini-multi-tenant-mall' into 租户3

yourname 2 tuần trước cách đây
mục cha
commit
37feb808b9

+ 9 - 9
mini/src/components/category/CategorySidebar/index.tsx

@@ -51,7 +51,7 @@ const CategorySidebar: React.FC<CategorySidebarProps> = (props) => {
     setChildrenList(prev => {
       const newList = [...prev, item];
       childrenRef.current = newList;
-      console.debug('CategorySidebar registerItem:', { itemIndex, totalItems: newList.length });
+      //console.debug('CategorySidebar registerItem:', { itemIndex, totalItems: newList.length });
       return newList;
     });
 
@@ -90,7 +90,7 @@ const CategorySidebar: React.FC<CategorySidebarProps> = (props) => {
     const preBottomRightRadiusItemIndexs = bottomRightRadiusItemIndexsRef.current;
 
     if (!children.length) {
-      console.debug('CategorySidebar setActive: no children available');
+      // console.debug('CategorySidebar setActive: no children available');
       return;
     }
 
@@ -98,14 +98,14 @@ const CategorySidebar: React.FC<CategorySidebarProps> = (props) => {
     // 或者如果是用户点击同一个item,也需要重新设置样式
     if (activeKey === currentActive && !isChildrenChange) {
       // 即使点击同一个item,也要确保样式正确应用
-      console.debug('CategorySidebar setActive: same item clicked, ensuring styles');
+      //console.debug('CategorySidebar setActive: same item clicked, ensuring styles');
     }
 
-    console.debug('CategorySidebar setActive:', { activeKey, currentActive, isChildrenChange, childrenCount: children.length });
+    // console.debug('CategorySidebar setActive:', { activeKey, currentActive, isChildrenChange, childrenCount: children.length });
 
     // 确保 activeKey 在有效范围内
     if (activeKey < 0 || activeKey >= children.length) {
-      console.debug('CategorySidebar setActive: invalid activeKey, using 0');
+     // console.debug('CategorySidebar setActive: invalid activeKey, using 0');
       setCurrentActive(0);
       return;
     }
@@ -115,10 +115,10 @@ const CategorySidebar: React.FC<CategorySidebarProps> = (props) => {
     const newTopRightRadiusItemIndexs = getTopRightRadiusItemIndexs(activeKey, children);
     const newBottomRightRadiusItemIndexs = getBottomRightRadiusItemIndexs(activeKey);
 
-    console.debug('CategorySidebar setActive - radius indexes:', {
-      top: newTopRightRadiusItemIndexs,
-      bottom: newBottomRightRadiusItemIndexs
-    });
+    // console.debug('CategorySidebar setActive - radius indexes:', {
+    //   top: newTopRightRadiusItemIndexs,
+    //   bottom: newBottomRightRadiusItemIndexs
+    // });
 
     setTopRightRadiusItemIndexs(newTopRightRadiusItemIndexs);
     setBottomRightRadiusItemIndexs(newBottomRightRadiusItemIndexs);

+ 12 - 12
mini/src/pages/goods-list/index.tsx

@@ -15,7 +15,6 @@ type Goods = GoodsResponse['data'][0]
 
 export default function GoodsListPage() {
   const [searchKeyword, setSearchKeyword] = useState('')
-  const [activeCategory, setActiveCategory] = useState('all')
   const { addToCart } = useCart()
 
   // 使用useRouter钩子获取路由参数
@@ -24,11 +23,6 @@ export default function GoodsListPage() {
   const categoryId = params?.cateId || ''
   const fromPage = params?.from || ''
 
-  const categories = [
-    { id: 'all', name: '全部' },
-    { id: 'hot', name: '热销' },
-    { id: 'new', name: '新品' },
-  ]
 
 
   const {
@@ -57,6 +51,12 @@ export default function GoodsListPage() {
           sortOrder: 'DESC' // 倒序排列
         }
       })
+
+      // console.log("categoryId:",categoryId);
+      // console.log("goodslistresponse:",response);
+      // console.debug("categoryId:",categoryId);
+      // console.debug("goodslistresponse:",response);
+
       if (response.status !== 200) {
         throw new Error('获取商品失败')
       }
@@ -77,7 +77,7 @@ export default function GoodsListPage() {
   // 分享功能 - 分享给好友
   useShareAppMessage(() => {
     // 如果有商品数据,使用第一个商品的图片作为分享图片
-    const shareImageUrl = allGoods.length > 0 ? allGoods[0]?.imageFile?.fullUrl || '' : '';
+    const shareImageUrl = allGoods.length > 0 ? (allGoods[0] as any)?.imageFile?.fullUrl || '' : '';
 
     // 构建分享标题
     let shareTitle = '商品分类 - 发现好物';
@@ -97,7 +97,7 @@ export default function GoodsListPage() {
   // 分享到朋友圈功能
   useShareTimeline(() => {
     // 朋友圈分享需要图片,使用第一个商品的图片
-    const shareImageUrl = allGoods.length > 0 ? allGoods[0]?.imageFile?.fullUrl || '' : '';
+    const shareImageUrl = allGoods.length > 0 ? (allGoods[0] as any)?.imageFile?.fullUrl || '' : '';
 
     // 朋友圈分享标题
     let shareTitle = '发现好物,快来选购!';
@@ -246,14 +246,14 @@ export default function GoodsListPage() {
                   const hasSpecOptions = goods.spuId === 0 && childGoodsIds && childGoodsIds.length > 0
                   // parentGoodsId: 如果是父商品,parentGoodsId = goods.id;如果是子商品,parentGoodsId = goods.spuId
                   const parentGoodsId = goods.spuId === 0 ? goods.id : goods.spuId
-                  const imageUrl = goods.imageFile?.fullUrl || ''
+                  const imageUrl = (goods as any).imageFile?.fullUrl || ''
 
                   return {
-                    id: goods.id.toString(),
+                    id: String(goods.id),
                     name: goods.name,
                     cover_image: imageUrl,
                     price: goods.price,
-                    originPrice: goods.originPrice,
+                    originPrice: (goods as any).originPrice,
                     tags: goods.stock <= 0 ? ['已售罄'] : goods.salesNum > 100 ? ['热销'] : [],
                     hasSpecOptions,
                     parentGoodsId,
@@ -262,7 +262,7 @@ export default function GoodsListPage() {
                     quantity: 1 // 默认数量为1
                   }
                 })}
-                onClick={(goods) => handleGoodsClick(allGoods.find(g => g.id.toString() === goods.id)!)}
+                onClick={(goods) => handleGoodsClick(allGoods.find(g => String(g.id) === goods.id)!)}
                 onAddCart={(goods) => handleAddToCart(goods)}
               />