Explorar el Código

在视频详情页中新增tagId字段,优化视频跳转逻辑以传递标签ID,提升用户体验。

yangwenlan hace 1 año
padre
commit
1f2a8d19cf
Se han modificado 3 ficheros con 11 adiciones y 6 borrados
  1. 8 4
      pages/video/detail.js
  2. 2 1
      pages/video/video.js
  3. 1 1
      pages/video/video.wxml

+ 8 - 4
pages/video/detail.js

@@ -19,12 +19,14 @@ Page({
     videoStatus: 0, // 0 未播放 1 播放中 2 暂停
     duration: 0, // 视频总时长
     currentTime: 0, // 当前播放时间
-    relatedVideos: []
+    relatedVideos: [],
+    tagId: 0
   },
   
   onLoad: function (options) {
     const videoId = parseInt(options.id);
     const videoTitle = options.title ? decodeURIComponent(options.title) : '';
+    const tagId = parseInt(options.tag_id);
     
     console.log('加载视频详情页,ID:', videoId, '标题:', videoTitle);
     
@@ -36,12 +38,14 @@ Page({
       this.setData({
         title: videoTitle,
         videoId: videoId,
-        isLoading: true
+        isLoading: true,
+        tagId: tagId
       });
     } else {
       this.setData({
         videoId: videoId,
-        isLoading: true
+        isLoading: true,
+        tagId: tagId
       });
     }
     
@@ -99,7 +103,7 @@ Page({
        // 构建请求参数
        const params = {
         id,
-        tag_id: 2072,
+        tag_id: this.data.tagId,
         uuid:getApp().globalData.uuid
       };
      

+ 2 - 1
pages/video/video.js

@@ -308,6 +308,7 @@ Page({
     // 点击视频
     onVideoTap(e) {
         const videoId = e.currentTarget.dataset.id;
+
         // 显示加载中提示
         wx.showLoading({
             title: '加载中...',
@@ -332,7 +333,7 @@ Page({
 
         // 跳转到视频详情页
         wx.navigateTo({
-            url: `/pages/video/detail?id=${videoId}&title=${encodedTitle}`,
+            url: `/pages/video/detail?id=${videoId}&title=${encodedTitle}&tag_id=${e.currentTarget.dataset.info.tag_ids[0]}`,
             success: () => {
                 wx.hideLoading();
             },

+ 1 - 1
pages/video/video.wxml

@@ -32,7 +32,7 @@
       <block wx:for="{{ videoList }}" wx:key="id">
         <view wx:if="{{ item.adType === 'video' }}">
           <!-- 视频卡片 -->
-          <view class="video-item" bindtap="onVideoTap" data-id="{{ item.id }}">
+          <view class="video-item" bindtap="onVideoTap" data-info="{{ item }}" data-id="{{ item.id }}">
             <view class="video-cover-container">
               <image
                 class="video-cover"