shenwu il y a 5 mois
Parent
commit
8aea3cdec7

+ 0 - 1
src/components/ScrollView/index.tsx

@@ -43,7 +43,6 @@ class ScrollViewHoc extends Component<Props, State> {
       return;
     }
     let { isShow } = this.state;
-    console.log(isShow);
     if (!isShow) {
       console.log("下拉");
       this.setState({ isShow: true }, async () => {

+ 29 - 25
src/pages/classify/index.tsx

@@ -24,9 +24,9 @@ const Index = forwardRef((props: Props) => {
     const { bookStore, classifyStore, indexStore } = props.store
     const { getBookPageList } = useApi()
     const [pageShow, setPageShow] = useState(false)//防止小程序切换页面组件不会被真实卸载,阻止不必要的操作
-    const [isFixed, setIsFixed] = useState(false)
     const [open, setOpen] = useState(false)
     const [showEmpty, setShowEmpty] = useState(false)
+    const [isSetOpen, setIsSetOpen] = useState(true)
     // 获取分类列表
     useEffect(() => {
         if (pageShow) {
@@ -42,7 +42,7 @@ const Index = forwardRef((props: Props) => {
             showEmpty && setShowEmpty(false)
             categoryId.id != 0 && classifyStore.categoryId && getList({ workDirection, categoryId: categoryId.id, pageNum: 1, pageSize: 10 }).then((res: any) => {
                 if (res?.data?.data?.total === 0) {
-                   !showEmpty && setShowEmpty(true)
+                    !showEmpty && setShowEmpty(true)
                 }
             })
         }
@@ -108,32 +108,36 @@ 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'>
+            {bookStore?.classifyData?.length > 0 && <View style={{ background: "#fff" }} className='classList' onClick={() => { setIsSetOpen(false) }}>
                 <BookTypeTabs open={open} onCallback={setOpen} typeValue={bookStore?.classifyData} typeTabIndex={classifyStore.categoryId} workDirection={bookStore.workDirection} ></BookTypeTabs>
             </View>}
-            <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) => {
-                            return <>
-                                <View key={item.bookId} ><BookboxRowBig {...item} /></View>
-                            </>
-                        })
-                    }
-                    {
-                        showEmpty && <Empty />
-                    }
-                </View>
-            </ScrollViewHoc>
+            <View onTouchStart={() => { setIsSetOpen(true) }}>
+                <ScrollViewHoc
+                    callback={(top) => {
+                        if (isSetOpen) {
+                            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) => {
+                                return <>
+                                    <View key={item.bookId} ><BookboxRowBig {...item} /></View>
+                                </>
+                            })
+                        }
+                        {
+                            showEmpty && <Empty />
+                        }
+                    </View>
+                </ScrollViewHoc>
+            </View>
         </View>
 
     );

+ 3 - 18
src/pages/my/index.tsx

@@ -1,6 +1,6 @@
-import { useEffect, useState } from 'react'
+import {  useState } from 'react'
 import Taro, { useDidHide, useShareAppMessage } from '@tarojs/taro'
-import { View, Text, Image, Navigator, Button } from '@tarojs/components'
+import { View, Text, Image, Navigator } from '@tarojs/components'
 import { observer, inject } from 'mobx-react'
 import './index.less'
 import { Store } from '@src/app'
@@ -45,21 +45,6 @@ function My(props: Props) {
         }
         return {}
     })
-    useEffect(() => {
-    }, [])
-
-    const getUserInfo = () => {
-        // if(!wxUser){
-        //     Taro.getUserProfile({
-        //         desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-        //         success: (res) => {
-        //             // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
-        //             console.log("res", res)
-        //             setWxUser(res.userInfo)
-        //         }
-        //     })
-        // }
-    }
     const copy = () => {
         Taro.setClipboardData({
             data: userInfoStore?.userInfo?.openId || "",
@@ -79,7 +64,7 @@ function My(props: Props) {
         <View className="userInfo">
             <View className="userInfo_box">
                 {/* 个人信息 */}
-                <View className="top" onClick={getUserInfo}>
+                <View className="top" >
                     <View className="left" >
                         <View className="avtai">
                             {/* || (userInfoStore.userInfo?.avatarUrl ? userInfoStore.userInfo?.avatarUrl : require('../../icon/avatar.jpg')) */}

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

@@ -1,28 +1,6 @@
 import Taro from "@tarojs/taro";
 import indexStore from "@src/store/index";
 import { setApp } from "@src/config";
-/**
- * 获取小程序组件配置列表
- * */
-// export function getAppComponent() {
-//     return new Promise(async (resolve, reject) => {
-//         try {
-//             // 初始化
-//             Taro.request({
-//                 url: '/app/appComponent/list',
-//                 method: 'GET',
-//                 success: (res) => {
-//                     resolve(res)
-//                 },
-//                 fail: (err) => {
-//                     reject(err);
-//                 }
-//             })
-//         } catch (error) {
-//             reject(error);
-//         }
-//     })
-// }
 
 
 
@@ -38,9 +16,7 @@ export function getShortBanners(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    if(JSON.stringify(indexStore.indexBanners) !== JSON.stringify(res.data.data)){
-                        indexStore.setData({ indexBanners: res.data.data })
-                    }
+                    indexStore.setData({ indexBanners: res.data.data })
                     resolve(res)
                 },
                 fail: (err) => {
@@ -64,9 +40,7 @@ export function getShortHotCategory(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    if(JSON.stringify(indexStore.indexHotCategory) !== JSON.stringify(res.data.data)){
-                        indexStore.setData({ indexHotCategory: res.data.data })
-                    }
+                    indexStore.setData({ indexHotCategory: res.data.data })
                     resolve(res)
                 },
                 fail: (err) => {
@@ -90,9 +64,7 @@ export function getShortNewBooks(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    if(JSON.stringify(indexStore.indexNewBooks) !== JSON.stringify(res.data.data)){
-                        indexStore.setData({ indexNewBooks: res.data.data })
-                    }
+                    indexStore.setData({ indexNewBooks: res.data.data })
                     resolve(res)
                 },
                 fail: (err) => {
@@ -116,9 +88,7 @@ export function getShortHotRec(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    if(JSON.stringify(indexStore.indexHotRec) !== JSON.stringify(res.data.data)){
-                        indexStore.setData({ indexHotRec: res.data.data })
-                    }
+                    indexStore.setData({ indexHotRec: res.data.data })
                     resolve(res)
                 },
                 fail: (err) => {
@@ -142,9 +112,7 @@ export function getShortBestReviews(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    if(JSON.stringify(indexStore.indexBestReviews) !== JSON.stringify(res.data.data)){
-                        indexStore.setData({ indexBestReviews: res.data.data })
-                    }
+                    indexStore.setData({ indexBestReviews: res.data.data })
                     resolve(res)
                 },
                 fail: (err) => {
@@ -168,9 +136,7 @@ export function getShortClassicBooks(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    if(JSON.stringify(indexStore.indexClassicBooks) !== JSON.stringify(res.data.data)){
-                        indexStore.setData({ indexClassicBooks: res.data.data })
-                    }
+                    indexStore.setData({ indexClassicBooks: res.data.data })
                     resolve(res)
                 },
                 fail: (err) => {
@@ -194,9 +160,7 @@ export function getShortBestBooks(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    if(JSON.stringify(indexStore.indexBestBooks) !== JSON.stringify(res.data.data)){
-                        indexStore.setData({ indexBestBooks: res.data.data })
-                    }
+                    indexStore.setData({ indexBestBooks: res.data.data })
                     resolve(res)
                 },
                 fail: (err) => {
@@ -220,9 +184,7 @@ export function getShortGuessLike(data) {
                 method: 'GET',
                 data,
                 success: (res) => {
-                    if(JSON.stringify(indexStore.indexGuessLike) !== JSON.stringify(res.data.data)){
-                        indexStore.setData({ indexGuessLike: res.data.data })
-                    }
+                    indexStore.setData({ indexGuessLike: res.data.data })
                     resolve(res)
                 },
                 fail: (err) => {
@@ -247,9 +209,7 @@ export function getShortHotBooks(workDirection) {
                 method: 'GET',
                 data: { workDirection },
                 success: (res) => {
-                    if(JSON.stringify(indexStore.indexHotBooks) !== JSON.stringify(res.data.data)){
-                        indexStore.setData({ indexHotBooks: res.data.data })
-                    }
+                    indexStore.setData({ indexHotBooks: res.data.data })
                     resolve(res)
                 },
                 fail: (err) => {

+ 5 - 2
src/store/book.ts

@@ -16,7 +16,7 @@ export interface OpenBookData {
     wordCount: number,//字数
     labelInfoList: { name: string }[],//标签
     contentData: ContentData | null //内容数据
-    vipFree:boolean//vip免费
+    vipFree: boolean//vip免费
 }
 
 interface ClassifyData {
@@ -67,7 +67,10 @@ const Book: BookStore = observable({
     setData(data: { [key: string]: any }) {
         if (data) {
             Object.keys(data).forEach(key => {
-                this[key] = data[key]
+                //数据不同才存放
+                if (JSON.stringify(this[key]) !== JSON.stringify(data[key])) {
+                    this[key] = data[key]
+                }
             })
         }
     },

+ 3 - 0
src/store/classIfy.ts

@@ -12,7 +12,10 @@ const classifyStore: ClassifyStore = observable({
     setData(data: { [key: string]: any }) {
         if (data) {
             Object.keys(data).forEach(key => {
+               //数据不同才存放
+               if(JSON.stringify(this[key]) !== JSON.stringify(data[key])){
                 this[key] = data[key]
+            }
             })
         }
     },

+ 4 - 1
src/store/index.ts

@@ -143,7 +143,10 @@ const Index:IndexStore = observable({
     setData(data: { [key: string]: any }) {
         if (data) {
             Object.keys(data).forEach(key => {
-                this[key] = data[key]
+                //数据不同才存放
+                if(JSON.stringify(this[key]) !== JSON.stringify(data[key])){
+                    this[key] = data[key]
+                }
             })
         }
     },

+ 9 - 6
src/store/userInfo.tsx

@@ -4,11 +4,11 @@ export interface UserInfoStore {
     isAuth: boolean,//是否授权获取头像信息,
     isVip: boolean,//是否是vip
     userInfo: {
-        openId:string,
-        nickname:string,
-        avatarUrl:string
-        vipExpireTime:string,//会员结束时间
-        coinNum:number,//书币
+        openId: string,
+        nickname: string,
+        avatarUrl: string
+        vipExpireTime: string,//会员结束时间
+        coinNum: number,//书币
     } | null,
     setData: (data: { [key: string]: any }) => void,
 }
@@ -22,7 +22,10 @@ const userInfoStore: UserInfoStore = observable({
     setData(data: { [key: string]: any }) {
         if (data) {
             Object.keys(data).forEach(key => {
-                this[key] = data[key]
+                //数据不同才存放
+                if (JSON.stringify(this[key]) !== JSON.stringify(data[key])) {
+                    this[key] = data[key]
+                }
             })
         }
     },