|
|
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
|
|
import { View } from '@tarojs/components';
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
import { goodsCategoryClient, advertisementClient } from '@/api';
|
|
|
+import { useAuth } from '@/utils/auth';
|
|
|
import CategorySidebar from '@/components/category/CategorySidebar';
|
|
|
import CategorySidebarItem from '@/components/category/CategorySidebarItem';
|
|
|
import CategoryTabbar, { TabItem } from '@/components/category/CategoryTabbar';
|
|
|
@@ -21,6 +22,7 @@ type AdvertisementResponse = InferResponseType<typeof advertisementClient.$get,
|
|
|
type Advertisement = AdvertisementResponse['data'][0]
|
|
|
|
|
|
const CategoryPage: React.FC = () => {
|
|
|
+ const { isLoggedIn } = useAuth();
|
|
|
const [activeCategoryIndex, setActiveCategoryIndex] = useState<number>(0);
|
|
|
const [activeSubCategoryId, setActiveSubCategoryId] = useState<string>('');
|
|
|
const [toastVisible, setToastVisible] = useState<boolean>(false);
|
|
|
@@ -136,11 +138,13 @@ const CategoryPage: React.FC = () => {
|
|
|
}
|
|
|
});
|
|
|
if (response.status !== 200) {
|
|
|
- throw new Error('获取广告数据失败');
|
|
|
+ console.debug('分类页广告API响应状态:', response.status, response.statusText);
|
|
|
+ throw new Error(`获取广告数据失败 (状态码: ${response.status})`);
|
|
|
}
|
|
|
return response.json();
|
|
|
},
|
|
|
staleTime: 5 * 60 * 1000,
|
|
|
+ enabled: isLoggedIn,
|
|
|
});
|
|
|
|
|
|
//console.log("categoryData:",categoryData);
|