mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: get/check coin
Closes #661 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -753,4 +753,6 @@ class Api {
|
|||||||
static const String addFavArticle = '/x/article/favorites/add';
|
static const String addFavArticle = '/x/article/favorites/add';
|
||||||
|
|
||||||
static const String replyTop = '/x/v2/reply/top';
|
static const String replyTop = '/x/v2/reply/top';
|
||||||
|
|
||||||
|
static const String getCoin = '${HttpString.accountBaseUrl}/site/getCoin';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,5 +8,7 @@ class HttpString {
|
|||||||
static const String messageBaseUrl = 'https://message.bilibili.com';
|
static const String messageBaseUrl = 'https://message.bilibili.com';
|
||||||
static const String dynamicShareBaseUrl = 'https://t.bilibili.com';
|
static const String dynamicShareBaseUrl = 'https://t.bilibili.com';
|
||||||
static const String spaceBaseUrl = 'https://space.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';
|
static const String sponsorBlockBaseUrl = 'https://www.bsbsb.top';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ import 'dart:convert';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:PiliPlus/build_config.dart';
|
import 'package:PiliPlus/build_config.dart';
|
||||||
import 'package:PiliPlus/http/retry_interceptor.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.dart';
|
||||||
import 'package:PiliPlus/utils/accounts/account_manager/account_mgr.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:archive/archive.dart';
|
||||||
import 'package:brotli/brotli.dart';
|
import 'package:brotli/brotli.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
@@ -41,6 +43,17 @@ class Request {
|
|||||||
isSecure: item.secure,
|
isSecure: item.secure,
|
||||||
isHttpOnly: item.httpOnly,
|
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
|
// 从cookie中获取 csrf token
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/models/video/later.dart';
|
import 'package:PiliPlus/models/video/later.dart';
|
||||||
|
import 'package:PiliPlus/utils/global_data.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
@@ -29,6 +30,7 @@ class UserHttp {
|
|||||||
var res = await Request().get(Api.userInfo);
|
var res = await Request().get(Api.userInfo);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
UserInfoData data = UserInfoData.fromJson(res.data['data']);
|
UserInfoData data = UserInfoData.fromJson(res.data['data']);
|
||||||
|
GlobalData().coins = data.money;
|
||||||
return {'status': true, 'data': data};
|
return {'status': true, 'data': data};
|
||||||
} else {
|
} else {
|
||||||
return {'status': false, 'msg': res.data['message']};
|
return {'status': false, 'msg': res.data['message']};
|
||||||
@@ -682,31 +684,12 @@ class UserHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析收藏夹视频
|
static Future getCoin() async {
|
||||||
// static Future parseFavVideo({
|
final res = await Request().get(Api.getCoin);
|
||||||
// required int mediaId,
|
if (res.data['code'] == 0) {
|
||||||
// required int oid,
|
return {'status': true, 'data': res.data['data']?['money']};
|
||||||
// required String bvid,
|
} else {
|
||||||
// }) async {
|
return {'status': false, 'msg': res.data['message']};
|
||||||
// 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<String, dynamic> jsonData = json.decode(jsonContent);
|
|
||||||
// return {
|
|
||||||
// 'status': true,
|
|
||||||
// 'data': jsonData['resourceList']
|
|
||||||
// .map<MediaVideoItemModel>((e) => MediaVideoItemModel.fromJson(e))
|
|
||||||
// .toList()
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/detail/introduction/pay_coins_page.dart';
|
import 'package:PiliPlus/pages/video/detail/introduction/pay_coins_page.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
|
import 'package:PiliPlus/utils/global_data.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.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/constants.dart';
|
||||||
import 'package:PiliPlus/http/search.dart';
|
import 'package:PiliPlus/http/search.dart';
|
||||||
import 'package:PiliPlus/http/video.dart';
|
import 'package:PiliPlus/http/video.dart';
|
||||||
@@ -54,8 +54,10 @@ class BangumiIntroController
|
|||||||
|
|
||||||
// 是否点赞
|
// 是否点赞
|
||||||
RxBool hasLike = false.obs;
|
RxBool hasLike = false.obs;
|
||||||
|
// 投币数量
|
||||||
|
final RxInt _coinNum = 0.obs;
|
||||||
// 是否投币
|
// 是否投币
|
||||||
RxBool hasCoin = false.obs;
|
bool get hasCoin => _coinNum.value != 0;
|
||||||
// 是否收藏
|
// 是否收藏
|
||||||
RxBool hasFav = false.obs;
|
RxBool hasFav = false.obs;
|
||||||
dynamic videoTags;
|
dynamic videoTags;
|
||||||
@@ -74,33 +76,12 @@ class BangumiIntroController
|
|||||||
if (Get.arguments.containsKey('bangumiItem') as bool) {
|
if (Get.arguments.containsKey('bangumiItem') as bool) {
|
||||||
preRender = true;
|
preRender = true;
|
||||||
bangumiItem = Get.arguments['bangumiItem'];
|
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');
|
userInfo = GStorage.userInfo.get('userInfoCache');
|
||||||
isLogin = userInfo != null;
|
isLogin = userInfo != null;
|
||||||
|
|
||||||
if (isLogin && epId != null) {
|
if (isLogin && epId != null) {
|
||||||
// // 获取点赞状态
|
|
||||||
// queryHasLikeVideo();
|
|
||||||
// // 获取投币状态
|
|
||||||
// queryHasCoinVideo();
|
|
||||||
// // 获取收藏状态
|
|
||||||
// queryHasFavVideo();
|
|
||||||
queryBangumiLikeCoinFav();
|
queryBangumiLikeCoinFav();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +123,7 @@ class BangumiIntroController
|
|||||||
var result = await VideoHttp.bangumiLikeCoinFav(epId: epId);
|
var result = await VideoHttp.bangumiLikeCoinFav(epId: epId);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
hasLike.value = result["data"]['like'] == 1;
|
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;
|
hasFav.value = result["data"]['favorite'] == 1;
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(result['msg']);
|
||||||
@@ -177,7 +158,8 @@ class BangumiIntroController
|
|||||||
hasLike.value = true;
|
hasLike.value = true;
|
||||||
bangumiDetail.stat!['likes'] = bangumiDetail.stat!['likes'] + 1;
|
bangumiDetail.stat!['likes'] = bangumiDetail.stat!['likes'] + 1;
|
||||||
}
|
}
|
||||||
hasCoin.value = true;
|
_coinNum.value += coin;
|
||||||
|
GlobalData().afterCoin(coin);
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
@@ -189,28 +171,20 @@ class BangumiIntroController
|
|||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
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<double>(begin: begin, end: end)
|
if (_coinNum.value >= 2) {
|
||||||
.chain(CurveTween(curve: curve));
|
SmartDialog.showToast('超过投币上限啦~');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return FadeTransition(
|
if (GlobalData().coins != null && GlobalData().coins! < 1) {
|
||||||
opacity: animation.drive(tween),
|
SmartDialog.showToast('硬币不足');
|
||||||
child: child,
|
return;
|
||||||
);
|
}
|
||||||
},
|
|
||||||
),
|
PayCoinsPage.toPayCoinsPage(
|
||||||
|
onPayCoin: coinVideo,
|
||||||
|
hasCoin: _coinNum.value == 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,7 +525,7 @@ class BangumiIntroController
|
|||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasLike.value && hasCoin.value && hasFav.value) {
|
if (hasLike.value && hasCoin && hasFav.value) {
|
||||||
// 已点赞、投币、收藏
|
// 已点赞、投币、收藏
|
||||||
SmartDialog.showToast('已三连');
|
SmartDialog.showToast('已三连');
|
||||||
return false;
|
return false;
|
||||||
@@ -559,7 +533,10 @@ class BangumiIntroController
|
|||||||
var result = await VideoHttp.triple(epId: epId, seasonId: seasonId);
|
var result = await VideoHttp.triple(epId: epId, seasonId: seasonId);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
hasLike.value = result["data"]["like"] == 1;
|
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;
|
hasFav.value = result["data"]["favorite"] == 1;
|
||||||
SmartDialog.showToast('三连成功');
|
SmartDialog.showToast('三连成功');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -469,7 +469,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
),
|
),
|
||||||
needAnim: true,
|
needAnim: true,
|
||||||
hasTriple: bangumiIntroController.hasLike.value &&
|
hasTriple: bangumiIntroController.hasLike.value &&
|
||||||
bangumiIntroController.hasCoin.value &&
|
bangumiIntroController.hasCoin &&
|
||||||
bangumiIntroController.hasFav.value,
|
bangumiIntroController.hasFav.value,
|
||||||
callBack: (start) {
|
callBack: (start) {
|
||||||
if (start) {
|
if (start) {
|
||||||
@@ -490,7 +490,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () =>
|
onTap: () =>
|
||||||
handleState(bangumiIntroController.actionCoinVideo),
|
handleState(bangumiIntroController.actionCoinVideo),
|
||||||
selectStatus: bangumiIntroController.hasCoin.value,
|
selectStatus: bangumiIntroController.hasCoin,
|
||||||
loadingStatus: false,
|
loadingStatus: false,
|
||||||
semanticsLabel: '投币',
|
semanticsLabel: '投币',
|
||||||
text: !widget.isLoading
|
text: !widget.isLoading
|
||||||
@@ -573,7 +573,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => handleState(bangumiIntroController.actionCoinVideo),
|
onTap: () => handleState(bangumiIntroController.actionCoinVideo),
|
||||||
selectStatus: bangumiIntroController.hasCoin.value,
|
selectStatus: bangumiIntroController.hasCoin,
|
||||||
loadingStatus: widget.isLoading,
|
loadingStatus: widget.isLoading,
|
||||||
text: !widget.isLoading
|
text: !widget.isLoading
|
||||||
? widget.bangumiDetail!.stat!['coins']!.toString()
|
? widget.bangumiDetail!.stat!['coins']!.toString()
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import 'package:PiliPlus/http/member.dart';
|
|||||||
import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.dart';
|
import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.dart';
|
||||||
import 'package:PiliPlus/pages/video/detail/introduction/pay_coins_page.dart';
|
import 'package:PiliPlus/pages/video/detail/introduction/pay_coins_page.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
|
import 'package:PiliPlus/utils/global_data.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:expandable/expandable.dart';
|
import 'package:expandable/expandable.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.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/constants.dart';
|
||||||
import 'package:PiliPlus/http/user.dart';
|
import 'package:PiliPlus/http/user.dart';
|
||||||
import 'package:PiliPlus/http/video.dart';
|
import 'package:PiliPlus/http/video.dart';
|
||||||
@@ -58,8 +58,10 @@ class VideoIntroController extends GetxController
|
|||||||
RxBool hasLike = false.obs;
|
RxBool hasLike = false.obs;
|
||||||
// 是否点踩
|
// 是否点踩
|
||||||
RxBool hasDislike = 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;
|
RxBool hasFav = false.obs;
|
||||||
// 是否稍后再看
|
// 是否稍后再看
|
||||||
@@ -179,13 +181,6 @@ class VideoIntroController extends GetxController
|
|||||||
queryVideoIntroData.value = result;
|
queryVideoIntroData.value = result;
|
||||||
if (isLogin) {
|
if (isLogin) {
|
||||||
queryAllStatus();
|
queryAllStatus();
|
||||||
// // 获取点赞状态
|
|
||||||
// queryHasLikeVideo();
|
|
||||||
// // 获取投币状态
|
|
||||||
// queryHasCoinVideo();
|
|
||||||
// // 获取收藏状态
|
|
||||||
// queryHasFavVideo();
|
|
||||||
// //
|
|
||||||
queryFollowStatus();
|
queryFollowStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,7 +189,6 @@ class VideoIntroController extends GetxController
|
|||||||
var result = await UserHttp.videoTags(bvid: bvid);
|
var result = await UserHttp.videoTags(bvid: bvid);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
videoTags = result['data'];
|
videoTags = result['data'];
|
||||||
// debugPrint('tags: ${result['data']}');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,40 +228,11 @@ class VideoIntroController extends GetxController
|
|||||||
var data = result['data'];
|
var data = result['data'];
|
||||||
hasLike.value = data['like'];
|
hasLike.value = data['like'];
|
||||||
hasDislike.value = data['dislike'];
|
hasDislike.value = data['dislike'];
|
||||||
hasCoin.value = data['coin'] != 0;
|
_coinNum.value = data['coin'];
|
||||||
hasFav.value = data['favorite'];
|
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 {
|
Future actionOneThree() async {
|
||||||
feedBack();
|
feedBack();
|
||||||
@@ -275,7 +240,7 @@ class VideoIntroController extends GetxController
|
|||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasLike.value && hasCoin.value && hasFav.value) {
|
if (hasLike.value && hasCoin && hasFav.value) {
|
||||||
// 已点赞、投币、收藏
|
// 已点赞、投币、收藏
|
||||||
SmartDialog.showToast('已三连');
|
SmartDialog.showToast('已三连');
|
||||||
return false;
|
return false;
|
||||||
@@ -283,7 +248,10 @@ class VideoIntroController extends GetxController
|
|||||||
var result = await VideoHttp.oneThree(bvid: bvid);
|
var result = await VideoHttp.oneThree(bvid: bvid);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
hasLike.value = result["data"]["like"];
|
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"];
|
hasFav.value = result["data"]["fav"];
|
||||||
SmartDialog.showToast('三连成功');
|
SmartDialog.showToast('三连成功');
|
||||||
} else {
|
} else {
|
||||||
@@ -362,7 +330,8 @@ class VideoIntroController extends GetxController
|
|||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
SmartDialog.showToast('投币成功');
|
SmartDialog.showToast('投币成功');
|
||||||
hasCoin.value = true;
|
_coinNum.value += coin;
|
||||||
|
GlobalData().afterCoin(coin);
|
||||||
videoDetail.value.stat!.coin = videoDetail.value.stat!.coin! + coin;
|
videoDetail.value.stat!.coin = videoDetail.value.stat!.coin! + coin;
|
||||||
if (selectLike && hasLike.value.not) {
|
if (selectLike && hasLike.value.not) {
|
||||||
hasLike.value = true;
|
hasLike.value = true;
|
||||||
@@ -380,60 +349,23 @@ class VideoIntroController extends GetxController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Navigator.of(Get.context!).push(
|
if (_coinNum.value >= 2) {
|
||||||
GetDialogRoute(
|
SmartDialog.showToast('超过投币上限啦~');
|
||||||
pageBuilder: (buildContext, animation, secondaryAnimation) {
|
return;
|
||||||
return PayCoinsPage(
|
}
|
||||||
callback: coinVideo,
|
|
||||||
copyright: (queryVideoIntroData.value['data'] as VideoDetailData?)
|
if (GlobalData().coins != null && GlobalData().coins! < 1) {
|
||||||
?.copyright ??
|
SmartDialog.showToast('硬币不足');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PayCoinsPage.toPayCoinsPage(
|
||||||
|
onPayCoin: coinVideo,
|
||||||
|
copyright:
|
||||||
|
(queryVideoIntroData.value['data'] as VideoDetailData?)?.copyright ??
|
||||||
1,
|
1,
|
||||||
|
hasCoin: _coinNum.value == 1,
|
||||||
);
|
);
|
||||||
},
|
|
||||||
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<double>(begin: begin, end: end)
|
|
||||||
.chain(CurveTween(curve: curve));
|
|
||||||
|
|
||||||
return FadeTransition(
|
|
||||||
opacity: animation.drive(tween),
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
// 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 枚'))
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// (取消)收藏
|
// (取消)收藏
|
||||||
|
|||||||
@@ -2,22 +2,58 @@ import 'dart:async';
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
|
import 'package:PiliPlus/utils/global_data.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:get/get_navigation/src/dialog/dialog_route.dart';
|
||||||
|
|
||||||
class PayCoinsPage extends StatefulWidget {
|
class PayCoinsPage extends StatefulWidget {
|
||||||
const PayCoinsPage({
|
const PayCoinsPage({
|
||||||
super.key,
|
super.key,
|
||||||
required this.callback,
|
required this.onPayCoin,
|
||||||
this.copyright = 1,
|
this.copyright = 1,
|
||||||
|
this.hasCoin = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Function callback;
|
final Function(int coin, bool coinWithLike) onPayCoin;
|
||||||
final int copyright;
|
final int copyright;
|
||||||
|
final bool hasCoin;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PayCoinsPage> createState() => _PayCoinsPageState();
|
State<PayCoinsPage> 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<double>(begin: begin, end: end)
|
||||||
|
.chain(CurveTween(curve: curve));
|
||||||
|
|
||||||
|
return FadeTransition(
|
||||||
|
opacity: animation.drive(tween),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PayCoinsPageState extends State<PayCoinsPage>
|
class _PayCoinsPageState extends State<PayCoinsPage>
|
||||||
@@ -29,6 +65,48 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
|
|
||||||
int get _index => _controller.hasClients ? _controller.page?.round() ?? 0 : 0;
|
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 _slide22Controller;
|
||||||
late AnimationController _scale22Controller;
|
late AnimationController _scale22Controller;
|
||||||
late AnimationController _coinSlideController;
|
late AnimationController _coinSlideController;
|
||||||
@@ -162,6 +240,7 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
height: 100,
|
height: 100,
|
||||||
child: PageView.builder(
|
child: PageView.builder(
|
||||||
key: PageStorageKey('PageView'),
|
key: PageStorageKey('PageView'),
|
||||||
|
physics: const ClampingScrollPhysics(),
|
||||||
itemCount: widget.copyright == 1 ? 2 : 1,
|
itemCount: widget.copyright == 1 ? 2 : 1,
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
onPageChanged: (index) => setState(() {
|
onPageChanged: (index) => setState(() {
|
||||||
@@ -183,6 +262,11 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 70 + (factor * 30),
|
height: 70 + (factor * 30),
|
||||||
width: 70 + (factor * 30),
|
width: 70 + (factor * 30),
|
||||||
|
child: ColorFiltered(
|
||||||
|
colorFilter: ColorFilter.mode(
|
||||||
|
_getColorFilter(index),
|
||||||
|
BlendMode.srcATop,
|
||||||
|
),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
@@ -190,8 +274,10 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
position:
|
position:
|
||||||
_boxAnimController.drive(
|
_boxAnimController.drive(
|
||||||
Tween(
|
Tween(
|
||||||
begin: const Offset(0.0, 0.0),
|
begin:
|
||||||
end: const Offset(0.0, -0.2),
|
const Offset(0.0, 0.0),
|
||||||
|
end:
|
||||||
|
const Offset(0.0, -0.2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
@@ -202,7 +288,8 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
position:
|
position:
|
||||||
_coinSlideController.drive(
|
_coinSlideController.drive(
|
||||||
Tween(
|
Tween(
|
||||||
begin: const Offset(0.0, 0.0),
|
begin:
|
||||||
|
const Offset(0.0, 0.0),
|
||||||
end: const Offset(0.0, -2),
|
end: const Offset(0.0, -2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -224,6 +311,7 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -265,8 +353,9 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
height: 155,
|
height: 155,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: _onPayCoin,
|
onTap: _canPay ? _onPayCoin : null,
|
||||||
onPanUpdate: (e) => _handlePanUpdate(e, true),
|
onPanUpdate:
|
||||||
|
_canPay ? (e) => _handlePanUpdate(e, true) : null,
|
||||||
child: ScaleTransition(
|
child: ScaleTransition(
|
||||||
scale: _scale22Controller.drive(
|
scale: _scale22Controller.drive(
|
||||||
Tween(begin: 1, end: 1.1),
|
Tween(begin: 1, end: 1.1),
|
||||||
@@ -281,10 +370,7 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 110,
|
width: 110,
|
||||||
height: 155,
|
height: 155,
|
||||||
child: Image.asset(
|
child: Image.asset(_getImage),
|
||||||
_index == 0
|
|
||||||
? 'assets/images/paycoins/ic_22_mario.png'
|
|
||||||
: 'assets/images/paycoins/ic_22_gun_sister.png',
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -292,7 +378,15 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
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),
|
const SizedBox(height: 10),
|
||||||
Stack(
|
Stack(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
@@ -394,7 +488,7 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
_coinSlideController.forward().whenComplete(() {
|
_coinSlideController.forward().whenComplete(() {
|
||||||
_coinFadeController.forward().whenComplete(() {
|
_coinFadeController.forward().whenComplete(() {
|
||||||
Get.back();
|
Get.back();
|
||||||
widget.callback(_index + 1, _coinWithLike.value);
|
widget.onPayCoin(_index + 1, _coinWithLike.value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -926,7 +926,7 @@ class _VideoInfoState extends State<VideoInfo> {
|
|||||||
: '-',
|
: '-',
|
||||||
needAnim: true,
|
needAnim: true,
|
||||||
hasTriple: videoIntroController.hasLike.value &&
|
hasTriple: videoIntroController.hasLike.value &&
|
||||||
videoIntroController.hasCoin.value &&
|
videoIntroController.hasCoin &&
|
||||||
videoIntroController.hasFav.value,
|
videoIntroController.hasFav.value,
|
||||||
callBack: (start) {
|
callBack: (start) {
|
||||||
if (start) {
|
if (start) {
|
||||||
@@ -958,7 +958,7 @@ class _VideoInfoState extends State<VideoInfo> {
|
|||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => handleState(videoIntroController.actionCoinVideo),
|
onTap: () => handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
semanticsLabel: '投币',
|
semanticsLabel: '投币',
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
@@ -1032,7 +1032,7 @@ class _VideoInfoState extends State<VideoInfo> {
|
|||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => handleState(videoIntroController.actionCoinVideo),
|
onTap: () => handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
text:
|
text:
|
||||||
!widget.loadingStatus ? videoDetail.stat!.coin!.toString() : '-',
|
!widget.loadingStatus ? videoDetail.stat!.coin!.toString() : '-',
|
||||||
|
|||||||
@@ -2300,7 +2300,7 @@ class HeaderControlState extends State<HeaderControl> {
|
|||||||
semanticsLabel: '点赞',
|
semanticsLabel: '点赞',
|
||||||
needAnim: true,
|
needAnim: true,
|
||||||
hasTriple: videoIntroController.hasLike.value &&
|
hasTriple: videoIntroController.hasLike.value &&
|
||||||
videoIntroController.hasCoin.value &&
|
videoIntroController.hasCoin &&
|
||||||
videoIntroController.hasFav.value,
|
videoIntroController.hasFav.value,
|
||||||
callBack: (start) {
|
callBack: (start) {
|
||||||
if (start) {
|
if (start) {
|
||||||
@@ -2352,8 +2352,7 @@ class HeaderControlState extends State<HeaderControl> {
|
|||||||
),
|
),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: videoIntroController.actionCoinVideo,
|
onTap: videoIntroController.actionCoinVideo,
|
||||||
selectStatus:
|
selectStatus: videoIntroController.hasCoin,
|
||||||
videoIntroController.hasCoin.value,
|
|
||||||
semanticsLabel: '投币',
|
semanticsLabel: '投币',
|
||||||
needAnim: true,
|
needAnim: true,
|
||||||
),
|
),
|
||||||
@@ -2422,7 +2421,7 @@ class HeaderControlState extends State<HeaderControl> {
|
|||||||
needAnim: true,
|
needAnim: true,
|
||||||
hasTriple:
|
hasTriple:
|
||||||
bangumiIntroController.hasLike.value &&
|
bangumiIntroController.hasLike.value &&
|
||||||
bangumiIntroController.hasCoin.value &&
|
bangumiIntroController.hasCoin &&
|
||||||
bangumiIntroController.hasFav.value,
|
bangumiIntroController.hasFav.value,
|
||||||
callBack: (start) {
|
callBack: (start) {
|
||||||
if (start) {
|
if (start) {
|
||||||
@@ -2455,8 +2454,7 @@ class HeaderControlState extends State<HeaderControl> {
|
|||||||
),
|
),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: bangumiIntroController.actionCoinVideo,
|
onTap: bangumiIntroController.actionCoinVideo,
|
||||||
selectStatus:
|
selectStatus: bangumiIntroController.hasCoin,
|
||||||
bangumiIntroController.hasCoin.value,
|
|
||||||
semanticsLabel: '投币',
|
semanticsLabel: '投币',
|
||||||
needAnim: true,
|
needAnim: true,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -177,7 +177,8 @@ class AccountManager extends Interceptor {
|
|||||||
'online/total',
|
'online/total',
|
||||||
'github',
|
'github',
|
||||||
'hdslb.com',
|
'hdslb.com',
|
||||||
'biliimg.com'
|
'biliimg.com',
|
||||||
|
'site/getCoin',
|
||||||
];
|
];
|
||||||
String url = err.requestOptions.uri.toString();
|
String url = err.requestOptions.uri.toString();
|
||||||
debugPrint('🌹🌹ApiInterceptor: $url');
|
debugPrint('🌹🌹ApiInterceptor: $url');
|
||||||
|
|||||||
@@ -3,6 +3,14 @@ class GlobalData {
|
|||||||
|
|
||||||
int replyLengthLimit = 6;
|
int replyLengthLimit = 6;
|
||||||
|
|
||||||
|
num? coins;
|
||||||
|
|
||||||
|
void afterCoin(int coin) {
|
||||||
|
if (coins != null) {
|
||||||
|
coins = coins! - coin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 私有构造函数
|
// 私有构造函数
|
||||||
GlobalData._();
|
GlobalData._();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user