shenwu 7 months ago
parent
commit
d60bd5db06

+ 1 - 2
src/app.config.ts

@@ -12,9 +12,8 @@ export default {
     'pages/my/aboutUs/index',//关于我们
     'pages/my/aboutUs/index',//关于我们
     'pages/my/contactService/index',//联系客服
     'pages/my/contactService/index',//联系客服
     'pages/book/bookArticle/index',//书籍内容 阅读页
     'pages/book/bookArticle/index',//书籍内容 阅读页
-    // 'pages/search/index',//搜索
+    'pages/search/index',//搜索
     'pages/indexMore/index', // 更多
     'pages/indexMore/index', // 更多
-    // 'pages/book/bookDetails1/index',//书籍详情
   ],
   ],
 
 
   window: {
   window: {

+ 17 - 14
src/components/PupPetry/BookBox/BookboxColumnBig.tsx

@@ -4,23 +4,26 @@ import { Text, View, Image, Navigator } from "@tarojs/components";
 import React from 'react'
 import React from 'react'
 import './index.less'
 import './index.less'
 export interface BookboxColumnBigProps {
 export interface BookboxColumnBigProps {
-    book_id?: number,//书籍ID
-    book_name?: string,//名称
-    penname?: string,//作者
-    intro?: string,//描述
-    cover?: string,//图片
-    category?: string,//标签分类
-    sign?: string,//热度,阅读人数 
-    action?: string//地址
+    bookId: number,//书ID
+    authorName: string,//作者
+    bookName: string,//书名称
+    bookDesc: string,//描述
+    picUrl: string,//封面
+    bookStatus: number,//完本|连载状态
+    wordCount: number,//字数
+    labelInfoList: { name: string }[],//标签
 }
 }
 function BookboxColumnBig(props: BookboxColumnBigProps) {
 function BookboxColumnBig(props: BookboxColumnBigProps) {
-    const { cover, book_name, penname, book_id } = props
-    return <View className='book_box_column_big'>
-        <Navigator url={'/pages/book/bookDetails/index?book_id=' + book_id} hoverClass="none">
-            <Image src={cover || ''} className='img'></Image>
+    const click = () => {
+        // BookStore.setData({ openBookData: props })
+    }
+    const { picUrl, bookName, bookId, authorName } = props
+    return <View className='book_box_column_big' onClick={click} >
+        <Navigator url={'/pages/book/bookDetails/index?bookId=' + bookId} hoverClass="none" >
+            <Image src={picUrl || ''} className='img'></Image>
             <View className='bottom'>
             <View className='bottom'>
-                <Text className='title'>{book_name}</Text>
-                <Text className='author'>{penname}</Text>
+                <Text className='title'>{bookName}</Text>
+                <Text className='author'>{authorName}</Text>
             </View>
             </View>
         </Navigator>
         </Navigator>
     </View>
     </View>

+ 2 - 3
src/components/PupPetry/BookBox/BookboxColumnSmall.tsx

@@ -3,7 +3,6 @@
 import { Text, View, Image, Navigator } from "@tarojs/components";
 import { Text, View, Image, Navigator } from "@tarojs/components";
 import React from 'react'
 import React from 'react'
 import './index.less'
 import './index.less'
-import BookStore from "@src/store/book"
 export interface BookboxColumnSmallProps {
 export interface BookboxColumnSmallProps {
     bookId: number,//书ID
     bookId: number,//书ID
     authorName: string,//作者
     authorName: string,//作者
@@ -17,10 +16,10 @@ export interface BookboxColumnSmallProps {
 function BookboxColumnSmall(props: BookboxColumnSmallProps) {
 function BookboxColumnSmall(props: BookboxColumnSmallProps) {
     const { picUrl, bookName, bookId } = props
     const { picUrl, bookName, bookId } = props
     const click = () => {
     const click = () => {
-        BookStore.setData({ openBookData: props })
+        // BookStore.setData({ openBookData: props })
     }
     }
     return <View className='book_box_column_small' onClick={click}>
     return <View className='book_box_column_small' onClick={click}>
-        <Navigator url={'/pages/book/bookDetails/index?book_id=' + bookId} hoverClass="none">
+        <Navigator url={'/pages/book/bookDetails/index?bookId=' + bookId} hoverClass="none">
             <Image src={picUrl || ''} className='img'></Image>
             <Image src={picUrl || ''} className='img'></Image>
             <View className='bottom'>
             <View className='bottom'>
                 <Text className='title'>{bookName}</Text>
                 <Text className='title'>{bookName}</Text>

+ 1 - 2
src/components/PupPetry/BookBox/BookboxRowBig.tsx

@@ -3,7 +3,6 @@
 import { Text, View, Image, Navigator } from "@tarojs/components";
 import { Text, View, Image, Navigator } from "@tarojs/components";
 import React from 'react'
 import React from 'react'
 import './index.less'
 import './index.less'
-import BookStore from "@src/store/book"
 export interface BookboxRowBigProps {
 export interface BookboxRowBigProps {
     bookId: number,//书ID
     bookId: number,//书ID
     authorName:string,//作者
     authorName:string,//作者
@@ -21,7 +20,7 @@ function BookboxRowBig(props: BookboxRowBigProps) {
         describe = `${bookName}·${(wordCount/10000).toFixed(0)}万字·${bookStatus === 0 ? '连载' : '完本'}`
         describe = `${bookName}·${(wordCount/10000).toFixed(0)}万字·${bookStatus === 0 ? '连载' : '完本'}`
     }
     }
     const click = () => {
     const click = () => {
-        BookStore.setData({ openBookData: props })
+        // BookStore.setData({ openBookData: props })
     }
     }
     return <View className='book_box_row_big' onClick={click}>
     return <View className='book_box_row_big' onClick={click}>
         <Navigator url={'/pages/book/bookDetails/index?bookId=' + bookId} hoverClass="none">
         <Navigator url={'/pages/book/bookDetails/index?bookId=' + bookId} hoverClass="none">

+ 5 - 2
src/components/PupPetry/BookBox/BookboxRowMiddle.tsx

@@ -15,8 +15,11 @@ export interface BookboxRowMiddleProps {
 }
 }
 function BookboxRowMiddle(props: BookboxRowMiddleProps) {
 function BookboxRowMiddle(props: BookboxRowMiddleProps) {
     const { bookName, picUrl, bookDesc, labelInfoList, authorName, bookId, wordCount, bookStatus } = props
     const { bookName, picUrl, bookDesc, labelInfoList, authorName, bookId, wordCount, bookStatus } = props
-    return <View className='book_box_row_middle'>
-        <Navigator url={'/pages/book/bookDetails/index?book_id=' + bookId} hoverClass="none">
+    const click = () => {
+        // BookStore.setData({ openBookData: props })
+    }
+    return <View className='book_box_row_middle'  onClick={click}>
+        <Navigator url={'/pages/book/bookDetails/index?bookId=' + bookId} hoverClass="none">
             <Image src={picUrl || ''} className='img'></Image>
             <Image src={picUrl || ''} className='img'></Image>
             <View className='right'>
             <View className='right'>
                 <Text className='title'>{bookName}</Text>
                 <Text className='title'>{bookName}</Text>

+ 29 - 22
src/components/PupPetry/BookBox/BookboxRowSmall.tsx

@@ -3,35 +3,43 @@
 import { Text, View, Image, Button, Navigator } from "@tarojs/components";
 import { Text, View, Image, Button, Navigator } from "@tarojs/components";
 import React from 'react'
 import React from 'react'
 import './index.less'
 import './index.less'
-
+import BookStore from "@src/store/book"
+import { setReadLog } from "@src/utils/loginSto";
 export interface BookboxRowSmallProps {
 export interface BookboxRowSmallProps {
-    book_id: number,  // 书ID
-    book_name: string, // 书名
-    category: string, //书类型
-    cover: string, //封面
-    intro: string,
-    penname: string, // 作者
-    sign: string,  //阅读人数
-    section: string,//章节
-    chapter_name?: string,
-    chapter_id?: number
+    bookId: number,//书ID
+    authorName: string,//作者
+    bookName: string,//书名称
+    bookDesc: string,//描述
+    picUrl: string,//封面
+    bookStatus: number,//完本|连载状态
+    wordCount: number,//字数
+    labelInfoList: { name: string }[],//标签
+    readLogId: string,//上次阅读的记录
 }
 }
 function BookboxRowSmall(props: BookboxRowSmallProps) {
 function BookboxRowSmall(props: BookboxRowSmallProps) {
-    const { book_id, book_name, category, cover, penname, chapter_name, section, chapter_id } = props
-    return <View className='book_box_row_small'>
-        <Navigator url={`/pages/book/bookArticle/index?book_id=${book_id}&chapter_id=${chapter_id || ''}`} hoverClass="none">
-            <Image src={cover} className='img'></Image>
+    const { bookName, picUrl, bookDesc, labelInfoList, authorName, bookId, wordCount, bookStatus, readLogId } = props
+    const click = () => {
+        BookStore.setData({ openBookData: props })
+        if (readLogId) {
+            setReadLog({ [bookId]: readLogId })
+        }
+    }
+    return <View className='book_box_row_small' onClick={click}>
+        <Navigator url={`/pages/book/bookArticle/index?bookId=${bookId}}`} hoverClass="none">
+            <Image src={picUrl} className='img'></Image>
             <View className='right'>
             <View className='right'>
-                <Text className='title'>{book_name}</Text>
+                <Text className='title'>{bookName}</Text>
                 <View className='content'>
                 <View className='content'>
                     <View className='left'>
                     <View className='left'>
-                        <Text className='author'>{penname}</Text>
+                        <Text className='author'>{authorName}</Text>
                         <View className='bottom'>
                         <View className='bottom'>
                             {
                             {
-                                chapter_name ? <>
-                                    {/* <Text className='time'>{time}</Text> */}
-                                    <Text className='section'>{chapter_name}</Text>
-                                </>:<Text className='null'>未读</Text>
+                                true ? <>
+                                    <Text className='time'>{123}</Text>
+                                    {/* <Text className='section'>{chapter_name}</Text> */}
+                                </>
+                                    :
+                                    <Text className='null'>未读</Text>
                             }
                             }
                         </View>
                         </View>
                     </View>
                     </View>
@@ -41,5 +49,4 @@ function BookboxRowSmall(props: BookboxRowSmallProps) {
         </Navigator>
         </Navigator>
     </View>
     </View>
 }
 }
-
 export default React.memo(BookboxRowSmall)
 export default React.memo(BookboxRowSmall)

+ 50 - 0
src/components/PupPetry/BookSearch/index.less

@@ -0,0 +1,50 @@
+@import '../../../globaStyle.less';
+.bookSearch{
+    display: flex;
+    justify-content: flex-start;
+    margin: 30px;
+    align-items: center;
+    .left {
+        flex: 1;
+        display: flex;
+        justify-content: flex-start;
+        align-items: center;
+        height: 72px;
+        padding: 0 30px;
+        background: @bg_F7;
+        border-radius: 40px;
+        margin-right: 36px;
+        image{
+            width: 52px;
+            height: 52px;
+            
+            &.search{
+                margin-right: 16px;
+            }
+            &.clear{
+                margin-left: 10px;
+            }
+        }
+        input{
+            flex: 1;
+            font-size: 28px;
+            font-family: PingFangSC-Regular, PingFang SC;
+            font-weight: 400;
+            color: @cl_333;
+        }
+    }
+    .right button {
+        height: 44px;
+        padding: 0;
+        margin: 0;
+        color: @cl_999;
+        font-weight: 400;
+        font-size: 32px;
+        font-family: PingFangSC-Regular, PingFang SC;
+        background: transparent;
+        line-height: normal;
+        &::after{
+            border: 0;
+        }
+    }
+}

+ 47 - 0
src/components/PupPetry/BookSearch/index.tsx

@@ -0,0 +1,47 @@
+import { View, Input, Image, Text, Button } from '@tarojs/components'
+import './index.less'
+import React, { useCallback, useState, useEffect } from 'react'
+
+/**
+ * 热门 tabs
+ */
+
+type props = {
+    onBack: (value: string) => void,     // 切换回调函数
+    val?: string,                        // 搜索框内容
+    onClear?: () => void,                // 清除触发
+}
+
+const BookSearch = (props: props) => {
+    let { onBack, val = "", onClear } = props
+
+    let [value, setValue] = useState<string>("")
+
+    let searchHandle = useCallback(() => {
+        onBack(value)
+    }, [value])
+
+    let clearHandle = useCallback(() => {
+        onClear && onClear()
+        setValue("")
+    }, [value])
+
+    useEffect(() => {
+        setValue(val)
+    }, [val])
+
+    return <View className="bookSearch">
+        <View className="left">
+            <Image src={require('../../../icon/search_1.png')} className="search"/>
+            <Input type='text' placeholder='书名、作者' value={value} onInput={(e)=>{setValue(e.detail.value)}} onConfirm={searchHandle}/>
+            {
+                value && <Image src={require('../../../icon/clear.png')} className="clear" onClick={clearHandle}/>
+            }
+        </View>
+        <View className="right" onClick={searchHandle}>
+            <Button>搜索</Button>
+        </View>
+    </View>
+}
+
+export default React.memo(BookSearch)

+ 30 - 18
src/components/ScrollView/index.tsx

@@ -4,16 +4,17 @@ import { UpLoading } from "@src/components/PupPetry/Loading"
 import Taro from "@tarojs/taro"
 import Taro from "@tarojs/taro"
 interface State {
 interface State {
     isShow: boolean  //是否开启刷新状态
     isShow: boolean  //是否开启刷新状态
-    loadNum: number, //加载次数
-    ref: any,
     isBoShow: boolean, //是否开启下拉刷新状态
     isBoShow: boolean, //是否开启下拉刷新状态
     isNull: boolean,  // 是否还有数据
     isNull: boolean,  // 是否还有数据
+    filterHeight: number,//容器排除的高度
 }
 }
 interface Props {
 interface Props {
-    children: any,
+    children: any,//渲染的子元素
+    filterClassName: string,//要排除的元素的高度
+    navHeight: number,//头部导航高度
     refresh?: () => Promise<any>,//刷新
     refresh?: () => Promise<any>,//刷新
     load?: () => Promise<any>,//加载
     load?: () => Promise<any>,//加载
-    callback?:(num:any)=>void,//返回滚动距离
+    callback?: (num: any) => void,//返回滚动距离
 }
 }
 /**页面上下加载*/
 /**页面上下加载*/
 class ScrollViewHoc extends Component<Props> {
 class ScrollViewHoc extends Component<Props> {
@@ -22,14 +23,13 @@ class ScrollViewHoc extends Component<Props> {
     }
     }
     state: State = {
     state: State = {
         isShow: false,
         isShow: false,
-        loadNum: 0,
-        ref: null,
         isBoShow: false,
         isBoShow: false,
-        isNull: false
+        isNull: false,
+        filterHeight: 0,
     }
     }
     //**向上刷新 */
     //**向上刷新 */
     onScrollToUpper = () => {
     onScrollToUpper = () => {
-        if(!this.props.refresh){
+        if (!this.props.refresh) {
             setTimeout(() => { this.setState({ isShow: false }) }, 500)
             setTimeout(() => { this.setState({ isShow: false }) }, 500)
             log('请传入自定义refresh事件')
             log('请传入自定义refresh事件')
             return
             return
@@ -43,13 +43,13 @@ class ScrollViewHoc extends Component<Props> {
                     await this?.props?.refresh().then(() => {
                     await this?.props?.refresh().then(() => {
                         setTimeout(() => { this.setState({ isShow: false }) }, 500)
                         setTimeout(() => { this.setState({ isShow: false }) }, 500)
                     })
                     })
-                } 
+                }
             })
             })
         }
         }
     }
     }
     /**向下加载 */
     /**向下加载 */
     onScrollToLower = () => {
     onScrollToLower = () => {
-        if(!this.props.load){
+        if (!this.props.load) {
             log('请传入自定义load事件')
             log('请传入自定义load事件')
             return
             return
         }
         }
@@ -64,23 +64,35 @@ class ScrollViewHoc extends Component<Props> {
                         this.setState({ isNull: true, isBoShow: false })
                         this.setState({ isNull: true, isBoShow: false })
                     })
                     })
                     setTimeout(() => { this.setState({ isBoShow: false }) }, 500)
                     setTimeout(() => { this.setState({ isBoShow: false }) }, 500)
-                } 
+                }
             })
             })
         }
         }
     }
     }
-    componentDidShow() {
-    }
-    ref = (ref) => {//拿到子组件的方法
-        this.setState({ ref })
+    componentDidMount() {
+        let { filterClassName, navHeight = 0 } = this.props
+        if (filterClassName) {
+            Taro.createSelectorQuery()
+                .select(filterClassName) // 选择器,用于选择要获取信息的元素
+                .boundingClientRect() // 获取节点的布局信息
+                .exec((res) => {
+                    if (res[0]) {
+                        const height = res[0].height; // 获取元素的高度
+                        this.setState({ filterHeight: height + navHeight })
+                    } else {
+                        console.log('未找到指定元素');
+                    }
+                });
+        }
     }
     }
     render() {
     render() {
         const { children } = this.props
         const { children } = this.props
+        const { filterHeight } = this.state
         return <ScrollView
         return <ScrollView
-            lowerThreshold={10}
-            // refresherEnabled={true}
+            lowerThreshold={filterHeight}
             refresherTriggered={this.state.isShow}
             refresherTriggered={this.state.isShow}
+            style={{ height: `calc(100vh - ${filterHeight}px)` }}
             onScrollToLower={this.onScrollToLower}
             onScrollToLower={this.onScrollToLower}
-            onScroll={(evt)=>{
+            onScroll={(evt) => {
                 this.props.callback?.(evt.detail.scrollTop)
                 this.props.callback?.(evt.detail.scrollTop)
             }}
             }}
             className='scrollview'
             className='scrollview'

+ 2 - 1
src/components/TopNavBar/index.tsx

@@ -80,6 +80,7 @@ function CustomNavbar(WrappedComponent, props: Props) {
         }
         }
         // 去搜索页面
         // 去搜索页面
         searchBackHandle = () => {
         searchBackHandle = () => {
+            console.log(1111)
             Taro.navigateTo({
             Taro.navigateTo({
                 url: '/pages/search/index'
                 url: '/pages/search/index'
             })
             })
@@ -121,7 +122,7 @@ function CustomNavbar(WrappedComponent, props: Props) {
                                 </View>
                                 </View>
                                 {
                                 {
                                     search && <View className="search">
                                     search && <View className="search">
-                                        <Image src={searchPng} className="searchImg" onClick={searchBack ? this.searchBackHandle : () => { }} />
+                                        <Image src={searchPng} className="searchImg" onClick={this.searchBackHandle} />
                                     </View>
                                     </View>
                                 }
                                 }
                             </View>
                             </View>

+ 30 - 0
src/pages/book/BookArticle/index.less

@@ -650,4 +650,34 @@
       border: 2px solid #FF5C77;
       border: 2px solid #FF5C77;
     }
     }
   }
   }
+}
+.text-with-lines {
+  position: relative;
+  text-align: center;
+  color: #FF2442;
+  font-size: 32px;  /* 可根据需要调整字体大小 */
+}
+// .text-with-lines  {
+//   position: relative;
+//   text-align: center;
+//   color: #FF2442;
+//   padding: 0 20px;  /* 为文本增加一些左右内边距,使线条不贴近文本 */
+//   font-size: 16px;  /* 可根据需要调整字体大小 */
+// }
+.text-with-lines::before,
+.text-with-lines::after {
+  content: '';
+  position: absolute;
+  top: 50%;
+  width: 25%;  /* 线条的宽度,可根据需要调整 */
+  border-top: 2px dashed #FF91A0 ;  /* 设置为虚线,并定义颜色 */
+  transform: translateY(-50%);
+}
+
+.text-with-lines::before {
+  left: 0;
+}
+
+.text-with-lines::after {
+  right: 0;
 }
 }

+ 19 - 8
src/pages/book/BookArticle/index.tsx

@@ -5,7 +5,7 @@ import { View, Text, ScrollView } from '@tarojs/components';
 import { observer, inject } from 'mobx-react';
 import { observer, inject } from 'mobx-react';
 import './index.less';
 import './index.less';
 import TopNavBar from '@src/components/TopNavBar/index';
 import TopNavBar from '@src/components/TopNavBar/index';
-import Taro from '@tarojs/taro';
+import Taro, { useDidHide } from '@tarojs/taro';
 import BookConfigPuP from '@src/components/bookConfigPup';
 import BookConfigPuP from '@src/components/bookConfigPup';
 import { BookStore } from '@src/store/book';
 import { BookStore } from '@src/store/book';
 import useApi from '@src/Hook/useApi';
 import useApi from '@src/Hook/useApi';
@@ -31,10 +31,11 @@ interface BookArticleProps extends PageStateProps { }
 const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
 const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
     const [isLoad, setIsLoad] = useState(false)
     const [isLoad, setIsLoad] = useState(false)
     const { bookStore, indexStore, appInfoStore } = store
     const { bookStore, indexStore, appInfoStore } = store
+    const [showPay, setShowPay] = useState(false)//需要付费展示
     const { openBookData } = bookStore
     const { openBookData } = bookStore
     const [bookConfig, setBookConfig] = useState<Config>({ size: 'pre_21', off_on: true, bg: 'bg_b', lh: 'lh_72' });
     const [bookConfig, setBookConfig] = useState<Config>({ size: 'pre_21', off_on: true, bg: 'bg_b', lh: 'lh_72' });
     const [pup, setPup] = useState(false);
     const [pup, setPup] = useState(false);
-    const { getBookContent,readingBook } = useApi(appInfoStore)
+    const { getBookContent, readingBook } = useApi(appInfoStore)
     const [currentScrollId, setCurrentScrollId] = useState('');
     const [currentScrollId, setCurrentScrollId] = useState('');
     const newReadLogIdRef = useRef("");
     const newReadLogIdRef = useRef("");
     const readLogInterval = useRef<NodeJS.Timeout>()
     const readLogInterval = useRef<NodeJS.Timeout>()
@@ -69,19 +70,20 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
             console.log("卸载", newReadLogIdRef.current);
             console.log("卸载", newReadLogIdRef.current);
             openBookData && setReadLog({ [openBookData.bookId]: newReadLogIdRef.current })//离开时存放当前位置
             openBookData && setReadLog({ [openBookData.bookId]: newReadLogIdRef.current })//离开时存放当前位置
             clearInterval(readLogInterval.current)//清除上报心跳
             clearInterval(readLogInterval.current)//清除上报心跳
+            readingBook({ readId: bookStore.readId, readLogId: newReadLogIdRef.current, updateReadLog: true })
         };
         };
     }, [])
     }, [])
     // 这里可以填写上报逻辑
     // 这里可以填写上报逻辑
     const reportRead = () => {
     const reportRead = () => {
         console.log("上报", newReadLogIdRef.current)
         console.log("上报", newReadLogIdRef.current)
         openBookData && setReadLog({ [openBookData.bookId]: newReadLogIdRef.current })
         openBookData && setReadLog({ [openBookData.bookId]: newReadLogIdRef.current })
-        if(readLogInterval.current){
+        if (readLogInterval.current) {
             clearInterval(readLogInterval.current)
             clearInterval(readLogInterval.current)
         }
         }
         // 定时上报心跳
         // 定时上报心跳
         readLogInterval.current = setInterval(() => {
         readLogInterval.current = setInterval(() => {
-            readingBook(bookStore.readId)
-            console.log("上报阅读心跳",newReadLogIdRef.current,bookStore.readId)
+            readingBook({ readId: bookStore.readId, readLogId: newReadLogIdRef.current })
+            console.log("上报阅读心跳", newReadLogIdRef.current, bookStore.readId)
         }, 3000);
         }, 3000);
     };
     };
     //设置配置
     //设置配置
@@ -181,7 +183,6 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
             }
             }
         });
         });
     };
     };
-
     const { size, bg, off_on, lh } = bookConfig;
     const { size, bg, off_on, lh } = bookConfig;
     return (
     return (
         <ScrollView
         <ScrollView
@@ -219,8 +220,17 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
                 <View onClick={togglePup}>
                 <View onClick={togglePup}>
                     {
                     {
                         openBookData?.contentData?.records?.map(item => {
                         openBookData?.contentData?.records?.map(item => {
+                            let needPay = item.needPay
+                            let isPay = item.isPay
+                            let showText = true
                             let arr = item.paragraphInfo.content?.match(/[^\n]*\n?/g);
                             let arr = item.paragraphInfo.content?.match(/[^\n]*\n?/g);
-                            return <View
+                            if (needPay && !isPay) {
+                                showText = false
+                                if (!showPay) {
+                                    setShowPay(true)
+                                }
+                            }
+                            return showText ? <View
                                 id={'paragraphNo-' + item.paragraphInfo.paragraphNo}
                                 id={'paragraphNo-' + item.paragraphInfo.paragraphNo}
                                 key={item.paragraphInfo.paragraphNo}
                                 key={item.paragraphInfo.paragraphNo}
                                 className={`pre ${size} ${lh}`}
                                 className={`pre ${size} ${lh}`}
@@ -233,9 +243,10 @@ const BookArticle: React.FC<BookArticleProps> = ({ store }) => {
                                         }</Text>
                                         }</Text>
                                     })
                                     })
                                 }
                                 }
-                            </View>
+                            </View> : null
                         })
                         })
                     }
                     }
+                    {showPay && <View className='text-with-lines' >剩余内容需付费解锁</View>}
                 </View>
                 </View>
                 {/* 设置弹窗 */}
                 {/* 设置弹窗 */}
                 {pup && <BookConfigPuP {...bookConfig} off_on={off_on} setOff={setOff} setSize={setSize} setBg={setBg} setLh={setLh} />}
                 {pup && <BookConfigPuP {...bookConfig} off_on={off_on} setOff={setOff} setSize={setSize} setBg={setBg} setLh={setLh} />}

+ 15 - 14
src/pages/book/bookDetails/index.tsx

@@ -18,23 +18,24 @@ interface Props {
 class BookDetails extends Component<Props> {
 class BookDetails extends Component<Props> {
     state: state = {
     state: state = {
     }
     }
-    onShareAppMessage() {
-        return {
-            title: '我的好朋友',
-            path: 'pages/book/bookDetails/index?bookId' + this.props.store.bookStore.openBookData?.bookId,
-            imageUrl: this.props.store.bookStore.openBookData?.picUrl
-        }
-    }
+    // onShareAppMessage() {
+    //     return {
+    //         title: '我的好朋友',
+    //         path: 'pages/book/bookDetails/index?bookId' + this.props.store.bookStore.openBookData?.bookId,
+    //         imageUrl: this.props.store.bookStore.openBookData?.picUrl
+    //     }
+    // }
+    
     componentDidShow(options) {
     componentDidShow(options) {
-        Taro.showShareMenu({
-            showShareItems: ["shareAppMessage"],
-            success: (res) => { log("成功") },
-            fail: (err) => { log("err") }
-        });
+        // Taro.showShareMenu({
+        //     showShareItems: ["shareAppMessage"],
+        //     success: (res) => { log("成功") },
+        //     fail: (err) => { log("err") }
+        // });
         let params = Taro.getCurrentInstance()?.router?.params
         let params = Taro.getCurrentInstance()?.router?.params
         let { bookStore, appInfoStore } = this.props.store
         let { bookStore, appInfoStore } = this.props.store
         // 获取书籍详情
         // 获取书籍详情
-        if (params?.bookId && !bookStore.openBookData) {
+        if (params?.bookId) {
             let { getBookInfo } = useApi(appInfoStore)
             let { getBookInfo } = useApi(appInfoStore)
             log("分享进入")
             log("分享进入")
             getBookInfo(params.bookId)
             getBookInfo(params.bookId)
@@ -52,7 +53,7 @@ class BookDetails extends Component<Props> {
     render() {
     render() {
         let { bookStore } = this.props.store
         let { bookStore } = this.props.store
         let { openBookData } = bookStore
         let { openBookData } = bookStore
-        let describe = `${openBookData?.bookName}·${openBookData?.wordCount ? (openBookData?.wordCount / 10000).toFixed(0) + "万字·" : ""}${openBookData?.bookStatus === 0 ? '连载' : '完本'}`
+        let describe = `${openBookData?.wordCount ? (openBookData?.wordCount / 10000).toFixed(0) + "万字·" : ""}${openBookData?.bookStatus === 0 ? '连载' : '完本'}`
         return <>
         return <>
             {
             {
                 <View className='book_details'>
                 <View className='book_details'>

+ 59 - 25
src/pages/bookrack/index.tsx

@@ -1,5 +1,5 @@
-import { useEffect } from 'react'
-import { View } from '@tarojs/components'
+import { useEffect, useState } from 'react'
+import { ScrollView, View } from '@tarojs/components'
 import Taro, { useDidHide, useDidShow } from '@tarojs/taro'
 import Taro, { useDidHide, useDidShow } from '@tarojs/taro'
 import { eventCenter, getCurrentInstance } from '@tarojs/taro'
 import { eventCenter, getCurrentInstance } from '@tarojs/taro'
 import { observer, inject } from 'mobx-react'
 import { observer, inject } from 'mobx-react'
@@ -10,8 +10,6 @@ import styles from './index.module.less'
 import TopNavBar from '@src/components/TopNavBar/index'
 import TopNavBar from '@src/components/TopNavBar/index'
 import ScrollViewHoc from '@src/components/ScrollView'
 import ScrollViewHoc from '@src/components/ScrollView'
 import BookboxRowSmall from '@src/components/PupPetry/BookBox/BookboxRowSmall'
 import BookboxRowSmall from '@src/components/PupPetry/BookBox/BookboxRowSmall'
-import Divider from '@src/components/PupPetry/Divider'
-import Empty from '@src/components/Empty'
 import { Store } from '@src/app'
 import { Store } from '@src/app'
 import useApi from '@src/Hook/useApi'
 import useApi from '@src/Hook/useApi'
 
 
@@ -19,48 +17,84 @@ import useApi from '@src/Hook/useApi'
 interface Props {
 interface Props {
     store: Store;
     store: Store;
 }
 }
-
+interface ContentData {
+    current: number,
+    total: number,
+    size: number,
+    records: any[]
+}
 const Index: React.FC<Props> = ({ store }) => {
 const Index: React.FC<Props> = ({ store }) => {
+    const { indexStore } = store
     const { bookrackList } = useApi(store.appInfoStore)
     const { bookrackList } = useApi(store.appInfoStore)
-
+    const [readData, setReadData] = useState<ContentData>({
+        current: 0,
+        total: 0,
+        size: 0,
+        records: []
+    })
+    const [pageShow, setPageShow] = useState(false)
     useEffect(() => {
     useEffect(() => {
-        log("componentDidMount", store.appInfoStore.appInfo);
-        bookrackList()
+        if (pageShow) {
+            getList({ pageNum: 1, pageSize: 20 })
+        }
         return () => {
         return () => {
             log("componentWillUnmount");
             log("componentWillUnmount");
         };
         };
-    }, []); // Dependency array, runs effect only once on mount and unmount
+    }, [pageShow]); // Dependency array, runs effect only once on mount and unmount
 
 
     // 使用 useDidShow 代替 onShow
     // 使用 useDidShow 代替 onShow
     useDidShow(() => {
     useDidShow(() => {
-        log("Page is shown or brought to foreground");
+        setPageShow(true)
     });
     });
 
 
     // 使用 useDidHide 如果需要在页面隐藏时做一些处理
     // 使用 useDidHide 如果需要在页面隐藏时做一些处理
     useDidHide(() => {
     useDidHide(() => {
-        log("Page is hidden or sent to background");
+        setPageShow(false)
     });
     });
-    return (
-        <ScrollViewHoc>
+    const getList = (params) => {
+        bookrackList(params).then((res: any) => {
+            setReadData(res.data.data)
+            return res
+        })
+        return Promise.resolve(true)
+    }
+    const load = () => {
+        return new Promise((resolve, reject) => {
+            let { size, total, records } = readData
+            let pageSize = size + 20
+            if (records?.length >= total) {
+                Taro.showToast({
+                    title: '没有更多了~~',
+                    duration: 2000,
+                    icon: 'none'
+                })
+                reject()
+                return
+            } else {
+                getList({ pageNum: 1, pageSize }).then(res => {
+                    resolve(true)
+                })
+            }
+        })
+    }
+    return <View>
+        <ScrollViewHoc
+            load={load}
+            filterClassName={""}
+            navHeight={indexStore.navHeight}
+
+        >
             <View className={styles.index}>
             <View className={styles.index}>
-                {/* {
-                    this.state.readLog.map((item: any, index: number) => {
+                {
+                    readData?.records?.map((item: any, index: number) => {
                         return <>
                         return <>
-                            <View key={index} onClick={() => { bookStore.action(item) }}> <BookboxRowSmall {...item} /></View>
+                            <View key={index} > <BookboxRowSmall {...item} /></View>
                         </>
                         </>
                     })
                     })
                 }
                 }
-                {
-                    this.state.guessData.length > 0 ? <Divider text="猜您想继续阅读"></Divider> : <Empty text='书架暂无书籍哦~' />
-                }
-                {
-                    this.state.guessData.map((item: any, index: number) => {
-                        return <View key={index} onClick={() => { bookStore.action(item) }}> <BookboxRowSmall {...item} /></View>
-                    })
-                } */}
             </View>
             </View>
         </ScrollViewHoc>
         </ScrollViewHoc>
-    );
+    </View>
 };
 };
 export default TopNavBar((inject('store')(observer(Index))), {
 export default TopNavBar((inject('store')(observer(Index))), {
     title: '阅读记录'
     title: '阅读记录'

+ 14 - 17
src/pages/classify/index.tsx

@@ -1,7 +1,8 @@
 import { forwardRef, useEffect, useState } from 'react'
 import { forwardRef, useEffect, useState } from 'react'
+import Taro from '@tarojs/taro'
 import { useDidHide, useDidShow } from '@tarojs/taro'
 import { useDidHide, useDidShow } from '@tarojs/taro'
-import { View } from '@tarojs/components'
 import { observer, inject } from 'mobx-react'
 import { observer, inject } from 'mobx-react'
+import { View } from '@tarojs/components'
 import './index.less'
 import './index.less'
 //==========components组件引用========================
 //==========components组件引用========================
 import TopNavBar from '@src/components/TopNavBar/index'
 import TopNavBar from '@src/components/TopNavBar/index'
@@ -12,14 +13,14 @@ import Empty from '@src/components/Empty'
 import { Store } from '@src/app'
 import { Store } from '@src/app'
 import useApi from '@src/Hook/useApi'
 import useApi from '@src/Hook/useApi'
 import { getBookCategoryList } from '@src/server/classify'
 import { getBookCategoryList } from '@src/server/classify'
-import Taro from '@tarojs/taro'
+
 
 
 interface Props {
 interface Props {
     store: Store;
     store: Store;
 }
 }
 
 
 const Index = forwardRef((props: Props) => {
 const Index = forwardRef((props: Props) => {
-    const { bookStore, appInfoStore, classifyStore } = props.store
+    const { bookStore, appInfoStore, classifyStore, indexStore } = props.store
     const { getBookPageList } = useApi(appInfoStore)
     const { getBookPageList } = useApi(appInfoStore)
     const [pageShow, setPageShow] = useState(false)//防止小程序切换页面组件不会被真实卸载,阻止不必要的操作
     const [pageShow, setPageShow] = useState(false)//防止小程序切换页面组件不会被真实卸载,阻止不必要的操作
     const [isFixed, setIsFixed] = useState(false)
     const [isFixed, setIsFixed] = useState(false)
@@ -46,6 +47,7 @@ const Index = forwardRef((props: Props) => {
     // 使用 useDidHide 如果需要在页面隐藏时做一些处理
     // 使用 useDidHide 如果需要在页面隐藏时做一些处理
     useDidHide(() => {
     useDidHide(() => {
         setPageShow(false)
         setPageShow(false)
+        bookStore.setData({ bookList: [] })
     });
     });
     //上拉刷新
     //上拉刷新
     const refresh = async () => {
     const refresh = async () => {
@@ -80,18 +82,12 @@ const Index = forwardRef((props: Props) => {
         return getBookPageList(params)
         return getBookPageList(params)
     }
     }
     return (
     return (
-        <ScrollViewHoc load={load} refresh={refresh} callback={(num) => {
-            // if(num > 100 && !isFixed){
-            //     setIsFixed(true)
-            // }
-            // if(num <100 && isFixed){
-            //     setIsFixed(false)
-            // }
-        }}>
-            <View className='index'>
-                {bookStore?.classifyData?.length > 0 && <View style={isFixed ? { position: 'fixed', background: "#fff" } : {background: "#fff"}}>
-                    <BookTypeTabs typeValue={bookStore?.classifyData} typeTabIndex={classifyStore.categoryId} workDirection={bookStore.workDirection} ></BookTypeTabs>
-                </View>}
+
+        <View className='index'>
+            {bookStore?.classifyData?.length > 0 && <View style={isFixed ? { position: 'fixed', background: "#fff" } : { background: "#fff" }} className='classList'>
+                <BookTypeTabs typeValue={bookStore?.classifyData} typeTabIndex={classifyStore.categoryId} workDirection={bookStore.workDirection} ></BookTypeTabs>
+            </View>}
+            <ScrollViewHoc load={load} refresh={refresh} filterClassName='.classList' navHeight={indexStore.navHeight}>
                 <View className='w  row for_top1 pd_btm'>
                 <View className='w  row for_top1 pd_btm'>
                     {
                     {
                         bookStore?.bookList?.records?.length > 0 ? bookStore?.bookList?.records?.map((item, index) => {
                         bookStore?.bookList?.records?.length > 0 ? bookStore?.bookList?.records?.map((item, index) => {
@@ -102,8 +98,9 @@ const Index = forwardRef((props: Props) => {
                             <Empty />
                             <Empty />
                     }
                     }
                 </View>
                 </View>
-            </View>
-        </ScrollViewHoc>
+            </ScrollViewHoc>
+        </View>
+
     );
     );
 });
 });
 export default TopNavBar(inject('store')(observer(Index)), {
 export default TopNavBar(inject('store')(observer(Index)), {

+ 37 - 43
src/pages/index/index.tsx

@@ -29,18 +29,13 @@ const Index: React.FC<Props> = ({ store }) => {
             return obj[item.componentType] = { ...item, eq: index }
             return obj[item.componentType] = { ...item, eq: index }
         })
         })
         return obj
         return obj
-    }, [indexComponents])
+    }, [indexComponents, pageShow])
     // 页面显示请求数据
     // 页面显示请求数据
     useEffect(() => {
     useEffect(() => {
         if (pageShow && appInfoStore.token) {
         if (pageShow && appInfoStore.token) {
             indexCompontent()
             indexCompontent()
         }
         }
     }, [pageShow, appInfoStore.token, , bookStore.workDirection, appInfoStore.appComponent]); // Dependency array, runs effect only once on mount and unmount
     }, [pageShow, appInfoStore.token, , bookStore.workDirection, appInfoStore.appComponent]); // Dependency array, runs effect only once on mount and unmount
-    // 分类改变重新请求分类列表
-    useEffect(() => {
-        getHotBooks(indexStore.indexCategoryId)
-    }, [indexStore.indexCategoryId])
-
     // 使用 useDidShow 代替 onShow
     // 使用 useDidShow 代替 onShow
     useDidShow(() => {
     useDidShow(() => {
         // 分享消息配置
         // 分享消息配置
@@ -50,6 +45,7 @@ const Index: React.FC<Props> = ({ store }) => {
     // 使用 useDidHide 如果需要在页面隐藏时做一些处理
     // 使用 useDidHide 如果需要在页面隐藏时做一些处理
     useDidHide(() => {
     useDidHide(() => {
         setPageShow(false)
         setPageShow(false)
+        bookStore.setData({ bookList: [] })
         // log("Page is hidden or sent to background");
         // log("Page is hidden or sent to background");
     });
     });
     // 处理首页展示的组件的请求
     // 处理首页展示的组件的请求
@@ -92,49 +88,47 @@ const Index: React.FC<Props> = ({ store }) => {
     const getToDayHotBooks = () => {
     const getToDayHotBooks = () => {
         indexComponents?.hot_books(bookStore.workDirection)
         indexComponents?.hot_books(bookStore.workDirection)
     }
     }
-    return (
-        <ScrollViewHoc>
-            <View style={{ display: "flex", flexFlow: 'column' }}>
-                {/* 轮播 */}
-                {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>
-                                }
-                            })
+    return <View style={{ display: "flex", flexFlow: 'column' }}>
+        {/* 轮播 */}
+        {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'>
-                        {
-                            bookStore?.bookList?.records?.map((item, index) => {
-                                return <View key={index}><BookboxColumnSmall {...item} /></View>
-                            })
-                        }
-                    </View>
-                </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 || []} onBack={(value) => {
+                getHotBooks(value)
+            }} />
+            <View className='w row4'>
+                {
+                    bookStore?.bookList?.records?.map((item, index) => {
+                        return <View key={index}><BookboxColumnSmall {...item} /></View>
+                    })
+                }
             </View>
             </View>
-        </ScrollViewHoc>
-    );
+        </View>}
+    </View>
 };
 };
 export default TopNavBar(inject('store')(observer(Index)), {
 export default TopNavBar(inject('store')(observer(Index)), {
     tab: true,
     tab: true,
     tabVal: [{ value: "男生", text: "男生" }, { value: "女生", text: "女生" }],
     tabVal: [{ value: "男生", text: "男生" }, { value: "女生", text: "女生" }],
     backgroundColor: '#fff',
     backgroundColor: '#fff',
     color: "#333",
     color: "#333",
-    search: false
+    search: true
 });
 });

+ 2 - 3
src/pages/indexMore/index.tsx

@@ -1,11 +1,10 @@
 import { Component } from 'react'
 import { Component } from 'react'
-import { View } from '@tarojs/components'
 import { observer, inject } from 'mobx-react'
 import { observer, inject } from 'mobx-react'
+import { View } from '@tarojs/components'
 import './index.less'
 import './index.less'
-import BookboxRowBig from '@src/components/PupPetry/BookBox/BookboxRowBig'
 import CustomNavbar from '@src/components/TopNavBar'
 import CustomNavbar from '@src/components/TopNavBar'
+import BookboxRowBig from '@src/components/PupPetry/BookBox/BookboxRowBig'
 import { Store } from '@src/app'
 import { Store } from '@src/app'
-
 interface NormalListState {
 interface NormalListState {
     title: string,
     title: string,
     dataName: string,//store 中的参数名称
     dataName: string,//store 中的参数名称

+ 194 - 156
src/pages/search/index.tsx

@@ -1,165 +1,203 @@
-// import { Component } from 'react'
-// import { View, Text } from '@tarojs/components'
-// import { observer, inject } from 'mobx-react'
-// import React from 'react'
-// import CustomNavbar from '../../components/customNavbar/index2'
-// import BookSearch from '../../components/puppetry/BookSearch'
-// import BookHead from '../../components/puppetry/BookHead'
-// import BookHotTabs from '../../components/puppetry/BookHotTabs'
-// import BookboxRowBig from '../../components/puppetry/BookBox/BookboxRowBig'
-// import Taro from '@tarojs/taro'
+import { Component } from 'react'
+import { View, Text } from '@tarojs/components'
+import { observer, inject } from 'mobx-react'
+import Taro from '@tarojs/taro'
 
 
-// import { getAllSearching, search } from '../../api/index'
+import './index.less'
+import CustomNavbar from '@src/components/TopNavBar'
+import ScrollViewHoc from '@src/components/ScrollView'
+import BookHead from '@src/components/PupPetry/BookHead'
+import BookboxRowBig from '@src/components/PupPetry/BookBox/BookboxRowBig'
+import BookSearch from '@src/components/PupPetry/BookSearch'
+import useApi from '@src/Hook/useApi'
+import { Store } from '@src/app'
 
 
-// import './index.less'
-// type PageStateProps = {
-//     store: {
-//         indexStore: {
-//             navBarTop: number,
-//             SET_NAVBARMARGINTOP: Function
-//         },
-//         bookStore: {
-//             action: Function,
-//             channel: 'f' | 'm',
-//             setChannel: (str: 'f' | 'm') => void
-//         },
-//     }
-// }
-// interface Search {
-//     props: PageStateProps;
-// }
 
 
+type PageStateProps = {
+    store: Store
+}
+interface Search {
+    props: PageStateProps;
+}
+interface ContentData {
+    current: number,
+    total: number,
+    size: number,
+    records: any[]
+}
+interface State {
+    searchData: ContentData;
+    searchVal: string,
+    hotVal: any[],
+    historyVal: any[],
+    api: {
+        getBookPageList: (data: any) => Promise<any>
+    } | null
+}
 
 
 
 
-// @inject('store')
-// @observer
-// class Search extends Component {
-//     state = {
-//         searchList: [],   // 搜索结果
-//         searchVal: "",    // 搜索内容
-//         hotVal: [],       // 搜索页大家都在搜list
-//         historyVal: [],   // 搜索历史
-//     }
-//     onLoad() {
-//         try{
-//             let searchValue: any[] = Taro.getStorageSync('search-val')
-//             if(searchValue) {
-//                 this.setState({
-//                     historyVal: searchValue
-//                 })
-//             }
-//         }catch(e) {}
-//         this.getList()
-//     }
+@inject('store')
+@observer
+class Search extends Component {
+    state: State = {
+        searchData: {
+            current: 0,
+            total: 0,
+            size: 0,
+            records: []
+        },   // 搜索结果
+        searchVal: "",    // 搜索内容
+        hotVal: [],       // 搜索页大家都在搜list
+        historyVal: [],   // 搜索历史
+        api: null
+    }
+    onLoad() {
+        try {
+            let searchValue: any[] = Taro.getStorageSync('search-val')
+            if (searchValue) {
+                this.setState({
+                    historyVal: searchValue,
+                })
+            }
+        } catch (e) { }
+    }
+    componentDidMount(): void {
+        let api = useApi(this.props.store.appInfoStore)
+        this.setState({ api })
+    }
+    /** 点击搜索历史 */
+    historyHanlde = (text: string) => {
+        this.searchHandle(text)
+    }
 
 
-//     getList = () => {
-//         /** 搜索页大家都在搜 */
-//         const { bookStore } = this.props.store
-//         getAllSearching({channel: bookStore.channel}).then((res: any) => {
-//             let body = res?.body?.map(item => {
-//                 let action = item?.action?.split('/')
-//                 return {
-//                     text: item?.character_title,
-//                     value: action[action.length - 1]
-//                 }
-//             })
-//             this.setState({
-//                 hotVal: body
-//             })
-//         })
-//     }
+    /** 搜索 */
+    searchHandle = (value: string) => {
+        this.setState({
+            searchVal: value
+        })
+        this.getSearchData({ bookNameOrAuthorName: value, pageNum: 1, pageSize: 20 })
+    }
+    // 获取搜索结果
+    getSearchData = (params) => {
+        return new Promise((resolve, reject) => {
+            let { bookNameOrAuthorName } = params
+            this.state.api?.getBookPageList(params).then((res: any) => {
+                console.log(res)
+                try {
+                    // 保存搜索记录
+                    let searchValue: any[] = this.state.historyVal
+                    if (searchValue) {
+                        let ind = searchValue.findIndex(item => item === bookNameOrAuthorName)
+                        if (ind === -1) {
+                            if (searchValue.length >= 10) {
+                                searchValue = searchValue.splice(1)
+                                searchValue.push(bookNameOrAuthorName)
+                            } else {
+                                searchValue.push(bookNameOrAuthorName)
+                            }
+                            Taro.setStorageSync('search-val', searchValue)
+                        }
+                    } else {
+                        Taro.setStorageSync('search-val', [bookNameOrAuthorName])
+                    }
+                    this.setState({
+                        historyVal: Taro.getStorageSync('search-val')
+                    })
+                } catch (e) {
+                }
+                this.setState({
+                    searchData: res?.data?.data
+                })
+                resolve(res)
+            })
+        })
+    }
+    /** 清除搜索历史 */
+    removeHistory = () => {
+        try {
+            Taro.removeStorageSync('search-val')
+            this.setState({
+                historyVal: []
+            })
+        } catch (e) {
+            // Do something when catch error
+        }
+    }
+    //下来加载
+    load = () => {
+        return new Promise((resolve, reject) => {
+            let { size, total, records } = this.state.searchData
+            let pageSize = size + 20
+            if (records?.length >= total) {
+                Taro.showToast({
+                    title: '没有更多了~~',
+                    duration: 2000,
+                    icon: 'none'
+                })
+                reject()
+                return
+            } else {
+                this.getSearchData({ bookNameOrAuthorName: this.state.searchVal, pageNum: 1, pageSize }).then(res => {
+                    console.log("Res", res)
+                    resolve(true)
+                })
+            }
+        })
+    }
+    render() {
+        return <View className='search'>
+            <View>
+                <BookSearch onBack={this.searchHandle} val={this.state.searchVal} onClear={() => {
+                    this.setState({
+                        searchVal: "",
+                        searchData: {
+                            current: 0,
+                            total: 0,
+                            size: 0,
+                            records: []
+                        }
+                    })
+                }} />
+            </View>
+            {
+                this.state.searchData?.records?.length === 0 ? <View>
+                    {/* 推荐小说缺少接口 */}
+                    {/* <BookHead title="大家都在搜" fontSize={32}></BookHead> */}
+                    {/* <BookHotTabs hotValue={this.state.hotVal} onBack={(id) => { Taro.navigateTo({ url: `/pages/book/bookDetails/index?bookId=${id}` }) }} scroll={false}></BookHotTabs> */}
+                    <View className="line"></View>
+                    <BookHead title="搜索历史" fontSize={32} imgUrl={require('../../icon/delete.png')} fitOnBack={this.removeHistory} imgWidth={36}></BookHead>
+                    {/* 历史记录 */}
+                    <View className="history">
+                        {
+                            this.state.historyVal?.map(item => {
+                                return <View className="histore_item" onClick={() => {
+                                    this.historyHanlde(item)
+                                }}>
+                                    <Text>{item}</Text>
+                                </View>
+                            })
+                        }
+                    </View>
+                </View> :
 
 
-//     /** 点击搜索历史 */
-//     historyHanlde = (text: string) => {
-//         this.searchHandle(text)
-//     }
+                    <View>
+                        <View className="searchTs">
+                            搜索"<Text>{this.state.searchVal}</Text>"结果,共<Text>{this.state.searchData?.total}</Text>条
+                        </View>
+                        <ScrollViewHoc load={this.load} filterClassName='.searchTs' navHeight={this.props.store.indexStore.navHeight}>
+                            <View className='w  row for_top pd_btm'>
+                                {
+                                    this.state.searchData?.records?.map((item) => {
+                                        return <View key={item.bookId}><BookboxRowBig {...item} /></View>
+                                    })
+                                }
+                            </View>
+                        </ScrollViewHoc>
+                    </View>
+            }
+        </View>
 
 
-//     /** 搜索 */
-//     searchHandle = (value: string) => {
-//         this.setState({
-//             searchVal: value
-//         })
-//         search({keyword: value}).then((res: any) => {
-//             try {
-//                 // 保存搜索记录
-//                 let searchValue: any[] = this.state.historyVal
-//                 if(searchValue){
-//                     let ind = searchValue.findIndex(item => item === value)
-//                     if(ind === -1){
-//                         if(searchValue.length >= 10) {
-//                             searchValue = searchValue.splice(1)
-//                             searchValue.push(value)
-//                         }else{
-//                             searchValue.push(value)
-//                         }
-//                         Taro.setStorageSync('search-val', searchValue)
-//                     }
-//                 }else{
-//                     Taro.setStorageSync('search-val', [value])
-//                 }
-//                 this.setState({
-//                     historyVal: Taro.getStorageSync('search-val')
-//                 })
-//             } catch (e) { }
+    }
+}
 
 
-//             this.setState({
-//                 searchList: res?.body?.list
-//             })
-//         })
-//     }
-//     /** 清除搜索历史 */
-//     removeHistory = () => {
-//         try {
-//             Taro.removeStorageSync('search-val')
-//             this.setState({
-//                 historyVal: []
-//             })
-//         } catch (e) {
-//             // Do something when catch error
-//         }
-//     }
-
-//     render() {
-//         const { indexStore: { navBarTop } } = this.props.store
-//         return (
-//             <View className='search'>
-//                 <CustomNavbar navBarTop={navBarTop} title="搜索" isToBack fontSize={36}></CustomNavbar>
-//                 <BookSearch onBack={this.searchHandle} val={this.state.searchVal} onClear={()=>{this.setState({searchList: []})}}></BookSearch>
-//                 {
-//                     this.state.searchList.length === 0 ? <View>
-//                         <BookHead title="大家都在搜" fontSize={32}></BookHead>
-//                         <BookHotTabs hotValue={this.state.hotVal} onBack={(id)=>{Taro.navigateTo({url: `/pages/book/bookDetails/index?book_id=${id}`})}} scroll={false}></BookHotTabs>
-//                         <View className="line"></View>
-//                         <BookHead title="搜索历史" fontSize={32} imgUrl={require('../../icon/delete.png')} fitOnBack={this.removeHistory} imgWidth={36}></BookHead>
-//                         {/* 历史记录 */}
-//                         <View className="history">
-//                             {
-//                                 this.state.historyVal?.map(item => {
-//                                     return <View className="histore_item" onClick={()=>{
-//                                         this.historyHanlde(item)
-//                                     }}>
-//                                         <Text>{item}</Text>
-//                                     </View>
-//                                 })
-//                             }
-//                         </View>
-//                     </View> :
-//                     <View>
-//                         <View className="searchTs">
-//                             搜索"<Text>{this.state.searchVal}</Text>"结果,共<Text>{this.state.searchList?.length}</Text>条
-//                         </View>
-//                         <View className='w  row for_top pd_btm'>
-//                         {
-//                             this.state.searchList?.map((item, index) => {
-//                                 return <View onClick={() => {  }} key={index}><BookboxRowBig {...item} /></View>
-//                             })
-//                         }
-//                         </View>
-//                     </View>
-//                 }
-//             </View>
-//         )
-//     }
-// }
-
-// export default Search
+export default CustomNavbar(Search, { title: "搜索", isToBack: true })

+ 8 - 2
src/server/book/short/index.tsx

@@ -1,6 +1,7 @@
 
 
 import Taro from "@tarojs/taro";
 import Taro from "@tarojs/taro";
 import bookStore from "@src/store/book";
 import bookStore from "@src/store/book";
+import { setReadLog } from "@src/utils/loginSto";
 
 
 interface BookParams {
 interface BookParams {
     workDirection: string,//频道
     workDirection: string,//频道
@@ -63,6 +64,10 @@ export function getShortBookInfo(bookId: any) {
             url: `/app/shortBookInfo/getInfo/${bookId}`,
             url: `/app/shortBookInfo/getInfo/${bookId}`,
             method: 'GET',
             method: 'GET',
             success: (res) => {
             success: (res) => {
+                let readLogId = res.data.data?.readLogId
+                if (readLogId) {
+                    setReadLog({ [bookId]: readLogId })
+                }
                 bookStore.setData({ openBookData: res.data.data })
                 bookStore.setData({ openBookData: res.data.data })
                 resolve(res)
                 resolve(res)
             },
             },
@@ -98,10 +103,11 @@ export function startReadShort(data: { bookId: any, readCondition: any }) {
 /**
 /**
  * 阅读中心跳上报
  * 阅读中心跳上报
  * */
  * */
-export function readingShort(readId: number) {
+export function readingShort(params: { readId: number, readLogId: string, updateReadLog?: boolean }) {
+    let { readId, readLogId, updateReadLog } = params
     return new Promise(async (resolve, reject) => {
     return new Promise(async (resolve, reject) => {
         Taro.request({
         Taro.request({
-            url: `/app/shortBookInfo/reading/${readId}`,
+            url: `/app/shortBookInfo/reading/${readId}?readLogId=${readLogId}&updateReadLog=${updateReadLog || false}`,
             method: 'PUT',
             method: 'PUT',
             success: (res) => {
             success: (res) => {
                 resolve(res)
                 resolve(res)

+ 2 - 1
src/server/bookrack/index.tsx

@@ -3,13 +3,14 @@ import bookStore from "@src/store/book";
 /**
 /**
  * 获取分类列表
  * 获取分类列表
  * */
  * */
-export function bookrackShrot() {
+export function bookrackShrot(data) {
     return new Promise(async (resolve, reject) => {
     return new Promise(async (resolve, reject) => {
         try {
         try {
             // 初始化
             // 初始化
             Taro.request({
             Taro.request({
                 url: '/app/shortBookshelf/listOfPage',
                 url: '/app/shortBookshelf/listOfPage',
                 method: 'GET',
                 method: 'GET',
+                data,
                 success: (res) => {
                 success: (res) => {
                     resolve(res)
                     resolve(res)
                 },
                 },