Explorar el Código

Merge branch 'main' of http://git.mokasz.com/maomao/mini_read_space_front

hank hace 1 año
padre
commit
d84087c331

+ 4 - 7
app.js

@@ -103,11 +103,9 @@ async function onNovelPluginLoad(data) {
   const novelManager = novelPlugin.getNovelManager(data.id)
   getApp().globalData.novelManager = novelManager
 
-  if (getApp().globalData.isShowDialog) {
-    novelManager.setFullScreenComponentStatus({
-      show: true,
-    })
-  }
+  novelManager.setFullScreenComponentStatus({
+    show: true,
+  })
 
   let pluginInfo = novelManager.getPluginInfo();
   let innerBookId = pluginInfo.query?.innerBookId;
@@ -142,14 +140,13 @@ async function onNovelPluginLoad(data) {
     
     let chapterConfigs = []
     for (let index = 0; index < bookDetail.latestChapterNo; index++) {
-      console.log(index + 1)
       if ((index + 1) % getApp().globalData.bookmarkAdNum === 0) {
         chapterConfigs.push({
           chapterIndex: index,
           blocks: [
             {
               type: 3,
-              unitId: 'adunit-343af082b8c8ea18'
+              unitId: apple.ads.bookmarkAdId
             }
           ]
         })

+ 16 - 6
components/charge-dialog/charge-dialog.js

@@ -2,6 +2,10 @@ import {
   unlockChapter
 } from '../../api/api.js'
 
+import {
+  apple
+} from '../../config/config'
+
 const novelPlugin = requirePlugin('novel-plugin')
 Component({
   properties: {
@@ -32,27 +36,30 @@ Component({
     isCounting: false
   },
 
-  ready() {
+  created() {
     this.rewardVideoLoad()
+  },
+
+  ready() {
     setTimeout(() => {
       this.startCountdown()
     }, 500)
   },
 
-  onUnload() {
+  detached() {
     this.stopCountdown(); // 页面卸载时清除定时器
   },
 
   methods: {
     unlock() {
+      this.stopCountdown();
       this.rewardVideoPlayFn()
     },
 
     // 激励视频加载
     rewardVideoLoad() {
       if (wx.createRewardedVideoAd) {
-        // let adId = apple.ads.rewardAdId
-        let adId = 'adunit-7df7b95b78f624f8'
+        let adId = apple.ads.rewardAdId
         this.videoAd = wx.createRewardedVideoAd({
           adUnitId: adId
         })
@@ -65,7 +72,9 @@ Component({
         this.videoAd.onClose((res) => {
           const novelManager = novelPlugin.getNovelManager(this.properties.novelManagerId)
           if (res && res.isEnded) {
-            novelManager.paymentCompleted()
+            // for (let index = 0; index < getApp().globalData.unlockChapterNum; index++) {
+
+            // }
             let params = {
               chapterNo: this.properties.chapterIndex,
               novelId: getApp().globalData.novelId,
@@ -73,8 +82,9 @@ Component({
             }
             unlockChapter(params).then(res => {
               console.log(res)
+              novelManager.paymentCompleted()
+              console.log('章节解锁成功')
             })
-            console.log('解锁章节')
           } else {
             novelManager.closeChargeDialog()
             console.log('关闭解锁组件')

+ 5 - 2
components/full-screen/full-screen.js

@@ -1,3 +1,7 @@
+import {
+  apple
+} from '../../config/config'
+
 const novelPlugin = requirePlugin('novel-plugin')
 let interstitialAd = null
 
@@ -39,8 +43,7 @@ Component({
   methods: {
     // 插屏广告加载
     interstitalLoad() {
-      const _this = this
-      let adId = 'adunit-37ee342a8fc046b7'
+      let adId = apple.ads.insertAdId
       interstitialAd = wx.createInterstitialAd({
         adUnitId: adId
       })

+ 5 - 0
config/config.js

@@ -3,6 +3,11 @@ const appInfoObj = {
         appid: 'wxa7a33088566e1292',
         ghid: 'gh_4e55f615d5dc',
         appName: '试读空间',
+        ads: {
+          insertAdId: 'adunit-37ee342a8fc046b7',
+          rewardAdId: 'adunit-7df7b95b78f624f8',
+          bookmarkAdId: 'adunit-343af082b8c8ea18'
+      },
     },
   };
   

+ 7 - 6
pages/bookshelf/bookshelf.js

@@ -5,6 +5,9 @@ import {
 import {
   goToBookDetail
 } from '../../utils/util'
+import {
+  apple
+} from '../../config/config'
 
 let interstitialAd = null
 
@@ -30,20 +33,18 @@ Page({
       bookList: []
     })
     this.loadBookList()
-
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
   },
 
   onTabItemTap(item) {
     console.log(item.index)
+    setTimeout(() => {
+      this.interstitalPlayFn()
+    }, 1000)
   },
 
   // 插屏广告加载
   interstitalLoad() {
-    const _this = this
-    let adId = 'adunit-37ee342a8fc046b7'
+    let adId = apple.ads.insertAdId
     interstitialAd = wx.createInterstitialAd({
       adUnitId: adId
     })

+ 7 - 7
pages/category/category.js

@@ -5,6 +5,9 @@ import {
 import {
   goToBookDetail
 } from '../../utils/util'
+import {
+  apple
+} from '../../config/config'
 
 let interstitialAd = null
 
@@ -30,23 +33,20 @@ Page({
   onShow: function () {
     // 每次页面显示时同步性别状态
     this.syncGenderState();
-
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
   },
 
   onTabItemTap: function (item) {
     console.log(item.index)
-
+    setTimeout(() => {
+      this.interstitalPlayFn()
+    }, 1000)
     // tabBar 点击时同步性别状态
     this.syncGenderState();
   },
 
   // 插屏广告加载
   interstitalLoad() {
-    const _this = this
-    let adId = 'adunit-37ee342a8fc046b7'
+    let adId = apple.ads.insertAdId
     interstitialAd = wx.createInterstitialAd({
       adUnitId: adId
     })

+ 2 - 1
pages/index/index.js

@@ -10,6 +10,7 @@ import {
 import {
   goToBookDetail
 } from '../../utils/util'
+import { apple } from '../../config/config'
 
 const app = getApp()
 let interstitialAd = null
@@ -110,7 +111,7 @@ Page({
 
   // 插屏广告加载
   interstitalLoad() {
-    let adId = 'adunit-37ee342a8fc046b7'
+    let adId = apple.ads.insertAdId
     interstitialAd = wx.createInterstitialAd({
       adUnitId: adId
     })

+ 8 - 5
pages/mine/mine.js

@@ -1,4 +1,8 @@
 // pages/mine/mine.js
+import {
+  apple
+} from '../../config/config'
+
 let interstitialAd = null
 
 const app = getApp()
@@ -18,19 +22,18 @@ Page({
   },
 
   onShow() {
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
   },
 
   onTabItemTap(item) {
+    setTimeout(() => {
+      this.interstitalPlayFn()
+    }, 1000)
     console.log(item.index)
   },
 
   // 插屏广告加载
   interstitalLoad() {
-    const _this = this
-    let adId = 'adunit-37ee342a8fc046b7'
+    let adId = apple.ads.insertAdId
     interstitialAd = wx.createInterstitialAd({
       adUnitId: adId
     })

+ 440 - 438
pages/video/video.js

@@ -1,14 +1,17 @@
 // pages/video/video.js
 import {
-    getVideoList,
-    getTemplateConfig,
-    getUuid
+  getVideoList,
+  getTemplateConfig,
+  getUuid
 } from '../../api/api'
 import {
-    rnd,
-    deepCopy,
-    goToBookDetail
+  rnd,
+  deepCopy,
+  goToBookDetail
 } from '../../utils/util'
+import {
+  apple
+} from '../../config/config'
 
 const app = getApp()
 let interstitialAd = null
@@ -37,462 +40,461 @@ Page({
         share_count: 1
     },
 
-    async onLoad() {
-        console.log('打开视频页面--------------------------')
-        if (!getApp().globalData.uuid) {
-            await this.getUUID().then(uuid => {
-                getApp().globalData.uuid = uuid
-            })
-        }
-
-        this.interstitalLoad()
-        getTemplateConfig({
-            box_type: 67,
-            uuid: getApp().globalData.uuid
-        }).then(res => {
-            this.setData({
-                globalConfig: res.globalConfig
-            })
-            // 获取视频分类
-            this.getVideoCategories()
-        })
-
-        // 获取状态栏高度
-        this.getSystemInfo()
-    },
-
-    onShow() {
-        console.log('页面显示--------------------------')
-        setTimeout(() => {
-            this.interstitalPlayFn()
-        }, 1000)
-
-        // 每次显示页面时刷新列表
-        if (this.data.videoList.length === 0) {
-            this.setData({
-                page: 1
-            })
-            // this.loadVideoList()
-        }
-
-        // 获取当前页面的参数
-        const pages = getCurrentPages();
-        const currentPage = pages[pages.length - 1];
-        const options = currentPage.options;
-
-        // 处理分享进入的情况
-        if (options.shared_video_id) {
-            if (+options.share_count === 1 && this.data.share_count === 1) {
-                this.setData({
-                    share_count: 2
-                })
-                this.goToBookDetail()
-            } else if (+options.share_count === 1 && this.data.share_count === 2) {
-                this.setData({
-                    share_count: 3
-                })
-                // 延迟跳转,确保列表页已经加载完成
-                setTimeout(() => {
-                    wx.navigateTo({
-                        url: `/pages/video/detail?id=${options.shared_video_id}&title=${options.title || ''}&tag_id=${options.tag_id || ''}`,
-                        fail: (err) => {
-                            console.error('跳转到视频详情页失败:', err);
-                            wx.showToast({
-                                title: '打开视频失败',
-                                icon: 'none'
-                            });
-                        }
-                    });
-                }, 500);
-            }
-        }
-    },
-
-    onTabItemTap(item) {
-        console.log(item.index)
-    },
-
-    // 插屏广告加载
-    interstitalLoad() {
-        const _this = this
-        let adId = 'adunit-37ee342a8fc046b7'
-        interstitialAd = wx.createInterstitialAd({
-            adUnitId: adId
-        })
-        interstitialAd.onLoad(() => {
-            console.log('视频页插屏广告onLoad')
-        })
-        interstitialAd.onError((err) => {
-            console.log('视频页插屏广告onError', err)
-        })
-        interstitialAd.onClose(() => {
-            console.log('视频页插屏广告onClose')
-        })
-    },
-
-    // 插屏广告展示
-    interstitalPlayFn() {
-        if (interstitialAd) {
-            interstitialAd.show().catch((err) => {
-                console.error(err)
-            })
-        }
-    },
-
-    /**
-     * 获取uuid
-     */
-    getUUID() {
-        return new Promise((resolve, reject) => {
-            wx.login({
-                success: res => {
-                    let body = {
-                        code: res.code,
-                        source_type: 1,
-                        source_id: ''
-                    }
-                    getUuid(body).then(async res => {
-
-                        resolve(res.uuid)
-                    }).catch((err) => {
-                        reject(err)
-                    })
-                }
-            })
-        })
-    },
-
-    // 获取系统信息
-    getSystemInfo() {
-        const systemInfo = wx.getSystemInfoSync()
-        const statusBarHeight = systemInfo.statusBarHeight
-        const navHeight = statusBarHeight + 44
-
-        this.setData({
-            statusBarHeight: statusBarHeight,
-            navHeight: navHeight,
-            navStyle: `height:${navHeight}px`,
-            listStyle: `top:${navHeight}px`
-        })
-    },
+  async onLoad() {
+    console.log('打开视频页面--------------------------')
+    if (!getApp().globalData.uuid) {
+      await this.getUUID().then(uuid => {
+        getApp().globalData.uuid = uuid
+      })
+    }
 
-    // 获取视频分类
-    getVideoCategories() {
-        console.log('getVideoCategories', this.data.globalConfig)
-        // 筛选出type=1的视频分类
-        const videoCategories = this.data.globalConfig.categoryList.filter(item => item.type === 1)
-
-        console.log('videoCategories', videoCategories)
-
-        if (videoCategories.length > 0) {
-            // 设置分类列表和默认选中的分类
-            this.setData({
-                categoryList: videoCategories,
-                currentCategoryId: videoCategories[0].id
-            })
-            // 加载第一个分类的视频列表
-            this.loadVideoList()
-        } else {
-            console.error('未找到视频分类')
-            wx.showToast({
-                title: '未找到视频分类',
-                icon: 'none'
-            })
-        }
-    },
+    this.interstitalLoad()
+    getTemplateConfig({
+      box_type: 67,
+      uuid: getApp().globalData.uuid
+    }).then(res => {
+      this.setData({
+        globalConfig: res.globalConfig
+      })
+      // 获取视频分类
+      this.getVideoCategories()
+    })
+
+    // 获取状态栏高度
+    this.getSystemInfo()
+  },
+
+  onShow() {
+    console.log('页面显示--------------------------')
+
+    // 每次显示页面时刷新列表
+    if (this.data.videoList.length === 0) {
+      this.setData({
+        page: 1
+      })
+      // this.loadVideoList()
+    }
 
-    // 切换分类
-    switchCategory(e) {
-        const categoryId = e.currentTarget.dataset.id
-        if (categoryId === this.data.currentCategoryId) return
+    // 获取当前页面的参数
+    const pages = getCurrentPages();
+    const currentPage = pages[pages.length - 1];
+    const options = currentPage.options;
 
+    // 处理分享进入的情况
+    if (options.shared_video_id) {
+      if (+options.share_count === 1 && this.data.share_count === 1) {
         this.setData({
-            currentCategoryId: categoryId,
-            page: 1,
-            videoList: [],
-            hasMore: true
+          share_count: 2
         })
-        this.loadVideoList()
-    },
-
-    // 加载视频列表
-    async loadVideoList() {
-        if (this.data.loading) return
-
+        this.goToBookDetail()
+      } else if (+options.share_count === 1 && this.data.share_count === 2) {
         this.setData({
-            loading: true
+          share_count: 3
         })
-
-        try {
-            const params = {
-                page: this.data.page,
-                size: this.data.size,
-                tag_id: this.data.currentCategoryId,
-                // 如果不是第一页,传递最后一个视频的ID作为next_id
-                next_id: this.data.page > 1 && this.data.videoList.length > 0 ?
-                    this.data.videoList[this.data.videoList.length - 1].id :
-                    ""
-            }
-
-            let videoList = []
-            try {
-                videoList = await getVideoList(params)
-
-                if (!Array.isArray(videoList)) {
-                    throw new Error('返回数据格式错误')
-                }
-
-                videoList = videoList.map(item => ({
-                    ...item,
-                    views: rnd(1, 10),
-                    favors: rnd(5000, 10000),
-                    adType: "video"
-                }))
-
-                videoList = this.formatVideoAdList(videoList);
-
-                console.log("format videoList", videoList)
-
-            } catch (apiError) {
-                console.error('API调用失败:', apiError)
-                throw apiError
-            }
-
-            // 如果是第一页,直接替换数据
-            if (this.data.page === 1) {
-                this.setData({
-                    videoList: videoList,
-                    loading: false,
-                    hasMore: videoList.length >= this.data.size
-                })
-            } else {
-                // 否则追加数据
-                this.setData({
-                    videoList: [...this.data.videoList, ...videoList],
-                    loading: false,
-                    hasMore: videoList.length >= this.data.size
-                })
+        // 延迟跳转,确保列表页已经加载完成
+        setTimeout(() => {
+          wx.navigateTo({
+            url: `/pages/video/detail?id=${options.shared_video_id}&title=${options.title || ''}&tag_id=${options.tag_id || ''}`,
+            fail: (err) => {
+              console.error('跳转到视频详情页失败:', err);
+              wx.showToast({
+                title: '打开视频失败',
+                icon: 'none'
+              });
             }
-        } catch (error) {
-            console.error('加载视频列表失败:', error)
+          });
+        }, 500);
+      }
+    }
+  },
+
+  onTabItemTap(item) {
+    console.log(item.index)
+    setTimeout(() => {
+      this.interstitalPlayFn()
+    }, 1000)
+  },
+
+  // 插屏广告加载
+  interstitalLoad() {
+    let adId = apple.ads.insertAdId
+    interstitialAd = wx.createInterstitialAd({
+      adUnitId: adId
+    })
+    interstitialAd.onLoad(() => {
+      console.log('视频页插屏广告onLoad')
+    })
+    interstitialAd.onError((err) => {
+      console.log('视频页插屏广告onError', err)
+    })
+    interstitialAd.onClose(() => {
+      console.log('视频页插屏广告onClose')
+    })
+  },
+
+  // 插屏广告展示
+  interstitalPlayFn() {
+    if (interstitialAd) {
+      interstitialAd.show().catch((err) => {
+        console.error(err)
+      })
+    }
+  },
+
+  /**
+   * 获取uuid
+   */
+  getUUID() {
+    return new Promise((resolve, reject) => {
+      wx.login({
+        success: res => {
+          let body = {
+            code: res.code,
+            source_type: 1,
+            source_id: ''
+          }
+          getUuid(body).then(async res => {
+
+            resolve(res.uuid)
+          }).catch((err) => {
+            reject(err)
+          })
+        }
+      })
+    })
+  },
+
+  // 获取系统信息
+  getSystemInfo() {
+    const systemInfo = wx.getSystemInfoSync()
+    const statusBarHeight = systemInfo.statusBarHeight
+    const navHeight = statusBarHeight + 44
+
+    this.setData({
+      statusBarHeight: statusBarHeight,
+      navHeight: navHeight,
+      navStyle: `height:${navHeight}px`,
+      listStyle: `top:${navHeight}px`
+    })
+  },
+
+  // 获取视频分类
+  getVideoCategories() {
+    console.log('getVideoCategories', this.data.globalConfig)
+    // 筛选出type=1的视频分类
+    const videoCategories = this.data.globalConfig.categoryList.filter(item => item.type === 1)
+
+    console.log('videoCategories', videoCategories)
+
+    if (videoCategories.length > 0) {
+      // 设置分类列表和默认选中的分类
+      this.setData({
+        categoryList: videoCategories,
+        currentCategoryId: videoCategories[0].id
+      })
+      // 加载第一个分类的视频列表
+      this.loadVideoList()
+    } else {
+      console.error('未找到视频分类')
+      wx.showToast({
+        title: '未找到视频分类',
+        icon: 'none'
+      })
+    }
+  },
+
+  // 切换分类
+  switchCategory(e) {
+    const categoryId = e.currentTarget.dataset.id
+    if (categoryId === this.data.currentCategoryId) return
+
+    this.setData({
+      currentCategoryId: categoryId,
+      page: 1,
+      videoList: [],
+      hasMore: true
+    })
+    this.loadVideoList()
+  },
+
+  // 加载视频列表
+  async loadVideoList() {
+    if (this.data.loading) return
+
+    this.setData({
+      loading: true
+    })
+
+    try {
+      const params = {
+        page: this.data.page,
+        size: this.data.size,
+        tag_id: this.data.currentCategoryId,
+        // 如果不是第一页,传递最后一个视频的ID作为next_id
+        next_id: this.data.page > 1 && this.data.videoList.length > 0 ?
+          this.data.videoList[this.data.videoList.length - 1].id :
+          ""
+      }
+
+      let videoList = []
+      try {
+        videoList = await getVideoList(params)
+
+        if (!Array.isArray(videoList)) {
+          throw new Error('返回数据格式错误')
         }
-    },
-    /* ------------------ 广告相关 ----------------- */
-    /**
-     * 标记广告位置
-     * @param {} arr
-     * @returns
-     */
-    formatVideoAdList(arr) {
-        // 原生广告间隔,激励广告间隔
-        let templateGap = 0,
-            rewardGap = 0
-
-        // 第二个固定是原生广告
-        let result = [arr.shift(), {
-            adType: 'templateAd'
-        }]
-        // 辅助计算间隔变量
-        let markIndex = 0
-        let templateAdFlag = true
-        let rewardAdFlag = true
-
-        do {
-            markIndex += 1
-            if (templateGap > 0) {
-                if (templateAdFlag && markIndex - 1 === templateGap) {
-                    markIndex = 0
-                    result.push({
-                        adType: "templateAd"
-                    })
-                    templateAdFlag = false
-                    rewardAdFlag = true
-                    continue
-                }
-            } else {
-                rewardAdFlag = true
-            }
-            if (rewardGap > 0) {
-                if (rewardAdFlag && markIndex - 1 === rewardGap) {
-                    markIndex = 0
-                    templateAdFlag = true
-                    rewardAdFlag = false
-                    let rewardItem = arr.shift()
-                    rewardItem.lock = true
-                    result.push(rewardItem)
-                    continue
-                }
-            } else {
-                templateAdFlag = true
-            }
 
-            result.push(arr.shift())
-        } while (arr.length > 0);
+        videoList = videoList.map(item => ({
+          ...item,
+          views: rnd(1, 10),
+          favors: rnd(5000, 10000),
+          adType: "video"
+        }))
 
-        return result;
-    },
-    // 加载更多
-    loadMore() {
-        console.log("触发loadMore")
-        console.log("当前状态:", {
-            loading: this.data.loading,
-            hasMore: this.data.hasMore,
-            page: this.data.page,
-            videoListLength: this.data.videoList.length
-        })
+        videoList = this.formatVideoAdList(videoList);
 
-        // 添加防抖,避免频繁触发
-        const now = Date.now()
-        if (now - this.data.lastLoadTime < 500) {
-            console.log("防抖触发,跳过本次加载")
-            return
-        }
-
-        if (this.data.hasMore && !this.data.loading) {
-            console.log("开始加载更多数据")
-            this.setData({
-                page: this.data.page + 1,
-                lastLoadTime: now
-            })
-            this.loadVideoList()
-        } else {
-            console.log("不满足加载条件:", {
-                hasMore: this.data.hasMore,
-                loading: this.data.loading
-            })
-        }
-    },
+        console.log("format videoList", videoList)
 
-    // 刷新列表
-    refreshList() {
-        wx.showLoading({
-            title: '刷新中...',
-        })
+      } catch (apiError) {
+        console.error('API调用失败:', apiError)
+        throw apiError
+      }
 
+      // 如果是第一页,直接替换数据
+      if (this.data.page === 1) {
         this.setData({
-            page: 1,
-            videoList: [],
-            hasMore: true
+          videoList: videoList,
+          loading: false,
+          hasMore: videoList.length >= this.data.size
         })
-
-        this.loadVideoList().then(() => {
-            wx.hideLoading()
-            wx.showToast({
-                title: '刷新成功',
-                icon: 'success',
-                duration: 1500
-            })
-        }).catch(() => {
-            wx.hideLoading()
+      } else {
+        // 否则追加数据
+        this.setData({
+          videoList: [...this.data.videoList, ...videoList],
+          loading: false,
+          hasMore: videoList.length >= this.data.size
         })
-    },
-
-    // 点击视频
-    onVideoTap(e) {
-        const videoId = e.currentTarget.dataset.id;
-
-        // 显示加载中提示
-        wx.showLoading({
-            title: '加载中...',
-            mask: true
-        });
-
-        // 获取当前点击的视频项
-        const video = this.data.videoList.find(item => item.id === videoId);
-
-        // 确保视频对象存在
-        if (!video) {
-            wx.hideLoading();
-            wx.showToast({
-                title: '视频数据错误',
-                icon: 'none'
-            });
-            return;
+      }
+    } catch (error) {
+      console.error('加载视频列表失败:', error)
+    }
+  },
+  /* ------------------ 广告相关 ----------------- */
+  /**
+   * 标记广告位置
+   * @param {} arr
+   * @returns
+   */
+  formatVideoAdList(arr) {
+    // 原生广告间隔,激励广告间隔
+    let templateGap = 0,
+      rewardGap = 0
+
+    // 第二个固定是原生广告
+    let result = [arr.shift(), {
+      adType: 'templateAd'
+    }]
+    // 辅助计算间隔变量
+    let markIndex = 0
+    let templateAdFlag = true
+    let rewardAdFlag = true
+
+    do {
+      markIndex += 1
+      if (templateGap > 0) {
+        if (templateAdFlag && markIndex - 1 === templateGap) {
+          markIndex = 0
+          result.push({
+            adType: "templateAd"
+          })
+          templateAdFlag = false
+          rewardAdFlag = true
+          continue
         }
+      } else {
+        rewardAdFlag = true
+      }
+      if (rewardGap > 0) {
+        if (rewardAdFlag && markIndex - 1 === rewardGap) {
+          markIndex = 0
+          templateAdFlag = true
+          rewardAdFlag = false
+          let rewardItem = arr.shift()
+          rewardItem.lock = true
+          result.push(rewardItem)
+          continue
+        }
+      } else {
+        templateAdFlag = true
+      }
+
+      result.push(arr.shift())
+    } while (arr.length > 0);
+
+    return result;
+  },
+  // 加载更多
+  loadMore() {
+    console.log("触发loadMore")
+    console.log("当前状态:", {
+      loading: this.data.loading,
+      hasMore: this.data.hasMore,
+      page: this.data.page,
+      videoListLength: this.data.videoList.length
+    })
+
+    // 添加防抖,避免频繁触发
+    const now = Date.now()
+    if (now - this.data.lastLoadTime < 500) {
+      console.log("防抖触发,跳过本次加载")
+      return
+    }
 
-        // 将标题进行URI编码处理(避免特殊字符导致的问题)
-        const encodedTitle = encodeURIComponent(video.title || '');
+    if (this.data.hasMore && !this.data.loading) {
+      console.log("开始加载更多数据")
+      this.setData({
+        page: this.data.page + 1,
+        lastLoadTime: now
+      })
+      this.loadVideoList()
+    } else {
+      console.log("不满足加载条件:", {
+        hasMore: this.data.hasMore,
+        loading: this.data.loading
+      })
+    }
+  },
+
+  // 刷新列表
+  refreshList() {
+    wx.showLoading({
+      title: '刷新中...',
+    })
+
+    this.setData({
+      page: 1,
+      videoList: [],
+      hasMore: true
+    })
+
+    this.loadVideoList().then(() => {
+      wx.hideLoading()
+      wx.showToast({
+        title: '刷新成功',
+        icon: 'success',
+        duration: 1500
+      })
+    }).catch(() => {
+      wx.hideLoading()
+    })
+  },
+
+  // 点击视频
+  onVideoTap(e) {
+    const videoId = e.currentTarget.dataset.id;
+
+    // 显示加载中提示
+    wx.showLoading({
+      title: '加载中...',
+      mask: true
+    });
+
+    // 获取当前点击的视频项
+    const video = this.data.videoList.find(item => item.id === videoId);
+
+    // 确保视频对象存在
+    if (!video) {
+      wx.hideLoading();
+      wx.showToast({
+        title: '视频数据错误',
+        icon: 'none'
+      });
+      return;
+    }
 
-        // 跳转到视频详情页
-        wx.navigateTo({
-            url: `/pages/video/detail?id=${videoId}&title=${encodedTitle}&tag_id=${e.currentTarget.dataset.info.tag_ids[0]}`,
-            success: () => {
-                wx.hideLoading();
-            },
-            fail: (err) => {
-                console.error('跳转失败:', err);
-                wx.hideLoading();
-                wx.showToast({
-                    title: '跳转失败',
-                    icon: 'none'
-                });
-            }
+    // 将标题进行URI编码处理(避免特殊字符导致的问题)
+    const encodedTitle = encodeURIComponent(video.title || '');
+
+    // 跳转到视频详情页
+    wx.navigateTo({
+      url: `/pages/video/detail?id=${videoId}&title=${encodedTitle}&tag_id=${e.currentTarget.dataset.info.tag_ids[0]}`,
+      success: () => {
+        wx.hideLoading();
+      },
+      fail: (err) => {
+        console.error('跳转失败:', err);
+        wx.hideLoading();
+        wx.showToast({
+          title: '跳转失败',
+          icon: 'none'
         });
-    },
-
-    // 下拉刷新
-    onPullDownRefresh() {
-        this.setData({
-            page: 1,
-            videoList: []
+      }
+    });
+  },
+
+  // 下拉刷新
+  onPullDownRefresh() {
+    this.setData({
+      page: 1,
+      videoList: []
+    })
+    this.loadVideoList().then(() => {
+      wx.stopPullDownRefresh()
+    })
+  },
+
+  // 分享按钮点击事件
+  onShareTap(e) {
+    // 阻止事件冒泡
+    e.stopPropagation();
+  },
+
+  // 分享给朋友
+  onShareAppMessage(e) {
+    const video = e.target.dataset.video
+    if (!video) return {}
+
+    return {
+      title: video.title,
+      path: `/pages/video/video?shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`,
+      imageUrl: video.cover_image,
+      success: function (res) {
+        wx.showToast({
+          title: '分享成功',
+          icon: 'success',
+          duration: 1500
         })
-        this.loadVideoList().then(() => {
-            wx.stopPullDownRefresh()
+      },
+      fail: function (res) {
+        wx.showToast({
+          title: '分享失败',
+          icon: 'none',
+          duration: 1500
         })
-    },
-
-    // 分享按钮点击事件
-    onShareTap(e) {
-        // 阻止事件冒泡
-        e.stopPropagation();
-    },
-
-    // 分享给朋友
-    onShareAppMessage(e) {
-        const video = e.target.dataset.video
-        if (!video) return {}
-
-        return {
-            title: video.title,
-            path: `/pages/video/video?shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`,
-            imageUrl: video.cover_image,
-            success: function (res) {
-                wx.showToast({
-                    title: '分享成功',
-                    icon: 'success',
-                    duration: 1500
-                })
-            },
-            fail: function (res) {
-                wx.showToast({
-                    title: '分享失败',
-                    icon: 'none',
-                    duration: 1500
-                })
-            }
-        }
-    },
-
-    // 分享到朋友圈
-    onShareTimeline(e) {
-        const video = e.target.dataset.video
-        if (!video) return {}
+      }
+    }
+  },
 
-        return {
-            title: video.title,
-            query: `shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`,
-            imageUrl: video.cover_image
-        }
-    },
+  // 分享到朋友圈
+  onShareTimeline(e) {
+    const video = e.target.dataset.video
+    if (!video) return {}
 
-    // 跳转到书籍详情
-    goToBookDetail() {
-        getApp().globalData.isShowDialog = true
-        // 使用公共的goToBookDetail函数
-        goToBookDetail({
-            bookId: 7266,
-            wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
-            chapterId: null
-        });
+    return {
+      title: video.title,
+      query: `shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`,
+      imageUrl: video.cover_image
     }
+  },
+
+  // 跳转到书籍详情
+  goToBookDetail() {
+    getApp().globalData.isShowDialog = true
+    // 使用公共的goToBookDetail函数
+    goToBookDetail({
+      bookId: 7266,
+      wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
+      chapterId: null
+    });
+  }
 })

+ 1 - 1
utils/util.js

@@ -33,7 +33,7 @@ export const goToBookDetail = (options) => {
   // 根据不同参数构建不同的URL
   if (options.wxBookId) {
     // 微信书籍ID跳转
-    url = `plugin-private://wx293c4b6097a8a4d0/pages/novel/index?bookId=${options.wxBookId}`;
+    url = `plugin-private://wx293c4b6097a8a4d0/pages/novel/index?share=1&bookId=${options.wxBookId}`;
     
     // 如果有章节ID,添加到URL
     if (options.chapterId) {