From 81e386b0388c39dff2da2d8004f197fd06c398e4 Mon Sep 17 00:00:00 2001 From: Seven Tsui <16225583+youyouliangshao@user.noreply.gitee.com> Date: Mon, 15 Sep 2025 17:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E8=A7=86=E9=A2=91=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E5=92=8C=E5=88=A0=E9=99=A4=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/api/video_api.dart | 3 ++ lib/pages/chat/notify/system.dart | 2 +- lib/pages/my/index.dart | 27 +++++++++++++++--- lib/pages/my/vloger.dart | 47 ++++++++++++++++--------------- 4 files changed, 51 insertions(+), 28 deletions(-) diff --git a/lib/api/video_api.dart b/lib/api/video_api.dart index 0cc561a..451142e 100644 --- a/lib/api/video_api.dart +++ b/lib/api/video_api.dart @@ -23,4 +23,7 @@ class VideoApi { static const String changeVlogStatus = '/app/vlog/changeVlogStatus'; //修改我的视频状态(删除视频) static const String changeToPublic = '/app/vlog/changeToPublic'; //将视频改为公开状态 static const String changeToPrivate = '/app/vlog/changeToPrivate'; //将视频改为私密状态 + + static const String deleteVideo = '/app/vlog/delete'; //删除当前用户的视频 + static const String getVideoListByMemberId = '/app/vlog/page'; //查询某人的作品 } diff --git a/lib/pages/chat/notify/system.dart b/lib/pages/chat/notify/system.dart index 7b3fa6e..3fa5245 100644 --- a/lib/pages/chat/notify/system.dart +++ b/lib/pages/chat/notify/system.dart @@ -176,7 +176,7 @@ class SystemState extends State { "socialCode": value }); if(res != null && res['code'] == 200){ - MyDialog.toast('推广码绑定失败', icon: const Icon(Icons.check_circle), style: ToastStyle(backgroundColor: Colors.green.withAlpha(200))); + MyDialog.toast('推广码绑定成功', icon: const Icon(Icons.check_circle), style: ToastStyle(backgroundColor: Colors.green.withAlpha(200))); Get.toNamed('/vloger', arguments: {'memberId':value}); } } catch (e) { diff --git a/lib/pages/my/index.dart b/lib/pages/my/index.dart index 3dff36b..5c074bd 100644 --- a/lib/pages/my/index.dart +++ b/lib/pages/my/index.dart @@ -246,6 +246,22 @@ class MyPageState extends State with SingleTickerProviderStateMixin { } } + // 删除当前用户发布的视频 + void deletePersonalVideo(videoId) async { + logger.i('删除视频${videoId}'); + try { + final res = await Http.post('${VideoApi.deleteVideo}', data: { + 'vlogerId':videoId + }); + logger.i('删除成功响应${res}'); + if(res != null && res['code'] == 200){ + MyDialog.toast('删除成功', icon: const Icon(Icons.check_circle), style: ToastStyle(backgroundColor: Colors.green.withAlpha(200))); + loadData(0); + } + } catch (e) { + + } + } // 二维码名片弹窗 void qrcodeAlertDialog(BuildContext context) { showDialog( @@ -525,7 +541,7 @@ class MyPageState extends State with SingleTickerProviderStateMixin { borderRadius: BorderRadius.circular(10.0), ), alignment: Alignment.center, - child: _buildVdCard(listToShow[index]), + child: _buildVdCard(listToShow[index],tabIndex), ); }, childCount: listToShow.length, @@ -551,14 +567,15 @@ class MyPageState extends State with SingleTickerProviderStateMixin { }); } - Widget _buildVdCard(item) { + Widget _buildVdCard(item,tabIndex) { return InkWell( onTap: () { //去视频详情 Get.toNamed('/videoDetail', arguments: {'videoId': item['id']}); }, onLongPress: () { - showModalBottomSheet( + if(tabIndex == 0){ // 个人发布作品可以长按删除 + showModalBottomSheet( context: Get.context!, backgroundColor: Colors.white, shape: const RoundedRectangleBorder( @@ -588,7 +605,7 @@ class MyPageState extends State with SingleTickerProviderStateMixin { ); if (confirmed == true) { Get.back(); - // TODO: 删除逻辑 + deletePersonalVideo(item['id']); } }, ), @@ -597,6 +614,8 @@ class MyPageState extends State with SingleTickerProviderStateMixin { ); }, ); + } + }, child: Container( decoration: BoxDecoration( diff --git a/lib/pages/my/vloger.dart b/lib/pages/my/vloger.dart index 134ef35..40d8500 100644 --- a/lib/pages/my/vloger.dart +++ b/lib/pages/my/vloger.dart @@ -4,7 +4,9 @@ import 'package:get/get.dart'; import 'package:get/get_rx/src/rx_typedefs/rx_typedefs.dart'; import 'package:loopin/IM/controller/chat_controller.dart'; import 'package:loopin/IM/im_service.dart'; +import 'package:loopin/service/http.dart'; import 'package:loopin/components/custom_sticky_header.dart'; +import 'package:loopin/api/video_api.dart'; import 'package:loopin/components/network_or_asset_image.dart'; import 'package:loopin/components/only_down_scroll_physics.dart'; import 'package:loopin/styles/index.dart'; @@ -124,29 +126,28 @@ class MyPageState extends State with SingleTickerProviderStateMixin { final index = tabIndex ?? currentTabIndex.value; if (index == 0) { if (itemsParams.isLoading || !itemsParams.hasMore) return; - - itemsParams.isLoading = true; - - await Future.delayed(const Duration(seconds: 1)); - - // 模拟生成新数据 - List newItems = List.generate( - itemsParams.pageSize, - (i) => '作品 ${(itemsParams.page - 1) * itemsParams.pageSize + i + 1}', - ); - - // 模拟判断是否还有更多数据 - if (itemsParams.page >= 2) { - itemsParams.hasMore = false; - } - - // 添加新数据,触发响应式更新 - items.addAll(newItems); - - // 页码加一 - itemsParams.page++; - - itemsParams.isLoading = false; + itemsParams.isLoading = true; + final res = await Http.post(VideoApi.getVideoListByMemberId, data: { + "memberId": args['memberId'], + "current": itemsParams.page, + "size": itemsParams.pageSize, + }); + final obj = res['data']; + final total = obj['total']; + final row = obj['records'] ?? []; + logger.i(res['data']); + // 判断是否还有更多数据 + logger.e(items.length); + // 添加新数据,触发响应式更新 + items.addAll(row); + logger.e(obj); + if (items.length >= total) { + itemsParams.hasMore = false; + } + // 页码加一 + itemsParams.page++; + // + itemsParams.isLoading = false; } }