فهرست منبع

Merge branch 'main' of http://git.mokasz.com/maomao/mini_read_space_front

# Conflicts:
#	pages/video/video.js
qiansailong 1 سال پیش
والد
کامیت
c1afe3adf7
2فایلهای تغییر یافته به همراه555 افزوده شده و 546 حذف شده
  1. 58 58
      api/api.js
  2. 497 488
      pages/video/detail.js

+ 58 - 58
api/api.js

@@ -53,19 +53,19 @@ export const getNovelDetail = (id) => {
 
 // /novel/search
 export const getNovelSearch = ({
-    keyword,
-    page=1,
-    size=10,
-    category
-}) => {
+                                   keyword,
+                                   page = 1,
+                                   size = 10,
+                                   category
+                               }) => {
     // 创建基本参数对象
-    const params = { keyword, page, size };
-    
+    const params = {keyword, page, size};
+
     // 如果category有值,才添加到参数中
     if (category) {
         params.category = category;
     }
-    
+
     return requestAll('/novel/search', params, 'GET', addTokenToHeader());
 }
 
@@ -106,77 +106,77 @@ export const getBrowsingHistory = () => {
 
 // 获取短剧列表
 export function getVideoList(params = {}) {
-  const { page = 1, size = 10, tag_id = 2245, filter_id = "", next_id = "" } = params;
-  
-  const requestData = {
-    tag_id: tag_id,
-    filter_id: filter_id,
-    next_id: next_id,
-    count: size,
-    uuid: getApp().globalData.uuid, // 固定值,实际应用中可能需要动态生成
-    gh_id: "gh_4e55f615d5dc" // 固定值
-  };
-  
-  return postWithCommonParams("https://applet.xiaoduer.cn/cashvideoapi/cashvideo/getvideolist", requestData)
-    .then(data => {
-
-     return data;
-      // 处理返回数据的格式转换,确保与页面期望的数据结构一致
-      if (data) {
-        return data.map(video => ({
-          id: video.id,
-          title: video.title,
-          cover: video.cover_image,
-          playCount: video.views || '0'
-        }));
-      }
-      return [];
-    });
+    const {page = 1, size = 10, tag_id = 2245, filter_id = "", next_id = ""} = params;
+
+    const requestData = {
+        tag_id: tag_id,
+        filter_id: filter_id,
+        next_id: next_id,
+        count: size,
+        uuid: getApp().globalData.uuid, // 固定值,实际应用中可能需要动态生成
+        gh_id: "gh_4e55f615d5dc" // 固定值
+    };
+
+    return postWithCommonParams("https://applet.xiaoduer.cn/cashvideoapi/cashvideo/getvideolist", requestData)
+        .then(data => {
+
+            return data;
+            // 处理返回数据的格式转换,确保与页面期望的数据结构一致
+            if (data) {
+                return data.map(video => ({
+                    id: video.id,
+                    title: video.title,
+                    cover: video.cover_image,
+                    playCount: video.views || '0'
+                }));
+            }
+            return [];
+        });
 }
 
 // 获取视频详情
 export function getVideoDetail(params = {}) {
-  if (!params.id) {
-    return Promise.reject(new Error('缺少必要参数: id'));
-  }
+    if (!params.id) {
+        return Promise.reject(new Error('缺少必要参数: id'));
+    }
 
-  return postWithCommonParams('https://applet.xiaoduer.cn/cashvideoapi/cashvideo/getvideoinfo', params);
+    return postWithCommonParams('https://applet.xiaoduer.cn/cashvideoapi/cashvideo/getvideoinfo', params);
 }
 
 // 获取真实视频播放地址
 export function getRealVideoUrl(id, tagId) {
-  if (!id || !tagId) {
-    return Promise.reject(new Error('缺少必要参数: id 或 tagId'));
-  }
+    if (!id || !tagId) {
+        return Promise.reject(new Error('缺少必要参数: id 或 tagId'));
+    }
 
-  const url = `https://applet.xiaoduer.cn/coral/cashvideo/getOasVideoUrl?id=${id}&tagId=${tagId}`;
-  return postWithCommonParams(url, {}, 'GET');
+    const url = `https://applet.xiaoduer.cn/coral/cashvideo/getOasVideoUrl?id=${id}&tagId=${tagId}`;
+    return postWithCommonParams(url, {}, 'GET');
 }
 
 // 获取相关视频列表
 export function getRelatedVideos(params = {}) {
-  const { tag_id = 2250, count = 10, filter_id = "" } = params;
-  
-  const requestData = {
-    tag_id,
-    count,
-    filter_id,
-    uuid: getApp().globalData.uuid,
-    gh_id: "gh_acc9a32b2122"
-  };
-  
-  return post("https://applet.xiaoduer.cn/cashvideoapi/cashvideo/getrandvideolistpro", requestData);
+    const {tag_id = 2250, count = 10, filter_id = "", gh_id = ""} = params;
+
+    const requestData = {
+        tag_id,
+        count,
+        filter_id,
+        uuid: getApp().globalData.uuid,
+        gh_id: gh_id
+    };
+
+    return post("https://applet.xiaoduer.cn/cashvideoapi/cashvideo/getrandvideolistpro", requestData);
 }
 
 /**
  * 获取 uuid
  */
-export function getUuid (body){
+export function getUuid(body) {
     return postWithCommonParams('https://applet.xiaoduer.cn/api/user/getuuid', body)
-} 
+}
 
 // https://applet.xiaoduer.cn/coral/template/config
-export function getTemplateConfig (body){
+export function getTemplateConfig(body) {
     return postWithCommonParams('https://applet.xiaoduer.cn/coral/template/config', body)
 }
 
@@ -186,4 +186,4 @@ export { postWithCommonParams };
 /**
  * 打点
  */
-export const recordLog = (body) => uploadTrackLog('/track', body)
+export const recordLog = (body) => uploadTrackLog('/track', body)

+ 497 - 488
pages/video/detail.js

@@ -1,509 +1,518 @@
 // pages/video/detail.js
-import { getVideoDetail, getRealVideoUrl, postWithCommonParams, getRelatedVideos,getUuid } from '../../api/api'
-import { rnd } from '../../utils/util'
+import {getVideoDetail, getRealVideoUrl, postWithCommonParams, getRelatedVideos, getUuid} from '../../api/api'
+import {rnd} from '../../utils/util'
+import {apple} from "../../config/config";
 
 Page({
-  data: {
-    videoId: '',
-    videoInfo: null,
-    videoDetail:null,
-    episodeList: [],
-    currentEpisodeIndex: 0,
-    currentEpisode: null, // 当前播放的剧集
-    isPlaying: false,
-    isLoading: true,
-    title: '',
-    scrollHeight: 0,
-    windowHeight: 0,
-    realVideoUrl: '', // 存储真实的视频播放地址
-    videoStatus: 0, // 0 未播放 1 播放中 2 暂停
-    duration: 0, // 视频总时长
-    currentTime: 0, // 当前播放时间
-    relatedVideos: [],
-    tagId: 0,
-    share_count: 1
-  },
-  
-  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);
-    
-    // 获取系统信息
-    this.getSystemInfo();
-    
-    // 如果有传递标题,则直接使用
-    if (videoTitle) {
-      this.setData({
-        title: videoTitle,
-        videoId: videoId,
-        isLoading: true,
-        tagId: tagId
-      });
-    } else {
-      this.setData({
-        videoId: videoId,
+    data: {
+        videoId: '',
+        videoInfo: null,
+        videoDetail: null,
+        episodeList: [],
+        currentEpisodeIndex: 0,
+        currentEpisode: null, // 当前播放的剧集
+        isPlaying: false,
         isLoading: true,
-        tagId: tagId
-      });
-    }
-    
-    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
-   */
-  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)
-          })
+        title: '',
+        scrollHeight: 0,
+        windowHeight: 0,
+        realVideoUrl: '', // 存储真实的视频播放地址
+        videoStatus: 0, // 0 未播放 1 播放中 2 暂停
+        duration: 0, // 视频总时长
+        currentTime: 0, // 当前播放时间
+        relatedVideos: [],
+        tagId: 0,
+        share_count: 1
+    },
+
+    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);
+
+        // 获取系统信息
+        this.getSystemInfo();
+
+        // 如果有传递标题,则直接使用
+        if (videoTitle) {
+            this.setData({
+                title: videoTitle,
+                videoId: videoId,
+                isLoading: true,
+                tagId: tagId
+            });
+        } else {
+            this.setData({
+                videoId: videoId,
+                isLoading: true,
+                tagId: tagId
+            });
+        }
+
+        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
+            })
         }
-      })
-    })
-  },
-  
-  // 获取系统信息
-  getSystemInfo() {
-    const systemInfo = wx.getSystemInfoSync();
-    this.setData({
-      windowHeight: systemInfo.windowHeight
-    });
-  },
-  
-  // 加载视频详情
-  async loadVideoDetail(id) {
-    try {
-      wx.showLoading({
-        title: '加载中...',
-        mask: true
-      });
-      
-      //getUuid
-      if(!getApp().globalData.uuid){
-
-        await this.getUUID().then(uuid => {
-          getApp().globalData.uuid = uuid
+    },
+
+
+    /**
+     * 获取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)
+                    })
+                }
+            })
         })
-      }
-
-       // 构建请求参数
-       const params = {
-        id,
-        tag_id: this.data.tagId,
-        uuid:getApp().globalData.uuid
-      };
-     
-      const videoDetail = await getVideoDetail(params);
-      console.log('视频详情数据:', videoDetail);
-      
-      if (videoDetail) {
-        // 处理视频信息
-        const formattedVideoInfo = {
-          id: videoDetail.id,
-          title: videoDetail.title || this.data.title,
-          cover: videoDetail.cover_image,
-          playCount: videoDetail.views || '0',
-          playUV: videoDetail.play_uv || '0',
-          videoUrl: '', // 暂时为空,等待获取真实播放地址
-          description: videoDetail.description || '暂无简介',
-          tags: videoDetail.tag_ids || [],
-          likeCount: videoDetail.like || '0',
-          shareCount: videoDetail.share || '0',
-          isCollect: videoDetail.is_collect === 1,
-          video_type: videoDetail.video_type, // 保存原始视频类型
-          tag_ids: videoDetail.tag_ids // 保存标签ID列表
-        };
-        
+    },
+
+    // 获取系统信息
+    getSystemInfo() {
+        const systemInfo = wx.getSystemInfoSync();
         this.setData({
-          videoInfo: formattedVideoInfo,
-          title: formattedVideoInfo.title,
-          isLoading: false
+            windowHeight: systemInfo.windowHeight
         });
+    },
+
+    // 加载视频详情
+    async loadVideoDetail(id) {
+        try {
+            wx.showLoading({
+                title: '加载中...',
+                mask: true
+            });
+
+            //getUuid
+            if (!getApp().globalData.uuid) {
+
+                await this.getUUID().then(uuid => {
+                    getApp().globalData.uuid = uuid
+                })
+            }
+
+            // 构建请求参数
+            const params = {
+                id,
+                tag_id: this.data.tagId,
+                uuid: getApp().globalData.uuid
+            };
+
+            const videoDetail = await getVideoDetail(params);
+            console.log('视频详情数据:', videoDetail);
+
+            if (videoDetail) {
+                // 处理视频信息
+                const formattedVideoInfo = {
+                    id: videoDetail.id,
+                    title: videoDetail.title || this.data.title,
+                    cover: videoDetail.cover_image,
+                    playCount: videoDetail.views || '0',
+                    playUV: videoDetail.play_uv || '0',
+                    videoUrl: '', // 暂时为空,等待获取真实播放地址
+                    description: videoDetail.description || '暂无简介',
+                    tags: videoDetail.tag_ids || [],
+                    likeCount: videoDetail.like || '0',
+                    shareCount: videoDetail.share || '0',
+                    isCollect: videoDetail.is_collect === 1,
+                    video_type: videoDetail.video_type, // 保存原始视频类型
+                    tag_ids: videoDetail.tag_ids // 保存标签ID列表
+                };
+
+                this.setData({
+                    videoInfo: formattedVideoInfo,
+                    title: formattedVideoInfo.title,
+                    isLoading: false
+                });
+
+                // 获取真实播放地址
+                this.getVideoPlayUrl(videoDetail);
+
+                // 加载相关视频
+                this.loadRelatedVideos(videoDetail.tag_ids);
+            } else {
+                this.setData({
+                    isLoading: false
+                });
+
+                wx.showToast({
+                    title: '获取视频详情失败',
+                    icon: 'none'
+                });
+            }
+        } catch (error) {
+            console.error('获取视频详情失败:', error);
+
+            this.setData({
+                isLoading: false
+            });
+
+            wx.showToast({
+                title: '获取视频详情失败',
+                icon: 'none'
+            });
+        } finally {
+            wx.hideLoading();
+        }
+    },
+
+    // 获取视频播放地址
+    async getVideoPlayUrl(videoDetail) {
+
+
+        console.log(`videoDetail`, videoDetail)
+        try {
+            // 根据视频类型进行处理
+            switch (videoDetail.video_type) {
+                case 3: // OAS视频
+                    // 获取真实播放地址
+                    const tagId = videoDetail.tag_ids && videoDetail.tag_ids.length > 0 ? videoDetail.tag_ids[0] : 2072;
+                    let parseRes = await getRealVideoUrl(videoDetail.id, tagId);
+
+                    console.log('parseRes', parseRes)
+
+                    // 默认视频为免费视频
+                    videoDetail.lock = false
+                    // 标记暂停插屏是否显示过
+                    videoDetail.pauseInsertAd = false
+
+
+                    // 默认视频不显示插屏
+                    videoDetail.insertAd = false
+                    videoDetail.adType = 'video'
+                    videoDetail.likeNum = rnd(101, 209) / 10
+                    videoDetail.like = false
+                    videoDetail.shareNum = rnd(51, 99) / 10
+                    if (videoDetail.video_type !== 4) {
+                        videoDetail.playUrl = parseRes.url_info[0].url
+                    }
+                    if (videoDetail.is_top === 1) {
+                        videoDetail.top = true
+                    }
+                    this.setData({
+                        isLoading: false,
+                        videoDetail: videoDetail
+                    })
+
+
+                    break;
+
+                case 4: // 微信视频
+                    // 直接使用video_vid
+                    this.setData({
+                        'videoInfo.videoUrl': videoDetail.video_vid
+                    });
+                    break;
+
+                default:
+                    // 默认使用url字段
+                    if (videoDetail.url) {
+                        this.setData({
+                            'videoInfo.videoUrl': videoDetail.url
+                        });
+                    } else {
+                        throw new Error('不支持的视频类型');
+                    }
+            }
+        } catch (error) {
+            console.error('获取视频播放地址失败:', error);
+            wx.showToast({
+                title: '无法获取视频播放地址',
+                icon: 'none'
+            });
+        }
+    },
+
+    // 切换剧集
+    switchEpisode(e) {
+        const index = e.currentTarget.dataset.index;
+        if (index === this.data.currentEpisodeIndex) return;
+
+        const episode = this.data.episodeList[index];
+        if (!episode) return;
 
-        // 获取真实播放地址
-        this.getVideoPlayUrl(videoDetail);
-        
-        // 加载相关视频
-        this.loadRelatedVideos(videoDetail.tag_ids);
-      } else {
         this.setData({
-          isLoading: false
+            currentEpisodeIndex: index,
+            currentEpisode: episode,
+            isPlaying: true
         });
-        
-        wx.showToast({
-          title: '获取视频详情失败',
-          icon: 'none'
+
+        // 获取视频实例并播放
+        const videoContext = wx.createVideoContext('myVideo');
+        videoContext.play();
+    },
+
+    // 视频播放事件
+    onVideoPlay() {
+        this.setData({
+            isPlaying: true,
+            videoStatus: 1
         });
-      }
-    } catch (error) {
-      console.error('获取视频详情失败:', error);
-      
-      this.setData({
-        isLoading: false
-      });
-      
-      wx.showToast({
-        title: '获取视频详情失败',
-        icon: 'none'
-      });
-    } finally {
-      wx.hideLoading();
-    }
-  },
-  
-  // 获取视频播放地址
-  async getVideoPlayUrl(videoDetail) {
-
-    
-    console.log(`videoDetail`,videoDetail)
-    try {
-      // 根据视频类型进行处理
-      switch (videoDetail.video_type) {
-        case 3: // OAS视频
-          // 获取真实播放地址
-          const tagId = videoDetail.tag_ids && videoDetail.tag_ids.length > 0 ? videoDetail.tag_ids[0] : 2072;
-          let parseRes = await getRealVideoUrl(videoDetail.id, tagId);
-          
-          console.log('parseRes',parseRes)
-
-          // 默认视频为免费视频
-          videoDetail.lock = false
-          // 标记暂停插屏是否显示过
-          videoDetail.pauseInsertAd = false
-        
-
-          // 默认视频不显示插屏
-          videoDetail.insertAd = false
-          videoDetail.adType = 'video'
-          videoDetail.likeNum = rnd(101, 209) / 10
-          videoDetail.like = false
-          videoDetail.shareNum = rnd(51, 99) / 10
-          if (videoDetail.video_type !== 4) {
-            videoDetail.playUrl =  parseRes.url_info[0].url
-          }
-          if (videoDetail.is_top === 1) {
-            videoDetail.top = true
-          }
-          this.setData({
-            isLoading:false,
-            videoDetail: videoDetail
-          })
-          
-          
-          break;
-          
-        case 4: // 微信视频
-          // 直接使用video_vid
-          this.setData({
-            'videoInfo.videoUrl': videoDetail.video_vid
-          });
-          break;
-          
-        default:
-          // 默认使用url字段
-          if (videoDetail.url) {
-            this.setData({
-              'videoInfo.videoUrl': videoDetail.url
+
+        // 可以添加播放埋点
+        console.log('视频开始播放:', this.data.videoInfo.id);
+    },
+
+    // 视频暂停事件
+    onVideoPause() {
+        this.setData({
+            isPlaying: false,
+            videoStatus: 2
+        });
+    },
+
+    // 视频播放结束事件
+    onVideoEnd() {
+        this.setData({
+            isPlaying: false,
+            videoStatus: 0
+        });
+
+        // 可以添加结束埋点
+        console.log('视频播放结束:', this.data.videoInfo.id);
+    },
+
+    // 视频时间更新事件
+    onVideoUpdate(e) {
+        const {currentTime, duration} = e.detail;
+        this.setData({
+            currentTime,
+            duration
+        });
+    },
+
+    // 视频元数据加载完成
+    onVideoLoaded(e) {
+        console.log('视频元数据加载完成', e.detail);
+    },
+
+    // 点击视频控制区
+    onClickVideoControls() {
+        if (this.data.videoStatus === 1) {
+            // 当前正在播放,暂停视频
+            const videoContext = wx.createVideoContext('myVideo');
+            videoContext.pause();
+        } else {
+            // 当前已暂停,开始播放
+            const videoContext = wx.createVideoContext('myVideo');
+            videoContext.play();
+        }
+    },
+
+    // 点击相关推荐视频
+    onRelatedVideoTap(e) {
+        console.log(e.currentTarget.dataset)
+        const videoId = e.currentTarget.dataset.id;
+        const video = this.data.relatedVideos.find(item => item.id === videoId);
+        // console.log('video',video)
+        if (!video) {
+            wx.showToast({
+                title: '视频信息获取失败',
+                icon: 'none'
             });
-          } else {
-            throw new Error('不支持的视频类型');
-          }
-      }
-    } catch (error) {
-      console.error('获取视频播放地址失败:', error);
-      wx.showToast({
-        title: '无法获取视频播放地址',
-        icon: 'none'
-      });
-    }
-  },
-  
-  // 切换剧集
-  switchEpisode(e) {
-    const index = e.currentTarget.dataset.index;
-    if (index === this.data.currentEpisodeIndex) return;
-    
-    const episode = this.data.episodeList[index];
-    if (!episode) return;
-    
-    this.setData({
-      currentEpisodeIndex: index,
-      currentEpisode: episode,
-      isPlaying: true
-    });
-    
-    // 获取视频实例并播放
-    const videoContext = wx.createVideoContext('myVideo');
-    videoContext.play();
-  },
-  
-  // 视频播放事件
-  onVideoPlay() {
-    this.setData({
-      isPlaying: true,
-      videoStatus: 1
-    });
-    
-    // 可以添加播放埋点
-    console.log('视频开始播放:', this.data.videoInfo.id);
-  },
-  
-  // 视频暂停事件
-  onVideoPause() {
-    this.setData({
-      isPlaying: false,
-      videoStatus: 2
-    });
-  },
-  
-  // 视频播放结束事件
-  onVideoEnd() {
-    this.setData({
-      isPlaying: false,
-      videoStatus: 0
-    });
-    
-    // 可以添加结束埋点
-    console.log('视频播放结束:', this.data.videoInfo.id);
-  },
-  
-  // 视频时间更新事件
-  onVideoUpdate(e) {
-    const { currentTime, duration } = e.detail;
-    this.setData({
-      currentTime,
-      duration
-    });
-  },
-  
-  // 视频元数据加载完成
-  onVideoLoaded(e) {
-    console.log('视频元数据加载完成', e.detail);
-  },
-  
-  // 点击视频控制区
-  onClickVideoControls() {
-    if (this.data.videoStatus === 1) {
-      // 当前正在播放,暂停视频
-      const videoContext = wx.createVideoContext('myVideo');
-      videoContext.pause();
-    } else {
-      // 当前已暂停,开始播放
-      const videoContext = wx.createVideoContext('myVideo');
-      videoContext.play();
-    }
-  },
-  
-  // 点击相关推荐视频
-  onRelatedVideoTap(e) {
-    console.log(e.currentTarget.dataset)
-    const videoId = e.currentTarget.dataset.id;
-    const video = this.data.relatedVideos.find(item => item.id === videoId);
-    // console.log('video',video)
-    if (!video) {
-      wx.showToast({
-        title: '视频信息获取失败',
-        icon: 'none'
-      });
-      return;
-    }
-    const tag_id = video.tag_id;
-    // console.log('tag_id',tag_id)
-    // 显示加载中提示
-    wx.showLoading({
-      title: '加载中...',
-      mask: true
-    });
-
-    // 将标题进行URI编码处理
-    const encodedTitle = encodeURIComponent(video.title || '');
-    
-    // 跳转到视频详情页
-    wx.navigateTo({
-      url: `/pages/video/detail?id=${videoId}&title=${encodedTitle}&tag_id=${tag_id}`,
-      success: () => {
-        wx.hideLoading();
-      },
-      fail: (err) => {
-        console.error('跳转失败:', err);
-        wx.hideLoading();
-        wx.showToast({
-          title: '跳转失败',
-          icon: 'none'
+            return;
+        }
+        const tag_id = video.tag_id;
+        // console.log('tag_id',tag_id)
+        // 显示加载中提示
+        wx.showLoading({
+            title: '加载中...',
+            mask: true
         });
-      }
-    });
-  },
-
-  // 跳转到书籍详情
-  goToBookDetail() {      
-    getApp().globalData.isShowDialog = true
-    goToBookDetail({
-      bookId: 7266,
-      wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
-      chapterId: null
-    });
-  },
-
-  // 返回上一页
-  goBack() {
-    wx.navigateBack();
-  },
-  
-  // 分享按钮点击事件
-  onShareTap(e) {
-    // 阻止事件冒泡
-    e.stopPropagation();
-  },
-
-  // 分享给朋友
-  onShareAppMessage(e) {
-    // 如果是从推荐视频分享
-    if (e.target && e.target.dataset.video) {
-      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]}&share_count=1`,
-        imageUrl: video.cover_image,
-        success: function(res) {
-          wx.showToast({
-            title: '分享成功',
-            icon: 'success',
-            duration: 1500
-          });
-        },
-        fail: function(res) {
-          wx.showToast({
-            title: '分享失败',
-            icon: 'none',
-            duration: 1500
-          });
+
+        // 将标题进行URI编码处理
+        const encodedTitle = encodeURIComponent(video.title || '');
+
+        // 跳转到视频详情页
+        wx.navigateTo({
+            url: `/pages/video/detail?id=${videoId}&title=${encodedTitle}&tag_id=${tag_id}`,
+            success: () => {
+                wx.hideLoading();
+            },
+            fail: (err) => {
+                console.error('跳转失败:', err);
+                wx.hideLoading();
+                wx.showToast({
+                    title: '跳转失败',
+                    icon: 'none'
+                });
+            }
+        });
+    },
+
+    // 跳转到书籍详情
+    goToBookDetail() {
+        getApp().globalData.isShowDialog = true
+        goToBookDetail({
+            bookId: 7266,
+            wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
+            chapterId: null
+        });
+    },
+
+    // 返回上一页
+    goBack() {
+        wx.navigateBack({
+                delta: 1
+            }
+        );
+        // wx.redirectTo({
+        //     url: '/pages/video/video',
+        // });
+        console.log('返回上一页')
+    },
+
+    // 分享按钮点击事件
+    onShareTap(e) {
+        // 阻止事件冒泡
+        e.stopPropagation();
+    },
+
+    // 分享给朋友
+    onShareAppMessage(e) {
+        // 如果是从推荐视频分享
+        if (e.target && e.target.dataset.video) {
+            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]}&share_count=1&type=share`,
+                imageUrl: video.cover_image,
+                success: function (res) {
+                    wx.showToast({
+                        title: '分享成功',
+                        icon: 'success',
+                        duration: 1500
+                    });
+                },
+                fail: function (res) {
+                    wx.showToast({
+                        title: '分享失败',
+                        icon: 'none',
+                        duration: 1500
+                    });
+                }
+            };
         }
-      };
-    }
-    
-    // 默认分享当前视频
-    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]}&share_count=1`,
-      imageUrl: videoInfo.cover,
-      success: function(res) {
+
+        // 默认分享当前视频
+        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]}&share_count=1&type=share`,
+            imageUrl: videoInfo.cover,
+            success: function (res) {
+                wx.showToast({
+                    title: '分享成功',
+                    icon: 'success',
+                    duration: 1500
+                });
+            },
+            fail: function (res) {
+                wx.showToast({
+                    title: '分享失败',
+                    icon: 'none',
+                    duration: 1500
+                });
+            }
+        };
+    },
+
+    // 分享到朋友圈
+    onShareTimeline() {
+        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]}&share_count=1&type=share`,
+            imageUrl: videoInfo.cover
+        };
+    },
+
+    // 收藏视频
+    toggleCollect() {
+        const isCollect = !this.data.videoInfo.isCollect;
+
+        this.setData({
+            'videoInfo.isCollect': isCollect
+        });
+
         wx.showToast({
-          title: '分享成功',
-          icon: 'success',
-          duration: 1500
+            title: isCollect ? '收藏成功' : '已取消收藏',
+            icon: 'success'
         });
-      },
-      fail: function(res) {
+    },
+
+    // 点赞视频
+    likeVideo() {
+        const currentLikes = parseInt(this.data.videoInfo.likeCount) || 0;
+
+        this.setData({
+            'videoInfo.likeCount': (currentLikes + 1).toString()
+        });
+
         wx.showToast({
-          title: '分享失败',
-          icon: 'none',
-          duration: 1500
+            title: '点赞成功',
+            icon: 'success'
         });
-      }
-    };
-  },
-
-  // 分享到朋友圈
-  onShareTimeline() {
-    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]}&share_count=1`,
-      imageUrl: videoInfo.cover
-    };
-  },
-  
-  // 收藏视频
-  toggleCollect() {
-    const isCollect = !this.data.videoInfo.isCollect;
-    
-    this.setData({
-      'videoInfo.isCollect': isCollect
-    });
-    
-    wx.showToast({
-      title: isCollect ? '收藏成功' : '已取消收藏',
-      icon: 'success'
-    });
-  },
-  
-  // 点赞视频
-  likeVideo() {
-    const currentLikes = parseInt(this.data.videoInfo.likeCount) || 0;
-    
-    this.setData({
-      'videoInfo.likeCount': (currentLikes + 1).toString()
-    });
-    
-    wx.showToast({
-      title: '点赞成功',
-      icon: 'success'
-    });
-  },
-  
-  // 滚动事件
-  onScroll(e) {
-    this.setData({
-      scrollHeight: e.detail.scrollTop
-    });
-  },
-  
-  // 加载相关视频
-  async loadRelatedVideos(tagIds) {
-    try {
-      // 使用第一个标签ID获取相关视频
-      const tagId = tagIds && tagIds.length > 0 ? tagIds[0] : 2250;
-      const relatedVideos = await getRelatedVideos({ tag_id: tagId });
-      // console.log('推荐视频',relatedVideos)
-      // 处理相关视频数据
-      const formattedVideos = relatedVideos.map(video => ({
-        id: video.id,
-        title: video.title,
-        tag_id:video.tag_ids[0],
-        cover_image: video.cover_image,
-        playCount: video.views || '0',
-        likeCount: video.like || '0',
-        shareCount: video.share || '0'
-      }));
-      
-      this.setData({
-        relatedVideos: formattedVideos
-      });
-    } catch (error) {
-      console.error('获取相关视频失败:', error);
+    },
+
+    // 滚动事件
+    onScroll(e) {
+        this.setData({
+            scrollHeight: e.detail.scrollTop
+        });
+    },
+
+    // 加载相关视频
+    async loadRelatedVideos(tagIds) {
+        try {
+            // 使用第一个标签ID获取相关视频
+            const tagId = tagIds && tagIds.length > 0 ? tagIds[0] : 2250;
+            console.log("原始ID:", apple.ghid)
+            const relatedVideos = await getRelatedVideos({tag_id: tagId, gh_id: apple.ghid});
+            // console.log('推荐视频',relatedVideos)
+            // 处理相关视频数据
+            const formattedVideos = relatedVideos.map(video => ({
+                id: video.id,
+                title: video.title,
+                tag_id: video.tag_ids[0],
+                cover_image: video.cover_image,
+                playCount: video.views || '0',
+                likeCount: video.like || '0',
+                shareCount: video.share || '0'
+            }));
+
+            this.setData({
+                relatedVideos: formattedVideos
+            });
+        } catch (error) {
+            console.error('获取相关视频失败:', error);
+        }
     }
-  }
 })