diff --git a/lib/http/api.dart b/lib/http/api.dart index 44156cc2..fb69806d 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -753,4 +753,6 @@ class Api { static const String addFavArticle = '/x/article/favorites/add'; static const String replyTop = '/x/v2/reply/top'; + + static const String getCoin = '${HttpString.accountBaseUrl}/site/getCoin'; } diff --git a/lib/http/constants.dart b/lib/http/constants.dart index 325dd530..46b54796 100644 --- a/lib/http/constants.dart +++ b/lib/http/constants.dart @@ -8,5 +8,7 @@ class HttpString { static const String messageBaseUrl = 'https://message.bilibili.com'; static const String dynamicShareBaseUrl = 'https://t.bilibili.com'; static const String spaceBaseUrl = 'https://space.bilibili.com'; + static const String accountBaseUrl = 'https://account.bilibili.com'; + static const String sponsorBlockBaseUrl = 'https://www.bsbsb.top'; } diff --git a/lib/http/init.dart b/lib/http/init.dart index 7314ee03..154c6355 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -3,8 +3,10 @@ import 'dart:convert'; import 'dart:io'; import 'package:PiliPlus/build_config.dart'; import 'package:PiliPlus/http/retry_interceptor.dart'; +import 'package:PiliPlus/http/user.dart'; import 'package:PiliPlus/utils/accounts/account.dart'; import 'package:PiliPlus/utils/accounts/account_manager/account_mgr.dart'; +import 'package:PiliPlus/utils/global_data.dart'; import 'package:archive/archive.dart'; import 'package:brotli/brotli.dart'; import 'package:dio/dio.dart'; @@ -41,6 +43,17 @@ class Request { isSecure: item.secure, isHttpOnly: item.httpOnly, ))); + + if (Accounts.main.isLogin) { + getCoin(); + } + } + + static Future getCoin() async { + final res = await UserHttp.getCoin(); + if (res['status']) { + GlobalData().coins = res['data']; + } } // 从cookie中获取 csrf token diff --git a/lib/http/user.dart b/lib/http/user.dart index a270543c..ed43f3b7 100644 --- a/lib/http/user.dart +++ b/lib/http/user.dart @@ -1,5 +1,6 @@ import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/models/video/later.dart'; +import 'package:PiliPlus/utils/global_data.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:dio/dio.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -29,6 +30,7 @@ class UserHttp { var res = await Request().get(Api.userInfo); if (res.data['code'] == 0) { UserInfoData data = UserInfoData.fromJson(res.data['data']); + GlobalData().coins = data.money; return {'status': true, 'data': data}; } else { return {'status': false, 'msg': res.data['message']}; @@ -682,31 +684,12 @@ class UserHttp { } } - // 解析收藏夹视频 - // static Future parseFavVideo({ - // required int mediaId, - // required int oid, - // required String bvid, - // }) async { - // var res = await Request().get( - // 'https://www.bilibili.com/list/ml$mediaId', - // queryParameters: { - // 'oid': mediaId, - // 'bvid': bvid, - // }, - // ); - // String scriptContent = - // extractScriptContents(parse(res.data).body!.outerHtml)[0]; - // int startIndex = scriptContent.indexOf('{'); - // int endIndex = scriptContent.lastIndexOf('};'); - // String jsonContent = scriptContent.substring(startIndex, endIndex + 1); - // // 解析JSON字符串为Map - // Map jsonData = json.decode(jsonContent); - // return { - // 'status': true, - // 'data': jsonData['resourceList'] - // .map((e) => MediaVideoItemModel.fromJson(e)) - // .toList() - // }; - // } + static Future getCoin() async { + final res = await Request().get(Api.getCoin); + if (res.data['code'] == 0) { + return {'status': true, 'data': res.data['data']?['money']}; + } else { + return {'status': false, 'msg': res.data['message']}; + } + } } diff --git a/lib/pages/bangumi/introduction/controller.dart b/lib/pages/bangumi/introduction/controller.dart index 4e32f810..307f3728 100644 --- a/lib/pages/bangumi/introduction/controller.dart +++ b/lib/pages/bangumi/introduction/controller.dart @@ -8,11 +8,11 @@ import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.dart'; import 'package:PiliPlus/pages/video/detail/introduction/controller.dart'; import 'package:PiliPlus/pages/video/detail/introduction/pay_coins_page.dart'; import 'package:PiliPlus/utils/extension.dart'; +import 'package:PiliPlus/utils/global_data.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; -import 'package:get/get_navigation/src/dialog/dialog_route.dart'; import 'package:PiliPlus/http/constants.dart'; import 'package:PiliPlus/http/search.dart'; import 'package:PiliPlus/http/video.dart'; @@ -54,8 +54,10 @@ class BangumiIntroController // 是否点赞 RxBool hasLike = false.obs; + // 投币数量 + final RxInt _coinNum = 0.obs; // 是否投币 - RxBool hasCoin = false.obs; + bool get hasCoin => _coinNum.value != 0; // 是否收藏 RxBool hasFav = false.obs; dynamic videoTags; @@ -74,33 +76,12 @@ class BangumiIntroController if (Get.arguments.containsKey('bangumiItem') as bool) { preRender = true; bangumiItem = Get.arguments['bangumiItem']; - // bangumiItem!['pic'] = args.pic; - // if (args.title is String) { - // videoItem!['title'] = args.title; - // } else { - // String str = ''; - // for (Map map in args.title) { - // str += map['text']; - // } - // videoItem!['title'] = str; - // } - // if (args.stat != null) { - // videoItem!['stat'] = args.stat; - // } - // videoItem!['pubdate'] = args.pubdate; - // videoItem!['owner'] = args.owner; } } userInfo = GStorage.userInfo.get('userInfoCache'); isLogin = userInfo != null; if (isLogin && epId != null) { - // // 获取点赞状态 - // queryHasLikeVideo(); - // // 获取投币状态 - // queryHasCoinVideo(); - // // 获取收藏状态 - // queryHasFavVideo(); queryBangumiLikeCoinFav(); } @@ -142,7 +123,7 @@ class BangumiIntroController var result = await VideoHttp.bangumiLikeCoinFav(epId: epId); if (result['status']) { hasLike.value = result["data"]['like'] == 1; - hasCoin.value = result["data"]['coin_number'] != 0; + _coinNum.value = result["data"]['coin_number']; hasFav.value = result["data"]['favorite'] == 1; } else { SmartDialog.showToast(result['msg']); @@ -177,7 +158,8 @@ class BangumiIntroController hasLike.value = true; bangumiDetail.stat!['likes'] = bangumiDetail.stat!['likes'] + 1; } - hasCoin.value = true; + _coinNum.value += coin; + GlobalData().afterCoin(coin); } else { SmartDialog.showToast(res['msg']); } @@ -189,28 +171,20 @@ class BangumiIntroController SmartDialog.showToast('账号未登录'); return; } - Navigator.of(Get.context!).push( - GetDialogRoute( - pageBuilder: (buildContext, animation, secondaryAnimation) { - return PayCoinsPage( - callback: coinVideo, - ); - }, - transitionDuration: const Duration(milliseconds: 225), - transitionBuilder: (context, animation, secondaryAnimation, child) { - const begin = 0.0; - const end = 1.0; - const curve = Curves.linear; - var tween = Tween(begin: begin, end: end) - .chain(CurveTween(curve: curve)); + if (_coinNum.value >= 2) { + SmartDialog.showToast('超过投币上限啦~'); + return; + } - return FadeTransition( - opacity: animation.drive(tween), - child: child, - ); - }, - ), + if (GlobalData().coins != null && GlobalData().coins! < 1) { + SmartDialog.showToast('硬币不足'); + return; + } + + PayCoinsPage.toPayCoinsPage( + onPayCoin: coinVideo, + hasCoin: _coinNum.value == 1, ); } @@ -551,7 +525,7 @@ class BangumiIntroController SmartDialog.showToast('账号未登录'); return; } - if (hasLike.value && hasCoin.value && hasFav.value) { + if (hasLike.value && hasCoin && hasFav.value) { // 已点赞、投币、收藏 SmartDialog.showToast('已三连'); return false; @@ -559,7 +533,10 @@ class BangumiIntroController var result = await VideoHttp.triple(epId: epId, seasonId: seasonId); if (result['status']) { hasLike.value = result["data"]["like"] == 1; - hasCoin.value = result["data"]["coin"] == 1; + if (result["data"]["coin"] == 1) { + _coinNum.value = 2; + GlobalData().afterCoin(2); + } hasFav.value = result["data"]["favorite"] == 1; SmartDialog.showToast('三连成功'); } else { diff --git a/lib/pages/bangumi/introduction/view.dart b/lib/pages/bangumi/introduction/view.dart index 54df444a..3bbe324e 100644 --- a/lib/pages/bangumi/introduction/view.dart +++ b/lib/pages/bangumi/introduction/view.dart @@ -469,7 +469,7 @@ class _BangumiInfoState extends State { ), needAnim: true, hasTriple: bangumiIntroController.hasLike.value && - bangumiIntroController.hasCoin.value && + bangumiIntroController.hasCoin && bangumiIntroController.hasFav.value, callBack: (start) { if (start) { @@ -490,7 +490,7 @@ class _BangumiInfoState extends State { selectIcon: const Icon(FontAwesomeIcons.b), onTap: () => handleState(bangumiIntroController.actionCoinVideo), - selectStatus: bangumiIntroController.hasCoin.value, + selectStatus: bangumiIntroController.hasCoin, loadingStatus: false, semanticsLabel: '投币', text: !widget.isLoading @@ -573,7 +573,7 @@ class _BangumiInfoState extends State { () => ActionRowItem( icon: const Icon(FontAwesomeIcons.b), onTap: () => handleState(bangumiIntroController.actionCoinVideo), - selectStatus: bangumiIntroController.hasCoin.value, + selectStatus: bangumiIntroController.hasCoin, loadingStatus: widget.isLoading, text: !widget.isLoading ? widget.bangumiDetail!.stat!['coins']!.toString() diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index bdd73a98..bf597c18 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -7,12 +7,12 @@ import 'package:PiliPlus/http/member.dart'; import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.dart'; import 'package:PiliPlus/pages/video/detail/introduction/pay_coins_page.dart'; import 'package:PiliPlus/utils/extension.dart'; +import 'package:PiliPlus/utils/global_data.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:expandable/expandable.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; -import 'package:get/get_navigation/src/dialog/dialog_route.dart'; import 'package:PiliPlus/http/constants.dart'; import 'package:PiliPlus/http/user.dart'; import 'package:PiliPlus/http/video.dart'; @@ -58,8 +58,10 @@ class VideoIntroController extends GetxController RxBool hasLike = false.obs; // 是否点踩 RxBool hasDislike = false.obs; + // 投币数量 + final RxInt _coinNum = 0.obs; // 是否投币 - RxBool hasCoin = false.obs; + bool get hasCoin => _coinNum.value != 0; // 是否收藏 RxBool hasFav = false.obs; // 是否稍后再看 @@ -179,13 +181,6 @@ class VideoIntroController extends GetxController queryVideoIntroData.value = result; if (isLogin) { queryAllStatus(); - // // 获取点赞状态 - // queryHasLikeVideo(); - // // 获取投币状态 - // queryHasCoinVideo(); - // // 获取收藏状态 - // queryHasFavVideo(); - // // queryFollowStatus(); } } @@ -194,7 +189,6 @@ class VideoIntroController extends GetxController var result = await UserHttp.videoTags(bvid: bvid); if (result['status']) { videoTags = result['data']; - // debugPrint('tags: ${result['data']}'); } } @@ -234,40 +228,11 @@ class VideoIntroController extends GetxController var data = result['data']; hasLike.value = data['like']; hasDislike.value = data['dislike']; - hasCoin.value = data['coin'] != 0; + _coinNum.value = data['coin']; hasFav.value = data['favorite']; - // followStatus['attritube'] = data['attention'] ? 2 : 0; } } - // // 获取点赞状态 - // Future queryHasLikeVideo() async { - // var result = await VideoHttp.hasLikeVideo(bvid: bvid); - // // data num 被点赞标志 0:未点赞 1:已点赞 2:已点踩 - // hasLike.value = result["data"] == 1; - // hasDislike.value = result["data"] == 2; - // } - - // // 获取投币状态 - // Future queryHasCoinVideo() async { - // var result = await VideoHttp.hasCoinVideo(bvid: bvid); - // if (result['status']) { - // hasCoin.value = result["data"]['multiply'] != 0; - // } - // } - - // // 获取收藏状态 - // Future queryHasFavVideo() async { - // /// fix 延迟查询 - // await Future.delayed(const Duration(milliseconds: 200)); - // var result = await VideoHttp.hasFavVideo(aid: IdUtils.bv2av(bvid)); - // if (result['status']) { - // hasFav.value = result["data"]['favoured']; - // } else { - // hasFav.value = false; - // } - // } - // 一键三连 Future actionOneThree() async { feedBack(); @@ -275,7 +240,7 @@ class VideoIntroController extends GetxController SmartDialog.showToast('账号未登录'); return; } - if (hasLike.value && hasCoin.value && hasFav.value) { + if (hasLike.value && hasCoin && hasFav.value) { // 已点赞、投币、收藏 SmartDialog.showToast('已三连'); return false; @@ -283,7 +248,10 @@ class VideoIntroController extends GetxController var result = await VideoHttp.oneThree(bvid: bvid); if (result['status']) { hasLike.value = result["data"]["like"]; - hasCoin.value = result["data"]["coin"]; + if (result["data"]["coin"]) { + _coinNum.value = 2; + GlobalData().afterCoin(2); + } hasFav.value = result["data"]["fav"]; SmartDialog.showToast('三连成功'); } else { @@ -362,7 +330,8 @@ class VideoIntroController extends GetxController ); if (res['status']) { SmartDialog.showToast('投币成功'); - hasCoin.value = true; + _coinNum.value += coin; + GlobalData().afterCoin(coin); videoDetail.value.stat!.coin = videoDetail.value.stat!.coin! + coin; if (selectLike && hasLike.value.not) { hasLike.value = true; @@ -380,60 +349,23 @@ class VideoIntroController extends GetxController return; } - Navigator.of(Get.context!).push( - GetDialogRoute( - pageBuilder: (buildContext, animation, secondaryAnimation) { - return PayCoinsPage( - callback: coinVideo, - copyright: (queryVideoIntroData.value['data'] as VideoDetailData?) - ?.copyright ?? - 1, - ); - }, - transitionDuration: const Duration(milliseconds: 225), - transitionBuilder: (context, animation, secondaryAnimation, child) { - const begin = 0.0; - const end = 1.0; - const curve = Curves.linear; + if (_coinNum.value >= 2) { + SmartDialog.showToast('超过投币上限啦~'); + return; + } - var tween = Tween(begin: begin, end: end) - .chain(CurveTween(curve: curve)); + if (GlobalData().coins != null && GlobalData().coins! < 1) { + SmartDialog.showToast('硬币不足'); + return; + } - return FadeTransition( - opacity: animation.drive(tween), - child: child, - ); - }, - ), + PayCoinsPage.toPayCoinsPage( + onPayCoin: coinVideo, + copyright: + (queryVideoIntroData.value['data'] as VideoDetailData?)?.copyright ?? + 1, + hasCoin: _coinNum.value == 1, ); - // showDialog( - // context: Get.context!, - // builder: (context) { - // return AlertDialog( - // title: const Text('选择投币个数'), - // contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12), - // actions: [ - // TextButton( - // onPressed: () => Get.back(), - // child: Text('取消', - // style: TextStyle( - // color: Theme.of(context).colorScheme.outline))), - // TextButton( - // onPressed: () async { - // coinVideo(1); - // Get.back(); - // }, - // child: const Text('投 1 枚')), - // TextButton( - // onPressed: () async { - // coinVideo(2); - // Get.back(); - // }, - // child: const Text('投 2 枚')) - // ], - // ); - // }, - // ); } // (取消)收藏 diff --git a/lib/pages/video/detail/introduction/pay_coins_page.dart b/lib/pages/video/detail/introduction/pay_coins_page.dart index 16be43d4..0e3e54c6 100644 --- a/lib/pages/video/detail/introduction/pay_coins_page.dart +++ b/lib/pages/video/detail/introduction/pay_coins_page.dart @@ -2,22 +2,58 @@ import 'dart:async'; import 'dart:math'; import 'package:PiliPlus/utils/extension.dart'; +import 'package:PiliPlus/utils/global_data.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:get/get_navigation/src/dialog/dialog_route.dart'; class PayCoinsPage extends StatefulWidget { const PayCoinsPage({ super.key, - required this.callback, + required this.onPayCoin, this.copyright = 1, + this.hasCoin = false, }); - final Function callback; + final Function(int coin, bool coinWithLike) onPayCoin; final int copyright; + final bool hasCoin; @override State createState() => _PayCoinsPageState(); + + static toPayCoinsPage({ + required Function(int coin, bool coinWithLike) onPayCoin, + int copyright = 1, + bool hasCoin = false, + }) async { + Navigator.of(Get.context!).push( + GetDialogRoute( + pageBuilder: (buildContext, animation, secondaryAnimation) { + return PayCoinsPage( + onPayCoin: onPayCoin, + copyright: copyright, + hasCoin: hasCoin, + ); + }, + transitionDuration: const Duration(milliseconds: 225), + transitionBuilder: (context, animation, secondaryAnimation, child) { + const begin = 0.0; + const end = 1.0; + const curve = Curves.linear; + + var tween = Tween(begin: begin, end: end) + .chain(CurveTween(curve: curve)); + + return FadeTransition( + opacity: animation.drive(tween), + child: child, + ); + }, + ), + ); + } } class _PayCoinsPageState extends State @@ -29,6 +65,48 @@ class _PayCoinsPageState extends State int get _index => _controller.hasClients ? _controller.page?.round() ?? 0 : 0; + num? get _coins => GlobalData().coins; + bool get _canPay { + if (_index == 1 && widget.hasCoin) { + return false; + } + if (_coins == null) { + return true; + } + if (_index == 0 && _coins! >= 1) { + return true; + } + if (_index == 1 && _coins! >= 2) { + return true; + } + return false; + } + + Color _getColorFilter(int index) { + if (index == 1 && widget.hasCoin) { + return Colors.black45; + } + if (_coins == null) { + return Colors.transparent; + } + if (index == 0 && _coins == 0) { + return Colors.black45; + } + if (index == 1 && _coins! < 2) { + return Colors.black45; + } + return Colors.transparent; + } + + String get _getImage { + if (!_canPay) { + return 'assets/images/paycoins/ic_22_not_enough_pay.png'; + } + return _index == 0 + ? 'assets/images/paycoins/ic_22_mario.png' + : 'assets/images/paycoins/ic_22_gun_sister.png'; + } + late AnimationController _slide22Controller; late AnimationController _scale22Controller; late AnimationController _coinSlideController; @@ -162,6 +240,7 @@ class _PayCoinsPageState extends State height: 100, child: PageView.builder( key: PageStorageKey('PageView'), + physics: const ClampingScrollPhysics(), itemCount: widget.copyright == 1 ? 2 : 1, controller: _controller, onPageChanged: (index) => setState(() { @@ -183,44 +262,53 @@ class _PayCoinsPageState extends State child: SizedBox( height: 70 + (factor * 30), width: 70 + (factor * 30), - child: Stack( - alignment: Alignment.center, - children: [ - SlideTransition( - position: - _boxAnimController.drive( - Tween( - begin: const Offset(0.0, 0.0), - end: const Offset(0.0, -0.2), + child: ColorFiltered( + colorFilter: ColorFilter.mode( + _getColorFilter(index), + BlendMode.srcATop, + ), + child: Stack( + alignment: Alignment.center, + children: [ + SlideTransition( + position: + _boxAnimController.drive( + Tween( + begin: + const Offset(0.0, 0.0), + end: + const Offset(0.0, -0.2), + ), ), - ), - child: Image.asset( - 'assets/images/paycoins/ic_pay_coins_box.png', - ), - ), - SlideTransition( - position: - _coinSlideController.drive( - Tween( - begin: const Offset(0.0, 0.0), - end: const Offset(0.0, -2), - ), - ), - child: FadeTransition( - opacity: Tween( - begin: 1, end: 0) - .animate( - _coinFadeController), child: Image.asset( - height: 35 + (factor * 15), - width: 35 + (factor * 15), - index == 0 - ? 'assets/images/paycoins/ic_coins_one.png' - : 'assets/images/paycoins/ic_coins_two.png', + 'assets/images/paycoins/ic_pay_coins_box.png', ), ), - ), - ], + SlideTransition( + position: + _coinSlideController.drive( + Tween( + begin: + const Offset(0.0, 0.0), + end: const Offset(0.0, -2), + ), + ), + child: FadeTransition( + opacity: Tween( + begin: 1, end: 0) + .animate( + _coinFadeController), + child: Image.asset( + height: 35 + (factor * 15), + width: 35 + (factor * 15), + index == 0 + ? 'assets/images/paycoins/ic_coins_one.png' + : 'assets/images/paycoins/ic_coins_two.png', + ), + ), + ), + ], + ), ), ), ), @@ -265,8 +353,9 @@ class _PayCoinsPageState extends State height: 155, child: Center( child: GestureDetector( - onTap: _onPayCoin, - onPanUpdate: (e) => _handlePanUpdate(e, true), + onTap: _canPay ? _onPayCoin : null, + onPanUpdate: + _canPay ? (e) => _handlePanUpdate(e, true) : null, child: ScaleTransition( scale: _scale22Controller.drive( Tween(begin: 1, end: 1.1), @@ -281,11 +370,7 @@ class _PayCoinsPageState extends State child: SizedBox( width: 110, height: 155, - child: Image.asset( - _index == 0 - ? 'assets/images/paycoins/ic_22_mario.png' - : 'assets/images/paycoins/ic_22_gun_sister.png', - ), + child: Image.asset(_getImage), ), ), ), @@ -293,6 +378,15 @@ class _PayCoinsPageState extends State ), ), ), + if (_coins != null || widget.hasCoin) ...[ + const SizedBox(height: 10), + Center( + child: Text( + '${_coins != null ? '硬币余额:${_coins!.toDouble().toPrecision(1)}' : ''}${widget.hasCoin ? '${_coins != null ? ',' : ''}已投1枚硬币' : ''}', + style: TextStyle(color: Colors.white, fontSize: 13), + ), + ), + ], const SizedBox(height: 10), Stack( alignment: Alignment.centerLeft, @@ -394,7 +488,7 @@ class _PayCoinsPageState extends State _coinSlideController.forward().whenComplete(() { _coinFadeController.forward().whenComplete(() { Get.back(); - widget.callback(_index + 1, _coinWithLike.value); + widget.onPayCoin(_index + 1, _coinWithLike.value); }); }); }); diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index bffa6ad5..13ec3ede 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -926,7 +926,7 @@ class _VideoInfoState extends State { : '-', needAnim: true, hasTriple: videoIntroController.hasLike.value && - videoIntroController.hasCoin.value && + videoIntroController.hasCoin && videoIntroController.hasFav.value, callBack: (start) { if (start) { @@ -958,7 +958,7 @@ class _VideoInfoState extends State { icon: const Icon(FontAwesomeIcons.b), selectIcon: const Icon(FontAwesomeIcons.b), onTap: () => handleState(videoIntroController.actionCoinVideo), - selectStatus: videoIntroController.hasCoin.value, + selectStatus: videoIntroController.hasCoin, loadingStatus: widget.loadingStatus, semanticsLabel: '投币', text: !widget.loadingStatus @@ -1032,7 +1032,7 @@ class _VideoInfoState extends State { () => ActionRowItem( icon: const Icon(FontAwesomeIcons.b), onTap: () => handleState(videoIntroController.actionCoinVideo), - selectStatus: videoIntroController.hasCoin.value, + selectStatus: videoIntroController.hasCoin, loadingStatus: widget.loadingStatus, text: !widget.loadingStatus ? videoDetail.stat!.coin!.toString() : '-', diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 9a1b6b02..e7c804bc 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -2300,7 +2300,7 @@ class HeaderControlState extends State { semanticsLabel: '点赞', needAnim: true, hasTriple: videoIntroController.hasLike.value && - videoIntroController.hasCoin.value && + videoIntroController.hasCoin && videoIntroController.hasFav.value, callBack: (start) { if (start) { @@ -2352,8 +2352,7 @@ class HeaderControlState extends State { ), selectIcon: const Icon(FontAwesomeIcons.b), onTap: videoIntroController.actionCoinVideo, - selectStatus: - videoIntroController.hasCoin.value, + selectStatus: videoIntroController.hasCoin, semanticsLabel: '投币', needAnim: true, ), @@ -2422,7 +2421,7 @@ class HeaderControlState extends State { needAnim: true, hasTriple: bangumiIntroController.hasLike.value && - bangumiIntroController.hasCoin.value && + bangumiIntroController.hasCoin && bangumiIntroController.hasFav.value, callBack: (start) { if (start) { @@ -2455,8 +2454,7 @@ class HeaderControlState extends State { ), selectIcon: const Icon(FontAwesomeIcons.b), onTap: bangumiIntroController.actionCoinVideo, - selectStatus: - bangumiIntroController.hasCoin.value, + selectStatus: bangumiIntroController.hasCoin, semanticsLabel: '投币', needAnim: true, ), diff --git a/lib/utils/accounts/account_manager/account_mgr.dart b/lib/utils/accounts/account_manager/account_mgr.dart index 059c0644..06e78d4e 100644 --- a/lib/utils/accounts/account_manager/account_mgr.dart +++ b/lib/utils/accounts/account_manager/account_mgr.dart @@ -177,7 +177,8 @@ class AccountManager extends Interceptor { 'online/total', 'github', 'hdslb.com', - 'biliimg.com' + 'biliimg.com', + 'site/getCoin', ]; String url = err.requestOptions.uri.toString(); debugPrint('🌹🌹ApiInterceptor: $url'); diff --git a/lib/utils/global_data.dart b/lib/utils/global_data.dart index f7c34f45..6174754b 100644 --- a/lib/utils/global_data.dart +++ b/lib/utils/global_data.dart @@ -3,6 +3,14 @@ class GlobalData { int replyLengthLimit = 6; + num? coins; + + void afterCoin(int coin) { + if (coins != null) { + coins = coins! - coin; + } + } + // 私有构造函数 GlobalData._();