hank 1 yıl önce
ebeveyn
işleme
ea69e95e44

+ 156 - 151
pages/bookshelf/bookshelf.js

@@ -1,177 +1,182 @@
 import {
-  getBookshelfList,
-  getBrowsingHistory
+    getBookshelfList,
+    getBrowsingHistory
 } from '../../api/api'
 import {
-  goToBookDetail
+    goToBookDetail, SendEvent
 } from '../../utils/util'
 import {
-  apple
+    apple
 } from '../../config/config'
 
 let interstitialAd = null
 
 Page({
-  data: {
-    activeTab: 'history',
-    bookList: [],
-    loading: false,
-    hasMore: true,
-    page: 1,
-    size: 10,
-    isLoggedIn: false
-  },
-
-  onLoad() {
-    this.autoLogin()
-  },
-
-  onShow() {
-    // 每次显示页面时刷新列表
-    this.setData({
-      page: 1,
-      bookList: []
-    })
-
-    if (this.data.isLoggedIn) {
-      this.loadBookList()
-    }
-  },
+    data: {
+        activeTab: 'history',
+        bookList: [],
+        loading: false,
+        hasMore: true,
+        page: 1,
+        size: 10,
+        isLoggedIn: false
+    },
 
-  onTabItemTap(item) {
-    console.log(item.index)
-    setTimeout(() => {
-      this.interstitalPlayFn()
-    }, 1000)
-  },
+    onLoad() {
+        this.autoLogin()
+    },
 
-  // 自动登录
-  async autoLogin() {
-    try {
-      // 检查是否已经登录
-      const token = wx.getStorageSync('accessToken');
-      if (token) {
+    onShow() {
+        // 每次显示页面时刷新列表
         this.setData({
-          isLoggedIn: true
-        });
-        // 已经登录
-        console.log('已经登录')
-        // 页面首次加载时的处理
-        this.loadBookList()
-        this.interstitalLoad()
-        return;
-      }
-      // 未登录,执行登录
-      const res = await getApp().login();
-      this.setData({
-        isLoggedIn: true
-      });
-      console.log('重新登录', res)
-      // 页面首次加载时的处理
-      if (res.accessToken) {
-        this.loadBookList();
-      }
-      this.interstitalLoad();
-    } catch (error) {
-      console.error('登录失败:', error);
-    }
-  },
+            page: 1,
+            bookList: []
+        })
 
-  // 插屏广告加载
-  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')
-    })
-  },
+        if (this.data.isLoggedIn) {
+            this.loadBookList()
+        }
+    },
 
-  // 插屏广告展示
-  interstitalPlayFn() {
-    if (interstitialAd) {
-      interstitialAd.show().catch((err) => {
-        console.error(err)
-      })
-    }
-  },
+    onTabItemTap(item) {
+        console.log(item.index)
+        setTimeout(() => {
+            this.interstitalPlayFn()
+        }, 1000)
+    },
 
-  // 切换标签
-  switchTab(e) {
-    const tab = e.currentTarget.dataset.tab
-    this.setData({
-      activeTab: tab,
-      page: 1,
-      bookList: []
-    })
-    this.loadBookList()
-  },
+    // 自动登录
+    async autoLogin() {
+        try {
+            // 检查是否已经登录
+            const token = wx.getStorageSync('accessToken');
+            if (token) {
+                this.setData({
+                    isLoggedIn: true
+                });
+                // 已经登录
+                console.log('已经登录')
+                // 页面首次加载时的处理
+                this.loadBookList()
+                this.interstitalLoad()
+                return;
+            }
+            // 未登录,执行登录
+            const res = await getApp().login();
+            this.setData({
+                isLoggedIn: true
+            });
+            console.log('重新登录', res)
+            // 页面首次加载时的处理
+            if (res.accessToken) {
+                this.loadBookList();
+            }
+            this.interstitalLoad();
+        } catch (error) {
+            console.error('登录失败:', error);
+        }
+    },
 
-  // 加载书架列表
-  async loadBookList() {
-    if (this.data.loading) return
-    this.setData({
-      loading: true
-    })
-    try {
-      let result = [];
-      // 根据当前激活的标签页加载不同的数据
-      if (this.data.activeTab === 'history') {
-        // 加载阅读历史记录
-        result = await getBrowsingHistory();
-      } else {
-        // 加载书架列表
-        result = await getBookshelfList();
-      }
+    // 插屏广告加载
+    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)
+            })
+        }
+    },
 
-      if (Array.isArray(result)) {
+    // 切换标签
+    switchTab(e) {
+        const tab = e.currentTarget.dataset.tab
         this.setData({
-          bookList: result,
-          loading: false,
-          hasMore: false // 目前接口不支持分页,所以直接设置为false
+            activeTab: tab,
+            page: 1,
+            bookList: []
         })
-      } else {
+        this.loadBookList()
+    },
+
+    // 加载书架列表
+    async loadBookList() {
+        if (this.data.loading) return
         this.setData({
-          loading: false,
-          hasMore: false
+            loading: true
         })
-      }
-    } catch (error) {
-      console.error('加载数据失败:', error)
-      this.setData({
-        loading: false,
-        hasMore: false
-      })
-      wx.showToast({
-        title: '加载失败,请重试',
-        icon: 'none'
-      })
-    }
-  },
+        try {
+            let result = [];
+            // 根据当前激活的标签页加载不同的数据
+            if (this.data.activeTab === 'history') {
+                // 加载阅读历史记录
+                result = await getBrowsingHistory();
+            } else {
+                // 加载书架列表
+                result = await getBookshelfList();
+            }
 
-  // 加载更多
-  loadMore() {
-    if (this.data.hasMore) {
-      this.loadBookList()
-    }
-  },
+            if (Array.isArray(result)) {
+                this.setData({
+                    bookList: result,
+                    loading: false,
+                    hasMore: false // 目前接口不支持分页,所以直接设置为false
+                })
+            } else {
+                this.setData({
+                    loading: false,
+                    hasMore: false
+                })
+            }
+        } catch (error) {
+            console.error('加载数据失败:', error)
+            this.setData({
+                loading: false,
+                hasMore: false
+            })
+            wx.showToast({
+                title: '加载失败,请重试',
+                icon: 'none'
+            })
+        }
+    },
 
-  // 跳转到书籍详情
-  goToBookDetail(e) {
-    const book = e.currentTarget.dataset.book;
+    // 加载更多
+    loadMore() {
+        if (this.data.hasMore) {
+            this.loadBookList()
+        }
+    },
 
-    // 使用公共的goToBookDetail函数
-    goToBookDetail({
-      bookId: book.novelId,
-      wxBookId: book.wxBookId,
-      chapterId: book.novelChapterId
-    });
-  }
+    // 跳转到书籍详情
+    goToBookDetail(e) {
+        const book = e.currentTarget.dataset.book;
+        console.log(book)
+        SendEvent('click_shelf_novel', {
+            "video_id": book.novelId,
+            "wx_book_id": book.wxBookId,
+            "chapter_no": book.novelChapterId
+        });
+        // 使用公共的goToBookDetail函数
+        goToBookDetail({
+            bookId: book.novelId,
+            wxBookId: book.wxBookId,
+            chapterId: book.novelChapterId
+        });
+    }
 })

+ 45 - 42
pages/category/category.js

@@ -3,7 +3,7 @@ import {
     getNovelSearch
 } from '../../api/api'
 import {
-    goToBookDetail
+    goToBookDetail, SendEvent
 } from '../../utils/util'
 import {
     apple
@@ -13,16 +13,16 @@ let interstitialAd = null
 
 Page({
     data: {
-      gender: 'male', // 当前性别选择
-      currentCategory: '', // 当前选中的分类
-      categories: [],
-      bookList: [],
-      loading: false,
-      keyword: '',
-      page: 1,
-      size: 10,
-      hasMore: true, // 是否还有更多数据,
-      isLoggedIn: false, //是否登录
+        gender: 'male', // 当前性别选择
+        currentCategory: '', // 当前选中的分类
+        categories: [],
+        bookList: [],
+        loading: false,
+        keyword: '',
+        page: 1,
+        size: 10,
+        hasMore: true, // 是否还有更多数据,
+        isLoggedIn: false, //是否登录
     },
 
     onLoad: function (options) {
@@ -30,9 +30,9 @@ Page({
     },
 
     onShow: function () {
-      if (this.data.isLoggedIn) {
-        this.syncGenderState();
-      }
+        if (this.data.isLoggedIn) {
+            this.syncGenderState();
+        }
     },
 
     onTabItemTap: function (item) {
@@ -41,38 +41,38 @@ Page({
             this.interstitalPlayFn()
         }, 1000)
         if (this.data.isLoggedIn) {
-          this.syncGenderState();
+            this.syncGenderState();
         }
     },
 
     // 自动登录
     async autoLogin() {
-      try {
-        // 检查是否已经登录
-        const token = wx.getStorageSync('accessToken');
-        if (token) {
-          this.setData({
-              isLoggedIn: true
-          });
-          // 已经登录
-          console.log('已经登录')
-          // 页面首次加载时的处理
-          this.syncGenderState();
-          this.interstitalLoad();
-          return;
+        try {
+            // 检查是否已经登录
+            const token = wx.getStorageSync('accessToken');
+            if (token) {
+                this.setData({
+                    isLoggedIn: true
+                });
+                // 已经登录
+                console.log('已经登录')
+                // 页面首次加载时的处理
+                this.syncGenderState();
+                this.interstitalLoad();
+                return;
+            }
+            // 未登录,执行登录
+            getApp().login().then(res => {
+                this.setData({
+                    isLoggedIn: true
+                });
+                this.syncGenderState();
+                this.interstitalLoad();
+                console.log('重新登录', res)
+            })
+        } catch (error) {
+            console.error('登录失败:', error);
         }
-        // 未登录,执行登录
-        getApp().login().then(res => {
-          this.setData({
-            isLoggedIn: true
-          });
-          this.syncGenderState();
-          this.interstitalLoad();
-          console.log('重新登录', res)
-        })
-      } catch (error) {
-        console.error('登录失败:', error);
-      }
     },
 
     // 插屏广告加载
@@ -110,7 +110,7 @@ Page({
             });
             await this.loadCategories();
         } else {
-          await this.loadCategories();
+            await this.loadCategories();
         }
     },
 
@@ -126,8 +126,9 @@ Page({
             page: 1,
             hasMore: true
         });
+        SendEvent('click_classify_type', {"gender": gender});
         if (this.data.isLoggedIn) {
-          await this.loadCategories();
+            await this.loadCategories();
         }
     },
 
@@ -167,6 +168,7 @@ Page({
             page: 1,
             hasMore: true
         });
+        SendEvent('click_classify_name', {"category": category});
         this.loadBookList(category);
     },
 
@@ -230,6 +232,7 @@ Page({
             id,
             wxbookid
         } = e.currentTarget.dataset;
+        SendEvent('click_classfy_novel', {"novel_id": id, "wx_book_id": wxbookid})
         goToBookDetail({
             bookId: id,
             wxBookId: wxbookid

+ 9 - 1
pages/index/index.js

@@ -289,6 +289,11 @@ Page({
     // 跳转到最近阅读的书籍
     goToRecentBook() {
         if (this.data.recentBook) {
+            SendEvent('click_bookmall_recently_read', {
+                "video_id": this.data.recentBook.novelId,
+                "wx_book_id": this.data.recentBook.wxBookId,
+                "chapter_no": this.data.recentBook.novelChapterId
+            });
             goToBookDetail({
                 bookId: this.data.recentBook.novelId,
                 wxBookId: this.data.recentBook.wxBookId,
@@ -327,13 +332,16 @@ Page({
         this.setData({
             gender
         });
-
+        SendEvent('click_bookmall_classify', {
+            "gender": gender
+        });
         // 重新加载数据
         this.loadAllData();
     },
 
     // 跳转到搜索页面
     goToSearch: function () {
+        // SendEvent('click_bookmall_classify', {});
         wx.navigateTo({
             url: '/pages/search/search',
         });

+ 3 - 2
pages/mine/mine.js

@@ -17,7 +17,8 @@ Page({
         this.autoLogin();
         this.setData({
             userCode: app.globalData.userCode
-        })
+        });
+        console.log('userCode', app.globalData.userCode);
     },
 
     onShow() {
@@ -46,7 +47,7 @@ Page({
           return;
         }
         // 未登录,执行登录
-        const res = await getApp().login();
+        const res = await app.login();
         this.setData({
           isLoggedIn: true
         });

+ 7 - 3
pages/video/detail.js

@@ -1,6 +1,6 @@
 // pages/video/detail.js
 import {getVideoDetail, getRealVideoUrl, postWithCommonParams, getRelatedVideos, getUuid} from '../../api/api'
-import {rnd} from '../../utils/util'
+import {rnd, SendEvent} from '../../utils/util'
 import {apple} from "../../config/config";
 
 const app = getApp();
@@ -35,7 +35,7 @@ Page({
         this.setData({
             scene: wx.getStorageSync('scene') || 1001
         })
-
+        SendEvent('show_video', {"video_id": videoId, "tag_id": tagId, "scene": this.data.scene});
         console.log('加载视频详情页,ID:', videoId, '标题:', videoTitle);
 
         // 获取系统信息
@@ -362,7 +362,7 @@ Page({
 
         // 将标题进行URI编码处理
         const encodedTitle = encodeURIComponent(video.title || '');
-
+        SendEvent('click_recommend_video', {"video_id": videoId, "tag_id": tag_id});
         // 跳转到视频详情页
         wx.navigateTo({
             url: `/pages/video/detail?id=${videoId}&title=${encodedTitle}&tag_id=${tag_id}`,
@@ -400,6 +400,7 @@ Page({
         //     url: '/pages/video/video',
         // });
         console.log('返回上一页')
+        SendEvent('click_return_list', {"video_id": this.data.videoId, "tag_id": this.data.tagId});
     },
 
     // 分享按钮点击事件
@@ -419,6 +420,7 @@ Page({
             if (jump === 1) {
                 url += '&jump=1';
             }
+            SendEvent('click_share', {"video_id": video.id, "tag_id": video.tag_ids[0]});
             return {
                 title: video.title,
                 path: url,
@@ -446,6 +448,7 @@ Page({
         if (jump === 1) {
             url += '&jump=1';
         }
+        SendEvent('click_share', {"video_id": videoInfo.id, "tag_id": videoInfo.tag_ids[0]});
         return {
             title: videoInfo.title,
             path: url,
@@ -475,6 +478,7 @@ Page({
         if (jump === 1) {
             params += '&jump=1';
         }
+        SendEvent('click_share_moment', {"video_id": videoInfo.id, "tag_id": videoInfo.tag_ids[0]});
         return {
             title: videoInfo.title,
             query: params,

+ 7 - 1
pages/video/video.js

@@ -8,7 +8,7 @@ import {
     rnd,
     deepCopy,
     goToBookDetail,
-    goToVideoDetail
+    goToVideoDetail, SendEvent
 } from '../../utils/util'
 import {
     apple
@@ -547,6 +547,7 @@ Page({
             });
             return;
         }
+        SendEvent('click_video_tab_video', {"video_id": id, "tag_id": info.tag_ids[0]})
         const encodedTitle = encodeURIComponent(info.title || '');
         this.unlockUrl = `/pages/video/detail?id=${id}&title=${encodedTitle}&tag_id=${info.tag_ids[0]}`
         if (!info.lock) {
@@ -592,6 +593,7 @@ Page({
     onShareTap(e) {
         // 阻止事件冒泡
         e.stopPropagation();
+        // SendEvent('click_list_share', {"video_id": video.id, "tag_id": video.tag_ids[0]});
     },
 
     // 分享给朋友
@@ -599,10 +601,12 @@ Page({
         const video = e.target.dataset.video
         if (!video) return {}
         const jump = wx.getStorageSync('jump');// 是否跳转阅读器
+        let url = '';
         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';
         }
+        SendEvent('click_list_share', {"video_id": video.id, "tag_id": video.tag_ids[0]});
         return {
             title: video.title,
             path: url,
@@ -629,7 +633,9 @@ Page({
         const video = e.target.dataset.video
         if (!video) return {}
         const jump = wx.getStorageSync('jump');// 是否跳转阅读器
+        let url = '';
         url = `shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`;
+        SendEvent('click_list_share', {"video_id": video.id, "tag_id": video.tag_ids[0]});
         if (jump === 1) {
             url += '&jump=1';
         }