From 7859711073ae0111144aaaa6c10981525272004f Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 07 七月 2025 12:01:39 +0800
Subject: [PATCH] 视频播放记录

---
 pages/mine/myTracks.vue |   87 ++++++++++++++++++++++++++++++-------------
 1 files changed, 60 insertions(+), 27 deletions(-)

diff --git a/pages/mine/myTracks.vue b/pages/mine/myTracks.vue
index bd4c2f3..7f6a935 100644
--- a/pages/mine/myTracks.vue
+++ b/pages/mine/myTracks.vue
@@ -30,23 +30,26 @@
 			v-for="(item, index) in videoHistory" 
 			:key="index" 
 			class="video-item"
-			@click="goToVideoDetail(item)"
+			@click="goToVideoPlay(item, index)"
 		  >
 			  <u-swipe-action style="width: 100%;" :show="item.show" :index="index" :key="item.id"
-				@click="delTracks" @open="open" :options="options">
-				<image class="video-cover" :src="item.coverUrl" mode="aspectFill"></image>
-				<view class="video-info">
-				  <view class="video-title">{{item.title}}</view>
-				  <view class="video-author">{{item.authorName}}</view>
-				  <view class="video-meta">
-					<text>鎾斁鑷�: {{formatPlayTime(item.playAt)}}</text>
-					<text class="separator">|</text>
-					<text>{{formatDate(item.playTime)}}</text>
-				  </view>
+				@click="deleteVideoView(item.id)" @open="open" :options="options">
+				<view style="display: flex;" @click="goToVideoPlay(item, index)">
+					<image class="video-cover" :src="item.coverUrl" mode="aspectFill"></image>
+					<view class="video-info">
+					  <view class="video-title">{{item.title}}</view>
+					  <view class="video-author">{{item.authorName}}</view>
+					  <view class="video-meta">
+						<text>鎾斁鑷�: {{formatPlayTime(item.playAt)}}</text>
+						<text class="separator">|</text>
+						<text>{{formatDate(item.playTime)}}</text>
+					  </view>
+					</view>
 				</view>
+				
 			  </u-swipe-action>
 		  </view>
-		  <div @click="handleClickDeleteSelected" v-if="isEdit" class="submit">
+		  <div @click="deleteVideoView(item.id)" v-if="isEdit" class="submit">
 		  	鍒犻櫎鎵�閫�
 		  </div>
 		  <view v-if="videoHistory.length === 0" class="empty-tip">
@@ -83,11 +86,11 @@
 
 				</view>
 				<view class="myTracks-divider"></view>
-
+				<div @click="handleClickDeleteSelected(item.id)" v-if="isEdit" class="submit">
+					鍒犻櫎鎵�閫�
+				</div>
 			</view>
-			<div @click="handleClickDeleteSelected" v-if="isEdit" class="submit">
-				鍒犻櫎鎵�閫�
-			</div>
+			
 			<view v-if="trackList.length === 0" class="empty-tip">
 						鏆傛棤鍟嗗搧娴忚璁板綍
 			</view>
@@ -104,6 +107,7 @@
 		deleteHistoryListId,
 		myVideoHistory
 	} from "@/api/members.js";
+import storage from '@/utils/storage';
 
 	export default {
 		data() {
@@ -152,17 +156,25 @@
 			},
 			
 			// 璺宠浆鍒拌棰戣鎯呴〉
-			goToVideoDetail(item) {
-			  uni.navigateTo({
-				url: `/pages/video-detail/video-detail?id=${item.id}`
-			  })
+			goToVideoPlay(item, index) {
+				const playInfo = {
+					videoList: this.videoHistory,
+					nomore: true,
+					pageNumber: this.params.pageNumber,
+					playIndex: index
+				}
+				uni.setStorageSync("playInfo", playInfo)
+			    uni.navigateTo({
+				  url: `/pages/video/video-play?authorId=${storage.getUserInfo().id}&videoFrom=history`
+			    })
 			},
 			
 			// 鏍煎紡鍖栨挱鏀炬椂闂� (绉� -> 鍒�:绉�)
 			formatPlayTime(seconds) {
-			  const mins = Math.floor(seconds / 60)
-			  const secs = seconds % 60
-			  return `${mins}:${secs < 10 ? '0' + secs : secs}`
+				const secsInt = Math.floor(seconds); // 鍘绘帀灏忔暟閮ㄥ垎
+			    const mins = Math.floor(secsInt / 60)
+			    const secs = secsInt % 60
+			    return `${mins}:${secs < 10 ? '0' + secs : secs}`
 			},
 			
 			// 鏍煎紡鍖栨棩鏈�
@@ -191,6 +203,22 @@
 			},
 			checkboxChangeDP(val){
 				console.log(val)
+			},
+			// 鍒犻櫎瑙嗛娴忚璁板綍
+			deleteVideoView(id) {
+				deleteHistoryListId([id], 'video').then((res) => {
+					if (res.data.code == 200) {
+						this.videoHistory = [];
+						this.params.pageNumber = 1
+						this.getList();
+					} else {
+						uni.showToast({
+							title: res.data.message,
+							duration: 2000,
+							icon: "none",
+						});
+					}
+				});
 			},
 			// 鍒犻櫎鎵�閫夌殑鏁版嵁
 			handleClickDeleteSelected(val){
@@ -267,7 +295,12 @@
 						if (data.total == 0) {
 							this.whetherEmpty = true;
 						} else {
-							this.videoHistory.push(...data);
+							this.videoHistory = [
+							  ...this.videoHistory,
+							  ...res.data.data.filter(
+							    (newItem) => !this.videoHistory.some((oldItem) => oldItem.id === newItem.id)
+							  ),
+							];
 						}
 					})
 				}
@@ -277,7 +310,7 @@
 			 * 鍒犻櫎瓒宠抗
 			 */
 			delTracks(index,ids) {
-				deleteHistoryListId(ids || this.trackList[index].goodsId).then((res) => {
+				deleteHistoryListId(ids || this.trackList[index].goodsId, 'goods').then((res) => {
 					if (res.data.code == 200) {
 						this.trackList = [];
 						this.params.pageNumber = 1
@@ -456,8 +489,8 @@
 	
 	.video-item {
 	  display: flex;
-	  margin-bottom: 30rpx;
-	  padding-bottom: 30rpx;
+	  padding-bottom: 10rpx;
+	  padding-left: 20rpx;
 	  border-bottom: 1rpx solid #f5f5f5;
 	}
 	

--
Gitblit v1.8.0