mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 点赞投币调整为app接口,启用长按三连功能
This commit is contained in:
@@ -8,7 +8,8 @@ class Api {
|
|||||||
|
|
||||||
// APP端不感兴趣、取消不感兴趣
|
// APP端不感兴趣、取消不感兴趣
|
||||||
static const String feedDislike = '${HttpString.appBaseUrl}/x/feed/dislike';
|
static const String feedDislike = '${HttpString.appBaseUrl}/x/feed/dislike';
|
||||||
static const String feedDislikeCancel = '${HttpString.appBaseUrl}/x/feed/dislike/cancel';
|
static const String feedDislikeCancel =
|
||||||
|
'${HttpString.appBaseUrl}/x/feed/dislike/cancel';
|
||||||
|
|
||||||
// 热门视频
|
// 热门视频
|
||||||
static const String hotList = '/x/web-interface/popular';
|
static const String hotList = '/x/web-interface/popular';
|
||||||
@@ -35,8 +36,10 @@ class Api {
|
|||||||
/// like num 操作方式 必要 1:点赞 2:取消赞
|
/// like num 操作方式 必要 1:点赞 2:取消赞
|
||||||
// csrf str CSRF Token(位于cookie) 必要
|
// csrf str CSRF Token(位于cookie) 必要
|
||||||
// https://api.bilibili.com/x/web-interface/archive/like
|
// https://api.bilibili.com/x/web-interface/archive/like
|
||||||
static const String likeVideo = '/x/web-interface/archive/like';
|
// static const String likeVideo = '/x/web-interface/archive/like';
|
||||||
|
|
||||||
|
// 改用app端点赞接口
|
||||||
|
static const String likeVideo = '${HttpString.appBaseUrl}/x/v2/view/like';
|
||||||
//判断视频是否被点赞(双端)Get
|
//判断视频是否被点赞(双端)Get
|
||||||
// access_key str APP登录Token APP方式必要
|
// access_key str APP登录Token APP方式必要
|
||||||
/// aid num 稿件avid 必要(可选) avid与bvid任选一个
|
/// aid num 稿件avid 必要(可选) avid与bvid任选一个
|
||||||
@@ -50,7 +53,8 @@ class Api {
|
|||||||
/// access_key str APP登录Token 必要
|
/// access_key str APP登录Token 必要
|
||||||
/// aid num 稿件avid 必要
|
/// aid num 稿件avid 必要
|
||||||
///
|
///
|
||||||
static const String dislikeVideo = '${HttpString.appBaseUrl}/x/v2/view/dislike';
|
static const String dislikeVideo =
|
||||||
|
'${HttpString.appBaseUrl}/x/v2/view/dislike';
|
||||||
|
|
||||||
// 投币视频(web端)POST
|
// 投币视频(web端)POST
|
||||||
/// aid num 稿件avid 必要(可选) avid与bvid任选一个
|
/// aid num 稿件avid 必要(可选) avid与bvid任选一个
|
||||||
@@ -59,7 +63,10 @@ class Api {
|
|||||||
/// select_like num 是否附加点赞 非必要 0:不点赞 1:同时点赞 默认为0
|
/// select_like num 是否附加点赞 非必要 0:不点赞 1:同时点赞 默认为0
|
||||||
// csrf str CSRF Token(位于cookie) 必要
|
// csrf str CSRF Token(位于cookie) 必要
|
||||||
// https://api.bilibili.com/x/web-interface/coin/add
|
// https://api.bilibili.com/x/web-interface/coin/add
|
||||||
static const String coinVideo = '/x/web-interface/coin/add';
|
// static const String coinVideo = '/x/web-interface/coin/add';
|
||||||
|
|
||||||
|
// 改用app端投币接口
|
||||||
|
static const String coinVideo = '${HttpString.appBaseUrl}/x/v2/view/coin/add';
|
||||||
|
|
||||||
// 判断视频是否被投币(双端)GET
|
// 判断视频是否被投币(双端)GET
|
||||||
// access_key str APP登录Token APP方式必要
|
// access_key str APP登录Token APP方式必要
|
||||||
@@ -383,13 +390,16 @@ class Api {
|
|||||||
//https://api.bilibili.com/x/msgfeed/like?platform=web&build=0&mobi_app=web
|
//https://api.bilibili.com/x/msgfeed/like?platform=web&build=0&mobi_app=web
|
||||||
static const String msgFeedLike = '/x/msgfeed/like';
|
static const String msgFeedLike = '/x/msgfeed/like';
|
||||||
//https://message.bilibili.com/x/sys-msg/query_user_notify?csrf=xxxx&csrf=xxxx&page_size=20&build=0&mobi_app=web
|
//https://message.bilibili.com/x/sys-msg/query_user_notify?csrf=xxxx&csrf=xxxx&page_size=20&build=0&mobi_app=web
|
||||||
static const String msgSysUserNotify = '${HttpString.messageBaseUrl}/x/sys-msg/query_user_notify';
|
static const String msgSysUserNotify =
|
||||||
|
'${HttpString.messageBaseUrl}/x/sys-msg/query_user_notify';
|
||||||
//https://message.bilibili.com/x/sys-msg/query_unified_notify?csrf=xxxx&csrf=xxxx&page_size=10&build=0&mobi_app=web
|
//https://message.bilibili.com/x/sys-msg/query_unified_notify?csrf=xxxx&csrf=xxxx&page_size=10&build=0&mobi_app=web
|
||||||
static const String msgSysUnifiedNotify = '${HttpString.messageBaseUrl}/x/sys-msg/query_unified_notify';
|
static const String msgSysUnifiedNotify =
|
||||||
|
'${HttpString.messageBaseUrl}/x/sys-msg/query_unified_notify';
|
||||||
|
|
||||||
// 系统信息光标更新(已读标记)
|
// 系统信息光标更新(已读标记)
|
||||||
//https://message.bilibili.com/x/sys-msg/update_cursor?csrf=xxxx&csrf=xxxx&cursor=1705288500000000000&has_up=0&build=0&mobi_app=web
|
//https://message.bilibili.com/x/sys-msg/update_cursor?csrf=xxxx&csrf=xxxx&cursor=1705288500000000000&has_up=0&build=0&mobi_app=web
|
||||||
static const String msgSysUpdateCursor = '${HttpString.messageBaseUrl}/x/sys-msg/update_cursor';
|
static const String msgSysUpdateCursor =
|
||||||
|
'${HttpString.messageBaseUrl}/x/sys-msg/update_cursor';
|
||||||
|
|
||||||
/// 私聊
|
/// 私聊
|
||||||
/// 'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions?
|
/// 'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions?
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ class VideoHttp {
|
|||||||
// };
|
// };
|
||||||
return {
|
return {
|
||||||
'status': false,
|
'status': false,
|
||||||
'data': null,
|
'data': result.data,
|
||||||
'code': result.code,
|
'code': result.code,
|
||||||
'msg': result.message,
|
'msg': result.message,
|
||||||
// 'msg': errMap[result.code] ?? '请求异常',
|
// 'msg': errMap[result.code] ?? '请求异常',
|
||||||
@@ -307,12 +307,16 @@ class VideoHttp {
|
|||||||
var res = await Request().post(
|
var res = await Request().post(
|
||||||
Api.coinVideo,
|
Api.coinVideo,
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'bvid': bvid,
|
'aid': IdUtils.bv2av(bvid),
|
||||||
|
// 'bvid': bvid,
|
||||||
'multiply': multiply,
|
'multiply': multiply,
|
||||||
'select_like': 0,
|
'select_like': 0,
|
||||||
'csrf': await Request.getCsrf(),
|
'access_key': GStorage.localCache
|
||||||
|
.get(LocalCacheKey.accessKey, defaultValue: {})['value'],
|
||||||
|
// 'csrf': await Request.getCsrf(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
print(res);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {'status': true, 'data': res.data['data']};
|
return {'status': true, 'data': res.data['data']};
|
||||||
} else {
|
} else {
|
||||||
@@ -351,10 +355,16 @@ class VideoHttp {
|
|||||||
var res = await Request().post(
|
var res = await Request().post(
|
||||||
Api.likeVideo,
|
Api.likeVideo,
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'bvid': bvid,
|
'aid': IdUtils.bv2av(bvid),
|
||||||
'like': type ? 1 : 2,
|
'like': type ? 0 : 1,
|
||||||
'csrf': await Request.getCsrf(),
|
'access_key': GStorage.localCache
|
||||||
},
|
.get(LocalCacheKey.accessKey, defaultValue: {})['value'],
|
||||||
|
}
|
||||||
|
// queryParameters: {
|
||||||
|
// 'bvid': bvid,
|
||||||
|
// 'like': type ? 1 : 2,
|
||||||
|
// 'csrf': await Request.getCsrf(),
|
||||||
|
// },
|
||||||
);
|
);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {'status': true, 'data': res.data['data']};
|
return {'status': true, 'data': res.data['data']};
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class BangumiIntroController extends GetxController {
|
|||||||
Future actionLikeVideo() async {
|
Future actionLikeVideo() async {
|
||||||
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
|
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
SmartDialog.showToast(!hasLike.value ? '点赞成功' : '取消赞');
|
SmartDialog.showToast(!hasLike.value ? result['data']['toast'] : '取消赞');
|
||||||
hasLike.value = !hasLike.value;
|
hasLike.value = !hasLike.value;
|
||||||
bangumiDetail.value.stat!['likes'] =
|
bangumiDetail.value.stat!['likes'] =
|
||||||
bangumiDetail.value.stat!['likes'] + (!hasLike.value ? 1 : -1);
|
bangumiDetail.value.stat!['likes'] + (!hasLike.value ? 1 : -1);
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ class VideoIntroController extends GetxController {
|
|||||||
List delMediaIdsNew = [];
|
List delMediaIdsNew = [];
|
||||||
// 关注状态 默认未关注
|
// 关注状态 默认未关注
|
||||||
RxMap followStatus = {}.obs;
|
RxMap followStatus = {}.obs;
|
||||||
int _tempThemeValue = -1;
|
|
||||||
|
|
||||||
RxInt lastPlayCid = 0.obs;
|
RxInt lastPlayCid = 0.obs;
|
||||||
var userInfo;
|
var userInfo;
|
||||||
@@ -123,7 +122,8 @@ class VideoIntroController extends GetxController {
|
|||||||
// 获取到粉丝数再返回
|
// 获取到粉丝数再返回
|
||||||
await queryUserStat();
|
await queryUserStat();
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(
|
||||||
|
"${result['code']} ${result['msg']} ${result['data']}");
|
||||||
}
|
}
|
||||||
if (userLogin) {
|
if (userLogin) {
|
||||||
// 获取点赞状态
|
// 获取点赞状态
|
||||||
@@ -175,43 +175,26 @@ class VideoIntroController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 一键三连
|
// 一键三连
|
||||||
Future actionOneThree(BuildContext context) async {
|
Future actionOneThree() async {
|
||||||
|
feedBack();
|
||||||
if (userInfo == null) {
|
if (userInfo == null) {
|
||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasLike.value && hasCoin.value && hasFav.value) {
|
if (hasLike.value && hasCoin.value && hasFav.value) {
|
||||||
// 已点赞、投币、收藏
|
// 已点赞、投币、收藏
|
||||||
SmartDialog.showToast('🙏 UP已经收到了~');
|
SmartDialog.showToast('已三连');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
await showDialog(
|
var result = await VideoHttp.oneThree(bvid: bvid);
|
||||||
context: context,
|
if (result['status']) {
|
||||||
builder: (context) {
|
hasLike.value = result["data"]["like"];
|
||||||
return AlertDialog(
|
hasCoin.value = result["data"]["coin"];
|
||||||
title: const Text('提示'),
|
hasFav.value = result["data"]["fav"];
|
||||||
content: const Text('一键三连 给UP送温暖'),
|
SmartDialog.showToast('三连成功');
|
||||||
actions: [
|
} else {
|
||||||
TextButton(onPressed: () => Get.back(), child: const Text('点错了')),
|
SmartDialog.showToast(result['msg']);
|
||||||
TextButton(
|
}
|
||||||
onPressed: () async {
|
|
||||||
Get.back();
|
|
||||||
var result = await VideoHttp.oneThree(bvid: bvid);
|
|
||||||
if (result['status']) {
|
|
||||||
hasLike.value = result["data"]["like"];
|
|
||||||
hasCoin.value = result["data"]["coin"];
|
|
||||||
hasFav.value = result["data"]["fav"];
|
|
||||||
SmartDialog.showToast('三连成功 🎉');
|
|
||||||
} else {
|
|
||||||
SmartDialog.showToast(result['msg']);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: const Text('确认'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// (取消)点赞
|
// (取消)点赞
|
||||||
@@ -224,7 +207,7 @@ class VideoIntroController extends GetxController {
|
|||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
// hasLike.value = result["data"] == 1 ? true : false;
|
// hasLike.value = result["data"] == 1 ? true : false;
|
||||||
if (!hasLike.value) {
|
if (!hasLike.value) {
|
||||||
SmartDialog.showToast('点赞成功');
|
SmartDialog.showToast(result['data']['toast']);
|
||||||
hasLike.value = true;
|
hasLike.value = true;
|
||||||
hasDislike.value = false;
|
hasDislike.value = false;
|
||||||
videoDetail.value.stat!.like = videoDetail.value.stat!.like! + 1;
|
videoDetail.value.stat!.like = videoDetail.value.stat!.like! + 1;
|
||||||
@@ -268,54 +251,42 @@ class VideoIntroController extends GetxController {
|
|||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
void coinVideo(int coin) async {
|
||||||
|
var res = await VideoHttp.coinVideo(bvid: bvid, multiply: coin);
|
||||||
|
if (res['status']) {
|
||||||
|
print(res);
|
||||||
|
SmartDialog.showToast('投币成功');
|
||||||
|
hasCoin.value = true;
|
||||||
|
videoDetail.value.stat!.coin = videoDetail.value.stat!.coin! + coin;
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: Get.context!,
|
context: Get.context!,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text('选择投币个数'),
|
title: const Text('选择投币个数'),
|
||||||
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
|
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: [
|
actions: [
|
||||||
TextButton(onPressed: () => Get.back(), child: const Text('取消')),
|
TextButton(
|
||||||
|
onPressed: () => Get.back(),
|
||||||
|
child: Text('取消',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.outline))),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var res = await VideoHttp.coinVideo(
|
coinVideo(1);
|
||||||
bvid: bvid, multiply: _tempThemeValue);
|
|
||||||
if (res['status']) {
|
|
||||||
SmartDialog.showToast('投币成功');
|
|
||||||
hasCoin.value = true;
|
|
||||||
videoDetail.value.stat!.coin =
|
|
||||||
videoDetail.value.stat!.coin! + _tempThemeValue;
|
|
||||||
} else {
|
|
||||||
SmartDialog.showToast(res['msg']);
|
|
||||||
}
|
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
child: const Text('确定'))
|
child: const Text('投 1 枚')),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
coinVideo(1);
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
child: const Text('投 2 枚'))
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -444,6 +415,10 @@ class VideoIntroController extends GetxController {
|
|||||||
|
|
||||||
// 关注/取关up
|
// 关注/取关up
|
||||||
Future actionRelationMod(BuildContext context) async {
|
Future actionRelationMod(BuildContext context) async {
|
||||||
|
if (userInfo == null) {
|
||||||
|
SmartDialog.showToast('账号未登录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
feedBack();
|
feedBack();
|
||||||
int mid = videoDetail.value.owner!.mid!;
|
int mid = videoDetail.value.owner!.mid!;
|
||||||
MemberController _ = Get.put<MemberController>(MemberController(mid: mid),
|
MemberController _ = Get.put<MemberController>(MemberController(mid: mid),
|
||||||
|
|||||||
Reference in New Issue
Block a user