Selaa lähdekoodia

更新视频页面的文本描述为“视频”,并优化视频分享逻辑以支持通过共享视频ID跳转到视频详情页,提升用户体验。

yangwenlan 1 vuosi sitten
vanhempi
commit
654b6747e6
3 muutettua tiedostoa jossa 28 lisäystä ja 6 poistoa
  1. 1 1
      app.json
  2. 3 3
      pages/video/detail.js
  3. 24 2
      pages/video/video.js

+ 1 - 1
app.json

@@ -59,7 +59,7 @@
       },
       {
         "pagePath": "pages/video/video",
-        "text": "短剧",
+        "text": "视频",
         "iconPath": "assets/images/tabs/tab-video.png",
         "selectedIconPath": "assets/images/tabs/tab-video_active.png"
       },

+ 3 - 3
pages/video/detail.js

@@ -365,7 +365,7 @@ Page({
       const video = e.target.dataset.video;
       return {
         title: video.title,
-        path: `/pages/video/detail?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]}`,
         imageUrl: video.cover_image,
         success: function(res) {
           wx.showToast({
@@ -388,7 +388,7 @@ Page({
     const videoInfo = this.data.videoInfo;
     return {
       title: videoInfo.title,
-      path: `/pages/video/detail?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]}`,
       imageUrl: videoInfo.cover,
       success: function(res) {
         wx.showToast({
@@ -412,7 +412,7 @@ Page({
     const videoInfo = this.data.videoInfo;
     return {
       title: videoInfo.title,
-      query: `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]}`,
       imageUrl: videoInfo.cover
     };
   },

+ 24 - 2
pages/video/video.js

@@ -34,6 +34,28 @@ Page({
             })
         }
 
+        // 获取当前页面的参数
+        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
@@ -372,7 +394,7 @@ Page({
         
         return {
             title: video.title,
-            path: `/pages/video/detail?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]}`,
             imageUrl: video.cover_image,
             success: function(res) {
                 wx.showToast({
@@ -398,7 +420,7 @@ Page({
         
         return {
             title: video.title,
-            query: `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]}`,
             imageUrl: video.cover_image
         }
     }