فهرست منبع

重构视频播放器逻辑,移除登录成功处理,优化未登录和非付费用户的购买状态检查,更新视频信息加载逻辑,提升用户体验和交互性。

wuyi 2 ماه پیش
والد
کامیت
7338b71b75
1فایلهای تغییر یافته به همراه51 افزوده شده و 41 حذف شده
  1. 51 41
      src/views/VideoPlayer.vue

+ 51 - 41
src/views/VideoPlayer.vue

@@ -1118,15 +1118,6 @@ const onVideoPlay = () => {};
 // 视频播放进度更新处理
 // 视频播放进度更新处理
 const onVideoTimeUpdate = () => {};
 const onVideoTimeUpdate = () => {};
 
 
-// 登录成功处理
-const onLoginSuccess = async () => {
-  // 登录成功后刷新用户信息
-  await userStore.sync();
-
-  // 检查单片购买状态
-  await checkVideoPurchaseStatus();
-};
-
 // 格式化时长
 // 格式化时长
 const formatDuration = (duration: string | number): string => {
 const formatDuration = (duration: string | number): string => {
   const seconds = parseInt(String(duration));
   const seconds = parseInt(String(duration));
@@ -1255,38 +1246,11 @@ const loadVideoInfo = async () => {
       taginfo: [],
       taginfo: [],
     };
     };
   } else if (!isVipUser) {
   } else if (!isVipUser) {
-    // 未登录或guest或free用户
-    console.log("isNotVipUser");
-    const response = await checkSinglePurchase(videoId as string);
-    console.log("checkVideoPurchaseStatus", response);
-    const wasPurchased = response.status === 1 || response === true;
-    isSinglePurchased.value = wasPurchased;
-    if (response) {
-      // 关闭弹窗
-      showSinglePurchaseModal.value = false;
-      showMembershipPurchaseModal.value = false;
-      showPurchasePrompt.value = false;
-      const response = await getVideoDetail(device, String(videoId));
-      if (response.status === 0 && response.data) {
-        const data = response.data;
-        videoInfo.value = {
-          id: videoId,
-          name: data.name || "",
-          cover: data.cover || "",
-          m3u8: data.m3u8 || "",
-          duration: data.duration || 0,
-          view: data.view || 0,
-          like: data.like || 0,
-          time: data.time || 0,
-          taginfo: data.tags
-            ? data.tags
-                .split(",")
-                .map((tag: string) => ({ name: tag.trim(), hash: tag.trim() }))
-            : [],
-        };
-      }
-    } else {
-      const { name, cover, m3u8, duration, view, like } = route.query;
+    // 未登录
+    console.log("isNotLogin");
+    if (!isLoginUser) {
+      showPurchasePrompt.value = true;
+      const { name, cover, duration, view, like } = route.query;
       videoInfo.value = {
       videoInfo.value = {
         id: videoId,
         id: videoId,
         name: name as string,
         name: name as string,
@@ -1298,6 +1262,52 @@ const loadVideoInfo = async () => {
         time: 0,
         time: 0,
         taginfo: [],
         taginfo: [],
       };
       };
+    } else {
+      // guest或free用户
+      console.log("isNotVipUser");
+      const response = await checkSinglePurchase(videoId as string);
+      console.log("checkVideoPurchaseStatus", response);
+      const wasPurchased = response.status === 1 || response === true;
+      isSinglePurchased.value = wasPurchased;
+      if (response) {
+        // 已购买单片
+        // 关闭弹窗
+        showPurchasePrompt.value = false;
+        const response = await getVideoDetail(device, String(videoId));
+        if (response.status === 0 && response.data) {
+          const data = response.data;
+          videoInfo.value = {
+            id: videoId,
+            name: data.name || "",
+            cover: data.cover || "",
+            m3u8: data.m3u8 || "",
+            duration: data.duration || 0,
+            view: data.view || 0,
+            like: data.like || 0,
+            time: data.time || 0,
+            taginfo: data.tags
+              ? data.tags.split(",").map((tag: string) => ({
+                  name: tag.trim(),
+                  hash: tag.trim(),
+                }))
+              : [],
+          };
+        }
+      } else {
+        showPurchasePrompt.value = true;
+        const { name, cover, duration, view, like } = route.query;
+        videoInfo.value = {
+          id: videoId,
+          name: name as string,
+          cover: cover as string,
+          m3u8: "",
+          duration: parseInt(duration as string) || 0,
+          view: parseInt(view as string) || 0,
+          like: parseInt(like as string) || 0,
+          time: 0,
+          taginfo: [],
+        };
+      }
     }
     }
   } else if (isVipUser) {
   } else if (isVipUser) {
     // 付费用户,从详情接口获取视频信息
     // 付费用户,从详情接口获取视频信息