11.28提交

This commit is contained in:
zoujiandong
2025-11-28 10:43:13 +08:00
parent 91726b87c5
commit 9788e723a2
17 changed files with 1005 additions and 408 deletions
+94 -32
View File
@@ -41,16 +41,17 @@
:src="videoSrc"
:videoHeight="220"
:seekTime="0"
@fullscreenchange="onFullscreenChange"
/>
<!-- 标签切换 -->
<cover-view class="tabs" v-if="from != 'download'">
<cover-view class="tabs" v-if="from != 'download'" :style="{ opacity: isFullScreen ? 0: 1 }">
<cover-view
class="tab"
:class="{ active: activeTab === 'info' }"
@click="switchTab('info')"
>
视频简介
<view-cover class="tab-line" v-if="activeTab === 'info'"></view-cover>
<cover-view class="tab-line" v-if="activeTab === 'info'"></cover-view>
</cover-view>
<cover-view
class="tab"
@@ -58,7 +59,7 @@
@click="switchTab('comment')"
>
评论
<view-cover class="tab-line" v-if="activeTab === 'comment'"></view-cover>
<cover-view class="tab-line" v-if="activeTab === 'comment'"></cover-view>
</cover-view>
</cover-view>
<view class="video-detail-page" v-if="from != 'download'">
@@ -132,7 +133,8 @@
<text v-if="!isVideoDownloadRecord && welfareNum > 0">(剩余免费下载{{ welfareNum }}次数)</text>
</text
>
<text class="download-text" v-else-if="downLoadStatus === 'loading'">视频缓存中</text>
<text class="download-text" v-else-if="downLoadStatus === 'loading' || downLoadStatus === 'failed'">视频缓存中</text>
<text class="download-text" v-else-if="downLoadStatus === 'completed'">查看缓存</text>
</view>
<view v-if="activeTab !== 'info' && from != 'download'" class="bottom-comment">
@@ -226,6 +228,7 @@ const hasDownload = ref(false);
const downLoadStatus = ref('start');
let downList = uni.getStorageSync("downLoadVideo") || [];
const downLoadList = ref(downList);
const isFullScreen = ref(false);
//import DomVideoPlayer from 'uniapp-video-player'
import sunnyVideo from "@/uni_modules/sunny-video/components/sunny-video/sunny-video.vue";
import downloadStore from "@/store/downloadStoreVideo.js";
@@ -239,6 +242,12 @@ const addDownloadTask = (item) => {
// 开始下载
startDownload(taskIndex);
};
const onFullscreenChange = (e) => {
let { fullScreen, direction } = e;
nextTick(() => {
isFullScreen.value = fullScreen;
});
};
// 开始下载
const startDownload = (index) => {
const taskItem = downloadStore.getTask(index);
@@ -260,7 +269,7 @@ const startDownload = (index) => {
icon: "none",
});
downLoadStatus.value = 'completed';
uni.saveFile({
tempFilePath: res1.tempFilePath,
success: function (res2) {
@@ -342,17 +351,11 @@ const toCollection = () => {
};
const networkConfirm = () => {
networkVisible.value = false;
pointVisible.value = true;
if(welfareNum.value > 0) {
useWelfareNum();
}else{
addDownloadTask({
url: videoSrc.value,
id: video_uuid.value,
imgpath: videoInfo.value.imgpath,
author: videoInfo.value.public_name,
name: videoInfo.value.name,
});
pointVisible.value = true;
}
};
@@ -399,18 +402,7 @@ const videoDetail = async () => {
if (res.code == 200) {
const userInfo = uni.getStorageSync("userInfo");
videoInfo.value = res.video;
downloadTasks.value.forEach(item => {
if (item.id == video_uuid.value) {
uni.getSavedFileInfo({
filePath: item.localPath, //仅做示例用,非真正的文件路径
success: function (res) {
hasDownload.value = true;
downLoadStatus.value = 'completed';
}
});
}
});
//hasDownload.value = downLoadList.value.includes(video_uuid.value);
let vid = res.video.polyv_uuid;
let uuid = vid.substring(0, 10);
@@ -452,6 +444,24 @@ const VideoDownloadRecord = async () => {
const res = await api.isVideoDownloadRecord({ video_uuid: video_uuid.value });
if (res.code == 200) {
isVideoDownloadRecord.value = res.result == 0 ? false : true;
if(isVideoDownloadRecord.value) {
downloadTasks.value.forEach(item => {
if (item.id == video_uuid.value) {
uni.getSavedFileInfo({
filePath: item.localPath, //仅做示例用,非真正的文件路径
success: function (res) {
hasDownload.value = true;
downLoadStatus.value = 'completed';
},
fail: function (err) {
// hasDownload.value = false;
// downLoadStatus.value = 'failed';
}
});
}
});
}
}
};
@@ -496,17 +506,48 @@ const resumeDownloadingTasks = () => {
onShow(() => {
hasDownload.value = false;
downLoadStatus.value = 'start';
console.log('onShow');
syncTasksFromStore();
// 监听store变化
downloadStore.addListener((tasks) => {
downloadTasks.value = tasks;
});
// 恢复正在下载的任务
resumeDownloadingTasks();
console.log('tasks');
console.log(downloadTasks.value);
if(downloadTasks.value.length > 0) {
for(let i = 0; i < downloadTasks.value.length; i++) {
if(downloadTasks.value[i].id == video_uuid.value) {
console.log('runing');
console.log(downloadTasks.value[i].status);
hasDownload.value = true;
if(downloadTasks.value[i].status == 'completed') {
downLoadStatus.value = 'completed';
}else if(downloadTasks.value[i].status == 'downloading') {
uni.showToast({
title: '视频缓存中',
icon: 'none',
});
hasDownload.value = true;
downLoadStatus.value = 'loading';
}else if(downloadTasks.value[i].status == 'paused') {
hasDownload.value = true;
downLoadStatus.value = 'loading';
}else if(downloadTasks.value[i].status == 'failed') {
hasDownload.value = true;
downLoadStatus.value = 'loading';
}
}
}
};
if (activeTab.value == "comment") {
videoCommentListV2();
}
videoDetail();
if(from.value != 'download') {
videoDetail();
}
uni.hideLoading();
});
@@ -694,9 +735,12 @@ onLoad((options) => {
});
video_uuid.value = options.id;
from.value = options.from;
addVideoWatchRecord();
VideoDownloadRecord();
getWelfareNum();
if(from.value != 'download') {
addVideoWatchRecord();
VideoDownloadRecord();
getWelfareNum();
}
// 从store同步任务列表
syncTasksFromStore();
// 监听store变化
@@ -706,6 +750,18 @@ onLoad((options) => {
});
// 恢复正在下载的任务
resumeDownloadingTasks();
if(from.value == 'download') {
downloadTasks.value.forEach(item => {
if(item.id == video_uuid.value) {
console.log(222222);
console.log(item.localPath);
videoSrc.value = item.localPath;
showVideo.value = true;
}
});
}
// navTo({
// url: "/pages_app/downLoadVideo/downLoadVideo",
// });
@@ -736,6 +792,7 @@ const payVideoDownload = async () => {
author: videoInfo.value.public_name,
name: videoInfo.value.name,
});
} else if (res.code == 106) {
notEnoughVisible.value = true;
notEnoughContent.value = `您的积分不足,是否购买积分?`;
@@ -885,6 +942,7 @@ $theme-color: #8b2316;
}
.video-detail-page {
border-top: 2rpx solid #cccccc;
background: $bg-color;
overflow: hidden;
}
@@ -914,7 +972,7 @@ $theme-color: #8b2316;
top: calc(var(--status-bar-height) + 44px + 220px);
padding: 24rpx 0 0;
border-bottom: 2rpx solid #cccccc;
width: 100%;
z-index: 99;
@@ -926,7 +984,7 @@ $theme-color: #8b2316;
align-items: center;
padding: 16rpx 0 24rpx;
color: $text-secondary;
font-size: 28rpx;
font-size: 28rpx!important;
.tab-line {
position: absolute;
bottom: 0;
@@ -939,7 +997,11 @@ $theme-color: #8b2316;
background: $theme-color;
}
&:nth-child(2) {
display: flex;
margin-left: 200rpx;
justify-content: center;
align-items: center;
text-align: center;
}
&.active {
color: $theme-color;
@@ -963,7 +1025,7 @@ $theme-color: #8b2316;
width: 100%;
background: #fff;
// padding: 24rpx 28rpx 40rpx;
top: calc(var(--status-bar-height) + 44px + 220px + 88rpx);
top: calc(var(--status-bar-height) + 44px + 220px + 99rpx);
height: calc(100vh - var(--status-bar-height) - 44px - 220px - 90rpx);
overflow-y: scroll;
// background: red;