From 4f9a8b45f77974a5f59fc3e9f5820f03828d8be9 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期三, 18 六月 2025 17:58:26 +0800 Subject: [PATCH] 视频编辑、下架、删除功能 --- pages/video/home-page.vue | 82 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 72 insertions(+), 10 deletions(-) diff --git a/pages/video/home-page.vue b/pages/video/home-page.vue index 76ca651..5ce3063 100644 --- a/pages/video/home-page.vue +++ b/pages/video/home-page.vue @@ -73,9 +73,10 @@ <view class="stat"> <uni-icons type="heart" size="16" color="#fff"></uni-icons> <text>{{item.collectNum}}</text> - <view class="more-op"> + <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" @@ -118,6 +119,18 @@ <!-- <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> @@ -125,16 +138,20 @@ import DropdownMenu from '@/components/dropdown-menu.vue' import {getAuthorInfo, getAuthorVideoPage, getAuthorCollectVideoPage} from '@/api/user.js' -import {subscribe, unSubscribe} from '@/api/video.js' +import {subscribe, unSubscribe, delVideo, updateVideo, userDownVideo} from '@/api/video.js' export default { components: {DropdownMenu}, data() { return { - options: [ - { command: 1, label: '鍖椾含' }, - { command: 2, label: '涓婃捣' }, - { command: 3, label: '骞垮窞' } - ], + options: [ + { command: 1, label: '鍖椾含' }, + { command: 2, label: '涓婃捣' }, + { command: 3, label: '骞垮窞' } + ], + opVideo: { // 姝e湪鎿嶄綔鐨勮棰� + id: '', + title: '' + }, currentTab: 'works', // works: 浣滃搧, likes: 鍠滄 authorId: '', userInfo: { @@ -174,9 +191,54 @@ this.getAuthorVideoPage(); }, methods: { - handleChange(value) { - console.log('閫変腑鍊�:', value) - }, + 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) { -- Gitblit v1.8.0