|
@@ -81,7 +81,13 @@
|
|
|
<VideoJSPlayer
|
|
<VideoJSPlayer
|
|
|
ref="videoProcessorRef"
|
|
ref="videoProcessorRef"
|
|
|
:cover-url="videoInfo.cover"
|
|
:cover-url="videoInfo.cover"
|
|
|
- :m3u8-url="isSinglePurchased || isVip ? videoInfo.m3u8 : ''"
|
|
|
|
|
|
|
+ :m3u8-url="
|
|
|
|
|
+ isSinglePurchased || isVip
|
|
|
|
|
+ ? videoInfo.m3u8
|
|
|
|
|
+ : isFreeVideo
|
|
|
|
|
+ ? route.query.m3u8
|
|
|
|
|
+ : ''
|
|
|
|
|
+ "
|
|
|
:alt="videoInfo.name"
|
|
:alt="videoInfo.name"
|
|
|
:auto-play="false"
|
|
:auto-play="false"
|
|
|
:hide-error="false"
|
|
:hide-error="false"
|
|
@@ -101,7 +107,7 @@
|
|
|
|
|
|
|
|
<!-- 非付费用户提示弹窗 - 页面级别显示 -->
|
|
<!-- 非付费用户提示弹窗 - 页面级别显示 -->
|
|
|
<div
|
|
<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"
|
|
class="fixed inset-0 bg-black/50 flex items-center justify-center z-50"
|
|
|
@click.self="closePurchasePrompt"
|
|
@click.self="closePurchasePrompt"
|
|
|
>
|
|
>
|
|
@@ -800,6 +806,7 @@ const currentVipLevel = computed(() => userStore.getVipLevel());
|
|
|
// 判断是否为试看视频
|
|
// 判断是否为试看视频
|
|
|
const isFreeVideo = computed(() => {
|
|
const isFreeVideo = computed(() => {
|
|
|
return (
|
|
return (
|
|
|
|
|
+ console.log("isFreeVideo", route.query.isFree, videoInfo.value.id),
|
|
|
route.query.isFree === "true" || videoInfo.value.id?.startsWith("free-")
|
|
route.query.isFree === "true" || videoInfo.value.id?.startsWith("free-")
|
|
|
);
|
|
);
|
|
|
});
|
|
});
|
|
@@ -1222,13 +1229,62 @@ const checkVideoPurchaseStatus = async () => {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const response = await checkSinglePurchase(videoInfo.value.id);
|
|
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) {
|
|
} catch (error) {
|
|
|
console.error("检查视频购买状态失败:", error);
|
|
console.error("检查视频购买状态失败:", error);
|
|
|
isSinglePurchased.value = false;
|
|
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 loadVideoInfo = async () => {
|
|
|
const userInfo = userStore.userInfo;
|
|
const userInfo = userStore.userInfo;
|
|
@@ -1438,6 +1494,9 @@ onMounted(async () => {
|
|
|
if (!priceStore.isPriceConfigLoaded) {
|
|
if (!priceStore.isPriceConfigLoaded) {
|
|
|
await priceStore.fetchPriceConfig();
|
|
await priceStore.fetchPriceConfig();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 单片是否购买
|
|
|
|
|
+ await checkVideoPurchaseStatus();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|