Browse Source

更新免费视频列表,修改视频信息和排序选项逻辑,支持根据用户会员状态动态显示排序选项。同时,优化视频播放器组件,确保非付费用户和试看视频的处理逻辑,提升用户体验和交互性。

wuyi 2 months ago
parent
commit
c9643a4f29
3 changed files with 119 additions and 29 deletions
  1. 18 18
      src/data/freeVideo.ts
  2. 39 8
      src/views/Home.vue
  3. 62 3
      src/views/VideoPlayer.vue

+ 18 - 18
src/data/freeVideo.ts

@@ -14,39 +14,39 @@ export interface FreeVideo {
 export const freeVideos: FreeVideo[] = [
   {
     id: "free-1",
-    cover: "https://cknz.t1mg0oa.com/ts4/2510/7NE42EETD31O/cover",
-    m3u8: "https://api.xmqspco.com//v/cTDMWpLWoPEwmn5Vn0l51Q.m3u8?user_id=605500911&plat_id=60005",
-    name: "MARAA-212_Himitsu-chan_是_H_杯___Himitsu-chan_与_Inst",
+    cover: "https://cknz.t1mg0oa.com/2209/CVELA54RLB2N/cover",
+    m3u8: "https://api.xmqspco.com//v/mMPq4Ua6YhQmDBxqIVQ73Q.m3u8?user_id=605500911&plat_id=60005",
+    name: "姐姐是情色博主.精东影业",
   },
   {
     id: "free-2",
-    cover: "https://cknz.t1mg0oa.com/ts4/2510/7H1JO3C92O64/cover",
-    m3u8: "https://api.xmqspco.com//v/NJto-NuaAdzLH9ZvzBjv4g.m3u8?user_id=605500911&plat_id=60005",
-    name: "START-411_現役工廠妹子來當一天宿舍媽媽!SODSTAR天音環奈親自到宿舍照顧你~上班前、下",
+    cover: "https://cknz.t1mg0oa.com/2209/77G8BSFETL8V/cover",
+    m3u8: "https://api.xmqspco.com//v/YccfZkGyfDqhnkAQGP-tZA.m3u8?user_id=605500911&plat_id=60005",
+    name: "常去保健室的我和保健科小花老师上课时放学后的中出SEX 小花暖   中文字幕 角色剧情 制服诱惑 ",
   },
   {
     id: "free-3",
-    cover: "https://cknz.t1mg0oa.com/ts4/2510/550264K68J9J/cover",
-    m3u8: "https://api.xmqspco.com//v/R7dZv_VU5UyXbE7hvvfISw.m3u8?user_id=605500911&plat_id=60005",
-    name: "【高清】麻豆传媒 m220 18岁艺考生的献祭为名次贡献自己的初夜",
+    cover: "https://cknz.t1mg0oa.com/2208/MDSQ00006700/cover",
+    m3u8: "https://api.xmqspco.com//v/uUIHFW3MfZvlwL7hTQWNng.m3u8?user_id=605500911&plat_id=60005",
+    name: "樱狸子-白丝水手服自拍#网红#福利姬#萝莉#白丝#超短裙#爆乳#樱狸子编号C1802109",
   },
   {
     id: "free-4",
-    cover: "https://cknz.t1mg0oa.com/ts4/2510/8AORMJIE8F24/cover",
-    m3u8: "https://api.xmqspco.com//v/NXl77-NVV6438VnlPowBlw.m3u8?user_id=605500911&plat_id=60005",
-    name: "【高清】麻豆传媒 m215 无套双飞JK萝莉高中生两少女一起争着吃鸡巴",
+    cover: "https://cknz.t1mg0oa.com/2208/MDSQ00006222/cover",
+    m3u8: "https://api.xmqspco.com//v/gS4t6fB-EU6vS4WGeLO60Q.m3u8?user_id=605500911&plat_id=60005",
+    name: "きょう肉肉引き裂き靴下撕黑丝OL秘书#黑丝#包臀裙#气质#性感#丝袜诱惑#蜜桃臀#肉感#肉肉编号24C8F8E6",
   },
   {
     id: "free-5",
-    cover: "https://cknz.t1mg0oa.com/ts4/2509/E6O45R5VVNG2/cover",
-    m3u8: "https://api.xmqspco.com//v/vF4W9CE_C28-iGklVPTVmw.m3u8?user_id=605500911&plat_id=60005",
-    name: "CARIBBEANCOM-090225-001_老师像我一样做!_!_〜热爱并关心每次射精的老师〜",
+    cover: "https://cknz.t1mg0oa.com/2208/K1CP3FVKKS5K/cover",
+    m3u8: "https://api.xmqspco.com//v/S_tGP-yHk44OZyq70mnk-w.m3u8?user_id=605500911&plat_id=60005",
+    name: "强 スワッピング&种付け轮  辈达からの凌 の果て 孕まされた2人 巨乳若妻 お腹 子 种は友达 旦那乙爱丽丝 姬咲华  凌辱强暴 多P群交 角色剧情  ",
   },
   {
     id: "free-6",
-    cover: "https://cknz.t1mg0oa.com/ts4/2510/0J6BH028UMKT/cover",
-    m3u8: "https://api.xmqspco.com//v/OFnZyzVFkKyuJ8cx3lNu-A.m3u8?user_id=605500911&plat_id=60005",
-    name: "WAAA-572_コンドームが破れてまさかの生ハメ!超加速するピストンで何度も中出し!_新井里真",
+    cover: "https://cknz.t1mg0oa.com/2208/C00IU6149KDT/cover",
+    m3u8: "https://api.xmqspco.com//v/j2tCad8_KNrE083MnrgPGQ.m3u8?user_id=605500911&plat_id=60005",
+    name: "え、ここでヤルの ダメッ すぐイっちゃうってばぁ 早漏ビンカン娘にいきなり即ズボッ大作戦 1日完全密着イクイク声我慢ドキュメント森千里   直接开啪 ",
   },
 ];
 

+ 39 - 8
src/views/Home.vue

@@ -374,7 +374,14 @@
 </template>
 
 <script setup lang="ts">
-import { ref, onMounted, onBeforeUnmount, watch, nextTick } from "vue";
+import {
+  ref,
+  computed,
+  onMounted,
+  onBeforeUnmount,
+  watch,
+  nextTick,
+} from "vue";
 import { useRouter, useRoute } from "vue-router";
 import { searchVideoByTags, searchVideoByKeyword } from "@/services/api";
 import { videoMenus as fixedVideoMenus } from "@/data/videoMenus";
@@ -422,15 +429,39 @@ const totalPages = ref(0);
 const totalCount = ref(0);
 const jumpToPage = ref<number | string>("");
 
-// 排序选项
-const sortOptions = ref([
-  { value: "time", label: "最新" },
-  { value: "view", label: "热门" },
-  { value: "like", label: "点赞" },
-  { value: "free", label: "试看" },
-]);
+// 排序选项 - 根据用户会员状态动态显示
+const sortOptions = computed(() => {
+  const vipLevel = userStore.getVipLevel();
+  const isVip = vipLevel !== VipLevel.GUEST && vipLevel !== VipLevel.FREE;
+
+  const options = [
+    { value: "time", label: "最新" },
+    { value: "view", label: "热门" },
+    { value: "like", label: "点赞" },
+  ];
+
+  // 只有非会员用户才显示试看选项
+  if (!isVip) {
+    options.push({ value: "free", label: "试看" });
+  }
+
+  return options;
+});
 const selectedSort = ref<string>("time");
 
+// 监听用户会员状态变化,如果当前是试看排序但用户已升级为会员,则切换到最新
+watch(
+  () => userStore.getVipLevel(),
+  (newVipLevel) => {
+    const isVip =
+      newVipLevel !== VipLevel.GUEST && newVipLevel !== VipLevel.FREE;
+    if (isVip && selectedSort.value === "free") {
+      selectedSort.value = "time";
+      console.log("用户已升级为会员,自动切换到最新排序");
+    }
+  }
+);
+
 // 标签展开状态
 const showAllTags = ref(false);
 

+ 62 - 3
src/views/VideoPlayer.vue

@@ -81,7 +81,13 @@
         <VideoJSPlayer
           ref="videoProcessorRef"
           :cover-url="videoInfo.cover"
-          :m3u8-url="isSinglePurchased || isVip ? videoInfo.m3u8 : ''"
+          :m3u8-url="
+            isSinglePurchased || isVip
+              ? videoInfo.m3u8
+              : isFreeVideo
+              ? route.query.m3u8
+              : ''
+          "
           :alt="videoInfo.name"
           :auto-play="false"
           :hide-error="false"
@@ -101,7 +107,7 @@
 
     <!-- 非付费用户提示弹窗 - 页面级别显示 -->
     <div
-      v-if="!isSinglePurchased && !isVip && showPurchasePrompt"
+      v-if="!isSinglePurchased && !isVip && showPurchasePrompt && !isFreeVideo"
       class="fixed inset-0 bg-black/50 flex items-center justify-center z-50"
       @click.self="closePurchasePrompt"
     >
@@ -800,6 +806,7 @@ const currentVipLevel = computed(() => userStore.getVipLevel());
 // 判断是否为试看视频
 const isFreeVideo = computed(() => {
   return (
+    console.log("isFreeVideo", route.query.isFree, videoInfo.value.id),
     route.query.isFree === "true" || videoInfo.value.id?.startsWith("free-")
   );
 });
@@ -1222,13 +1229,62 @@ const checkVideoPurchaseStatus = async () => {
 
   try {
     const response = await checkSinglePurchase(videoInfo.value.id);
-    isSinglePurchased.value = response === true;
+    console.log("checkVideoPurchaseStatus", response);
+    // 根据API返回的数据结构判断是否已购买
+    // 如果API返回status为1表示已购买,或者直接返回true/false
+    const wasPurchased = response.status === 1 || response === true;
+    isSinglePurchased.value = wasPurchased;
+
+    // 如果用户已购买但还没有视频源,则调用详情接口获取视频源
+    if (
+      wasPurchased &&
+      (!videoInfo.value.m3u8 || videoInfo.value.m3u8 === "")
+    ) {
+      console.log("用户已购买,调用详情接口获取视频源");
+      await loadVideoDetailForPurchasedUser();
+    }
   } catch (error) {
     console.error("检查视频购买状态失败:", error);
     isSinglePurchased.value = false;
   }
 };
 
+// 为已购买用户加载视频详情
+const loadVideoDetailForPurchasedUser = async () => {
+  const videoId = videoInfo.value.id;
+  if (!videoId || videoId === "unknown") {
+    return;
+  }
+
+  try {
+    const response = await getVideoDetail(device, String(videoId));
+    console.log("loadVideoDetailForPurchasedUser", response);
+
+    if (response.status === 0 && response.data) {
+      const data = response.data;
+      // 更新视频信息,特别是m3u8视频源
+      videoInfo.value = {
+        ...videoInfo.value,
+        m3u8: data.m3u8 || "", // 获取视频源
+        duration: data.duration || videoInfo.value.duration,
+        view: data.view || videoInfo.value.view,
+        like: data.like || videoInfo.value.like,
+        time: data.time || videoInfo.value.time,
+        taginfo: data.tags
+          ? data.tags
+              .split(",")
+              .map((tag: string) => ({ name: tag.trim(), hash: tag.trim() }))
+          : videoInfo.value.taginfo,
+      };
+      console.log("已购买用户视频详情加载成功,m3u8:", videoInfo.value.m3u8);
+    } else {
+      console.error("获取已购买用户视频详情失败:", response);
+    }
+  } catch (error) {
+    console.error("调用详情接口失败:", error);
+  }
+};
+
 // 加载视频信息
 const loadVideoInfo = async () => {
   const userInfo = userStore.userInfo;
@@ -1438,6 +1494,9 @@ onMounted(async () => {
   if (!priceStore.isPriceConfigLoaded) {
     await priceStore.fetchPriceConfig();
   }
+
+  // 单片是否购买
+  await checkVideoPurchaseStatus();
 });
 
 onUnmounted(() => {