|
@@ -12,6 +12,7 @@ import Taro from '@tarojs/taro';
|
|
|
import BookHead from '@src/components/PupPetry/BookHead';
|
|
|
import BookHotTabs from '@src/components/PupPetry/BookHotTabs';
|
|
|
import BookboxColumnSmall from '@src/components/PupPetry/BookBox/BookboxColumnSmall';
|
|
|
+import BookboxRowMiddle from '@src/components/PupPetry/BookBox/BookboxRowMiddle';
|
|
|
|
|
|
|
|
|
interface Props {
|
|
@@ -19,7 +20,7 @@ interface Props {
|
|
|
}
|
|
|
const Index: React.FC<Props> = ({ store }) => {
|
|
|
const { appInfoStore, bookStore, indexStore } = store
|
|
|
- const { indexComponents } = useApi(appInfoStore)
|
|
|
+ const { indexComponents, getBookPageList } = useApi(appInfoStore)
|
|
|
const [pageShow, setPageShow] = useState(false)//防止小程序切换页面组件不会被真实卸载,阻止不必要的操作
|
|
|
// 首页配置信息
|
|
|
const indexConfig = useMemo(() => {
|
|
@@ -59,6 +60,9 @@ const Index: React.FC<Props> = ({ store }) => {
|
|
|
case "banners"://轮播
|
|
|
getBanners()
|
|
|
break;
|
|
|
+ case "hot_books"://今日热书
|
|
|
+ getToDayHotBooks()
|
|
|
+ break;
|
|
|
case "hot_category"://热门分类
|
|
|
getHotCategory()
|
|
|
break;
|
|
@@ -76,15 +80,18 @@ const Index: React.FC<Props> = ({ store }) => {
|
|
|
if (data?.length > 0) {
|
|
|
getHotBooks(data[0].id)
|
|
|
}
|
|
|
- console.log("data====>", data)
|
|
|
})
|
|
|
}
|
|
|
// 热门分类书籍
|
|
|
const getHotBooks = (categoryId) => {
|
|
|
if (categoryId) {
|
|
|
- indexComponents?.hot_books(bookStore.workDirection, categoryId)
|
|
|
+ getBookPageList({ pageNum: 1, pageSize: 8, workDirection: bookStore.workDirection, categoryId })
|
|
|
}
|
|
|
}
|
|
|
+ // 今日热书
|
|
|
+ const getToDayHotBooks = () => {
|
|
|
+ indexComponents?.hot_books(bookStore.workDirection)
|
|
|
+ }
|
|
|
return (
|
|
|
<ScrollViewHoc>
|
|
|
<View style={{ display: "flex", flexFlow: 'column' }}>
|
|
@@ -92,13 +99,29 @@ const Index: React.FC<Props> = ({ store }) => {
|
|
|
{indexConfig['banners'] && <View style={{ order: indexConfig['banners'].eq }}>
|
|
|
<BannerBox data={indexStore?.indexBanners || []} />
|
|
|
</View>}
|
|
|
+ {/* 今日热门 */}
|
|
|
+ {indexConfig['hot_books'] && <View style={{ order: indexConfig['banners'].eq }}>
|
|
|
+ <BookHead title="今日热书" fitTitle="更多" imgUrl={require('../../icon/right.png')} fitOnBack={() => {
|
|
|
+ Taro.navigateTo({ url: `/pages/indexMore/index?title=今日热书&dataName=indexHotBooks` })
|
|
|
+ }}></BookHead>
|
|
|
+ <View ><BookboxRowMiddle {...indexStore?.indexHotBooks?.[0]} /></View>
|
|
|
+ <View className='w row'>
|
|
|
+ {
|
|
|
+ indexStore?.indexHotBooks?.map((item, index) => {
|
|
|
+ if (index > 0 && index < 5) {
|
|
|
+ return <View key={index}><BookboxColumnSmall {...item} /></View>
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>}
|
|
|
{/* 热门分类 */}
|
|
|
{indexConfig['hot_category'] && <View style={{ order: indexConfig['banners'].eq }}>
|
|
|
<BookHead title="热门分类" fitTitle="全部分类" imgUrl={require('../../icon/right.png')} fitOnBack={() => { Taro.switchTab({ url: '/pages/classify/index' }) }} />
|
|
|
<BookHotTabs hotValue={indexStore?.indexHotCategory || []} />
|
|
|
<View className='w row4'>
|
|
|
{
|
|
|
- indexStore?.indexHotBooks?.map((item, index) => {
|
|
|
+ bookStore?.bookList?.records?.map((item, index) => {
|
|
|
return <View key={index}><BookboxColumnSmall {...item} /></View>
|
|
|
})
|
|
|
}
|