shenwu 2 ay önce
ebeveyn
işleme
a5cdce3a38

+ 8 - 12
src/app.tsx

@@ -48,10 +48,6 @@ class App extends Component {
   //每次打开小程序触发,后台切入不算
   onLaunch(options) {
     console.log("apponLaunch", options)
-    const {query} =options
-    if(query?.pageId){
-      Taro.navigateTo({url:"/pages/Ldpage/index?pageId="+query.pageId})
-    }
     // 监听进入插件页事件
     novelPlugin.onPageLoad(this.onNovelPluginLoad)
   }
@@ -69,9 +65,9 @@ class App extends Component {
       }
     }
     //假如书籍已在书架改变插件书架状态
-    if(customParams && customParams.inBookshelf){
+    if (customParams && customParams.inBookshelf) {
       novelManager.setBookshelfStatus({
-        bookshelfStatus:1
+        bookshelfStatus: 1
       })
     }
     // 默认设置目录状态
@@ -93,23 +89,22 @@ class App extends Component {
     })
     // 监听用户行为事件
     novelManager.onUserTriggerEvent(res => {
-    
+
     })
     novelManager.onClickBookshelf((res) => {
-      if(res.bookshelfStatus == 0){
+      if (res.bookshelfStatus == 0) {
         console.log("点击了加入书架")
         bookrackShrotAddOrRemove({ bookId: customParams.bookId, add: true })
-      }else if(res.bookshelfStatus == 1){
+      } else if (res.bookshelfStatus == 1) {
         console.log("点击了移出书架")
         bookrackShrotAddOrRemove({ bookId: customParams.bookId, add: false })
       }
-       novelManager.setBookshelfStatus({
-        bookshelfStatus:res.bookshelfStatus == 0 ? 1 : 0
+      novelManager.setBookshelfStatus({
+        bookshelfStatus: res.bookshelfStatus == 0 ? 1 : 0
       })
     })
   }
   componentDidMount() {
-    console.log("APPcomponentDidMount")
     /**获取状态栏高度 */
     Taro.getSystemInfo({}).then(res => {
       let { system, statusBarHeight, platform } = res
@@ -142,6 +137,7 @@ class App extends Component {
     })
     // 初始化登录,获取登录使用的token存放用于登录使用
     await api.loginInit(appId)
+
   }
   componentDidHide() { }
 

+ 31 - 4
src/components/PupPetry/BannerBox/index.tsx

@@ -2,12 +2,35 @@ import { Swiper, SwiperItem, Image, Navigator } from "@tarojs/components";
 import React from "react";
 import './index.less'
 import { IndexStore } from "@src/store";
+import Taro from "@tarojs/taro";
+import useApi from "@src/Hook/useApi";
+let { getBookInfo } = useApi()
 /**轮播图 */
 interface BannerBoxProps {
     data?: IndexStore["indexBanners"]
 }
 function BannerBox(props: BannerBoxProps) {
     const { data } = props
+    const click = (bookId) => {
+        getBookInfo(bookId).then((res: { data: any, code: any }) => {
+            if (res?.data?.code == 200) {
+                console.log(res?.data?.data)
+                let { wechatBookId, inBookshelf } = res?.data?.data
+                let json = JSON.stringify({ inBookshelf, bookId })
+                let encode = encodeURIComponent(json)
+                if (wechatBookId) {
+                    Taro.navigateTo({
+                        url: `plugin-private://wx293c4b6097a8a4d0/pages/novel/index?bookId=${wechatBookId}&customServerParams=${encode}`
+                    })
+                } else {
+                    Taro.showToast({
+                        title: '小说未上架',
+                        icon: 'none'
+                    })
+                }
+            }
+        })
+    }
     return <Swiper
         className='banner_box'
         indicatorColor='#999'
@@ -20,11 +43,15 @@ function BannerBox(props: BannerBoxProps) {
         {
             data?.map((item, index: number) => {
                 let { bookId, bannerType, bannerImage, activityPagePath } = item
-                console.log(bannerType === 0 ? '/pages/book/bookDetails/index?bookId=' + bookId : '/' + activityPagePath)
                 return <SwiperItem key={index}>
-                    <Navigator url={bannerType === 0 ? '/pages/book/bookDetails/index?bookId=' + bookId : '/' + activityPagePath} hoverClass="none">
-                        <Image src={bannerImage} className='img' />
-                    </Navigator>
+                    {
+                        bannerType === 0 ?
+                            <Image src={bannerImage} className='img' onClick={()=>{click(bookId)}}/>
+                            :
+                            <Navigator url={'/' + activityPagePath} hoverClass="none">
+                                <Image src={bannerImage} className='img' />
+                            </Navigator>
+                    }
                 </SwiperItem>
             })
         }

+ 0 - 191
src/pages/classify/index copy.tsx

@@ -1,191 +0,0 @@
-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'
-import { ScrollView, View } from '@tarojs/components'
-import './index.less'
-//==========components组件引用========================
-import TopNavBar from '@src/components/TopNavBar/index'
-import BookboxRowBig from '@src/components/PupPetry/BookBox/BookboxRowBig'
-import BookTypeTabs from '@src/components/PupPetry/BookTypeTabs'
-import Empty from '@src/components/Empty'
-import { Store } from '@src/app'
-import useApi from '@src/Hook/useApi'
-import { getBookCategoryList } from '@src/server/classify'
-import { share } from '@src/utils'
-
-
-interface Props {
-    store: Store;
-}
-
-const Index = forwardRef((props: Props) => {
-    const { classifyStore, indexStore } = props.store
-    const { getBookPageList } = useApi()
-    const [pageShow, setPageShow] = useState(false)//防止小程序切换页面组件不会被真实卸载,阻止不必要的操作
-    const [open, setOpen] = useState(false)
-    const [showEmpty, setShowEmpty] = useState(false)
-    const [isSetOpen, setIsSetOpen] = useState(true)
-    const [filterHeight, setFilterHeight] = useState(0)
-    // 获取分类列表
-    useEffect(() => {
-        if (pageShow) {
-            console.log("获取分类列表")
-            let { workDirection } = classifyStore
-            getBookCategoryList(workDirection).then((res: any) => {
-                if (res?.data?.code === 200) {
-                    classifyStore.setData({ classifyData: res?.data?.data })
-                }
-            })
-        }
-    }, [classifyStore.workDirection, pageShow]); // Dependency array, runs effect only once on mount and unmount
-    //获取书籍列表
-    useEffect(() => {
-        if (pageShow) {
-            console.log("获取书籍列表")
-            let { workDirection } = classifyStore
-            let { categoryId } = classifyStore
-            categoryId.id != 0 && classifyStore.categoryId && getList({ workDirection, categoryId: categoryId.id, pageNum: 1, pageSize: 10, type: 'class' }).then((res: any) => {
-                if (res?.data?.data?.total === 0) {
-                    setShowEmpty(true)
-                } else {
-                    setShowEmpty(false)
-                }
-            })
-        }
-    }, [classifyStore.workDirection, classifyStore.categoryId, pageShow])
-    // 使用 useDidShow 代替 onShow
-    useDidShow(() => {
-        setPageShow(true)
-    });
-    // 使用 useDidHide 如果需要在页面隐藏时做一些处理
-    useDidHide(() => {
-        setPageShow(false)
-    });
-
-    //下拉加载
-    const load = () => {
-        return new Promise((resolve, reject) => {
-            let { size, total, records } = classifyStore.bookList
-            let pageSize = size + 10
-            let { workDirection } = classifyStore
-            let { categoryId } = classifyStore
-            if (records?.length >= total) {
-                Taro.showToast({
-                    title: '没有更多了~~',
-                    duration: 2000,
-                    icon: 'none'
-                })
-                reject()
-                return
-            } else {
-                getList({ workDirection, categoryId: categoryId.id, pageNum: 1, pageSize, type: 'class' }).then((res: any) => {
-                    if (res?.data?.data?.total === 0) {
-                        setShowEmpty(true)
-                    } else {
-                        console.log("isSetOpen", isSetOpen)
-                        setShowEmpty(false)
-                    }
-                    resolve(true)
-                })
-            }
-        })
-    }
-    const getList = async (params) => {
-        return getBookPageList(params)
-    }
-    // 分享
-    useShareAppMessage(async () => {
-        // 获取当前页面栈
-        const pages = Taro.getCurrentPages()
-        // 获取栈顶的页面,即当前页面
-        const currentPage = pages[pages.length - 1]
-        // 获取页面的路径和参数
-        const route = currentPage.route // 页面路径
-        if (route) {
-            let shareInfo = await share({ pagePath: route })
-            let { sharePicUrl, shareTitles, pageName, pagePath } = shareInfo
-            return {
-                title: shareTitles || app.appInfo?.appName + '-' + pageName,
-                path: pagePath || undefined,
-                imageUrl: sharePicUrl || undefined
-            }
-        }
-        return {}
-    })
-
-    const callBacn = (b) => {
-        Taro.createSelectorQuery()
-            .select('.classList') // 选择器,用于选择要获取信息的元素
-            .boundingClientRect() // 获取节点的布局信息
-            .exec((res) => {
-                if (res[0]) {
-                    const height = res[0].height; // 获取元素的高度
-                    setFilterHeight(height + indexStore.navHeight);
-                } else {
-                    console.log("未找到指定元素");
-                }
-            });
-        setOpen(b)
-    }
-    useEffect(() => {
-        callBacn(false)
-    }, [])
-    return (
-        <View className='index'>
-            {classifyStore?.classifyData?.length > 0 && <View style={{ background: "#fff" }} className='classList' onClick={() => { setIsSetOpen(false) }}>
-                <BookTypeTabs open={open} onCallback={callBacn} typeValue={classifyStore?.classifyData} typeTabIndex={classifyStore.categoryId} workDirection={classifyStore.workDirection} ></BookTypeTabs>
-            </View>}
-            <View>
-
-            </View>
-            <View onTouchStart={() => {
-                setIsSetOpen(true)
-            }} >
-                <ScrollView
-                    lowerThreshold={filterHeight}
-                    // refresherTriggered={this.state.isShow}
-                    style={{ height: `calc(100vh - ${filterHeight + 10}px)` }}
-                    onScrollToLower={load}
-                    onScroll={(evt: any) => {
-                        console.log(evt)
-                        let top = evt.detail.scrollTop
-                        if (isSetOpen) {
-                            if (top > 100 && open) {
-                                callBacn(false)
-                            }
-                            if (top < 100 && !open) {
-                                callBacn(true)
-                            }
-                        }
-                    }}
-                    className="scrollview"
-                    scrollY={true}
-                    refresherDefaultStyle="black"
-                // scrollWithAnimation={true}
-                >
-                    <View className='w  row for_top1 pd_btm'>
-                        {
-                            classifyStore?.bookList?.records?.length > 0 && classifyStore?.bookList?.records?.map((item, index) => {
-                                return <>
-                                    <View key={item.bookId} ><BookboxRowBig {...item} /></View>
-                                </>
-                            })
-                        }
-                        {
-                            showEmpty && <Empty />
-                        }
-                    </View>
-                </ScrollView>
-            </View>
-        </View>
-
-    );
-});
-export default TopNavBar(inject('store')(observer(Index)), {
-    tab: true,
-    tabVal: [{ value: 0, text: "男生" }, { value: 1, text: "女生" }],
-    backgroundColor: '#fff',
-    color: "#333",
-    search: false,
-});

+ 15 - 9
src/pages/ldPage/index.tsx

@@ -35,7 +35,9 @@ function LdPage() {
                             console.log("url", url)
                             obj[item.elementType] = { ...item, url, eq: index }
                         } else if (item.elementType === "TEXT") {
-                             obj[item.elementType] = obj[item.elementType] ? [...obj[item.elementType], { ...item, eq: index }] : [{ ...item, eq: index }]
+                            obj[item.elementType] = obj[item.elementType] ? [...obj[item.elementType], { ...item, eq: index }] : [{ ...item, eq: index }]
+                        } else if (item.elementType === "IMAGE") {
+                            obj[item.elementType] = obj[item.elementType] ? [...obj[item.elementType], { ...item, eq: index }] : [{ ...item, eq: index }]
                         } else {
                             obj[item.elementType] = { ...item, eq: index }
                         }
@@ -46,15 +48,17 @@ function LdPage() {
             })
         }
     }, [])
-    console.log("data", data)
+    const onLongPress = (str) => {
+        console.log("用户长按了二维码:",str)
+    }
     return <View >
         <View style={{ marginTop: (systemInfo.statusBarHeight as any) + 10 }}></View>
         {/* 标题 */}
-        <View style={{ textAlign: 'center', paddingBottom: 10 }}>&nbsp;标题</View>
+        <View style={{ textAlign: 'center', paddingBottom: 10 }}>{data ? data["name"] : ""}&nbsp;</View>
         {/* 内容 */}
-        <View style={{ height: `calc(100vh - ${(systemInfo.statusBarHeight || 0) + 32}px)`, backgroundColor: "#d5e8d6", overflowY: "auto", display: 'flex', flexFlow: 'column' }}>
+        <View style={{ height: `calc(100vh - ${(systemInfo.statusBarHeight || 0) + 32}px)`, backgroundColor: "#d5e8d6", overflowY: "auto" }}>
             {
-                data ? <View>
+                data ? <View style={{ display: 'flex', flexFlow: 'column', paddingBottom: 100 }}>
                     {/* 顶图 */}
                     {data["TOP_IMAGE"] && <Image src={data["TOP_IMAGE"].url} mode="widthFix" style={{ height: "auto", width: "100vw", order: data["TOP_IMAGE"].eq }} />}
                     {/* 文本 */}
@@ -66,13 +70,15 @@ function LdPage() {
                         })}</View>
                     })}
                     {/* 图 */}
-                    {data["IMAGE"] && <Image src={data["IMAGE"].url} mode="widthFix" style={{ height: "auto", width: "100vw", order: data["IMAGE"].eq }} />}
+                    {data["IMAGE"] && data["IMAGE"].map((imgObj, index) => {
+                        return <Image src={imgObj.url} mode="widthFix" style={{ height: "auto", width: "100vw", order: imgObj.eq }} />
+                    })}
                     {/* 二维码 */}
-                    {data["QR_CODE"] && <Image src={data["QR_CODE"].url} mode="widthFix" showMenuByLongpress style={{ height: "auto", width: "70vw", display: 'block', margin: '0 auto' }} />}
+                    {data["QR_CODE"] && <Image src={data["QR_CODE"].url}  onLongPress={()=>{onLongPress("QR_CODE")}} mode="widthFix" showMenuByLongpress style={{ height: "auto", width: "70vw", display: 'block', margin: '0 auto', order: data["QR_CODE"].eq }} />}
                     {/* 动图 */}
-                    <Image src={"https://app-cloud-images.oss-cn-hangzhou.aliyuncs.com/1768559009681.gif"} mode="widthFix" style={{ height: "auto", width: "100vw", marginTop: -30, paddingBottom: 70 }} />
+                    {/* <Image src={"https://app-cloud-images.oss-cn-hangzhou.aliyuncs.com/1768559009681.gif"} mode="widthFix" style={{ height: "auto", width: "100vw", marginTop: -30, paddingBottom: 70 }} /> */}
                     {/* 底部浮选图 */}
-                    {data["FLOAT_BUTTON"] && <Image src={data["FLOAT_BUTTON"].url} mode="widthFix" showMenuByLongpress style={{ height: "auto", width: "100vw", position: 'fixed', bottom: 0, left: 0, zIndex: 999 }} />}
+                    {data["FLOAT_BUTTON"] && <Image src={data["FLOAT_BUTTON"].url} mode="widthFix" onLongPress={()=>{onLongPress("FLOAT_BUTTON")}}showMenuByLongpress style={{ height: "auto", width: "100vw", position: 'fixed', bottom: 0, left: 0, zIndex: 999, order: data["FLOAT_BUTTON"].eq }} />}
                 </View> : <View></View>
             }
         </View>