From 51e529d5061acf0a8e0580758e335594f5603159 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期五, 04 七月 2025 14:25:19 +0800
Subject: [PATCH] 我的-收藏列表bug、优化

---
 pages/mine/myCollect/myCollect.vue |   63 +++++++++++++++++++------------
 1 files changed, 39 insertions(+), 24 deletions(-)

diff --git a/pages/mine/myCollect/myCollect.vue b/pages/mine/myCollect/myCollect.vue
index 1349aa0..f6217f8 100644
--- a/pages/mine/myCollect/myCollect.vue
+++ b/pages/mine/myCollect/myCollect.vue
@@ -15,9 +15,9 @@
 				<scroll-view scroll-y class="activity-list" style="height: 100vh;" @scrolltolower="loadMore"
 					:lower-threshold="100">
 					<view v-if="videoCollects.length > 0">
-						<view v-for="(item, idx) in videoCollects" :key="idx" class="video-item">
+						<view v-for="(item, idx) in videoCollects" :key="item.id" class="video-item">
 							<!-- 瑙嗛灏侀潰+鎾斁鎸夐挳 -->
-							<view class="video-cover-container">
+							<view class="video-cover-container" @click="jumpToPlay(idx)">
 								<image :src="item.coverUrl" mode="aspectFill" class="video-cover" />
 								<view class="play-icon">
 									<u-icon name="play-circle-fill" size="60" color="#fff"></u-icon>
@@ -26,7 +26,7 @@
 							</view>
 
 							<!-- 瑙嗛淇℃伅 -->
-							<view class="video-info">
+							<view class="video-info" @click="jumpToPlay(idx)">
 								<view class="video-title">{{ item.authorName || '鏈煡浣滆��' }}</view>
 								<view class="video-meta">
 									<text class="video-weight" v-if="item.weight > 0">
@@ -38,7 +38,7 @@
 
 							<!-- 鎿嶄綔鎸夐挳 -->
 							<view class="video-actions">
-								<button class="cancel-btn" @click.stop="handleCancelCollection(item,'video')">
+								<button class="cancel-btn" @click.stop="handleCancelCollection(item,'video',idx)">
 									鍙栨秷鏀惰棌
 								</button>
 							</view>
@@ -65,7 +65,7 @@
 				<scroll-view scroll-y class="activity-list" style="height: 100vh;" @scrolltolower="loadMore"
 					:lower-threshold="100">
 					<view v-if="goodsCollects.length > 0">
-						<view v-for="(item, idx) in goodsCollects" :key="idx" class="activity-item">
+						<view v-for="(item, idx) in goodsCollects" :key="item.id" class="activity-item">
 							<!-- 灏侀潰鍖哄煙 -->
 							<block>
 								<image :src="item.original" mode="aspectFill" class="activity-cover" />
@@ -82,7 +82,7 @@
 
 							<!-- 鎿嶄綔鍖哄煙 -->
 							<view class="action-container">
-								<button class="cancel-btn" @click="handleCancelCollection(item,'goods')"
+								<button class="cancel-btn" @click="handleCancelCollection(item,'goods',idx)"
 									hover-class="cancel-btn-hover">
 									鍙栨秷鏀惰棌
 								</button>
@@ -109,7 +109,7 @@
 				<scroll-view scroll-y class="activity-list" style="height: 80vh;" @scrolltolower="loadMore"
 					:lower-threshold="100">
 					<view v-if="activityCollects.length > 0">
-						<view v-for="(item, idx) in activityCollects" :key="idx" class="activity-item">
+						<view v-for="(item, idx) in activityCollects" :key="item.id" class="activity-item">
 							<!-- 灏侀潰鍖哄煙 -->
 							<block v-if="item.coverType === '鍥剧墖' || item.coverType === '瑙嗛'">
 								<image :src="item.cover" mode="aspectFill" class="activity-cover" />
@@ -128,7 +128,7 @@
 							</view>
 							<!-- 鎿嶄綔鍖哄煙 -->
 							<view class="action-container">
-								<button class="cancel-btn" @click="handleCancelCollection(item,'activity')"
+								<button class="cancel-btn" @click="handleCancelCollection(item,'activity', idx)"
 									hover-class="cancel-btn-hover">
 									鍙栨秷鏀惰棌
 								</button>
@@ -165,6 +165,8 @@
 
 <script>
 	import '@/components/uview-components/uview-ui';
+	import storage from '@/utils/storage';
+	import {getAuthorCollectVideoPage} from '@/api/user.js'
 	import {
 		getFilePreviewUrl
 	} from '@/api/common.js'
@@ -181,11 +183,7 @@
 			return {
 				total: 0,
 				loading: false,
-				noMore: {
-					video: false,
-					goods: false,
-					activity: false
-				},
+				noMore: false,
 				currentTab: 0, // 褰撳墠閫変腑鐨則ab绱㈠紩
 				tabs: ['瑙嗛', '鍟嗗搧', '娲诲姩'],
 				//
@@ -197,6 +195,7 @@
 					refId: '',
 				},
 				query: {
+					authorId: '',
 					type: 'video',
 					pageNumber: 1,
 					pageSize: 5,
@@ -205,11 +204,22 @@
 		},
 		onLoad() {
 			this.currentTab = 0;
-			//TODO 鏈櫥褰曢渶瑕乮d锛屾祴璇曠敤鍐欐\
+			this.query.authorId = storage.getUserInfo().id
 			this.getintit()
 		},
 		methods: {
-
+			jumpToPlay(index) {
+				const playInfo = {
+					  videoList: this.videoCollects,
+					  nomore: this.noMore,
+					  pageNumber: this.query.pageNumber,
+					  playIndex: index
+				}
+				uni.setStorageSync("playInfo", playInfo)
+				uni.navigateTo({
+				  url: `/pages/video/video-play?authorId=${this.query.authorId}&videoFrom=collect`
+				});
+			},
 			/**
 			 * 涓嬫媺鍒锋柊鏃�
 			 */
@@ -224,25 +234,31 @@
 			},
 			loadMore() {
 				this.loading = true;
-				this.query.pageNumber += 1;
 				// 寤惰繜鎵ц璁︰I鏈夊弽搴旀椂闂�
 				setTimeout(() => {
 					this.query.pageNumber += 1;
 					this.getintit();
 				}, 300);
 			},
-			handleCancelCollection(item, type) {
+			handleCancelCollection(item, type, index) {
 				console.log(item)
 				this.collectForm.collectType = type;
 				this.collectForm.refId = item.id;
 				changeCollect(this.collectForm).then(res => {
-					if (res.statusCode === 200) {
+					if (res.data.code === 200) {
 						uni.showToast({
 							title: res.data.msg, // 鎻愮ず鏂囧瓧
 							icon: 'none', // 鍥炬爣绫诲瀷锛坰uccess/loading/none锛�
 							mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛堥槻姝㈣Е鎽哥┛閫忥級
 						});
-						this.getintit();
+						this.query.pageNumber = 1
+						// 鍥犱负瑙嗛璧扮殑mq鏈夊欢杩燂紝鍓嶇鐩存帴鍒犻櫎璇ュ厓绱犺揪鍒版晥鏋�
+						if (type === 'video') {
+							this.videoCollects.splice(index, 1)
+						} else {
+							this.noMore = false
+							this.getintit()
+						}
 					}
 
 				})
@@ -272,11 +288,11 @@
 				});
 				if (this.currentTab === 0) {
 					this.query.type = 'video';
-					getMyCollectList(this.query).then(res => {
+					getAuthorCollectVideoPage(this.query).then(res => {
 						uni.hideLoading();
 						this.loading = false;
 
-						if (res.statusCode === 200) {
+						if (res.data.code === 200) {
 							const newData = res.data.data
 							this.total = res.data.total || 0;
 							// 杩藉姞鎴栨浛鎹㈡暟鎹�
@@ -286,7 +302,6 @@
 							// 鍒ゆ柇鏄惁杩樻湁鏇村鏁版嵁
 							this.noMore = newData.length < this.query.pageSize ||
 								this.videoCollects.length >= this.total;
-
 						}
 					})
 				} else if (this.currentTab === 1) {
@@ -294,7 +309,7 @@
 					getMyCollectList(this.query).then(res => {
 						uni.hideLoading();
 						this.loading = false;
-						if (res.statusCode === 200) {
+						if (res.data.code === 200) {
 							const newData = res.data.data
 							this.total = res.data.total || 0;
 
@@ -311,7 +326,7 @@
 					getMyCollectList(this.query).then(res => {
 						uni.hideLoading();
 						this.loading = false;
-						if (res.statusCode === 200) {
+						if (res.data.code === 200) {
 							const newData = res.data.data
 							this.total = res.data.total || 0;
 

--
Gitblit v1.8.0