From 63116e19824ceabc68a72f10b134d815f462e711 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期四, 23 十月 2025 20:21:49 +0800
Subject: [PATCH] 抽奖页面调整
---
pages/video/home-page.vue | 374 +++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 303 insertions(+), 71 deletions(-)
diff --git a/pages/video/home-page.vue b/pages/video/home-page.vue
index 11cc980..5580ded 100644
--- a/pages/video/home-page.vue
+++ b/pages/video/home-page.vue
@@ -4,9 +4,6 @@
<view class="user-header">
<view class="user-avatar-container">
<image class="user-avatar" :src="userInfo.avatar" mode="aspectFill"></image>
- <view class="edit-icon" @click="editProfile" v-if="isSelf">
- <uni-icons type="compose" size="20" color="#666"></uni-icons>
- </view>
</view>
<view class="user-info">
<view class="user-name">{{userInfo.nickName}}</view>
@@ -27,67 +24,109 @@
<text class="stat-label">鑾疯禐</text>
</view>
</view>
-
+
<!-- 鍏虫敞鎸夐挳 -->
<view class="follow-btn-container" v-if="!userInfo.self">
- <button
- class="follow-btn"
- :class="{followed: userInfo.hasSub}"
+ <button
+ class="follow-btn"
+ :class="{followed: userInfo.hasSub}"
@click="toggleFollow"
>
{{userInfo.hasSub ? '鍙栨秷鍏虫敞' : '鍏虫敞'}}
</button>
</view>
+
+ <view class="edit-icon" @click="editInfo" v-if="userInfo.self">
+ <uni-icons type="compose" size="20" color="#666"></uni-icons>缂栬緫涓婚〉淇℃伅
+ </view>
</view>
-
+
<!-- 浣滃搧/鍠滄鍒囨崲 -->
<view class="tab-bar">
- <view
- class="tab-item"
- :class="{active: currentTab === 'works'}"
+ <view
+ class="tab-item"
+ :class="{active: currentTab === 'works'}"
@click="switchTab('works')"
>
浣滃搧{{`(${videoTotal})`}}
</view>
- <view
- class="tab-item"
- :class="{active: currentTab === 'likes'}"
- @click="switchTab('likes')"
+ <view
+ class="tab-item"
+ :class="{active: currentTab === 'collect'}"
+ @click="switchTab('collect')"
>
- 鍠滄
+ 鏀惰棌
</view>
+ <view
+ class="tab-item"
+ :class="{active: currentTab === 'likes'}"
+ @click="switchTab('likes')"
+ >
+ 鍠滄
+ </view>
</view>
-
+
+
+
<!-- 瑙嗛鍒楄〃 -->
<scroll-view class="video-list" scroll-y :show-scrollbar="false" @scrolltolower="getPage" v-show="currentTab === 'works' && videoList.length > 0">
<view class="video-container">
<view
- class="video-item"
- v-for="(item, index) in videoList"
+ class="video-item"
+ v-for="(item, index) in videoList"
:key="item.id"
- @click="playAuthorVideo(index)"
>
- <image class="video-cover" :src="item.coverUrl" mode="aspectFill"></image>
+ <image v-if="item.videoContentType === 'img'" class="video-cover" @click="playAuthorVideo(index)" :src="item.imgs[0]" mode="aspectFill"></image>
+ <!-- <image class="video-cover" @click="playAuthorVideo(index)" :src="item.videoContentType === 'video' ? item.coverUrl : item.imgs[0]" mode="aspectFill"></image> -->
+ <video v-else :src="item.videoUrl"
+ :poster-for-crawler='item.coverUrl'
+ object-fit='"cover"'
+ :show-fullscreen-btn='false'
+ :show-play-btn='false'
+ :show-center-play-btn='false'
+ :enable-progress-gesture='false'
+ class="video-cover" @click="playAuthorVideo(index)"></video>
<view class="video-info">
<view class="video-stats">
<view class="stat">
<uni-icons type="heart" size="16" color="#fff"></uni-icons>
<text>{{item.collectNum}}</text>
+ <view class="more-op" v-if="userInfo.self">
+ <dropdown-menu
+ :options="item.options"
+ :data="{id: item.id, title: item.title}"
+ placement="top"
+ theme-color="#07C160"
+ @change="handleChange"
+ ></dropdown-menu>
+ </view>
</view>
</view>
</view>
- </view>
+ </view>
</view>
</scroll-view>
- <scroll-view class="video-list" scroll-y :show-scrollbar="false" @scrolltolower="getPage" v-show="currentTab === 'likes' && collectVideoList.length > 0">
+ <view>
+ <mycollect v-show ="currentTab ==='collect'"></mycollect>
+ </view>
+ <!-- <scroll-view class="video-list" scroll-y :show-scrollbar="false" @scrolltolower="getPage" v-show="currentTab === 'collect' && collectVideoList.length > 0">
<view class="video-container">
<view
- class="video-item"
- v-for="(item, index) in collectVideoList"
+ class="video-item"
+ v-for="(item, index) in collectVideoList"
:key="item.id"
@click="playCollectVideo(index)"
>
- <image class="video-cover" :src="item.coverUrl" mode="aspectFill"></image>
+ <image v-if="tem.videoContentType === 'img'" class="video-cover" :src="item.imgs[0]" mode="aspectFill"></image>
+ <video v-else class="video-cover"
+ :src="item.videoUrl"
+ initial-time='0.01'
+ muted
+ :controls="false"
+ :show-center-play-btn="false"
+ object-fit="cover"></video>
+
+
<view class="video-info">
<view class="video-stats">
<view class="stat">
@@ -96,29 +135,86 @@
</view>
</view>
</view>
- </view>
+ </view>
+ </view>
+ </scroll-view> -->
+ <scroll-view class="video-list" scroll-y :show-scrollbar="false" @scrolltolower="getPage" v-show="currentTab === 'likes' && likeVideoList.length > 0">
+ <view class="video-container">
+ <view
+ class="video-item"
+ v-for="(item, index) in likeVideoList"
+ :key="item.id"
+ @click="playLikeVideo(index)"
+ >
+ <video class="video-cover"
+ :src="item.videoContentType === 'video' ? item.videoUrl : item.imgs[0]" mode="aspectFill"
+ initial-time='0.01'
+ muted
+ :controls="false"
+ :show-center-play-btn="false"
+ object-fit="cover"></video>
+ <view class="video-info">
+ <view class="video-stats">
+ <view class="stat">
+ <uni-icons type="heart" size="16" color="#fff"></uni-icons>
+ <text>{{item.collectNum}}</text>
+ </view>
+ </view>
+ </view>
+ </view>
</view>
</scroll-view>
-
+
<!-- 绌虹姸鎬� -->
<view class="empty-state" v-if="videoList.length === 0 && currentTab === 'works'">
<!-- <image src="/static/images/empty.png" mode="aspectFit" class="empty-image"></image> -->
<text class="empty-text">杩樻湭鍙戝竷浣滃搧鍝</text>
</view>
<!-- 绌虹姸鎬� -->
- <view class="empty-state" v-if="collectVideoList.length === 0 && currentTab === 'likes'">
+ <view class="empty-state" v-if="collectVideoList.length === 0 && currentTab === 'collect'">
+ <!-- <image src="/static/images/empty.png" mode="aspectFit" class="empty-image"></image> -->
+ <text class="empty-text">杩樻病鏈夋敹钘忎綔鍝佸摝~</text>
+ </view>
+ <!-- 绌虹姸鎬� -->
+ <view class="empty-state" v-if="likeVideoList.length === 0 && currentTab === 'likes'">
<!-- <image src="/static/images/empty.png" mode="aspectFit" class="empty-image"></image> -->
<text class="empty-text">杩樻病鏈夌偣璧炰綔鍝佸摝~</text>
</view>
+
+ <!-- 鍒犻櫎瑙嗛鎻愰啋妗� -->
+ <uni-popup ref="delDialog" type="dialog">
+ <uni-popup-dialog type="error" cancelText="鍙栨秷" confirmText="鍒犻櫎" title="鎻愰啋" :content="`鎮ㄦ鍦ㄥ垹闄わ細${opVideo.title}`" @confirm="deleteVideo"
+ @close="dialogClose"></uni-popup-dialog>
+ </uni-popup>
+
+ <!-- 涓嬫灦瑙嗛鎻愰啋妗� -->
+ <uni-popup ref="downDialog" type="dialog">
+ <uni-popup-dialog type="error" cancelText="鍙栨秷" confirmText="涓嬫灦" title="鎻愰啋" :content="`鎮ㄦ鍦ㄤ笅鏋讹細${opVideo.title}`" @confirm="downVideo"
+ @close="dialogClose"></uni-popup-dialog>
+ </uni-popup>
</view>
</template>
<script>
-import {getAuthorInfo, getAuthorVideoPage, getAuthorCollectVideoPage} from '@/api/user.js'
-import {subscribe, unSubscribe} from '@/api/video.js'
+import DropdownMenu from '@/pages/video/dropdown-menu.vue'
+
+import {getAuthorInfo, getAuthorVideoPage, getAuthorCollectVideoPage, getAuthorLikeVideoPage} from '@/api/user.js'
+import {subscribe, unSubscribe, delVideo, updateVideo, userDownVideo} from '@/api/video.js'
+import mycollect from '@/pages/video/myCollect.vue'
export default {
+ components: {DropdownMenu,
+ mycollect},
data() {
return {
+ options: [
+ { command: 1, label: '鍖椾含' },
+ { command: 2, label: '涓婃捣' },
+ { command: 3, label: '骞垮窞' }
+ ],
+ opVideo: { // 姝e湪鎿嶄綔鐨勮棰�
+ id: '',
+ title: ''
+ },
currentTab: 'works', // works: 浣滃搧, likes: 鍠滄
authorId: '',
userInfo: {
@@ -142,19 +238,100 @@
pageNumber: 1,
pageSize: 10
},
+ likeVideoQuery: {
+ authorId: '',
+ pageNumber: 1,
+ pageSize: 10
+ },
videoTotal: 0,
videoList: [], // 浣滃搧
collectVideoList: [], // 鏀惰棌
+ likeVideoList: [], // 鐐硅禐
nomoreVideo: false,
- nomoreCollectVideo: false
+ nomoreCollectVideo: false,
+ nomoreLikeVideo: false,
}
},
+ onShow() {
+ if (this.authorId) {
+ this.getAuthorInfo();
+ if (this.currentTab === 'works') {
+ this.videoQuery.pageNumber = 1
+ this.nomoreVideo = false
+ this.getAuthorVideoPage();
+ } else if (this.currentTab === 'collect') {
+ this.collectVideoQuery.pageNumber = 1
+ this.nomoreCollectVideo = false
+ this.getAuthorCollectVideoPage()
+ } else if (this.currentTab === 'likes') {
+ this.likeVideoQuery.pageNumber = 1
+ this.nomoreLikeVideo = false
+ this.getAuthorLikeVideoPage()
+ }
+ }
+ },
onLoad(option) {
+ console.log("鏀跺埌鍙傛暟", option);
this.authorId = option.authorId;
this.getAuthorInfo();
this.getAuthorVideoPage();
},
methods: {
+ getCoverUrl(item) {
+ if (item.videoContentType === 'video') {
+ // OSS瑙嗛灏侀潰鍙傛暟锛堝畬鏁存牸寮忥級
+ return `${item.videoUrl}?x-oss-process=video/snapshot,t_1000,f_jpg,m_fast`
+ }
+ return item.imgs?.[0]
+ },
+ dialogClose() {
+ this.opVideo = {
+ id: '',
+ title: ''
+ }
+ },
+ // 涓嬫灦瑙嗛
+ downVideo() {
+ userDownVideo(this.opVideo.id).then(res => {
+ uni.showToast({
+ title: '涓嬫灦鎴愬姛',
+ duration: 2000
+ });
+ // 鍒锋柊鏁版嵁
+ this.videoList = [];
+ this.videoQuery.pageNumber = 1;
+ this.getAuthorVideoPage();
+ })
+ },
+ // 鍒犻櫎瑙嗛
+ deleteVideo() {
+ delVideo(this.opVideo.id).then(res => {
+ uni.showToast({
+ title: '鍒犻櫎鎴愬姛',
+ duration: 2000
+ });
+ // 鍒锋柊鏁版嵁
+ this.videoList = [];
+ this.videoQuery.pageNumber = 1;
+ this.getAuthorVideoPage();
+ })
+ },
+ // 瑙﹀彂瑙嗛鎿嶄綔
+ handleChange(value, data) {
+ console.log('閫変腑鍊�:', value)
+ this.opVideo.id = data.id;
+ this.opVideo.title = data.title;
+ if (value === 'DELETE') {
+ this.$refs.delDialog.open()
+ } else if (value === 'DOWN') {
+ this.$refs.downDialog.open()
+ } else if (value === 'EDIT') {
+ // 璺宠浆缂栬緫瑙嗛椤甸潰
+ uni.navigateTo({
+ url: `/pages/video/video-edit?id=${this.opVideo.id}`
+ });
+ }
+ },
getPage() {
if(this.currentTab === 'works') {
if(this.nomoreVideo) {
@@ -177,7 +354,7 @@
this.videoQuery.pageNumber += 1;
}
})
- } else if(this.currentTab === 'likes') {
+ } else if(this.currentTab === 'collect') {
if(this.nomoreCollectVideo) {
return;
}
@@ -196,6 +373,27 @@
this.nomoreCollectVideo = true;
} else {
this.collectVideoQuery.pageNumber += 1;
+ }
+ })
+ } else if(this.currentTab === 'likes') {
+ if(this.nomoreLikeVideo) {
+ return;
+ }
+ getAuthorLikeVideoPage(this.likeVideoQuery).then(res => {
+ if(this.likeVideoQuery.pageNumber === 1) {
+ this.likeVideoList = res.data.data
+ } else {
+ this.likeVideoList = [
+ ...this.likeVideoList,
+ ...res.data.data.filter(
+ (newItem) => !this.likeVideoList.some((oldItem) => oldItem.id === newItem.id)
+ ),
+ ];
+ }
+ if(res.data.data.length < this.likeVideoQuery.pageSize) {
+ this.nomoreLikeVideo = true;
+ } else {
+ this.likeVideoQuery.pageNumber += 1;
}
})
}
@@ -249,14 +447,34 @@
this.currentTab = tab;
if(tab === 'works') {
this.collectVideoList = []
+ this.likeVideoList = []
this.videoQuery.pageNumber = 1
+ this.nomoreVideo = false
this.getAuthorVideoPage()
+ } else if(tab === 'collect') {
+ this.videoList = []
+ this.likeVideoList = []
+ this.collectVideoQuery.pageNumber = 1
+ this.nomoreCollectVideo = false
+ this.getAuthorCollectVideoPage()
} else if(tab === 'likes') {
this.videoList = []
- this.collectVideoQuery.pageNumber = 1
- this.getAuthorCollectVideoPage()
+ this.collectVideoList = []
+ this.likeVideoQuery.pageNumber = 1
+ this.nomoreLikeVideo = false
+ this.getAuthorLikeVideoPage()
}
},
+ // 鑾峰彇浣滆�呭枩娆㈢殑瑙嗛
+ async getAuthorLikeVideoPage() {
+ this.likeVideoQuery.authorId = this.authorId
+ getAuthorLikeVideoPage(this.likeVideoQuery).then(res => {
+ this.likeVideoList = res.data.data
+ if(res.data.data.length < this.likeVideoQuery.pageSize) {
+ this.nomoreLikeVideo = true;
+ }
+ })
+ },
// 鑾峰彇浣滆�呯殑鏀惰棌瑙嗛
async getAuthorCollectVideoPage() {
this.collectVideoQuery.authorId = this.authorId
@@ -281,7 +499,7 @@
});
},
// 鎾斁鏀惰棌瑙嗛
- playAuthorVideo(index) {
+ playCollectVideo(index) {
const playInfo = {
videoList: this.collectVideoList,
nomore: this.nomoreCollectVideo,
@@ -293,20 +511,33 @@
url: `/pages/video/video-play?authorId=${this.authorId}&videoFrom=collect`
});
},
+ // 鎾斁鐐硅禐瑙嗛
+ playLikeVideo(index) {
+ const playInfo = {
+ videoList: this.likeVideoList,
+ nomore: this.nomoreLikeVideo,
+ pageNumber: this.likeVideoQuery.pageNumber,
+ playIndex: index
+ }
+ uni.setStorageSync("playInfo", playInfo)
+ uni.navigateTo({
+ url: `/pages/video/video-play?authorId=${this.authorId}&videoFrom=like`
+ });
+ },
// 缂栬緫涓汉璧勬枡
- editProfile() {
+ editInfo() {
uni.navigateTo({
- url: '/pages/user/edit'
+ url: `/pages/video/home-page-edit?authorId=${this.authorId}&avatar=${this.userInfo.avatar}&motto=${this.userInfo.motto || ''}&nickName=${this.userInfo.nickName}`
});
},
-
+
// 璺宠浆鍒扮矇涓�/鍏虫敞鍒楄〃
navigateToFollow(type) {
uni.navigateTo({
url: `/pages/user/follow?type=${type}`
});
},
-
+
// 璺宠浆鍒扮偣璧炲垪琛�
navigateToLike() {
uni.navigateTo({
@@ -351,16 +582,13 @@
.edit-icon {
position: absolute;
- right: 0;
- bottom: 0;
+ right: 30rpx;
+ top: 30rpx;
background-color: #fff;
- border-radius: 50%;
- width: 40rpx;
height: 40rpx;
display: flex;
justify-content: center;
align-items: center;
- box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
}
.user-info {
@@ -443,16 +671,21 @@
}
.video-list {
- width: calc(100% - 20rpx);
- padding: 0 10rpx;
- height: calc(100vh - 554rpx);
- background-color: #fff;
+ width: 100%;
+ padding: 0 10rpx;
+ height: calc(100vh - 554rpx);
+ background-color: #fff;
+}
+
+.video-container {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: space-between;
}
.video-item {
- width: 50%;
- padding: 10rpx;
- box-sizing: border-box;
+ width: 49%;
+ margin-bottom: 20rpx;
position: relative;
}
@@ -465,11 +698,11 @@
.video-info {
position: absolute;
- bottom: 20rpx;
- left: 20rpx;
- right: 20rpx;
- color: #fff;
- font-size: 24rpx;
+ bottom: 10rpx;
+ left: 0;
+ right: 0;
+ padding: 0 10rpx;
+ box-sizing: border-box;
}
.video-title {
@@ -483,17 +716,25 @@
.video-stats {
display: flex;
+ width: 100%;
}
.stat {
display: flex;
+ width: 100%;
align-items: center;
- margin-right: 20rpx;
- text-shadow: 0 0 5rpx rgba(0, 0, 0, 0.5);
+ position: relative;
+}
+
+.more-op {
+ position: absolute;
+ right: 0;
}
.stat text {
margin-left: 5rpx;
+ color: #fff;
+ font-size: 14px;
}
.empty-state {
@@ -530,24 +771,15 @@
height: 70rpx;
line-height: 70rpx;
padding: 0 40rpx;
-
+
&::after {
border: none;
}
-
+
&.followed {
background-color: #f5f5f5;
color: #666;
}
}
-/* 濡傛灉鏄嚜宸辩殑涓婚〉锛岄殣钘忓叧娉ㄦ寜閽� */
-.user-header {
- position: relative;
-}
-
-.video-container {
- display: flex;
- flex-wrap: wrap
-}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.8.0