Browse Source

feat: 视频分享跳转地址交互修改;

qiansailong 1 year ago
parent
commit
aa8209cbea
4 changed files with 87 additions and 35 deletions
  1. 1 1
      pages/bookshelf/bookshelf.js
  2. 32 5
      pages/video/detail.js
  3. 50 26
      pages/video/video.js
  4. 4 3
      project.private.config.json

+ 1 - 1
pages/bookshelf/bookshelf.js

@@ -88,7 +88,7 @@ Page({
   // 跳转到书籍详情
   goToBookDetail(e) {
     const book = e.currentTarget.dataset.book;
-    
+        
     // 使用公共的goToBookDetail函数
     goToBookDetail({
       bookId: book.novelId,

+ 32 - 5
pages/video/detail.js

@@ -20,7 +20,8 @@ Page({
     duration: 0, // 视频总时长
     currentTime: 0, // 当前播放时间
     relatedVideos: [],
-    tagId: 0
+    tagId: 0,
+    share_count: 1
   },
   
   onLoad: function (options) {
@@ -52,6 +53,22 @@ Page({
     this.loadVideoDetail(videoId);
   },
 
+  onShow () {
+    const pages = getCurrentPages();
+    const currentPage = pages[pages.length - 1];
+    const options = currentPage.options;
+     if (+options.share_count === 1 && this.data.share_count === 1) {
+      this.setData({
+        share_count: 2
+      })
+       this.goToBookDetail()
+     } else if (+options.share_count === 1 && this.data.share_count === 2) { 
+      this.setData({
+        share_count: 3
+      })
+     }
+  },
+
 
   /**
    * 获取uuid
@@ -348,7 +365,17 @@ Page({
       }
     });
   },
-  
+
+  // 跳转到书籍详情
+  goToBookDetail() {      
+    // 使用公共的goToBookDetail函数
+    goToBookDetail({
+      bookId: 7266,
+      wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
+      chapterId: null
+    });
+  },
+
   // 返回上一页
   goBack() {
     wx.navigateBack();
@@ -367,7 +394,7 @@ Page({
       const video = e.target.dataset.video;
       return {
         title: video.title,
-        path: `/pages/video/video?shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}`,
+        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({
@@ -390,7 +417,7 @@ Page({
     const videoInfo = this.data.videoInfo;
     return {
       title: videoInfo.title,
-      path: `/pages/video/video?shared_video_id=${videoInfo.id}&title=${encodeURIComponent(videoInfo.title)}&tag_id=${videoInfo.tag_ids[0]}`,
+      path: `/pages/video/video?shared_video_id=${videoInfo.id}&title=${encodeURIComponent(videoInfo.title)}&tag_id=${videoInfo.tag_ids[0]}&share_count=1`,
       imageUrl: videoInfo.cover,
       success: function(res) {
         wx.showToast({
@@ -414,7 +441,7 @@ Page({
     const videoInfo = this.data.videoInfo;
     return {
       title: videoInfo.title,
-      query: `shared_video_id=${videoInfo.id}&title=${encodeURIComponent(videoInfo.title)}&tag_id=${videoInfo.tag_ids[0]}`,
+      query: `shared_video_id=${videoInfo.id}&title=${encodeURIComponent(videoInfo.title)}&tag_id=${videoInfo.tag_ids[0]}&share_count=1`,
       imageUrl: videoInfo.cover
     };
   },

+ 50 - 26
pages/video/video.js

@@ -1,6 +1,6 @@
 // pages/video/video.js
 import { getVideoList, getTemplateConfig, getUuid } from '../../api/api'
-import { rnd, deepCopy } from '../../utils/util'
+import { rnd, deepCopy, goToBookDetail } from '../../utils/util'
 
 const app = getApp()
 
@@ -24,38 +24,19 @@ Page({
         // 视频分类列表
         categoryList: [],
         // 当前选中的分类ID
-        currentCategoryId: null
+        currentCategoryId: null,
+
+        share_count: 1
     },
 
     async onLoad() {
+      console.log('打开视频页面--------------------------')
         if (!getApp().globalData.uuid) {
             await this.getUUID().then(uuid => {
                 getApp().globalData.uuid = uuid
             })
         }
 
-        // 获取当前页面的参数
-        const pages = getCurrentPages();
-        const currentPage = pages[pages.length - 1];
-        const options = currentPage.options;
-
-        // 处理分享进入的情况
-        if (options.shared_video_id) {
-            // 延迟跳转,确保列表页已经加载完成
-            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);
-        }
-
         getTemplateConfig({
             box_type: 67,
             uuid: getApp().globalData.uuid
@@ -73,6 +54,7 @@ Page({
     },
 
     onShow() {
+      console.log('页面显示--------------------------')
         // 每次显示页面时刷新列表
         if (this.data.videoList.length === 0) {
             this.setData({
@@ -80,6 +62,38 @@ Page({
             })
             // this.loadVideoList()
         }
+
+        // 获取当前页面的参数
+        const pages = getCurrentPages();
+        const currentPage = pages[pages.length - 1];
+        const options = currentPage.options;
+
+        // 处理分享进入的情况
+        if (options.shared_video_id) {
+          if (+options.share_count === 1 && this.data.share_count === 1) {
+            this.setData({
+              share_count: 2
+            })
+              this.goToBookDetail()
+          } else if (+options.share_count === 1 && this.data.share_count === 2) {
+            this.setData({
+              share_count: 3
+            })
+              // 延迟跳转,确保列表页已经加载完成
+              setTimeout(() => {
+                wx.navigateTo({
+                    url: `/pages/video/detail?id=${options.shared_video_id}&title=${options.title || ''}&tag_id=${options.tag_id || ''}`,
+                    fail: (err) => {
+                        console.error('跳转到视频详情页失败:', err);
+                        wx.showToast({
+                            title: '打开视频失败',
+                            icon: 'none'
+                        });
+                    }
+                });
+            }, 500);
+          }
+        }
     },
 
     /**
@@ -394,7 +408,7 @@ Page({
         
         return {
             title: video.title,
-            path: `/pages/video/video?shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}`,
+            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({
@@ -420,8 +434,18 @@ Page({
         
         return {
             title: video.title,
-            query: `shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}`,
+            query: `shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`,
             imageUrl: video.cover_image
         }
+    },
+
+    // 跳转到书籍详情
+    goToBookDetail() {      
+      // 使用公共的goToBookDetail函数
+      goToBookDetail({
+        bookId: 7266,
+        wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
+        chapterId: null
+      });
     }
 }) 

+ 4 - 3
project.private.config.json

@@ -1,8 +1,9 @@
 {
   "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-  "projectname": "readSpace",
+  "projectname": "mini_read_space_front",
   "setting": {
-    "compileHotReLoad": true
+    "compileHotReLoad": true,
+    "urlCheck": false
   },
-  "libVersion": "3.7.11"
+  "libVersion": "trial"
 }