From 92f77d2d656a48d1d11dbfc7d0be3b756d364962 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 4 Jun 2023 22:54:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8A=95=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/video.dart | 18 +++++ .../video/detail/introduction/controller.dart | 66 ++++++++++++++++--- 2 files changed, 75 insertions(+), 9 deletions(-) diff --git a/lib/http/video.dart b/lib/http/video.dart index 994d8e09..fd617a70 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -115,6 +115,24 @@ class VideoHttp { } } + // 投币 + static Future coinVideo({required String aid, required int multiply}) async { + var res = await Request().post( + Api.coinVideo, + queryParameters: { + 'aid': aid, + 'multiply': multiply, + 'select_like': 0, + 'csrf': await Request.getCsrf(), + }, + ); + if (res.data['code'] == 0) { + return {'status': true, 'data': res.data['data']}; + } else { + return {'status': true, 'data': [], 'msg': ''}; + } + } + // 获取收藏状态 static Future hasFavVideo({required String aid}) async { var res = await Request().get(Api.hasFavVideo, data: {'aid': aid}); diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index 4dfadeb8..697c7319 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -46,6 +46,7 @@ class VideoIntroController extends GetxController { List delMediaIdsNew = []; // 关注状态 默认未关注 RxMap followStatus = {}.obs; + int _tempThemeValue = -1; @override void onInit() { @@ -167,7 +168,7 @@ class VideoIntroController extends GetxController { if (!hasLike.value) { SmartDialog.showToast('点赞成功 👍'); hasLike.value = true; - } else if(hasLike.value){ + } else if (hasLike.value) { SmartDialog.showToast('取消赞'); hasLike.value = false; } @@ -179,7 +180,56 @@ class VideoIntroController extends GetxController { // 投币 Future actionCoinVideo() async { - print('投币'); + showDialog( + context: Get.context!, + builder: (context) { + return AlertDialog( + title: const Text('选择投币个数'), + contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12), + content: StatefulBuilder(builder: (context, StateSetter setState) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + RadioListTile( + value: 1, + title: const Text('1枚'), + groupValue: _tempThemeValue, + onChanged: (value) { + _tempThemeValue = value!; + Get.appUpdate(); + }, + ), + RadioListTile( + value: 2, + title: const Text('2枚'), + groupValue: _tempThemeValue, + onChanged: (value) { + _tempThemeValue = value!; + Get.appUpdate(); + }, + ), + ], + ); + }), + actions: [ + TextButton(onPressed: () => Get.back(), child: const Text('取消')), + TextButton( + onPressed: () async { + var res = await VideoHttp.coinVideo( + aid: aid, multiply: _tempThemeValue); + print(res); + if (res['status']) { + SmartDialog.showToast('投币成功'); + } else { + SmartDialog.showToast(res['msg']); + } + Get.back(); + queryHasCoinVideo(); + }, + child: const Text('确定')) + ], + ); + }); } // (取消)收藏 @@ -211,9 +261,8 @@ class VideoIntroController extends GetxController { // 分享视频 Future actionShareVideo() async { - var result = await Share.share( - '${HttpString.baseUrl}/video/$aid' - ).whenComplete(() { + var result = + await Share.share('${HttpString.baseUrl}/video/$aid').whenComplete(() { print("share completion block "); }); return result; @@ -253,11 +302,11 @@ class VideoIntroController extends GetxController { } // 关注/取关up - Future actionRelationMod() async{ + Future actionRelationMod() async { int currentStatus = followStatus['attribute']; print(currentStatus); int actionStatus = 0; - switch(currentStatus) { + switch (currentStatus) { case 0: actionStatus = 1; break; @@ -287,7 +336,7 @@ class VideoIntroController extends GetxController { reSrc: 14, ); if (result['status']) { - switch(currentStatus) { + switch (currentStatus) { case 0: actionStatus = 2; break; @@ -309,6 +358,5 @@ class VideoIntroController extends GetxController { ); }, ); - } }