Browse Source

优化BUG

hank 1 year ago
parent
commit
d6b5601dcd

+ 6 - 0
.idea/inspectionProfiles/Project_Default.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0">
+    <option name="myName" value="Project Default" />
+    <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
+  </profile>
+</component>

+ 12 - 0
.idea/mini_read_space_front.iml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/.tmp" />
+      <excludeFolder url="file://$MODULE_DIR$/temp" />
+      <excludeFolder url="file://$MODULE_DIR$/tmp" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/mini_read_space_front.iml" filepath="$PROJECT_DIR$/.idea/mini_read_space_front.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>

+ 34 - 11
app.js

@@ -17,10 +17,10 @@ App({
     onLaunch(options) {
         console.log('场景值:', options, options.scene);
         novelPlugin.setLoggerConfig({
-            info: true,
-            debug: true,
-            log: true,
-            warn: true,
+            info: false,
+            debug: false,
+            log: false,
+            warn: false,
             error: true,
         })
 
@@ -28,9 +28,9 @@ App({
         novelPlugin.onPageLoad(onNovelPluginLoad)
 
         // 展示本地存储能力
-        const logs = wx.getStorageSync('logs') || []
-        logs.unshift(Date.now())
-        wx.setStorageSync('logs', logs);
+        // const logs = wx.getStorageSync('logs') || []
+        // logs.unshift(Date.now())
+        // wx.setStorageSync('logs', logs);
         wx.setStorageSync('scene', options.scene)// 储存场景值
     },
 
@@ -54,8 +54,8 @@ App({
                         "srcId": "",
                         "cusId": "",
                         "inviter": "",
-                        "promotionId": "",
-                        "inviterPromotionId": promotionid,
+                        "promotionId": promotionid,
+                        "inviterPromotionId": "",
                         "system": "pc",
                         "type": "inner",
                         "inner": 1,
@@ -65,7 +65,10 @@ App({
                         wx.setStorageSync('accessToken', res.accessToken);
                         this.globalData.isLogin = true;
                         this.globalData.userCode = res.userCode;
+                        this.globalData.openId = res.openId;
+                        this.globalData.unionId = res.unionId;
                         console.log('登录成功', this.globalData)
+                        SendEvent('login', {})
                         resolve(res);
                     }).catch(err => {
                         this.globalData.isLogin = false;
@@ -80,6 +83,23 @@ App({
         })
     },
 
+    // 自动登录
+    async autoLogin(promotionid) {
+        try {
+            // 检查是否已经登录
+            const token = wx.getStorageSync('accessToken');
+            if (token) {
+                // 已经登录
+                console.log('已经登录')
+                return;
+            }
+            // 未登录,执行登录
+            const res = this.login(promotionid);
+        } catch (error) {
+            console.error('登录失败:', error);
+        }
+    },
+
     // 检查登录状态
     checkLoginStatus() {
         const token = wx.getStorageSync('accessToken');
@@ -94,7 +114,10 @@ App({
         isShowDialog: false,
         novelId: '',
         unlockChapterNum: 1,
-        bookmarkAdNum: 3
+        bookmarkAdNum: 3,
+        openId: '',
+        unionId: '',
+        isEnterVideoDetail: false  // 是否进入过视频详情页
     }
 })
 
@@ -106,7 +129,7 @@ async function onNovelPluginLoad(data) {
 
     novelManager.setFullScreenComponentStatus({
         show: true,
-    })
+    });
 
     let pluginInfo = novelManager.getPluginInfo();
     let innerBookId = pluginInfo.query?.innerBookId;

+ 46 - 23
config/config.js

@@ -14,50 +14,74 @@ const appInfoObj = {
         appid: 'wxa13166979d7011c4',
         ghid: 'gh_dd2c1a9b59d8',
         appName: '稻香悦读视界',
-        ads: {
-
-        },
+        ads: {},
     },
     wx8a8aae7f462df482: {
         appid: 'wx8a8aae7f462df482',
         ghid: 'gh_1098838a2d7e',
         appName: '稻香悠享阅界',
-        ads: {
-
-        },
+        ads: {},
     },
     wx1344c35820ac688e: {
         appid: 'wx1344c35820ac688e',
         ghid: 'gh_e6ca97959a69',
         appName: '稻香悠享视界',
-        ads: {
-
-        },
+        ads: {},
     },
     wx8bd40e8ce9deb2b6: {
         appid: 'wx8bd40e8ce9deb2b6',
         ghid: 'gh_c40c32e29788',
         appName: '稻香悦读空间',
-        ads: {
-
-        },
+        ads: {},
     },
     wx9e90adce31181f7f: {
         appid: 'wx9e90adce31181f7f',
         ghid: 'gh_8a8044f49d85',
         appName: '稻香视读空间',
-        ads: {
-
-        },
+        ads: {},
     },
     wxdabfa5e02785fe9b: {
-      appid: 'wxdabfa5e02785fe9b',
-      ghid: 'gh_cb3eb04d904c',
-      appName: '稻阅视觉',
-      ads: {
-
-      },
-  },
+        appid: 'wxdabfa5e02785fe9b',
+        ghid: 'gh_cb3eb04d904c',
+        appName: '稻阅视觉',
+        ads: {},
+    },
+    wx37dab28af5492d98: {
+        appid: 'wx37dab28af5492d98',
+        ghid: 'gh_c153bd1f3877',
+        appName: '蓝晶甄读空间',
+        ads: {},
+    },
+    wx04b705205757217b: {
+        appid: 'wx04b705205757217b',
+        ghid: 'gh_0f1c04dc3790',
+        appName: '蓝晶享看空间',
+        ads: {},
+    },
+    wxc4e78d0425e83571: {
+        appid: 'wxc4e78d0425e83571',
+        ghid: 'gh_e0fd18c3f79f',
+        appName: '蓝晶悦享视界',
+        ads: {},
+    },
+    wx9d93825db1c7dcbe: {
+        appid: 'wx9d93825db1c7dcbe',
+        ghid: 'gh_1042b9599e05',
+        appName: '蓝晶看这视界',
+        ads: {},
+    },
+    wx3fe2e6c200ec7133: {
+        appid: 'wx3fe2e6c200ec7133',
+        ghid: 'gh_298cbd19ddcb',
+        appName: '蓝晶畅看视界',
+        ads: {},
+    },
+    wx3800bb2ed4a326c5: {
+        appid: 'wx3800bb2ed4a326c5',
+        ghid: 'gh_7e70db53a149',
+        appName: '蓝晶享看视界',
+        ads: {},
+    },
 };
 
 // @config 确定使用的小程序appid
@@ -73,4 +97,3 @@ export const https = {
     test_apiHttps: 'https://hyperion-novel-qa-app.mokamrp.com',
     apiHttps: 'https://hyperion-novel-qa-app.mokamrp.com'
 };
-  

+ 228 - 191
pages/category/category.js

@@ -1,212 +1,249 @@
 import {
-  getCategoryList,
-  getNovelSearch
+    getCategoryList,
+    getNovelSearch
 } from '../../api/api'
 import {
-  goToBookDetail
+    goToBookDetail
 } from '../../utils/util'
 import {
-  apple
+    apple
 } from '../../config/config'
 
 let interstitialAd = null
+const app = getApp()
 
 Page({
-  data: {
-    gender: 'male', // 当前性别选择
-    currentCategory: '', // 当前选中的分类
-    categories: [],
-    bookList: [],
-    loading: false,
-    keyword: '',
-    page: 1,
-    size: 10,
-    hasMore: true // 是否还有更多数据
-  },
-
-  onLoad: function (options) {
-    // 页面首次加载时的处理
-    this.syncGenderState();
-    this.interstitalLoad()
-  },
-
-  onShow: function () {
-    // 每次页面显示时同步性别状态
-    this.syncGenderState();
-  },
-
-  onTabItemTap: function (item) {
-    console.log(item.index)
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
-    // tabBar 点击时同步性别状态
-    this.syncGenderState();
-  },
-
-  // 插屏广告加载
-  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)
-      })
-    }
-  },
-
-  // 同步性别状态
-  syncGenderState: async function () {
-    const gender = wx.getStorageSync('gender') || 'male';
-    if (gender !== this.data.gender) {
-      this.setData({
-        gender
-      });
-      await this.loadCategories();
-    }
-  },
-
-  // 切换性别
-  switchGender: async function (e) {
-    const {
-      gender
-    } = e.detail;
-    this.setData({
-      gender: gender,
-      currentCategory: '',
-      bookList: [],
-      page: 1,
-      hasMore: true
-    });
-    await this.loadCategories();
-  },
-
-  // 加载分类列表
-  async loadCategories() {
-    try {
-      const channel = this.data.gender === 'male' ? "man" : "woman";
-      const result = await getCategoryList(channel);
-
-      if (result && Array.isArray(result)) {
+    data: {
+        gender: 'male', // 当前性别选择
+        currentCategory: '', // 当前选中的分类
+        categories: [],
+        bookList: [],
+        loading: false,
+        keyword: '',
+        page: 1,
+        size: 10,
+        hasMore: true, // 是否还有更多数据,
+        isLoggedIn: false, //是否登录
+    },
+
+    onLoad: function (options) {
+        app.autoLogin();
+        if (app.globalData.isLogin) {
+            setTimeout(() => {
+                console.log('加载分类列表')
+                // 页面首次加载时的处理
+                this.syncGenderState();
+                this.interstitalLoad();
+            }, 1500);
+        }
+    },
+
+    onShow: function () {
+        // 每次页面显示时同步性别状态
+        this.syncGenderState();
+    },
+
+    onTabItemTap: function (item) {
+        console.log(item.index)
+        setTimeout(() => {
+            this.interstitalPlayFn()
+        }, 1000)
+        // tabBar 点击时同步性别状态
+        this.syncGenderState();
+    },
+
+    // 自动登录
+    async autoLogin() {
+        try {
+            // 检查是否已经登录
+            const token = wx.getStorageSync('accessToken');
+            if (token) {
+                this.setData({
+                    isLoggedIn: true
+                });
+                // 已经登录
+                console.log('已经登录')
+                // 页面首次加载时的处理
+                this.syncGenderState();
+                this.interstitalLoad();
+                return;
+            }
+            // 未登录,执行登录
+            const res = this.login(promotionid);
+            this.setData({
+                isLoggedIn: true
+            });
+            // 页面首次加载时的处理
+            this.syncGenderState();
+            this.interstitalLoad();
+        } catch (error) {
+            console.error('登录失败:', error);
+        }
+    },
+
+    // 插屏广告加载
+    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)
+            })
+        }
+    },
+
+    // 同步性别状态
+    syncGenderState: async function () {
+        const gender = wx.getStorageSync('gender') || 'male';
+        if (gender !== this.data.gender) {
+            this.setData({
+                gender
+            });
+            await this.loadCategories();
+        }
+    },
+
+    // 切换性别
+    switchGender: async function (e) {
+        const {
+            gender
+        } = e.detail;
         this.setData({
-          categories: result,
-          currentCategory: result[0]?.code || '',
-          page: 1,
-          hasMore: true
+            gender: gender,
+            currentCategory: '',
+            bookList: [],
+            page: 1,
+            hasMore: true
         });
-        // 加载第一个分类的书籍
-        if (result[0]?.code) {
-          this.loadBookList(result[0].code);
+        await this.loadCategories();
+    },
+
+    // 加载分类列表
+    async loadCategories() {
+        try {
+            const channel = this.data.gender === 'male' ? "man" : "woman";
+            const result = await getCategoryList(channel);
+
+            if (result && Array.isArray(result)) {
+                this.setData({
+                    categories: result,
+                    currentCategory: result[0]?.code || '',
+                    page: 1,
+                    hasMore: true
+                });
+                // 加载第一个分类的书籍
+                if (result[0]?.code) {
+                    this.loadBookList(result[0].code);
+                }
+            }
+        } catch (error) {
+            console.error('加载分类失败:', error);
+            wx.showToast({
+                title: '加载分类失败',
+                icon: 'none'
+            });
         }
-      }
-    } catch (error) {
-      console.error('加载分类失败:', error);
-      wx.showToast({
-        title: '加载分类失败',
-        icon: 'none'
-      });
-    }
-  },
-
-  // 切换分类
-  switchCategory: function (e) {
-    const category = e.currentTarget.dataset.category;
-    this.setData({
-      currentCategory: category,
-      bookList: [],
-      page: 1,
-      hasMore: true
-    });
-    this.loadBookList(category);
-  },
-
-  // 加载书籍列表
-  async loadBookList(category) {
-    if (this.data.loading) return; // 只检查loading状态,移除hasMore检查
-
-    this.setData({
-      loading: true
-    });
-
-    try {
-      const params = {
-        keyword: this.data.keyword,
-        page: this.data.page,
-        size: this.data.size,
-        category: category
-      };
-
-      const result = await getNovelSearch(params);
-
-      if (result && result.records) {
-        const newList = this.data.page === 1 ? result.records : [...this.data.bookList, ...result.records];
-        const hasMore = !result.last;
+    },
 
+    // 切换分类
+    switchCategory: function (e) {
+        const category = e.currentTarget.dataset.category;
         this.setData({
-          bookList: newList,
-          loading: false,
-          hasMore: hasMore,
-          page: hasMore ? this.data.page + 1 : this.data.page
+            currentCategory: category,
+            bookList: [],
+            page: 1,
+            hasMore: true
         });
-      } else {
+        this.loadBookList(category);
+    },
+
+    // 加载书籍列表
+    async loadBookList(category) {
+        if (this.data.loading) return; // 只检查loading状态,移除hasMore检查
+
         this.setData({
-          loading: false,
-          hasMore: false
+            loading: true
         });
-      }
-    } catch (error) {
-      console.error('加载书籍列表失败:', error);
-      this.setData({
-        loading: false,
-        hasMore: false
-      });
-      wx.showToast({
-        title: '加载失败,请重试',
-        icon: 'none'
-      });
-    }
-  },
 
-  // 监听滚动到底部
-  onScrollToLower: function () {
-    if (this.data.currentCategory && this.data.hasMore) {
-      this.loadBookList(this.data.currentCategory);
+        try {
+            const params = {
+                keyword: this.data.keyword,
+                page: this.data.page,
+                size: this.data.size,
+                category: category
+            };
+
+            const result = await getNovelSearch(params);
+
+            if (result && result.records) {
+                const newList = this.data.page === 1 ? result.records : [...this.data.bookList, ...result.records];
+                const hasMore = !result.last;
+
+                this.setData({
+                    bookList: newList,
+                    loading: false,
+                    hasMore: hasMore,
+                    page: hasMore ? this.data.page + 1 : this.data.page
+                });
+            } else {
+                this.setData({
+                    loading: false,
+                    hasMore: false
+                });
+            }
+        } catch (error) {
+            console.error('加载书籍列表失败:', error);
+            this.setData({
+                loading: false,
+                hasMore: false
+            });
+            wx.showToast({
+                title: '加载失败,请重试',
+                icon: 'none'
+            });
+        }
+    },
+
+    // 监听滚动到底部
+    onScrollToLower: function () {
+        if (this.data.currentCategory && this.data.hasMore) {
+            this.loadBookList(this.data.currentCategory);
+        }
+    },
+
+    // 跳转到书籍详情
+    handleBookTap: function (e) {
+        const {
+            id,
+            wxbookid
+        } = e.currentTarget.dataset;
+        goToBookDetail({
+            bookId: id,
+            wxBookId: wxbookid
+        });
+    },
+
+    // 跳转到搜索页面
+    goToSearch: function (e) {
+        // 如果有输入内容,则带上关键词
+        const keyword = e.detail?.value || '';
+        wx.navigateTo({
+            url: `/pages/search/search?keyword=${encodeURIComponent(keyword)}`
+        });
     }
-  },
-
-  // 跳转到书籍详情
-  handleBookTap: function (e) {
-    const {
-      id,
-      wxbookid
-    } = e.currentTarget.dataset;
-    goToBookDetail({
-      bookId: id,
-      wxBookId: wxbookid
-    });
-  },
-
-  // 跳转到搜索页面
-  goToSearch: function (e) {
-    // 如果有输入内容,则带上关键词
-    const keyword = e.detail?.value || '';
-    wx.navigateTo({
-      url: `/pages/search/search?keyword=${encodeURIComponent(keyword)}`
-    });
-  }
 })

+ 522 - 509
pages/index/index.js

@@ -2,543 +2,556 @@
 const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
 const testCover = '/assets/images/bg-book.png'
 import {
-  getBannerList,
-  getCardNovels,
-  getBrowsingHistory,
-  getNovelDetail
+    getBannerList,
+    getCardNovels,
+    getBrowsingHistory,
+    getNovelDetail
 } from '../../api/api'
 import {
-  goToBookDetail
+    goToBookDetail, SendEvent
 } from '../../utils/util'
-import { apple } from '../../config/config'
+import {apple} from '../../config/config'
 
 const app = getApp()
 let interstitialAd = null
 
 Page({
-  data: {
-    isLoggedIn: false,
-    // 轮播配置
-    indicatorDots: true,
-    autoplay: true,
-    interval: 3000,
-    duration: 500,
-    cardNovels: [],
-    bannerList: [], // 添加banner列表数据
-
-    // 性别选项
-    gender: 'male', // male or female
-
-    // 主编推荐数据
-    recommendBooks: [], // 主编推荐数据
-
-    // 推荐书籍列表
-    bookList: [],
-
-    // 全网热推
-    hotBooks: [], // 全网热推数据
-
-    // 强力推荐
-    showStrongRecommend: false, // 控制强力推荐模块显示/隐藏
-    strongBooks: [],
-
-    // 最近阅读书籍
-    recentBook: null, // 最近阅读的书籍
-    showRecentBook: false, // 是否显示最近阅读
-    isRecentBookHidden: false, // 最近阅读是否隐藏
-    recentBookAnimation: {}, // 最近阅读动画数据
-
-    motto: 'Hello World',
-    userInfo: {
-      avatarUrl: defaultAvatarUrl,
-      nickName: '',
+    data: {
+        isLoggedIn: false,
+        // 轮播配置
+        indicatorDots: true,
+        autoplay: true,
+        interval: 3000,
+        duration: 500,
+        cardNovels: [],
+        bannerList: [], // 添加banner列表数据
+
+        // 性别选项
+        gender: 'male', // male or female
+
+        // 主编推荐数据
+        recommendBooks: [], // 主编推荐数据
+
+        // 推荐书籍列表
+        bookList: [],
+
+        // 全网热推
+        hotBooks: [], // 全网热推数据
+
+        // 强力推荐
+        showStrongRecommend: false, // 控制强力推荐模块显示/隐藏
+        strongBooks: [],
+
+        // 最近阅读书籍
+        recentBook: null, // 最近阅读的书籍
+        showRecentBook: false, // 是否显示最近阅读
+        isRecentBookHidden: false, // 最近阅读是否隐藏
+        recentBookAnimation: {}, // 最近阅读动画数据
+
+        motto: 'Hello World',
+        userInfo: {
+            avatarUrl: defaultAvatarUrl,
+            nickName: '',
+        },
+        hasUserInfo: false,
+        canIUseGetUserProfile: wx.canIUse('getUserProfile'),
+        canIUseNicknameComp: wx.canIUse('input.type.nickname'),
+
+        share_count: 1,
     },
-    hasUserInfo: false,
-    canIUseGetUserProfile: wx.canIUse('getUserProfile'),
-    canIUseNicknameComp: wx.canIUse('input.type.nickname'),
-
-    share_count: 1
-  },
-
-  onLoad(options) {
-    console.log('入参options:', options)
-    const promotionid = parseInt(options.promotionid);
-    this.interstitalLoad()
-    this.autoLogin(promotionid);
-    // 创建动画实例
-    this.recentBookAnimator = wx.createAnimation({
-      duration: 300,
-      timingFunction: 'ease',
-    });
-
-    const bookId = parseInt(options.bookId);
-    console.log('传入bookid:', bookId)
-    if (bookId && this.data.share_count === 1) {
-      getNovelDetail(bookId).then(res => {
-        this.setData({
-          share_count: 2
+
+    onLoad(options) {
+        console.log('入参options:', options)
+        const promotionid = options.promotionId;
+        console.log('传入promotionid:', promotionid)
+        this.interstitalLoad()
+        this.autoLogin(promotionid);
+        // 创建动画实例
+        this.recentBookAnimator = wx.createAnimation({
+            duration: 300,
+            timingFunction: 'ease',
+        });
+        const scene = wx.getStorageSync('scene');
+        const bookId = parseInt(options.novelId);
+        const jump = options.jump;// 跳转类型 1-不进阅读器
+        console.log('传入jump:', jump)
+        console.log('scene:', scene)
+        console.log('传入novelId:', bookId)
+        if (bookId && this.data.share_count === 1 && (scene === 1008 || scene === 1007) && jump !== 1) {
+            getNovelDetail(bookId).then(res => {
+                this.setData({
+                    share_count: 2
+                })
+                goToBookDetail({
+                    bookId,
+                    wxBookId: res.wxBookId
+                })
+            })
+        } else if (bookId && this.data.share_count === 2) {
+            setTimeout(() => {
+                this.interstitalPlayFn()
+            }, 1000)
+        }
+    },
+
+    onShow() {
+        // 每次页面显示时检查是否需要更新数据
+        if (this.data.isLoggedIn) {
+            this.checkAndUpdateGender();
+            // 每次页面显示时获取最近阅读
+            this.getRecentReadBook();
+        }
+    },
+
+    onTabItemTap(item) {
+        console.log(item.index)
+        setTimeout(() => {
+            this.interstitalPlayFn()
+        }, 1000)
+        // tabBar 点击时检查是否需要更新数据
+        if (this.data.isLoggedIn) {
+            this.checkAndUpdateGender();
+        }
+    },
+
+    // 插屏广告加载
+    interstitalLoad() {
+        let adId = apple.ads.insertAdId
+        interstitialAd = wx.createInterstitialAd({
+            adUnitId: adId
         })
-        goToBookDetail({
-          bookId,
-          wxBookId: res.wxBookId
+        interstitialAd.onLoad(() => {
+            console.log('视频页插屏广告onLoad')
+        })
+        interstitialAd.onError((err) => {
+            console.log('视频页插屏广告onError', err)
+        })
+        interstitialAd.onClose(() => {
+            console.log('视频页插屏广告onClose')
         })
-      })
-    } else if (bookId && this.data.share_count === 2) {
-      setTimeout(() => {
-        this.interstitalPlayFn()
-      }, 1000)
-    }
-  },
-
-  onShow() {
-    // 每次页面显示时检查是否需要更新数据
-    if (this.data.isLoggedIn) {
-      this.checkAndUpdateGender();
-      // 每次页面显示时获取最近阅读
-      this.getRecentReadBook();
-    }
-  },
-
-  onTabItemTap(item) {
-    console.log(item.index)
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
-    // tabBar 点击时检查是否需要更新数据
-    if (this.data.isLoggedIn) {
-      this.checkAndUpdateGender();
-    }
-  },
-
-  // 插屏广告加载
-  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)
-      })
-    }
-  },
-
-  // 页面滚动触发
-  onPageScroll(e) {
-    // 清除之前的定时器
-    if (this.scrollTimer) {
-      clearTimeout(this.scrollTimer);
-      this.scrollTimer = null;
-    }
-
-    // 滚动时隐藏最近阅读
-    if (e.scrollTop > 300 && !this.data.isRecentBookHidden && this.data.showRecentBook) {
-      this.hideRecentBook();
-    }
-
-    // 设置滑动停止后的定时器
-    this.lastScrollTop = e.scrollTop;
-    this.scrollTimer = setTimeout(() => {
-      // 2秒后检查是否已经停止滚动
-      if (this.lastScrollTop === e.scrollTop && this.data.isRecentBookHidden && this.data.showRecentBook) {
-        this.showRecentBook();
-      }
-    }, 1500); // 2秒后执行
-  },
-
-  // 隐藏最近阅读
-  hideRecentBook() {
-    // 计算移动距离,只漏出10px
-    const windowWidth = wx.getSystemInfoSync().windowWidth;
-    const rpxToPx = windowWidth / 750; // rpx到px的转换比例
-    const btnWidth = 90 * rpxToPx; // 悬浮按钮宽度,90rpx转换为px
-    const moveX = -(btnWidth + 35); // 只漏出10px
-
-    this.recentBookAnimator.translateX(moveX).step();
-    this.setData({
-      recentBookAnimation: this.recentBookAnimator.export(),
-      isRecentBookHidden: true
-    });
-  },
-
-  // 显示最近阅读
-  showRecentBook() {
-    this.recentBookAnimator.translateX(0).step();
-    this.setData({
-      recentBookAnimation: this.recentBookAnimator.export(),
-      isRecentBookHidden: false
-    });
-  },
-
-  // 点击隐藏的最近阅读
-  toggleRecentBook() {
-    if (this.data.isRecentBookHidden) {
-      // 隐藏状态点击展开
-      this.showRecentBook();
-    } else {
-      // 展开状态点击跳转
-      this.goToRecentBook();
-    }
-  },
-
-  // 自动登录
-  async autoLogin(promotionid) {
-    try {
-      // 检查是否已经登录
-      const token = wx.getStorageSync('accessToken');
-      if (token) {
+    },
+
+    // 插屏广告展示
+    interstitalPlayFn() {
+        if (interstitialAd) {
+            interstitialAd.show().catch((err) => {
+                console.error(err)
+            })
+        }
+    },
+
+    // 页面滚动触发
+    onPageScroll(e) {
+        // 清除之前的定时器
+        if (this.scrollTimer) {
+            clearTimeout(this.scrollTimer);
+            this.scrollTimer = null;
+        }
+
+        // 滚动时隐藏最近阅读
+        if (e.scrollTop > 300 && !this.data.isRecentBookHidden && this.data.showRecentBook) {
+            this.hideRecentBook();
+        }
+
+        // 设置滑动停止后的定时器
+        this.lastScrollTop = e.scrollTop;
+        this.scrollTimer = setTimeout(() => {
+            // 2秒后检查是否已经停止滚动
+            if (this.lastScrollTop === e.scrollTop && this.data.isRecentBookHidden && this.data.showRecentBook) {
+                this.showRecentBook();
+            }
+        }, 1500); // 2秒后执行
+    },
+
+    // 隐藏最近阅读
+    hideRecentBook() {
+        // 计算移动距离,只漏出10px
+        const windowWidth = wx.getSystemInfoSync().windowWidth;
+        const rpxToPx = windowWidth / 750; // rpx到px的转换比例
+        const btnWidth = 90 * rpxToPx; // 悬浮按钮宽度,90rpx转换为px
+        const moveX = -(btnWidth + 35); // 只漏出10px
+
+        this.recentBookAnimator.translateX(moveX).step();
         this.setData({
-          isLoggedIn: true
+            recentBookAnimation: this.recentBookAnimator.export(),
+            isRecentBookHidden: true
         });
-        // 获取性别设置并加载数据
-        this.initGenderAndLoadData();
-        // 获取最近阅读记录
-        this.getRecentReadBook();
-        return;
-      }
-
-      // 未登录,执行登录
-      const res = await getApp().login(promotionid);
-      this.setData({
-        isLoggedIn: true
-      });
-      // 登录成功后获取性别设置并加载数据
-      this.initGenderAndLoadData();
-      // 获取最近阅读记录
-      this.getRecentReadBook();
-
-    } catch (error) {
-      console.error('登录失败:', error);
-      // 登录失败也尝试加载数据,使用默认性别
-      this.initGenderAndLoadData();
-    }
-  },
-
-  // 初始化性别设置并加载数据
-  initGenderAndLoadData() {
-    // 获取保存的性别设置,如果没有则使用默认值
-    const gender = wx.getStorageSync('gender') || 'male';
-    this.setData({
-      gender
-    });
-    // 加载所有数据
-    this.loadAllData();
-  },
-
-  // 检查并更新性别,如果有变化则重新加载数据
-  checkAndUpdateGender() {
-    const savedGender = wx.getStorageSync('gender') || 'male';
-    if (savedGender !== this.data.gender) {
-      this.setData({
-        gender: savedGender
-      });
-      this.loadAllData();
-    }
-  },
-
-  // 获取最近阅读的书籍
-  async getRecentReadBook() {
-    try {
-      const historyList = await getBrowsingHistory();
-      if (Array.isArray(historyList) && historyList.length > 0) {
-        // 取第一本作为最近阅读
-        const recentBook = historyList[0];
+    },
+
+    // 显示最近阅读
+    showRecentBook() {
+        this.recentBookAnimator.translateX(0).step();
         this.setData({
-          recentBook: recentBook,
-          showRecentBook: true,
-          isRecentBookHidden: false
+            recentBookAnimation: this.recentBookAnimator.export(),
+            isRecentBookHidden: false
         });
+    },
+
+    // 点击隐藏的最近阅读
+    toggleRecentBook() {
+        if (this.data.isRecentBookHidden) {
+            // 隐藏状态点击展开
+            this.showRecentBook();
+        } else {
+            // 展开状态点击跳转
+            this.goToRecentBook();
+        }
+    },
 
-        // 重置动画
-        if (this.recentBookAnimator) {
-          this.recentBookAnimator.translateX(0).step();
-          this.setData({
-            recentBookAnimation: this.recentBookAnimator.export()
-          });
+    // 自动登录
+    async autoLogin(promotionid) {
+        try {
+            // 检查是否已经登录
+            const token = wx.getStorageSync('accessToken');
+            if (token) {
+                this.setData({
+                    isLoggedIn: true
+                });
+                // 获取性别设置并加载数据
+                this.initGenderAndLoadData();
+                // 获取最近阅读记录
+                this.getRecentReadBook();
+                return;
+            }
+
+            // 未登录,执行登录
+            const res = await getApp().login(promotionid);
+            this.setData({
+                isLoggedIn: true
+            });
+            // 登录成功后获取性别设置并加载数据
+            this.initGenderAndLoadData();
+            // 获取最近阅读记录
+            this.getRecentReadBook();
+
+        } catch (error) {
+            console.error('登录失败:', error);
+            // 登录失败也尝试加载数据,使用默认性别
+            this.initGenderAndLoadData();
         }
-      } else {
+    },
+
+    // 初始化性别设置并加载数据
+    initGenderAndLoadData() {
+        // 获取保存的性别设置,如果没有则使用默认值
+        const gender = wx.getStorageSync('gender') || 'male';
         this.setData({
-          showRecentBook: false
+            gender
         });
-      }
-    } catch (error) {
-      console.error('获取最近阅读失败:', error);
-      this.setData({
-        showRecentBook: false
-      });
-    }
-  },
-
-  // 跳转到最近阅读的书籍
-  goToRecentBook() {
-    if (this.data.recentBook) {
-      goToBookDetail({
-        bookId: this.data.recentBook.novelId,
-        wxBookId: this.data.recentBook.wxBookId,
-        chapterId: this.data.recentBook.novelChapterId
-      });
-    }
-  },
-
-  // 加载所有数据
-  loadAllData() {
-    wx.showLoading({
-      title: '加载中...'
-    });
-
-    // 并行请求数据
-    Promise.all([
-      this.getBannerList(),
-      this.getCardNovels()
-    ]).finally(() => {
-      wx.hideLoading();
-    });
-  },
-
-  // 切换性别分类
-  switchGender: function (e) {
-    const {
-      gender
-    } = e.detail;
-    // 如果性别没有改变,直接返回
-    if (this.data.gender === gender) {
-      return;
-    }
-
-    // 保存性别设置到本地存储
-    wx.setStorageSync('gender', gender);
-    this.setData({
-      gender
-    });
-
-    // 重新加载数据
-    this.loadAllData();
-  },
-
-  // 跳转到搜索页面
-  goToSearch: function () {
-    wx.navigateTo({
-      url: '/pages/search/search',
-    });
-  },
-
-  // 跳转到书籍详情页
-  goToBookDetail: function (e) {
-    const bookId = e.currentTarget.dataset.bookId;
-    const wxBookId = e.currentTarget.dataset.wxBookId;
-    const chapterId = e.currentTarget.dataset.chapterId;
-
-    console.log('bookId', bookId);
-    console.log('wxBookId', wxBookId);
-    console.log('chapterId', chapterId);
-
-    goToBookDetail({
-      bookId,
-      wxBookId,
-      chapterId
-    });
-  },
-
-  // 跳转到功能页面
-  goToFeature: function (e) {
-    const feature = e.currentTarget.dataset.feature;
-
-    switch (feature) {
-      case 'recent':
-        // 修改为跳转到书架页面的阅读历史标签
-        wx.switchTab({
-          url: '/pages/bookshelf/bookshelf'
+        // 加载所有数据
+        this.loadAllData();
+    },
+
+    // 检查并更新性别,如果有变化则重新加载数据
+    checkAndUpdateGender() {
+        const savedGender = wx.getStorageSync('gender') || 'male';
+        if (savedGender !== this.data.gender) {
+            this.setData({
+                gender: savedGender
+            });
+            this.loadAllData();
+        }
+    },
+
+    // 获取最近阅读的书籍
+    async getRecentReadBook() {
+        try {
+            const historyList = await getBrowsingHistory();
+            if (Array.isArray(historyList) && historyList.length > 0) {
+                // 取第一本作为最近阅读
+                const recentBook = historyList[0];
+                this.setData({
+                    recentBook: recentBook,
+                    showRecentBook: true,
+                    isRecentBookHidden: false
+                });
+
+                // 重置动画
+                if (this.recentBookAnimator) {
+                    this.recentBookAnimator.translateX(0).step();
+                    this.setData({
+                        recentBookAnimation: this.recentBookAnimator.export()
+                    });
+                }
+            } else {
+                this.setData({
+                    showRecentBook: false
+                });
+            }
+        } catch (error) {
+            console.error('获取最近阅读失败:', error);
+            this.setData({
+                showRecentBook: false
+            });
+        }
+    },
+
+    // 跳转到最近阅读的书籍
+    goToRecentBook() {
+        if (this.data.recentBook) {
+            goToBookDetail({
+                bookId: this.data.recentBook.novelId,
+                wxBookId: this.data.recentBook.wxBookId,
+                chapterId: this.data.recentBook.novelChapterId
+            });
+        }
+    },
+
+    // 加载所有数据
+    loadAllData() {
+        wx.showLoading({
+            title: '加载中...'
         });
-        break;
-      case 'user':
-        // 修改为跳转到我的页面
-        wx.switchTab({
-          url: '/pages/mine/mine'
+
+        // 并行请求数据
+        Promise.all([
+            this.getBannerList(),
+            this.getCardNovels()
+        ]).finally(() => {
+            wx.hideLoading();
         });
-        break;
-      case 'category':
-        // 修改为跳转到分类页面
-        wx.switchTab({
-          url: '/pages/category/category'
+    },
+
+    // 切换性别分类
+    switchGender: function (e) {
+        const {
+            gender
+        } = e.detail;
+        // 如果性别没有改变,直接返回
+        if (this.data.gender === gender) {
+            return;
+        }
+
+        // 保存性别设置到本地存储
+        wx.setStorageSync('gender', gender);
+        this.setData({
+            gender
         });
-        break;
-      case 'hot':
+
+        // 重新加载数据
+        this.loadAllData();
+    },
+
+    // 跳转到搜索页面
+    goToSearch: function () {
         wx.navigateTo({
-          url: '/pages/book/list?type=hot'
+            url: '/pages/search/search',
         });
-        break;
-      case 'recommend':
-        wx.navigateTo({
-          url: '/pages/book/list?type=recommend'
+    },
+
+    // 跳转到书籍详情页
+    goToBookDetail: function (e) {
+        const bookId = e.currentTarget.dataset.bookId;
+        const wxBookId = e.currentTarget.dataset.wxBookId;
+        const chapterId = e.currentTarget.dataset.chapterId;
+
+        console.log('bookId', bookId);
+        console.log('wxBookId', wxBookId);
+        console.log('chapterId', chapterId);
+
+        goToBookDetail({
+            bookId,
+            wxBookId,
+            chapterId
         });
-        break;
-      default:
-        break;
-    }
-  },
-
-  bindViewTap() {
-    wx.navigateTo({
-      url: '../logs/logs'
-    })
-  },
-
-  onChooseAvatar(e) {
-    const {
-      avatarUrl
-    } = e.detail
-    const {
-      nickName
-    } = this.data.userInfo
-    this.setData({
-      "userInfo.avatarUrl": avatarUrl,
-      hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
-    })
-  },
-
-  onInputChange(e) {
-    const nickName = e.detail.value
-    const {
-      avatarUrl
-    } = this.data.userInfo
-    this.setData({
-      "userInfo.nickName": nickName,
-      hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
-    })
-  },
-
-  getUserProfile(e) {
-    // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
-    wx.getUserProfile({
-      desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-      success: (res) => {
-        console.log(res)
-        this.setData({
-          userInfo: res.userInfo,
-          hasUserInfo: true
+    },
+
+    // 跳转到功能页面
+    goToFeature: function (e) {
+        const feature = e.currentTarget.dataset.feature;
+
+        switch (feature) {
+            case 'recent':
+                // 修改为跳转到书架页面的阅读历史标签
+                SendEvent('click_shelf_tab', {'uuid': app.globalData.uuid})
+                wx.switchTab({
+                    url: '/pages/bookshelf/bookshelf'
+                });
+                break;
+            case 'user':
+                // 修改为跳转到我的页面
+                SendEvent('click_mine_tab', {'uuid': app.globalData.uuid})
+                wx.switchTab({
+                    url: '/pages/mine/mine'
+                });
+                break;
+            case 'category':
+                // 修改为跳转到分类页面
+                SendEvent('click_classify_tab', {'uuid': app.globalData.uuid})
+                wx.switchTab({
+                    url: '/pages/category/category'
+                });
+                break;
+            case 'hot':
+                SendEvent('click_bookmall_classify', {'uuid': app.globalData.uuid})
+                wx.navigateTo({
+                    url: '/pages/book/list?type=hot'
+                });
+                break;
+            case 'recommend':
+                SendEvent('click_bookmall_classify', {'uuid': app.globalData.uuid})
+                wx.navigateTo({
+                    url: '/pages/book/list?type=recommend'
+                });
+                break;
+            default:
+                break;
+        }
+    },
+
+    bindViewTap() {
+        wx.navigateTo({
+            url: '../logs/logs'
         })
-      }
-    })
-  },
-
-  // 获取banner列表
-  async getBannerList() {
-    try {
-      const channel = this.data.gender === 'male' ? 1 : 2;
-      const bannerList = await getBannerList(channel);
-      this.setData({
-        bannerList
-      });
-      return bannerList;
-    } catch (error) {
-      console.error('获取banner失败:', error);
-      wx.showToast({
-        title: '获取banner失败',
-        icon: 'none'
-      });
-      return [];
-    }
-  },
-
-  async getCardNovels() {
-    try {
-      const channel = this.data.gender === 'male' ? 1 : 2;
-      const cardNovels = await getCardNovels(channel);
-      this.setData({
-        cardNovels
-      });
-
-      // 处理主编推荐数据
-      if (cardNovels[0]) {
-        const [firstBook, ...restBooks] = cardNovels[0].novelList;
-        this.setData({
-          recommendBooks: firstBook ? [{
-            id: firstBook.id,
-            title: firstBook.title,
-            desc: firstBook.brief,
-            stats: `近期收藏${firstBook.readingNumber}`,
-            cover: firstBook.cover,
-            wxBookId: firstBook.wxBookId,
-            chapterId: firstBook.chapterId
-          }] : [],
-          bookList: restBooks.slice(0, 4).map(novel => ({
-            id: novel.id,
-            title: novel.title,
-            cover: novel.cover,
-            wxBookId: novel.wxBookId,
-            chapterId: novel.chapterId
-          })),
-          editorTitle: cardNovels[0].name // 设置实际的标题
-        });
-      }
+    },
 
-      // 处理全网热推数据
-      if (cardNovels[1]) {
+    onChooseAvatar(e) {
+        const {
+            avatarUrl
+        } = e.detail
+        const {
+            nickName
+        } = this.data.userInfo
         this.setData({
-          hotBooks: cardNovels[1].novelList.map(novel => ({
-            id: novel.id,
-            title: novel.title,
-            desc: novel.brief,
-            stats: `${novel.readingNumber}人看过`,
-            cover: novel.cover,
-            wxBookId: novel.wxBookId,
-            chapterId: novel.chapterId
-          })),
-          hotTitle: cardNovels[1].name // 设置实际的标题
-        });
-      }
+            "userInfo.avatarUrl": avatarUrl,
+            hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
+        })
+    },
 
-      // 处理强力推荐数据
-      if (cardNovels[2] && cardNovels[2].novelList.length > 0) {
+    onInputChange(e) {
+        const nickName = e.detail.value
+        const {
+            avatarUrl
+        } = this.data.userInfo
         this.setData({
-          strongBooks: cardNovels[2].novelList.slice(0, 4).map(novel => ({
-            id: novel.id,
-            title: novel.title,
-            cover: novel.cover,
-            wxBookId: novel.wxBookId,
-            chapterId: novel.chapterId
-          })),
-          showStrongRecommend: true
-        });
-      } else {
-        // 如果没有第三组数据,隐藏强力推荐模块
-        this.setData({
-          strongBooks: [],
-          showStrongRecommend: false
-        });
-      }
-
-      return cardNovels;
-    } catch (error) {
-      console.error('获取卡片小说失败:', error);
-      wx.showToast({
-        title: '获取卡片小说失败',
-        icon: 'none'
-      });
-      return [];
-    }
-  },
-
-  // 处理banner点击
-  onBannerTap(e) {
-    const banner = e.currentTarget.dataset.item;
-    if (banner.linkUrl) {
-      wx.navigateTo({
-        url: banner.linkUrl
-      });
-    }
-  },
+            "userInfo.nickName": nickName,
+            hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
+        })
+    },
+
+    getUserProfile(e) {
+        // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
+        wx.getUserProfile({
+            desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+            success: (res) => {
+                console.log(res)
+                this.setData({
+                    userInfo: res.userInfo,
+                    hasUserInfo: true
+                })
+            }
+        })
+    },
+
+    // 获取banner列表
+    async getBannerList() {
+        try {
+            const channel = this.data.gender === 'male' ? 1 : 2;
+            const bannerList = await getBannerList(channel);
+            this.setData({
+                bannerList
+            });
+            return bannerList;
+        } catch (error) {
+            console.error('获取banner失败:', error);
+            wx.showToast({
+                title: '获取banner失败',
+                icon: 'none'
+            });
+            return [];
+        }
+    },
+
+    async getCardNovels() {
+        try {
+            const channel = this.data.gender === 'male' ? 1 : 2;
+            const cardNovels = await getCardNovels(channel);
+            this.setData({
+                cardNovels
+            });
+
+            // 处理主编推荐数据
+            if (cardNovels[0]) {
+                const [firstBook, ...restBooks] = cardNovels[0].novelList;
+                this.setData({
+                    recommendBooks: firstBook ? [{
+                        id: firstBook.id,
+                        title: firstBook.title,
+                        desc: firstBook.brief,
+                        stats: `近期收藏${firstBook.readingNumber}`,
+                        cover: firstBook.cover,
+                        wxBookId: firstBook.wxBookId,
+                        chapterId: firstBook.chapterId
+                    }] : [],
+                    bookList: restBooks.slice(0, 4).map(novel => ({
+                        id: novel.id,
+                        title: novel.title,
+                        cover: novel.cover,
+                        wxBookId: novel.wxBookId,
+                        chapterId: novel.chapterId
+                    })),
+                    editorTitle: cardNovels[0].name // 设置实际的标题
+                });
+            }
+
+            // 处理全网热推数据
+            if (cardNovels[1]) {
+                this.setData({
+                    hotBooks: cardNovels[1].novelList.map(novel => ({
+                        id: novel.id,
+                        title: novel.title,
+                        desc: novel.brief,
+                        stats: `${novel.readingNumber}人看过`,
+                        cover: novel.cover,
+                        wxBookId: novel.wxBookId,
+                        chapterId: novel.chapterId
+                    })),
+                    hotTitle: cardNovels[1].name // 设置实际的标题
+                });
+            }
+
+            // 处理强力推荐数据
+            if (cardNovels[2] && cardNovels[2].novelList.length > 0) {
+                this.setData({
+                    strongBooks: cardNovels[2].novelList.slice(0, 4).map(novel => ({
+                        id: novel.id,
+                        title: novel.title,
+                        cover: novel.cover,
+                        wxBookId: novel.wxBookId,
+                        chapterId: novel.chapterId
+                    })),
+                    showStrongRecommend: true
+                });
+            } else {
+                // 如果没有第三组数据,隐藏强力推荐模块
+                this.setData({
+                    strongBooks: [],
+                    showStrongRecommend: false
+                });
+            }
+
+            return cardNovels;
+        } catch (error) {
+            console.error('获取卡片小说失败:', error);
+            wx.showToast({
+                title: '获取卡片小说失败',
+                icon: 'none'
+            });
+            return [];
+        }
+    },
+
+    // 处理banner点击
+    onBannerTap(e) {
+        const banner = e.currentTarget.dataset.item;
+        if (banner.linkUrl) {
+            SendEvent('banner_click', {
+                banner_id: banner.id,
+                banner_title: banner.title,
+            });
+            wx.navigateTo({
+                url: banner.linkUrl
+            });
+        }
+    },
 })

+ 54 - 52
pages/mine/mine.js

@@ -1,6 +1,6 @@
 // pages/mine/mine.js
 import {
-  apple
+    apple
 } from '../../config/config'
 
 let interstitialAd = null
@@ -8,62 +8,64 @@ let interstitialAd = null
 const app = getApp()
 
 Page({
-  data: {
-      userInfo: {},
-      userCode: '', // 用户id
-  },
+    data: {
+        userInfo: {},
+        userCode: '', // 用户id
+    },
 
-  onLoad: function (options) {
-    this.interstitalLoad();
-    // console.log('userCode:', app.globalData)
-    this.setData({
-      userCode:app.globalData.userCode
-    })
-  },
+    onLoad: function (options) {
+        app.autoLogin();
+        this.interstitalLoad();
+        // console.log('userCode:', app.globalData)
+        this.setData({
+            userCode: app.globalData.userCode
+        })
+    },
 
-  onShow() {
-  },
+    onShow() {
+    },
 
-  onTabItemTap(item) {
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
-    console.log(item.index)
-  },
+    onTabItemTap(item) {
+        setTimeout(() => {
+            this.interstitalPlayFn()
+        }, 1000)
+        console.log(item.index)
+    },
 
-  // 插屏广告加载
-  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')
-    })
-  },
+    // 插屏广告加载
+    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)
-      })
-    }
-  },
+    // 插屏广告展示
+    interstitalPlayFn() {
+        if (interstitialAd) {
+            interstitialAd.show().catch((err) => {
+                console.error(err)
+            })
+        }
+    },
 
-  onTabItemTap(item) {
-    console.log(item.index)
-  },
+    // onTabItemTap(item) {
+    //     console.log(item.index)
+    // },
 
-  goToReadingHistory() {
-    wx.navigateTo({
-      url: '/pages/readingHistory/readingHistory'
-    })
-  }
+    goToReadingHistory() {
+        SendEvent('mine_reading_history', {});
+        wx.navigateTo({
+            url: '/pages/readingHistory/readingHistory'
+        })
+    }
 })

+ 25 - 7
pages/video/detail.js

@@ -3,6 +3,8 @@ import {getVideoDetail, getRealVideoUrl, postWithCommonParams, getRelatedVideos,
 import {rnd} from '../../utils/util'
 import {apple} from "../../config/config";
 
+const app = getApp();
+
 Page({
     data: {
         videoId: '',
@@ -56,6 +58,7 @@ Page({
         }
 
         this.loadVideoDetail(videoId);
+        app.globalData.isEnterVideoDetail = true;
     },
 
     onShow() {
@@ -67,10 +70,10 @@ Page({
             this.setData({
                 share_count: 2
             })
-            if(this.data.scene === 1007 || this.data.scene === 1008){
+            if ((this.data.scene === 1007 || this.data.scene === 1008)) {
                 console.log('准备跳转novel')
                 this.goToBookDetail()
-            }else{
+            } else {
                 console.log('没有跳转novel')
             }
         } else if (+options.share_count === 1 && this.data.share_count === 2) {
@@ -381,8 +384,8 @@ Page({
     goToBookDetail() {
         getApp().globalData.isShowDialog = true
         goToBookDetail({
-            bookId: 7266,
-            wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
+            bookId: 10745,
+            wxBookId: 'A1L2D5CPFHZW6Gzr9VdypmijDJ',
             chapterId: null
         });
     },
@@ -407,12 +410,18 @@ Page({
 
     // 分享给朋友
     onShareAppMessage(e) {
+        const jump = wx.getStorageSync('jump'); // 是否跳转阅读器
+        let url = '';
         // 如果是从推荐视频分享
         if (e.target && e.target.dataset.video) {
             const video = e.target.dataset.video;
+            url = `/pages/video/video?shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1&type=share`;
+            if (jump === 1) {
+                url += '&jump=1';
+            }
             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&type=share`,
+                path: url,
                 imageUrl: video.cover_image,
                 success: function (res) {
                     wx.showToast({
@@ -433,9 +442,13 @@ Page({
 
         // 默认分享当前视频
         const videoInfo = this.data.videoInfo;
+        url = `/pages/video/video?shared_video_id=${videoInfo.id}&title=${encodeURIComponent(videoInfo.title)}&tag_id=${videoInfo.tag_ids[0]}&share_count=1&type=share`;
+        if (jump === 1) {
+            url += '&jump=1';
+        }
         return {
             title: videoInfo.title,
-            path: `/pages/video/video?shared_video_id=${videoInfo.id}&title=${encodeURIComponent(videoInfo.title)}&tag_id=${videoInfo.tag_ids[0]}&share_count=1&type=share`,
+            path: url,
             imageUrl: videoInfo.cover,
             success: function (res) {
                 wx.showToast({
@@ -457,9 +470,14 @@ Page({
     // 分享到朋友圈
     onShareTimeline() {
         const videoInfo = this.data.videoInfo;
+        const jump = wx.getStorageSync('jump'); // 是否跳转阅读器
+        let params = `shared_video_id=${videoInfo.id}&title=${encodeURIComponent(videoInfo.title)}&tag_id=${videoInfo.tag_ids[0]}&share_count=1&type=share`;
+        if (jump === 1) {
+            params += '&jump=1';
+        }
         return {
             title: videoInfo.title,
-            query: `shared_video_id=${videoInfo.id}&title=${encodeURIComponent(videoInfo.title)}&tag_id=${videoInfo.tag_ids[0]}&share_count=1&type=share`,
+            query: params,
             imageUrl: videoInfo.cover
         };
     },

+ 710 - 567
pages/video/video.js

@@ -1,601 +1,744 @@
 // pages/video/video.js
 import {
-  getVideoList,
-  getTemplateConfig,
-  getUuid
+    getVideoList,
+    getTemplateConfig,
+    getUuid, userLogin
 } from '../../api/api'
 import {
-  rnd,
-  deepCopy,
-  goToBookDetail
+    rnd,
+    deepCopy,
+    goToBookDetail,
+    goToVideoDetail
 } from '../../utils/util'
 import {
-  apple
+    apple
 } from '../../config/config'
 
 const app = getApp()
 let interstitialAd = null
 
 Page({
-  data: {
-    videoList: [],
-    loading: false,
-    hasMore: true,
-    page: 1,
-    size: 10,
-    // 状态栏高度
-    statusBarHeight: 20,
-    navHeight: 64, // 导航栏高度 = 状态栏 + 44
-    navStyle: '',
-    listStyle: '',
-    // 添加防抖时间戳
-    lastLoadTime: 0,
-    ads: null,
-    globalConfig: null,
-    // 视频分类列表
-    categoryList: [],
-    // 当前选中的分类ID
-    currentCategoryId: null,
-
-    share_count: 1,
-    hasLoadAdConfig: false,
-    templateAdId: '',
-    adErrorField: {
-      videoError: false,
-      bannerError: false,
-      templateError: false
+    data: {
+        videoList: [],
+        loading: false,
+        hasMore: true,
+        page: 1,
+        size: 10,
+        // 状态栏高度
+        statusBarHeight: 20,
+        navHeight: 64, // 导航栏高度 = 状态栏 + 44
+        navStyle: '',
+        listStyle: '',
+        // 添加防抖时间戳
+        lastLoadTime: 0,
+        ads: null,
+        globalConfig: null,
+        // 视频分类列表
+        categoryList: [],
+        // 当前选中的分类ID
+        currentCategoryId: null,
+
+        share_count: 1,
+        hasLoadAdConfig: false,
+        templateAdId: '',
+        adErrorField: {
+            videoError: false,
+            bannerError: false,
+            templateError: false
+        },
     },
-  },
-
-  async onLoad() {
-    console.log('打开视频页面--------------------------')
-    if (!getApp().globalData.uuid) {
-      await this.getUUID().then(uuid => {
-        getApp().globalData.uuid = uuid
-      })
-    }
-
-    this.setData({
-      templateAdId: apple.ads.templateAdId,
-      hasLoadAdConfig: true
-  })
-
-    this.interstitalLoad()
-    getTemplateConfig({
-      box_type: 67,
-      uuid: getApp().globalData.uuid
-    }).then(res => {
-      this.setData({
-        globalConfig: res.globalConfig
-      })
-      // 获取视频分类
-      this.getVideoCategories()
-    })
-
-    // 获取状态栏高度
-    this.getSystemInfo()
-  },
-
-  onShow() {
-    console.log('页面显示--------------------------')
-    this.rewardVideoLoad()
-    // 每次显示页面时刷新列表
-    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) {
+
+    onLoad(options) {
+        console.log('打开视频页面--------------------------')
+        wx.setStorageSync('jump', parseInt(options.jump)) // 是否跳转阅读器
+        if (!app.globalData.uuid) {
+            this.getUUID().then(uuid => {
+                // getApp().globalData.uuid = uuid
+                console.log('登录成功')
+            })
+        }
+        this.handleEntrace(options);
         this.setData({
-          share_count: 2
+            templateAdId: apple.ads.templateAdId,
+            hasLoadAdConfig: true
         })
-        this.goToBookDetail()
-      } else if (+options.share_count === 1 && this.data.share_count === 2) {
-        this.setData({
-          share_count: 3
+
+        this.interstitalLoad()
+        getTemplateConfig({
+            box_type: 67,
+            uuid: getApp().globalData.uuid
+        }).then(res => {
+            this.setData({
+                globalConfig: res.globalConfig
+            })
+            // 获取视频分类
+            this.getVideoCategories()
         })
-        // 延迟跳转,确保列表页已经加载完成
+
+        // 获取状态栏高度
+        this.getSystemInfo()
+        // this.handleEntrace(options);
+    },
+
+    onShow() {
+        console.log('页面显示--------------------------')
+        this.rewardVideoLoad()
+        // 每次显示页面时刷新列表
+        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;
+        const jump = parseInt(options.jump); // 是否跳转阅读器 1-不跳转
+        const scene = wx.getStorageSync('scene');
+        console.log('scene场景值:', scene);
+        console.log('jump阅读器:', jump);
+        console.log('shared_video_id:', options.shared_video_id);
+        console.log('share_count:', options.share_count);
+        console.log('isEnterVideoDetail:', app.globalData.isEnterVideoDetail);
+
+        if (options.shared_video_id) {
+            // 处理分享进入的情况
+            if (!app.globalData.isEnterVideoDetail) {
+                // 延迟跳转,确保列表页已经加载完成
+                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);
+            } else {
+                // 第二次进入把isEnterVideoDetail恢复默认值
+                app.globalData.isEnterVideoDetail = false;
+            }
+        }
+
+        // if (options.shared_video_id) {
+        //     if (+options.share_count === 1 && this.data.share_count === 1) {
+        //         this.setData({
+        //             share_count: 2
+        //         });
+        //         console.log('share_count1:', this.data.share_count)
+        //         if (jump === 1) {
+        //             console.log('jump为1直接跳转到视频详情页')
+        //             // 延迟跳转
+        //             setTimeout(() => {
+        //                 this.goToVideoDetail(options.shared_video_id, options.tag_id)
+        //             }, 500);
+        //         } else {
+        //             if (scene === 1007 || scene === 1008) {
+        //                 console.log('scene为1007或1008且jump不为1,跳转到书详情页')
+        //                 this.goToBookDetail();
+        //             } else {
+        //                 console.log('scene不为1007,1008且jump不为1,跳转到视频详情页')
+        //                 // 延迟跳转
+        //                 setTimeout(() => {
+        //                     this.goToVideoDetail(options.shared_video_id, options.tag_id)
+        //                 }, 500);
+        //             }
+        //         }
+        //         // if ((scene === 1007 || scene === 1008) && jump != 1) {
+        //         //     this.goToBookDetail();
+        //         // } else {
+        //         //     this.goToVideoDetail(options.shared_video_id, options.tag_id);
+        //         // }
+        //         // this.goToBookDetail();
+        //     } else if (+options.share_count === 1 && this.data.share_count === 2) {
+        //         this.setData({
+        //             share_count: 3
+        //         });
+        //         console.log('share_count2:', this.data.share_count)
+        //         // 延迟跳转,确保列表页已经加载完成
+        //         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);
+        //     }
+        // }
+    },
+
+    handleEntrace(options) {
+        console.log('点击入口按钮')
+        if (!options || Object.keys(options).length === 0) {
+            return
+        }
+        console.log('入口:', options)
+        try {
+            let {type, jump, shared_video_id, tag_id} = options
+            const scene = wx.getStorageSync('scene');
+            console.log('入口:', type, jump, scene, shared_video_id)
+            if ((type === 'share' || type === 'tuiguang') && shared_video_id) {
+                if (jump === "1") {
+                    console.log('jump为1直接跳转到视频详情页')
+                    // 延迟跳转,确保列表页已经加载完成
+                    setTimeout(() => {
+                        this.goToVideoDetail(shared_video_id, tag_id)
+                    }, 500);
+                } else {
+                    if (scene === 1007 || scene === 1008) {
+                        console.log('scene为1007或1008且jump不为1,跳转到书详情页')
+                        // 延迟跳转,确保列表页已经加载完成
+                        setTimeout(() => {
+                            this.goToBookDetail()
+                        }, 500);
+                    } else {
+                        console.log('scene不为1007,1008且jump不为1,跳转到视频详情页')
+                        // 延迟跳转,确保列表页已经加载完成
+                        setTimeout(() => {
+                            this.goToVideoDetail(shared_video_id, tag_id)
+                        }, 500);
+                    }
+                }
+            }
+        } catch (e) {
+            console.log('处理不同场景进入小程序出错', error)
+        }
+    },
+
+    onTabItemTap(item) {
+        console.log(item.index)
         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: '打开视频失败',
+            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 => {
+                    console.log('wxlogin:', res);
+                    let body = {
+                        code: res.code,
+                        source_type: 1,
+                        source_id: ''
+                    }
+                    getUuid(body).then(async uuidres => {
+                        console.log('登录成功:', uuidres);
+                        app.globalData.uuid = uuidres.uuid;
+                        // 直接从视频链接进入,同时登录IAA小说用户
+                        // userLogin({
+                        //     "appid": apple.appid,
+                        //     "channel": 1,
+                        //     "srcType": "0",
+                        //     "srcAppId": "",
+                        //     "srcId": "",
+                        //     "cusId": "",
+                        //     "inviter": "",
+                        //     "promotionId": "",
+                        //     "inviterPromotionId": "",
+                        //     "system": "pc",
+                        //     "type": "inner",
+                        //     "inner": 1,
+                        //     code: res.code,
+                        // }).then(logres => {
+                        //     console.log('userLogin', logres);
+                        //     wx.setStorageSync('accessToken', logres.accessToken);
+                        //     app.globalData.isLogin = true;
+                        //     app.globalData.userCode = logres.userCode;
+                        //     app.globalData.openId = logres.openId;
+                        //     app.globalData.unionId = logres.unionId;
+                        //     console.log('登录成功', app.globalData)
+                        //     resolve(logres);
+                        // }).catch(err => {
+                        //     app.globalData.isLogin = false;
+                        //     reject(err);
+                        // })
+                        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('返回数据格式错误')
+                }
+
+                videoList = videoList.map(item => ({
+                    ...item,
+                    views: rnd(1, 10),
+                    favors: rnd(5000, 10000),
+                    adType: "video",
+                    lock: false
+                }))
+                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
+                })
+            }
+        } catch (error) {
+            console.error('加载视频列表失败:', error)
+        }
+    },
+    /* ------------------ 广告相关 ----------------- */
+    /**
+     * 标记广告位置
+     * @param {} arr
+     * @returns
+     */
+    formatVideoAdList(arr) {
+        // 原生广告间隔,激励广告间隔
+        let templateGap = 0,
+            rewardGap = 0
+        console.log(this.data.globalConfig)
+        if (this.data.globalConfig.isHomeTemplateAd === 1) {
+            templateGap = this.data.globalConfig.homeTemplateAdInterval
+        } else {
+            templateGap = 0
+        }
+        if (this.data.globalConfig.isHomeRewardAd) {
+            rewardGap = this.data.globalConfig.homeRewardAdInterval
+        } else {
+            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
             }
-          });
-        }, 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)
-          })
+            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
         }
-      })
-    })
-  },
-
-  // 获取系统信息
-  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('返回数据格式错误')
+
+        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: '刷新中...',
+        })
 
-        videoList = videoList.map(item => ({
-          ...item,
-          views: rnd(1, 10),
-          favors: rnd(5000, 10000),
-          adType: "video",
-          lock: false
-        }))
-        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
+            page: 1,
+            videoList: [],
+            hasMore: true
+        })
+
+        this.loadVideoList().then(() => {
+            wx.hideLoading()
+            wx.showToast({
+                title: '刷新成功',
+                icon: 'success',
+                duration: 1500
+            })
+        }).catch(() => {
+            wx.hideLoading()
         })
-      } else {
-        // 否则追加数据
+    },
+
+    // 点击视频
+    onVideoTap(e) {
+        const {id, info, index} = e.currentTarget.dataset;
+        console.log(id, info, index, '视频详情')
+        if (!info) {
+            wx.hideLoading();
+            wx.showToast({
+                title: '视频数据错误',
+                icon: 'none'
+            });
+            return;
+        }
+        const encodedTitle = encodeURIComponent(info.title || '');
+        this.unlockUrl = `/pages/video/detail?id=${id}&title=${encodedTitle}&tag_id=${info.tag_ids[0]}`
+        if (!info.lock) {
+            // 显示加载中提示
+            wx.showLoading({
+                title: '加载中...',
+                mask: true
+            });
+            // 跳转到视频详情页
+            wx.navigateTo({
+                url: this.unlockUrl,
+                success: () => {
+                    wx.hideLoading();
+                },
+                fail: (err) => {
+                    console.error('跳转失败:', err);
+                    wx.hideLoading();
+                    wx.showToast({
+                        title: '跳转失败',
+                        icon: 'none'
+                    });
+                }
+            });
+        } else {
+            this.reawrdVideoIndex = index
+            this.rewardVideo = info
+            this.rewardVideoPlayFn()
+        }
+    },
+
+    // 下拉刷新
+    onPullDownRefresh() {
         this.setData({
-          videoList: [...this.data.videoList, ...videoList],
-          loading: false,
-          hasMore: videoList.length >= this.data.size
+            page: 1,
+            videoList: []
+        })
+        this.loadVideoList().then(() => {
+            wx.stopPullDownRefresh()
         })
-      }
-    } catch (error) {
-      console.error('加载视频列表失败:', error)
-    }
-  },
-  /* ------------------ 广告相关 ----------------- */
-  /**
-   * 标记广告位置
-   * @param {} arr
-   * @returns
-   */
-  formatVideoAdList(arr) {
-    // 原生广告间隔,激励广告间隔
-    let templateGap = 0,
-    rewardGap = 0
-    console.log(this.data.globalConfig)
-    if (this.data.globalConfig.isHomeTemplateAd === 1) {
-      templateGap = this.data.globalConfig.homeTemplateAdInterval
-    } else {
-      templateGap = 0
-    }
-    if (this.data.globalConfig.isHomeRewardAd) {
-      rewardGap = this.data.globalConfig.homeRewardAdInterval
-    } else {
-      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
+    },
+
+    // 分享按钮点击事件
+    onShareTap(e) {
+        // 阻止事件冒泡
+        e.stopPropagation();
+    },
+
+    // 分享给朋友
+    onShareAppMessage(e) {
+        const video = e.target.dataset.video
+        if (!video) return {}
+        const jump = wx.getStorageSync('jump');// 是否跳转阅读器
+        url = `/pages/video/video?shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`;
+        if (jump === 1) {
+            url += '&jump=1';
         }
-      } 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
+        return {
+            title: video.title,
+            path: url,
+            imageUrl: video.cover_image,
+            success: function (res) {
+                wx.showToast({
+                    title: '分享成功',
+                    icon: 'success',
+                    duration: 1500
+                })
+            },
+            fail: function (res) {
+                wx.showToast({
+                    title: '分享失败',
+                    icon: 'none',
+                    duration: 1500
+                })
+            }
         }
-      } 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
-    }
-
-    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 { id, info, index } = e.currentTarget.dataset;
-    console.log(id, info, index, '视频详情')
-    if (!info) {
-      wx.hideLoading();
-      wx.showToast({
-        title: '视频数据错误',
-        icon: 'none'
-      });
-      return;
-    }
-    const encodedTitle = encodeURIComponent(info.title || '');
-    this.unlockUrl = `/pages/video/detail?id=${id}&title=${encodedTitle}&tag_id=${info.tag_ids[0]}`
-    if (!info.lock) {
-      // 显示加载中提示
-      wx.showLoading({
-        title: '加载中...',
-        mask: true
-      });
-      // 跳转到视频详情页
-      wx.navigateTo({
-        url: this.unlockUrl,
-        success: () => {
-          wx.hideLoading();
-        },
-        fail: (err) => {
-          console.error('跳转失败:', err);
-          wx.hideLoading();
-          wx.showToast({
-            title: '跳转失败',
-            icon: 'none'
-          });
+    },
+
+    // 分享到朋友圈
+    onShareTimeline(e) {
+        const video = e.target.dataset.video
+        if (!video) return {}
+        const jump = wx.getStorageSync('jump');// 是否跳转阅读器
+        url = `shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`;
+        if (jump === 1) {
+            url += '&jump=1';
+        }
+
+        return {
+            title: video.title,
+            query: url,
+            imageUrl: video.cover_image
         }
-      });
-    } else {
-      this.reawrdVideoIndex = index
-      this.rewardVideo = info
-      this.rewardVideoPlayFn()
-    }
-  },
-
-  // 下拉刷新
-  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
+    },
+
+    // 跳转到书籍详情
+    goToBookDetail() {
+        getApp().globalData.isShowDialog = true
+        // 使用公共的goToBookDetail函数
+        goToBookDetail({
+            bookId: 7266,
+            wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
+            chapterId: null
+        });
+    },
+    // 跳转视频详情
+    goToVideoDetail(videoId, tagId) {
+        // 使用公共的goToVideoDetail函数
+        goToVideoDetail({
+            videoId: videoId,
+            tagId: tagId
+        });
+    },
+
+    // 激励视频加载
+    rewardVideoLoad() {
+        if (wx.createRewardedVideoAd) {
+            let adId = apple.ads.rewardAdId
+            let that = this
+            this.videoAd = wx.createRewardedVideoAd({
+                adUnitId: adId
+            })
+
+            this.videoAd.onLoad(() => {
+                console.log('首页激励加载成功')
+            })
+            this.videoAd.onError((err) => {
+                console.log('首页激励失败', err)
+            })
+            this.videoAd.onClose((res) => {
+                // 用户点击了【关闭广告】按钮
+                this.setData({
+                    isLoadingVideo: false
+                })
+                if (res && res.isEnded) {
+                    // 发放奖励
+                    that.setData({
+                        [`videoList[${that.reawrdVideoIndex}].lock`]: false
+                    })
+                    console.log('发放奖励跳转')
+                    wx.navigateTo({
+                        url: `${that.unlockUrl}`
+                    })
+                }
+            })
+        }
+    },
+
+    // 激励视频展示
+    rewardVideoPlayFn() {
+        wx.showLoading({
+            title: '解锁视频中',
         })
-      },
-      fail: function (res) {
-        wx.showToast({
-          title: '分享失败',
-          icon: 'none',
-          duration: 1500
+        this.videoAd.show().then(() => {
+            console.log('激励视频播放成功')
+        }).catch((err) => {
+            console.log('激励视频播放失败', err)
+            this.setData({
+                [`videoList[${that.reawrdVideoIndex}].lock`]: false
+            })
+            wx.navigateTo({
+                url: `${this.unlockUrl}`
+            })
+        }).then(() => {
+            wx.hideLoading()
         })
-      }
-    }
-  },
-
-  // 分享到朋友圈
-  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
-    }
-  },
-
-  // 跳转到书籍详情
-  goToBookDetail() {
-    getApp().globalData.isShowDialog = true
-    // 使用公共的goToBookDetail函数
-    goToBookDetail({
-      bookId: 7266,
-      wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
-      chapterId: null
-    });
-  },
-
-  // 激励视频加载
-  rewardVideoLoad() {
-    if (wx.createRewardedVideoAd) {
-      let adId = apple.ads.rewardAdId
-      let that = this
-      this.videoAd = wx.createRewardedVideoAd({
-        adUnitId: adId
-      })
-
-      this.videoAd.onLoad(() => {
-        console.log('首页激励加载成功')
-      })
-      this.videoAd.onError((err) => {
-        console.log('首页激励失败', err)
-      })
-      this.videoAd.onClose((res) => {
-        // 用户点击了【关闭广告】按钮
+    },
+
+    // 统一小程序广告加载成功
+    appletsAdLoad(e) {
+        let _target = e.currentTarget.dataset
         this.setData({
-          isLoadingVideo: false
+            [`adErrorField.${_target.field}`]: false
         })
-        if (res && res.isEnded) {
-          // 发放奖励
-          that.setData({
-            [`videoList[${that.reawrdVideoIndex}].lock`]: false
-          })
-          console.log('发放奖励跳转')
-          wx.navigateTo({
-            url: `${that.unlockUrl}`
-          })
-        }
-      })
-    }
-  },
-
-  // 激励视频展示
-  rewardVideoPlayFn() {
-    wx.showLoading({
-      title: '解锁视频中',
-    })
-    this.videoAd.show().then(() => {
-      console.log('激励视频播放成功')
-    }).catch((err) => {
-      console.log('激励视频播放失败', err)
-      this.setData({
-        [`videoList[${that.reawrdVideoIndex}].lock`]: false
-      })
-      wx.navigateTo({
-        url: `${this.unlockUrl}`
-      })
-    }).then(() => {
-      wx.hideLoading()
-    })
-  },
-
-  // 统一小程序广告加载成功
-  appletsAdLoad(e) {
-    let _target = e.currentTarget.dataset
-    this.setData({
-      [`adErrorField.${_target.field}`]: false
-    })
-  },
-
-  // 统一小程序广告加载失败
-  appletsAdError(e) {
-    let _target = e.currentTarget.dataset
-    this.setData({
-      [`adErrorField.${_target.field}`]: true
-    })
-    console.error(_target.name, '错误', e)
-  },
-
-  // 统一小程序广告关闭
-  appletsAdClose(e) {
-    let _target = e.currentTarget.dataset
-  },
-
-  // 统一小程序广告点击
-  appletsAdClick(e) {
-    let _target = e.currentTarget.dataset
-  }
+    },
+
+    // 统一小程序广告加载失败
+    appletsAdError(e) {
+        let _target = e.currentTarget.dataset
+        this.setData({
+            [`adErrorField.${_target.field}`]: true
+        })
+        console.error(_target.name, '错误', e)
+    },
+
+    // 统一小程序广告关闭
+    appletsAdClose(e) {
+        let _target = e.currentTarget.dataset
+    },
+
+    // 统一小程序广告点击
+    appletsAdClick(e) {
+        let _target = e.currentTarget.dataset
+    },
+
 })

+ 2 - 1
project.config.json

@@ -24,5 +24,6 @@
     "tabIndent": "auto",
     "tabSize": 2
   },
-  "appid": "wxa7a33088566e1292"
+  "appid": "wxa7a33088566e1292",
+  "simulatorPluginLibVersion": {}
 }

+ 60 - 1
project.private.config.json

@@ -5,5 +5,64 @@
     "compileHotReLoad": true,
     "urlCheck": false
   },
-  "libVersion": "trial"
+  "libVersion": "trial",
+  "condition": {
+    "miniprogram": {
+      "list": [
+        {
+          "name": "视频转阅读器再转播放",
+          "pathName": "pages/video/video",
+          "query": "shared_video_id=390300&tag_id=2245&share_count=1&type=tuiguang",
+          "launchMode": "default",
+          "scene": 1007
+        },
+        {
+          "name": "非1007,1008场景进入播放",
+          "pathName": "pages/video/video",
+          "query": "shared_video_id=390300&tag_id=2245&share_count=1&type=tuiguang",
+          "launchMode": "default",
+          "scene": 1001
+        },
+        {
+          "name": "视频直跳播放",
+          "pathName": "pages/video/video",
+          "query": "shared_video_id=390300&tag_id=2245&share_count=1&type=tuiguang&jump=1",
+          "launchMode": "default",
+          "scene": 1007
+        },
+        {
+          "name": "视频强制跳播放非卡片场景1007,1008",
+          "pathName": "pages/video/video",
+          "query": "shared_video_id=390300&tag_id=2245&share_count=1&type=tuiguang&jump=1",
+          "launchMode": "default",
+          "scene": 1001
+        },
+        {
+          "name": "推广链接进入",
+          "pathName": "pages/index/index",
+          "query": "promotionId=ZJW_157&type=link&novelId=10754&chapterNo=1&channel=9&srcType=1&srcId=--OPEN_ID--",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "小说阅读器",
+          "pathName": "pages/index/index",
+          "query": "bookId=7264",
+          "launchMode": "default",
+          "scene": null
+        }
+      ]
+    },
+    "plugin": {
+      "list": [
+        {
+          "name": "阅读器",
+          "pathName": "pages/index/index",
+          "query": "bookId=A1HfxT8JKd2JZVaNWv2wdUSzzt",
+          "launchMode": "default",
+          "scene": null
+        }
+      ]
+    }
+  }
 }

+ 130 - 103
utils/util.js

@@ -1,100 +1,126 @@
 import {
-  recordLog
+    recordLog
 } from '../api/api.js'
-import { apple } from '../config/config'
+import {apple} from '../config/config'
 
 const formatTime = date => {
-  const year = date.getFullYear()
-  const month = date.getMonth() + 1
-  const day = date.getDate()
-  const hour = date.getHours()
-  const minute = date.getMinutes()
-  const second = date.getSeconds()
-
-  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
+    const year = date.getFullYear()
+    const month = date.getMonth() + 1
+    const day = date.getDate()
+    const hour = date.getHours()
+    const minute = date.getMinutes()
+    const second = date.getSeconds()
+
+    return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
 }
 
 const formatNumber = n => {
-  n = n.toString()
-  return n[1] ? n : `0${n}`
+    n = n.toString()
+    return n[1] ? n : `0${n}`
 }
 
 // 跳转到书籍详情页
 export const goToBookDetail = (options) => {
-  console.log('goToBookDetail option:',options)
-  // 检查必要参数
-  if (!options || (!options.bookId || !options.wxBookId)) {
-    console.warn('书籍ID不能为空');
-    return;
-  }
-  
-  let url = '';
-  
-  // 根据不同参数构建不同的URL
-  if (options.wxBookId) {
-    // 微信书籍ID跳转
-    url = `plugin-private://wx293c4b6097a8a4d0/pages/novel/index?share=1&bookId=${options.wxBookId}`;
-    
-    // 如果有章节ID,添加到URL
-    if (options.chapterId) {
-      url += `&chapterId=${options.chapterId}`;
+    console.log('goToBookDetail option:', options)
+    // 检查必要参数
+    if (!options || (!options.bookId || !options.wxBookId)) {
+        console.warn('书籍ID不能为空');
+        return;
     }
 
-    if (options.bookId) {
-      url += `&innerBookId=${options.bookId}`;
+    let url = '';
+
+    // 根据不同参数构建不同的URL
+    if (options.wxBookId) {
+        // 微信书籍ID跳转
+        url = `plugin-private://wx293c4b6097a8a4d0/pages/novel/index?share=1&bookId=${options.wxBookId}`;
+
+        // 如果有章节ID,添加到URL
+        if (options.chapterId) {
+            url += `&chapterId=${options.chapterId}`;
+        }
+
+        if (options.bookId) {
+            url += `&innerBookId=${options.bookId}`;
+        }
     }
-  }
-  
-  wx.navigateTo({
-    url,
-    fail: (err) => {
-      console.error('跳转书籍详情页失败:', err);
-      console.log('url',url);
-      wx.showToast({
-        title: '跳转失败,请重试',
-        icon: 'none'
-      });
+
+    wx.navigateTo({
+        url,
+        fail: (err) => {
+            console.error('跳转书籍详情页失败:', err);
+            console.log('url', url);
+            wx.showToast({
+                title: '跳转失败,请重试',
+                icon: 'none'
+            });
+        }
+    });
+};
+
+export const goToVideoDetail = (options) => {
+    console.log('goToVideoDetail option:', options);
+    if (!options || (!options.videoId) || (!options.tagId)) {
+        console.warn('视频ID或标签ID不能为空');
+        return;
     }
-  });
+    let url = '';
+    // 拼接视频详情页的URL
+    url = `/pages/video/detail?id=${options.videoId}&title=&tag_id=${options.tagId}`;
+    wx.navigateTo({
+        url,
+        success: () => {
+            wx.hideLoading();
+        },
+        fail: (err) => {
+            console.error('跳转视频详情页失败:', err);
+            console.log('url', url);
+            wx.showToast({
+                title: '跳转失败,请重试',
+                icon: 'none'
+            });
+        }
+    })
+
 };
 
 // 随机整数方法
 export const rnd = (min = 0, max = 1) => {
-  const random = Math.floor(Math.random() * (max - min + 1) + min)
-  return random
+    const random = Math.floor(Math.random() * (max - min + 1) + min)
+    return random
 };
 
 // 随机整数方法
 export const rndone = (self = []) => {
-  return self.length > 0 ? self[rnd(0, self.length - 1)] : ''
+    return self.length > 0 ? self[rnd(0, self.length - 1)] : ''
 };
 
 /**
  * 拷贝
  */
 export function deepCopy(data) {
-  let t = typeof data
-  if (data instanceof Array) {
-    t = 'array'
-  }
-
-  let o
-
-  if (t === 'array') {
-    o = []
-    for (let i = 0; i < data.length; i++) {
-      o.push(deepCopy(data[i]))
+    let t = typeof data
+    if (data instanceof Array) {
+        t = 'array'
     }
-  } else if (t === 'object') {
-    o = {}
-    for (let i in data) {
-      o[i] = deepCopy(data[i])
+
+    let o
+
+    if (t === 'array') {
+        o = []
+        for (let i = 0; i < data.length; i++) {
+            o.push(deepCopy(data[i]))
+        }
+    } else if (t === 'object') {
+        o = {}
+        for (let i in data) {
+            o[i] = deepCopy(data[i])
+        }
+    } else {
+        return data
     }
-  } else {
-    return data
-  }
 
-  return o
+    return o
 }
 
 /**
@@ -103,50 +129,51 @@ export function deepCopy(data) {
  * @param {*} eventParam 事件参数
  */
 export const SendEvent = (eventName, eventParam, self) => {
-  try {
-    const app = self || getApp()
-    let eParam = { ...eventParam }
-
-    let opt = {
-      app_id: apple.appKey,
-      app_channel: apple.ghid,
-      app_type: 3,
-      event_id: eventName,
-      os_type: 1,
-      event_value: JSON.stringify(eParam),
-      report_time: Date.now(),
-      trace_id: uuid()
+    try {
+        const app = self || getApp()
+        let eParam = {...eventParam}
+
+        let opt = {
+            app_id: apple.appKey,
+            app_channel: apple.ghid,
+            app_type: 3,
+            event_id: eventName,
+            os_type: 1,
+            event_value: JSON.stringify(eParam),
+            report_time: Date.now(),
+            trace_id: uuid()
+        }
+
+        opt.union_id = app.globalData.unionId || ''
+        opt.open_id = app.globalData.openId || ''
+        opt.user_id = app.globalData.userCode || ''
+        console.log('uploadlog', eventName, opt.event_value, opt.union_id, opt.open_id, opt.user_id)
+        recordLog(opt)
+    } catch (error) {
+        console.error('record error:', error)
     }
-
-    opt.union_id = app.globalData.unionId || ''
-    opt.open_id = app.globalData.openId || ''
-    opt.user_id = app.globalData.userCode || ''
-    // console.log('uploadlog', eventName, opt.event_value)
-    recordLog(opt)
-  } catch (error) {
-    console.error('record error:', error)
-  }
 }
 
 // 生成uuid
 export const uuid = function () {
-  var s = [];
-  var hexDigits = "0123456789abcdef";
-  for (var i = 0; i < 36; i++) {
-    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
-  }
-  s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
-  s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
-  s[8] = s[13] = s[18] = s[23] = "-";
-  var uuid = s.join("");
-  return uuid
+    var s = [];
+    var hexDigits = "0123456789abcdef";
+    for (var i = 0; i < 36; i++) {
+        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
+    }
+    s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
+    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
+    s[8] = s[13] = s[18] = s[23] = "-";
+    var uuid = s.join("");
+    return uuid
 };
 
 module.exports = {
-  formatTime,
-  goToBookDetail,
-  rnd,
-  rndone,
-  deepCopy,
-  SendEvent
+    formatTime,
+    goToBookDetail,
+    rnd,
+    rndone,
+    deepCopy,
+    SendEvent,
+    goToVideoDetail
 }