shenwu 6 tháng trước cách đây
mục cha
commit
9eba221c6c

+ 0 - 2
src/app.config.ts

@@ -6,8 +6,6 @@ export default {
     'pages/classify/index',//分类
     'pages/my/index',//我的
     'pages/book/bookDetails/index',//书籍详情
-    'pages/vipCore/index',//会员中心
-    'pages/myAccount/index',//我的账户
     'pages/my/aboutUs/index',//关于我们
     'pages/my/contactService/index',//联系客服
     'pages/book/bookArticle/index',//书籍内容 阅读页

+ 0 - 1
src/app.less

@@ -37,7 +37,6 @@
 .for_top1 {
   >view {
     margin-top: 40px;
-
     &:nth-child(1) {
       margin-top: 11px;
     }

+ 18 - 18
src/components/PupPetry/BookTypeTabs/index.less

@@ -1,6 +1,6 @@
 @import "../../../globaStyle.less";
 .BookTypeTabs{
-    margin: 15px;
+    margin: 15px 15px 0 15px;
     display: flex;
     justify-content: flex-start;
     flex-wrap: wrap;
@@ -29,23 +29,23 @@
         }
         
     }
+}
 
-    .more{
-        display: flex;
-        justify-content: center;
-        align-items: center;
-        margin-top: 11px;
-        flex: 1;
-        text {
-            font-size: 28px;
-            font-family: PingFangSC-Regular, PingFang SC;
-            font-weight: 400;
-            color: #949BAB;
-        }
-        image{
-            width: 32px;
-            height: 32px;
-            margin-left: 12px;
-        }
+.more{
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    flex: 1;
+    margin-bottom: 15px;
+    text {
+        font-size: 28px;
+        font-family: PingFangSC-Regular, PingFang SC;
+        font-weight: 400;
+        color: #949BAB;
+    }
+    image{
+        width: 32px;
+        height: 32px;
+        margin-left: 12px;
     }
 }

+ 27 - 25
src/components/PupPetry/BookTypeTabs/index.tsx

@@ -4,6 +4,7 @@ import React, { useCallback, useState, useEffect } from 'react'
 import bottomImg from '@src/icon/bottom.png'
 import classifyStore from '@src/store/classIfy'
 type props = {
+    open: boolean,
     typeValue: {
         name: string,
         id: number
@@ -12,52 +13,53 @@ type props = {
         name: string,
         id: number
     },  // tab选中第几个  默认1
-    onCallback?: (value: string | number, isType?: boolean) => void,     // 切换回调函数
+    onCallback?: (value: any) => void,     // 切换回调函数
     workDirection: 0 | 1,//频道
 }
 
 
 /**分类页面顶部分类选择*/
 const BookTypeTabs = (props: props) => {
-    let { typeValue, typeTabIndex, workDirection } = props
-    let [open, setOpen] = useState<boolean>(false)
+    let { typeValue, typeTabIndex, workDirection, onCallback, open } = props
+
     //选择
     let selectHandle = useCallback((value: { id: number, name: string }) => {
         classifyStore.setData({ categoryId: value })
     }, [])
     //展示更多
     let openHandle = useCallback(() => {
-        setOpen(!open)
+        onCallback?.(!open)
     }, [open])
 
     useEffect(() => {
-        // onCallback("", true)
-    }, [workDirection])
-    return <View className="BookTypeTabs">
-        {
-            typeValue?.map((item, index) => {
-                if (!open && index < 8) {
-                    return <View className="typeTab">
-                        <View className={`${item.id === typeTabIndex?.id ? 'select' : ''}`} onClick={() => { selectHandle(item) }}>
-                            <Text>{item.name}</Text>
+    }, [])
+    return <>
+        <View className="BookTypeTabs">
+            {
+                typeValue?.map((item, index) => {
+                    if (!open && index < 4) {
+                        return <View className="typeTab">
+                            <View className={`${item.id === typeTabIndex?.id ? 'select' : ''}`} onClick={() => { selectHandle(item) }}>
+                                <Text>{item.name}</Text>
+                            </View>
                         </View>
-                    </View>
-                } else if (open) {
-                    return <View className="typeTab">
-                        <View className={`${item.id === typeTabIndex?.id ? 'select' : ''}`} onClick={() => { selectHandle(item) }}>
-                            <Text>{item.name}</Text>
+                    } else if (open) {
+                        return <View className="typeTab">
+                            <View className={`${item.id === typeTabIndex?.id ? 'select' : ''}`} onClick={() => { selectHandle(item) }}>
+                                <Text>{item.name}</Text>
+                            </View>
                         </View>
-                    </View>
-                }
+                    }
 
-            })
-        }
+                })
+            }
+        </View>
         {
-            typeValue.length > 8 && !open && <View className="more" onClick={openHandle}>
-                <Text>查看更多</Text> <Image src={bottomImg} />
+            typeValue.length > 4 && <View className="more" onClick={openHandle}>
+                <Text>{open ? "收起" : "查看更多"}</Text> <Image src={bottomImg} style={open ? { transform: "rotate(180deg)" } : {}} />
             </View>
         }
-    </View>
+    </>
 }
 
 export default React.memo(BookTypeTabs)

+ 129 - 100
src/components/ScrollView/index.tsx

@@ -1,116 +1,145 @@
-import { ScrollView } from "@tarojs/components"
-import { Component } from "react"
-import { UpLoading } from "@src/components/PupPetry/Loading"
-import Taro from "@tarojs/taro"
+import { ScrollView } from "@tarojs/components";
+import { Component } from "react";
+import { UpLoading } from "@src/components/PupPetry/Loading";
+import Taro from "@tarojs/taro";
+
 interface State {
-    isShow: boolean  //是否开启刷新状态
-    isBoShow: boolean, //是否开启下拉刷新状态
-    isNull: boolean,  // 是否还有数据
-    filterHeight: number,//容器排除的高度
+  isShow: boolean; // 是否开启刷新状态
+  isBoShow: boolean; // 是否开启下拉刷新状态
+  isNull: boolean; // 是否还有数据
+  filterHeight: number; // 容器排除的高度
 }
+
 interface Props {
-    children: any,//渲染的子元素
-    filterClassName: string,//要排除的元素的高度
-    navHeight: number,//头部导航高度
-    refresh?: () => Promise<any>,//刷新
-    load?: () => Promise<any>,//加载
-    callback?: (num: any) => void,//返回滚动距离
+  children: any; // 渲染的子元素
+  filterClassName: string; // 要排除的元素的高度
+  navHeight: number; // 头部导航高度
+  refresh?: () => Promise<any>; // 刷新
+  load?: () => Promise<any>; // 加载
+  callback?: (num: any) => void; // 返回滚动距离
+  reloadState?: boolean;
 }
+
 /**页面上下加载*/
-class ScrollViewHoc extends Component<Props> {
-    constructor(props) {
-        super(props)
-    }
-    state: State = {
-        isShow: false,
-        isBoShow: false,
-        isNull: false,
-        filterHeight: 0,
+class ScrollViewHoc extends Component<Props, State> {
+  constructor(props: Props) {
+    super(props);
+  }
+
+  state: State = {
+    isShow: false,
+    isBoShow: false,
+    isNull: false,
+    filterHeight: 0,
+  };
+
+  //**向上刷新 */
+  onScrollToUpper = () => {
+    if (!this.props.refresh) {
+      setTimeout(() => {
+        this.setState({ isShow: false });
+      }, 500);
+      console.log("请传入自定义refresh事件");
+      return;
     }
-    //**向上刷新 */
-    onScrollToUpper = () => {
-        if (!this.props.refresh) {
-            setTimeout(() => { this.setState({ isShow: false }) }, 500)
-            log('请传入自定义refresh事件')
-            return
-        }
-        let { isShow } = this.state
-        log(isShow)
-        if (!isShow) {
-            log('下拉')
-            this.setState({ isShow: true }, async () => {
-                if (this?.props?.refresh) {
-                    await this?.props?.refresh().then(() => {
-                        setTimeout(() => { this.setState({ isShow: false }) }, 500)
-                    })
-                }
-            })
+    let { isShow } = this.state;
+    console.log(isShow);
+    if (!isShow) {
+      console.log("下拉");
+      this.setState({ isShow: true }, async () => {
+        if (this?.props?.refresh) {
+          await this?.props?.refresh().then(() => {
+            setTimeout(() => {
+              this.setState({ isShow: false });
+            }, 500);
+          });
         }
+      });
     }
-    /**向下加载 */
-    onScrollToLower = () => {
-        if (!this.props.load) {
-            log('请传入自定义load事件')
-            return
-        }
-        let { isBoShow } = this.state
-        if (!isBoShow) {
-            log('上拉')
-            this.setState({ isBoShow: true }, () => {
-                if (this?.props?.load) {
-                    this?.props?.load().then(res => {
-                        this.setState({ isNull: false })
-                    }).catch(e => {
-                        this.setState({ isNull: true, isBoShow: false })
-                    })
-                    setTimeout(() => { this.setState({ isBoShow: false }) }, 500)
-                }
+  };
+
+  /**向下加载 */
+  onScrollToLower = () => {
+    if (!this.props.load) {
+      console.log("请传入自定义load事件");
+      return;
+    }
+    let { isBoShow } = this.state;
+    if (!isBoShow) {
+      console.log("上拉");
+      this.setState({ isBoShow: true }, () => {
+        if (this?.props?.load) {
+          this?.props?.load()
+            .then(() => {
+              this.setState({ isNull: false });
             })
+            .catch(() => {
+              this.setState({ isNull: true, isBoShow: false });
+            });
+          setTimeout(() => {
+            this.setState({ isBoShow: false });
+          }, 500);
         }
+      });
     }
-    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('未找到指定元素');
-                    }
-                });
-        }
+  };
+
+  // 初始获取 filterClassName 元素的高度
+  componentDidMount() {
+    this.calculateFilterHeight();
+  }
+
+  // 当 reloadState 变化时重新获取 filterClassName 元素的高度
+  componentDidUpdate(prevProps: Props) {
+    if (prevProps.reloadState !== this.props.reloadState) {
+      this.calculateFilterHeight();
     }
-    render() {
-        const { children } = this.props
-        const { filterHeight } = this.state
-        return <ScrollView
-            lowerThreshold={filterHeight}
-            refresherTriggered={this.state.isShow}
-            style={{ height: `calc(100vh - ${filterHeight}px)` }}
-            onScrollToLower={this.onScrollToLower}
-            onScroll={(evt) => {
-                this.props.callback?.(evt.detail.scrollTop)
-            }}
-            className='scrollview'
-            scrollY={true}
-            onRefresherRefresh={() => { this.onScrollToUpper() }}
-            refresherDefaultStyle='black'
-            scrollWithAnimation={true}
-        >
-            <>
-                {children}
-                {
-                    this.state.isBoShow && <UpLoading />
-                }
-            </>
+  }
 
-        </ScrollView>
+  calculateFilterHeight = () => {
+    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() {
+    const { children, reloadState } = this.props;
+    const { filterHeight } = this.state;
+    return (
+      <ScrollView
+        lowerThreshold={filterHeight}
+        refresherTriggered={this.state.isShow}
+        style={{ height: `calc(100vh - ${filterHeight}px)` }}
+        onScrollToLower={this.onScrollToLower}
+        onScroll={(evt) => {
+          this.props.callback?.(evt.detail.scrollTop);
+        }}
+        className="scrollview"
+        scrollY={true}
+        onRefresherRefresh={() => {
+          this.onScrollToUpper();
+        }}
+        refresherDefaultStyle="black"
+        scrollWithAnimation={true}
+      >
+        <>
+          {children}
+          {this.state.isBoShow && <UpLoading />}
+        </>
+      </ScrollView>
+    );
+  }
+}
 
-export default ScrollViewHoc
+export default ScrollViewHoc;

+ 4 - 3
src/pages/bookrack/index.tsx

@@ -10,6 +10,7 @@ import { Store } from '@src/app'
 import useApi from '@src/Hook/useApi'
 import SwipeAction from '@src/components/SwipeAction'
 import { share } from '@src/utils'
+import Empty from '@src/components/Empty'
 
 
 interface Props {
@@ -110,15 +111,15 @@ const Index: React.FC<Props> = ({ store }) => {
             filterClassName={""}
             navHeight={indexStore.navHeight}
         >
-            <View className={"index"}>
+            <View className={"index pd_btm"}>
                 {
-                    readData?.records?.map((item: any, index: number) => {
+                    readData?.records?.length > 0 ? readData?.records?.map((item: any, index: number) => {
                         return <View key={item.bookId} style={{ margin: '30rpx' }}>
                             <SwipeAction actions={actions(item.bookId)}>
                                 <BookboxRowSmall {...item} />
                             </SwipeAction>
                         </View>
-                    })
+                    }) : <Empty />
                 }
             </View>
         </ScrollViewHoc>

+ 13 - 3
src/pages/classify/index.tsx

@@ -1,4 +1,4 @@
-import { forwardRef, useEffect, useState } from 'react'
+import { forwardRef, useEffect, useRef, useState } from 'react'
 import Taro, { useShareAppMessage } from '@tarojs/taro'
 import { useDidHide, useDidShow } from '@tarojs/taro'
 import { observer, inject } from 'mobx-react'
@@ -25,6 +25,8 @@ const Index = forwardRef((props: Props) => {
     const { getBookPageList } = useApi()
     const [pageShow, setPageShow] = useState(false)//防止小程序切换页面组件不会被真实卸载,阻止不必要的操作
     const [isFixed, setIsFixed] = useState(false)
+    const [open, setOpen] = useState(false)
+    let openRef = useRef<any>(null)
     // 获取分类列表
     useEffect(() => {
         if (pageShow) {
@@ -101,13 +103,21 @@ const Index = forwardRef((props: Props) => {
         }
         return {}
     })
+    
     return (
 
         <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>
+                <BookTypeTabs open={open} onCallback={setOpen} typeValue={bookStore?.classifyData} typeTabIndex={classifyStore.categoryId} workDirection={bookStore.workDirection} ></BookTypeTabs>
             </View>}
-            <ScrollViewHoc load={load} refresh={refresh} filterClassName='.classList' navHeight={indexStore.navHeight}>
+            <ScrollViewHoc callback={(top) => {
+                if (top > 100 && open) {
+                    setOpen(false)
+                }
+                if (top < 100 && !open) {
+                    setOpen(true)
+                }
+            }} load={load} refresh={refresh} reloadState={open} filterClassName='.classList' navHeight={indexStore.navHeight}>
                 <View className='w  row for_top1 pd_btm'>
                     {
                         bookStore?.bookList?.records?.length > 0 ? bookStore?.bookList?.records?.map((item, index) => {

+ 7 - 6
src/pages/index/index.tsx

@@ -15,6 +15,7 @@ import BookboxColumnSmall from '@src/components/PupPetry/BookBox/BookboxColumnSm
 import BookboxRowMiddle from '@src/components/PupPetry/BookBox/BookboxRowMiddle';
 import BookboxColumnBig from '@src/components/PupPetry/BookBox/BookboxColumnBig';
 import { share } from '@src/utils';
+import BookboxRowBig from '@src/components/PupPetry/BookBox/BookboxRowBig';
 
 
 
@@ -246,11 +247,11 @@ const Index: React.FC<Props> = ({ store }) => {
                     <BookHead showBtn={indexStore?.indexHotRec?.showRightButton} title={indexStore?.indexHotRec?.name || "热门推荐"} fitTitle="更多" imgUrl={require('../../icon/right.png')} fitOnBack={() => {
                         Taro.navigateTo({ url: `/pages/indexMore/index?title=热门推荐&dataName=indexHotRec` })
                     }} />
-                    <View className='w row'>
+                    <View className='w  row for_top'>
                         {
                             indexStore?.indexHotRec?.[app?.appInfo?.appCategory === 1 ? "longBookInfoAppVOS" : "shortBookInfoAppVOS"]?.map((item, index) => {
                                 if (index < 3) {
-                                    return <View key={index}><BookboxRowMiddle {...item} /></View>
+                                    return <View key={index}><BookboxRowBig {...item} /></View>
                                 }
                             })
                         }
@@ -291,11 +292,11 @@ const Index: React.FC<Props> = ({ store }) => {
                     <BookHead showBtn={indexStore?.indexBestBooks?.showRightButton} title={indexStore?.indexBestBooks?.name || "必看好书"} fitTitle="更多" imgUrl={require('../../icon/right.png')} fitOnBack={() => {
                         Taro.navigateTo({ url: `/pages/indexMore/index?title=必看好书&dataName=indexBestBooks` })
                     }} />
-                    <View className='w row'>
+                    <View className='w  row for_top'>
                         {
                             indexStore?.indexBestBooks?.[app?.appInfo?.appCategory === 1 ? "longBookInfoAppVOS" : "shortBookInfoAppVOS"]?.map((item, index) => {
                                 if (index < 3) {
-                                    return <View key={index}><BookboxRowMiddle {...item} /></View>
+                                    return <View key={index}><BookboxRowBig {...item} /></View>
                                 }
                             })
                         }
@@ -304,10 +305,10 @@ const Index: React.FC<Props> = ({ store }) => {
                 {/* 猜你喜欢 guess_like*/}
                 {indexConfig['guess_like'] && <View style={{ order: indexConfig['banners'].eq }}>
                     <BookHead showBtn={indexStore?.indexGuessLike?.showRightButton} title={indexStore?.indexGuessLike?.name || "猜你喜欢"} />
-                    <View className='w row'>
+                    <View className='w  row for_top pd_btm'>
                         {
                             indexStore?.indexGuessLike?.[app?.appInfo?.appCategory === 1 ? "longBookInfoAppVOS" : "shortBookInfoAppVOS"]?.records?.map((item, index) => {
-                                return <View key={index}><BookboxRowMiddle {...item} /></View>
+                                return <View key={index}><BookboxRowBig {...item} /></View>
                             })
                         }
                     </View>

+ 0 - 4
src/pages/myAccount/index.config.ts

@@ -1,4 +0,0 @@
-export default {
-    navigationBarTitleText: '我的账户'
-}
-  

+ 0 - 18
src/pages/myAccount/index.less

@@ -1,18 +0,0 @@
-
-.myAccount{
-    padding: 30rpx;
-    box-sizing: border-box;
-    .title {
-        width: 144rpx;
-        height: 50rpx;
-        font-family: PingFang SC, PingFang SC;
-        font-weight: 400;
-        font-size: 36rpx;
-        color: #333333;
-        line-height: 42rpx;
-        text-align: left;
-        font-style: normal;
-        text-transform: none;
-        margin-bottom: 30rpx;
-    }
-}

+ 0 - 14
src/pages/myAccount/index.tsx

@@ -1,14 +0,0 @@
-import { View } from "@tarojs/components";
-import ShubiBox from "@src/components/pay/shubi";
-import "./index.less"
-
-function MyAccount() {
-    return <View className=".myAccount">
-        <View className=".title">选择套餐</View>
-        <ShubiBox data={
-            [100, 200, 300, 400, 500, 600]
-        } />
-    </View>
-}
-
-export default MyAccount

+ 0 - 4
src/pages/vipCore/index.config.ts

@@ -1,4 +0,0 @@
-export default {
-    navigationBarTitleText: '会员中心'
-}
-  

+ 0 - 203
src/pages/vipCore/index.less

@@ -1,203 +0,0 @@
-.VipCore{
-    height: 100vh;
-    display: flex;
-    flex-direction: column;
-    justify-content: flex-start;
-    .VipCoreTop{
-        padding: 30px 30px 50px;
-        box-sizing: border-box;
-        flex-grow: 1;
-        overflow-y: auto;
-    }
-    .VipCoreBottom{
-        height: 200px;
-        padding: 20px 30px;
-        box-sizing: border-box;
-    }
-    .userInfo{
-        position: relative;
-        width: 100%;
-        height: 278px;
-        &>image{
-            width: 100%;
-            height: 100%;
-        }
-        .con{
-            position: absolute;
-            width: 100%;
-            height: 100%;
-            top: 0;
-            left: 0;
-            padding: 0 36px;
-            box-sizing: border-box;
-            display: flex;
-            flex-direction: column;
-            justify-content: space-between;
-            .top{
-                margin-top: 38px;
-                display: flex;
-                justify-content: flex-start;
-                align-items: center;
-                .left{
-                    &>image{
-                        width: 80px;
-                        height: 80px;
-                        border-radius: 50%;
-                    }
-                }
-                .right{
-                    margin-left: 20px;
-                    display: flex;
-                    flex-direction: column;
-                    font-size: 32px;
-                    font-family: PingFangSC-Medium, PingFang SC;
-                    font-weight: 500;
-                    color: #9E6034;
-                    .isVip{
-                        font-size: 24px;
-                        font-weight: 400;
-                        color: #A66726;
-                    }
-                }
-            }
-            .bottom{
-                margin-bottom: 22px;
-                font-size: 40px;
-                font-family: STSongti-SC-Bold, STSongti-SC;
-                font-weight: bold;
-                color: #A66726;
-                background: angular-gradient(270deg, rgba(158, 96, 52, 0.6) 0%, #9E6034 100%);
-                background-clip: text;
-            }
-        }
-    }
-
-    .selectVipTitle{
-        margin-top: 68px;
-        font-size: 36px;
-        font-family: PingFangSC-Regular, PingFang SC;
-        font-weight: 400;
-        color: #333333;
-    }
-    .vipSetMeal{
-        margin-top: 30px;
-        display: flex;
-        justify-content: space-between;
-        flex-wrap: wrap;
-        &>view{
-            width: 336px;
-            height: 280px;
-            border-radius: 10px;
-            border: 2px solid #FF91A0;
-            margin-bottom: 18px;
-            display: flex;
-            flex-direction: column;
-            position: relative;
-            box-sizing: border-box;
-            .top{
-                width: 100%;
-                flex: 1;
-                display: flex;
-                justify-content: center;
-                align-items: center;
-                flex-direction: column;
-
-                .name{
-                    font-size: 28px;
-                    font-family: PingFangSC-Medium, PingFang SC;
-                    font-weight: 600;
-                    color: #333333;
-                }
-                .price{
-                    margin-top: 6px;
-                    font-size: 36px;
-                    font-family: PingFangSC-Regular, PingFang SC;
-                    font-weight: 400;
-                    color: #FF2442;
-                    text{
-                        font-size: 24px;
-                    }
-                }
-            }
-            .bottom{
-                height: 64px;
-                background: #FFBCC5;
-                text-align: center;
-                line-height: 64px;
-                font-size: 24px;
-                font-family: PingFangSC-Regular, PingFang SC;
-                font-weight: 400;
-                color: #FFFFFF;
-            }
-            .discount{
-                position: absolute;
-                top: 0;
-                right: -2px;
-                width: 140px;
-                height: 44px;
-                background: #FF2442;
-                border-radius: 0px 10px 0px 10px;
-                text-align: center;
-                font-size: 24px;
-                font-family: PingFangSC-Regular, PingFang SC;
-                font-weight: 400;
-                color: #FFFFFF;
-                line-height: 44px;
-            }
-            .cz{
-                position: absolute;
-                width: 110px;
-                height: 45px;
-                right: -2px;
-                top: -21px;
-                background: linear-gradient(to right, #FF957D , #FF4C4B);
-                border-bottom-left-radius: 10px;
-                border-bottom-right-radius: 5px;
-                border-top-right-radius: 10px;
-                border-top-left-radius: 5px;
-                display: flex;
-                justify-content: center;
-                align-items: center;
-                image{
-                    width: 28px;
-                    height: 32px;
-                    margin-right: 5px;
-                }
-                text{
-                    font-size: 28px;
-                    font-family: PingFangSC-Regular, PingFang SC;
-                    font-weight: 400;
-                    color: #FFFFFF;
-                }
-            }
-
-            &.select{
-                border: 4px solid #FF2442;
-                .bottom{
-                    background: #FF2442;
-                }
-                .cz{
-                    right: -4px;
-                }
-            }
-        }
-    }
-
-    .vipBt {
-        height: 86px;
-        background-color: #07BB0F;
-        border-radius: 48px;
-        color: #FFFFFF;
-        font-family: PingFangSC-Medium, PingFang SC;
-        font-size: 32px;
-        display: flex;
-        justify-content: center;
-        align-items: center;
-    
-        &>image {
-          width: 48px;
-          height: 48px;
-          margin-right: 10px;
-        }
-    }
-}

+ 0 - 157
src/pages/vipCore/index.tsx

@@ -1,157 +0,0 @@
-import { Component } from 'react'
-import { View, Image, Text } from '@tarojs/components'
-import { observer, inject } from 'mobx-react'
-import './index.less'
-// import { getProductInfo } from '../../api'
-// import { pay } from '../../ajax' 
-import Taro from '@tarojs/taro'
-import { Store } from '@src/app'
-type PageStateProps = {
-    store: Store
-}
-interface VipCore {
-    props: PageStateProps;
-}
-type state = {
-    selectVip: number,
-    productList: any[],
-    book_id: number,
-    chapter_id: number
-}
-
-@inject('store')
-@observer
-class VipCore extends Component {
-    state: state = {
-        selectVip: 0,
-        productList: [],
-        book_id: 0,
-        chapter_id: 0
-    }
-
-    onLoad(opt) {
-        let { book_id, chapter_id } = opt
-        if (book_id && chapter_id) {
-            this.setState({
-                book_id,
-                chapter_id
-            })
-        }
-        this.getData()
-    }
-
-    getData = () => {
-        // getProductInfo().then((res: any) => {
-        //     if(res?.body){
-        //         let index = res?.body?.findIndex((item: any)=> item?.is_default === 1)
-        //         this.setState({
-        //             productList: res?.body,
-        //             selectVip: index
-        //         })
-        //     }
-        // })
-    }
-
-    selectHanle = (index: number) => {
-        this.setState({
-            selectVip: index
-        })
-    }
-    /** 购买 */
-    purchase = () => {
-        let { selectVip, productList, book_id, chapter_id } = this.state
-        let product_id = productList[selectVip].product_id
-        let queryFor = { product_id, source: 1 }
-        book_id && (queryFor['book_id'] = book_id)
-        chapter_id && (queryFor['chapter_id'] = chapter_id)
-        // pay(queryFor).then(()=>{
-        //     let { indexStore } = this.props.store
-        //     SET_USERINFO()
-        // }).catch(err => {
-
-        // })
-    }
-
-    componentWillUnmount() {
-        let { indexStore } = this.props.store
-        // if (this.state.book_id !== 0) {
-        //     let pages = Taro.getCurrentPages(); //获取当前页面栈
-        //     if (pages.length > 1) {
-        //         let beforePage = pages[pages.length - 2]; //获取上一个页面实例对象
-        //         beforePage.setData({
-        //             //返回参数 ps:这里我打印出beforePage只有一个setData能调用到
-        //             'isVip': userInfo?.is_vip
-        //         })
-        //     }
-        // }
-    }
-
-    showToast = (title: string, duration?: number, icon?: "none" | "success" | "loading" | undefined) => {
-        Taro.showToast({
-            title: title,
-            icon: icon || 'none',
-            duration: duration || 2000
-        })
-    }
-
-    render() {
-        let { userInfoStore } = this.props.store
-        let { userInfo } = userInfoStore
-        return (
-            <View className='VipCore'>
-                <View className="VipCoreTop">
-                    <View className="userInfo">
-                        <View className="con">
-                            <View className="top">
-                                <View className="left">
-                                    <Image mode="widthFix" lazy-load src={require('../../icon/avatar.jpg')} />
-                                </View>
-                                <View className="right">
-                                    <Text className="ID">{userInfo?.nickname || "三金金"}</Text>
-                                    <Text className="isVip">{userInfo?.vipExpireTime ? `有效期至:${userInfo?.vipExpireTime}` : '未开通会员'}</Text>
-                                </View>
-                            </View>
-                            <View className="bottom">
-                                会员尊享纯净版阅读
-                            </View>
-                        </View>
-                        <Image src={require('../../icon/coreBack.png')} />
-                    </View>
-
-                    <View className="selectVipTitle">选择套餐</View>
-
-                    <View className="vipSetMeal">
-                        {
-                            this.state.productList?.map((item: any, index: number) => (<View key={item?.product_id || index} className={index === this.state.selectVip ? 'select' : ''} onClick={() => { this.selectHanle(index) }}>
-                                <View className="top">
-                                    <View className="name">{item?.product_name}</View>
-                                    <View className="price"><Text>¥</Text> {item?.product_amount}</View>
-                                </View>
-                                <View className="bottom">{item?.memo}</View>
-                                {
-                                    item?.icon && <View className="discount">{item?.icon}</View>
-                                }
-                                {
-                                    item?.is_default === 1 && <View className='cz'>
-                                        <Image lazy-load src={require('../../icon/spark.png')} />
-                                        <Text>超值</Text>
-                                    </View>
-                                }
-                            </View>))
-                        }
-                    </View>
-                </View>
-                <View className="VipCoreBottom">
-                    {
-                        this.state.productList.length > 0 && <View className="vipBt" onClick={this.purchase}>
-                            <Image lazy-load src={require('../../icon/weChat.png')} />
-                            {userInfo?.vipExpireTime ? '立即续费' : '立即开通'}
-                        </View>
-                    }
-                </View>
-            </View>
-        )
-    }
-}
-
-export default VipCore

+ 5 - 3
src/server/classify/index.tsx

@@ -13,9 +13,11 @@ export function getBookCategoryList(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    bookStore.setClassifyData(res.data.data)//存放本次拿到的数据
-                    if(res.data.data.length > 0 ){
-                        classifyStore.setData({categoryId:res.data.data[0]})//存放数据的第一个值为默认首次选中
+                    if(JSON.stringify(bookStore.classifyData) !== JSON.stringify(res.data.data)){
+                        bookStore.setClassifyData(res.data.data)//存放本次拿到的数据
+                        if(res.data.data.length > 0 ){
+                            classifyStore.setData({categoryId:res.data.data[0]})//存放数据的第一个值为默认首次选中
+                        }
                     }
                     resolve(res)
                 },

+ 27 - 9
src/server/index/index.ts

@@ -38,7 +38,9 @@ export function getShortBanners(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    indexStore.setData({ indexBanners: res.data.data })
+                    if(JSON.stringify(indexStore.indexBanners) !== JSON.stringify(res.data.data)){
+                        indexStore.setData({ indexBanners: res.data.data })
+                    }
                     resolve(res)
                 },
                 fail: (err) => {
@@ -62,7 +64,9 @@ export function getShortHotCategory(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    indexStore.setData({ indexHotCategory: res.data.data })
+                    if(JSON.stringify(indexStore.indexHotCategory) !== JSON.stringify(res.data.data)){
+                        indexStore.setData({ indexHotCategory: res.data.data })
+                    }
                     resolve(res)
                 },
                 fail: (err) => {
@@ -86,7 +90,9 @@ export function getShortNewBooks(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    indexStore.setData({ indexNewBooks: res.data.data })
+                    if(JSON.stringify(indexStore.indexNewBooks) !== JSON.stringify(res.data.data)){
+                        indexStore.setData({ indexNewBooks: res.data.data })
+                    }
                     resolve(res)
                 },
                 fail: (err) => {
@@ -110,7 +116,9 @@ export function getShortHotRec(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    indexStore.setData({ indexHotRec: res.data.data })
+                    if(JSON.stringify(indexStore.indexHotRec) !== JSON.stringify(res.data.data)){
+                        indexStore.setData({ indexHotRec: res.data.data })
+                    }
                     resolve(res)
                 },
                 fail: (err) => {
@@ -134,7 +142,9 @@ export function getShortBestReviews(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    indexStore.setData({ indexBestReviews: res.data.data })
+                    if(JSON.stringify(indexStore.indexBestReviews) !== JSON.stringify(res.data.data)){
+                        indexStore.setData({ indexBestReviews: res.data.data })
+                    }
                     resolve(res)
                 },
                 fail: (err) => {
@@ -158,7 +168,9 @@ export function getShortClassicBooks(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    indexStore.setData({ indexClassicBooks: res.data.data })
+                    if(JSON.stringify(indexStore.indexClassicBooks) !== JSON.stringify(res.data.data)){
+                        indexStore.setData({ indexClassicBooks: res.data.data })
+                    }
                     resolve(res)
                 },
                 fail: (err) => {
@@ -182,7 +194,9 @@ export function getShortBestBooks(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    indexStore.setData({ indexBestBooks: res.data.data })
+                    if(JSON.stringify(indexStore.indexBestBooks) !== JSON.stringify(res.data.data)){
+                        indexStore.setData({ indexBestBooks: res.data.data })
+                    }
                     resolve(res)
                 },
                 fail: (err) => {
@@ -206,7 +220,9 @@ export function getShortGuessLike(data) {
                 method: 'GET',
                 data,
                 success: (res) => {
-                    indexStore.setData({ indexGuessLike: res.data.data })
+                    if(JSON.stringify(indexStore.indexGuessLike) !== JSON.stringify(res.data.data)){
+                        indexStore.setData({ indexGuessLike: res.data.data })
+                    }
                     resolve(res)
                 },
                 fail: (err) => {
@@ -231,7 +247,9 @@ export function getShortHotBooks(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    indexStore.setData({ indexHotBooks: res.data.data })
+                    if(JSON.stringify(indexStore.indexHotBooks) !== JSON.stringify(res.data.data)){
+                        indexStore.setData({ indexHotBooks: res.data.data })
+                    }
                     resolve(res)
                 },
                 fail: (err) => {