mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 补充关注相关操作;统一关注表现
This commit is contained in:
@@ -509,10 +509,11 @@ class VideoHttp {
|
|||||||
're_src': reSrc,
|
're_src': reSrc,
|
||||||
'csrf': await Request.getCsrf(),
|
'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};
|
||||||
} else {
|
} else {
|
||||||
return {'status': false, 'data': []};
|
return {'status': false, 'msg': res.data['message']};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,14 +11,18 @@ import 'package:PiliPalaX/models/member/info.dart';
|
|||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
|
import '../video/detail/introduction/widgets/group_panel.dart';
|
||||||
|
|
||||||
class MemberController extends GetxController {
|
class MemberController extends GetxController {
|
||||||
late int mid;
|
int? mid;
|
||||||
|
MemberController({this.mid});
|
||||||
Rx<MemberInfoModel> memberInfo = MemberInfoModel().obs;
|
Rx<MemberInfoModel> memberInfo = MemberInfoModel().obs;
|
||||||
late Map userStat;
|
late Map userStat;
|
||||||
RxString face = ''.obs;
|
RxString face = ''.obs;
|
||||||
String? heroTag;
|
String? heroTag;
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
late int ownerMid;
|
late int ownerMid;
|
||||||
|
bool specialFollowed = false;
|
||||||
// 投稿列表
|
// 投稿列表
|
||||||
RxList<VListItemModel>? archiveList = <VListItemModel>[].obs;
|
RxList<VListItemModel>? archiveList = <VListItemModel>[].obs;
|
||||||
dynamic userInfo;
|
dynamic userInfo;
|
||||||
@@ -27,9 +31,9 @@ class MemberController extends GetxController {
|
|||||||
RxList<MemberCoinsDataModel> recentCoinsList = <MemberCoinsDataModel>[].obs;
|
RxList<MemberCoinsDataModel> recentCoinsList = <MemberCoinsDataModel>[].obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() async {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
mid = int.parse(Get.parameters['mid']!);
|
mid = mid ?? int.parse(Get.parameters['mid']!);
|
||||||
userInfo = userInfoCache.get('userInfoCache');
|
userInfo = userInfoCache.get('userInfoCache');
|
||||||
ownerMid = userInfo != null ? userInfo.mid : -1;
|
ownerMid = userInfo != null ? userInfo.mid : -1;
|
||||||
face.value = Get.arguments['face'] ?? '';
|
face.value = Get.arguments['face'] ?? '';
|
||||||
@@ -60,13 +64,21 @@ class MemberController extends GetxController {
|
|||||||
|
|
||||||
// 获取用户播放数 获赞数
|
// 获取用户播放数 获赞数
|
||||||
Future<Map<String, dynamic>> getMemberView() async {
|
Future<Map<String, dynamic>> getMemberView() async {
|
||||||
var res = await MemberHttp.memberView(mid: mid);
|
var res = await MemberHttp.memberView(mid: mid!);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
userStat.addAll(res['data']);
|
userStat.addAll(res['data']);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future delayedUpdateRelation() async {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 1000), () async {
|
||||||
|
SmartDialog.showToast('更新状态');
|
||||||
|
await relationSearch();
|
||||||
|
memberInfo.update((val) {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 关注/取关up
|
// 关注/取关up
|
||||||
Future actionRelationMod(BuildContext context) async {
|
Future actionRelationMod(BuildContext context) async {
|
||||||
if (userInfo == null) {
|
if (userInfo == null) {
|
||||||
@@ -85,62 +97,97 @@ class MemberController extends GetxController {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text('提示'),
|
title: const Text('操作'),
|
||||||
content: Text(memberInfo.value.isFollowed! ? '取消关注UP主?' : '关注UP主?'),
|
|
||||||
actions: [
|
actions: [
|
||||||
|
if (memberInfo.value.isFollowed!) ...[
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Get.back(),
|
onPressed: () async {
|
||||||
child: Text(
|
final res = await MemberHttp.addUsers(
|
||||||
'点错了',
|
mid, specialFollowed ? '0' : '-10');
|
||||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
SmartDialog.showToast(res['msg']);
|
||||||
),
|
if (res['status']) {
|
||||||
|
specialFollowed = !specialFollowed;
|
||||||
|
}
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
child: Text(specialFollowed ? '移除特别关注' : '加入特别关注'),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
await Get.bottomSheet(
|
||||||
|
GroupPanel(mid: mid),
|
||||||
|
isScrollControlled: true,
|
||||||
|
);
|
||||||
Get.back();
|
Get.back();
|
||||||
await VideoHttp.relationMod(
|
},
|
||||||
mid: mid,
|
child: const Text('设置分组'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
var res = await VideoHttp.relationMod(
|
||||||
|
mid: mid!,
|
||||||
act: memberInfo.value.isFollowed! ? 2 : 1,
|
act: memberInfo.value.isFollowed! ? 2 : 1,
|
||||||
reSrc: 11,
|
reSrc: 11,
|
||||||
);
|
);
|
||||||
|
SmartDialog.showToast(res['status'] ? "操作成功" : res['msg']);
|
||||||
|
if (res['status']) {
|
||||||
memberInfo.value.isFollowed = !memberInfo.value.isFollowed!;
|
memberInfo.value.isFollowed = !memberInfo.value.isFollowed!;
|
||||||
relationSearch();
|
}
|
||||||
memberInfo.update((val) {});
|
Get.back();
|
||||||
},
|
},
|
||||||
child: const Text('确认'),
|
child: Text(memberInfo.value.isFollowed! ? '取消关注' : '关注'),
|
||||||
)
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Get.back(),
|
||||||
|
child: Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
await delayedUpdateRelation();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关系查询
|
// 关系查询
|
||||||
Future relationSearch() async {
|
Future relationSearch() async {
|
||||||
if (userInfo == null) return;
|
if (userInfo == null) return;
|
||||||
if (mid == ownerMid) return;
|
if (mid == ownerMid) return;
|
||||||
var res = await UserHttp.hasFollow(mid);
|
var res = await UserHttp.hasFollow(mid!);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
attribute.value = res['data']['attribute'];
|
attribute.value = res['data']['attribute'];
|
||||||
switch (attribute.value) {
|
switch (attribute.value) {
|
||||||
case 1:
|
case 1:
|
||||||
attributeText.value = '悄悄关注';
|
attributeText.value = '悄悄关注';
|
||||||
|
memberInfo.value.isFollowed = true;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
attributeText.value = '已关注';
|
attributeText.value = '已关注';
|
||||||
|
memberInfo.value.isFollowed = true;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
attributeText.value = '已互关';
|
attributeText.value = '已互关';
|
||||||
|
memberInfo.value.isFollowed = true;
|
||||||
break;
|
break;
|
||||||
case 128:
|
case 128:
|
||||||
attributeText.value = '已拉黑';
|
attributeText.value = '已拉黑';
|
||||||
|
memberInfo.value.isFollowed = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
attributeText.value = '关注';
|
attributeText.value = '关注';
|
||||||
|
memberInfo.value.isFollowed = false;
|
||||||
}
|
}
|
||||||
if (res['data']['special'] == 1) {
|
if (res['data']['special'] == 1) {
|
||||||
attributeText.value += 'SP';
|
specialFollowed = true;
|
||||||
|
attributeText.value += ' 🔔';
|
||||||
|
} else {
|
||||||
|
specialFollowed = false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +215,7 @@ class MemberController extends GetxController {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Get.back();
|
Get.back();
|
||||||
var res = await VideoHttp.relationMod(
|
var res = await VideoHttp.relationMod(
|
||||||
mid: mid,
|
mid: mid!,
|
||||||
act: attribute.value != 128 ? 5 : 6,
|
act: attribute.value != 128 ? 5 : 6,
|
||||||
reSrc: 11,
|
reSrc: 11,
|
||||||
);
|
);
|
||||||
@@ -205,7 +252,7 @@ class MemberController extends GetxController {
|
|||||||
// 请求投币视频
|
// 请求投币视频
|
||||||
Future getRecentCoinVideo() async {
|
Future getRecentCoinVideo() async {
|
||||||
if (userInfo == null) return;
|
if (userInfo == null) return;
|
||||||
var res = await MemberHttp.getRecentCoinVideo(mid: mid);
|
var res = await MemberHttp.getRecentCoinVideo(mid: mid!);
|
||||||
recentCoinsList.value = res['data'];
|
recentCoinsList.value = res['data'];
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import 'package:PiliPalaX/utils/feed_back.dart';
|
|||||||
import 'package:PiliPalaX/utils/id_utils.dart';
|
import 'package:PiliPalaX/utils/id_utils.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
|
import 'package:PiliPalaX/pages/member/controller.dart';
|
||||||
|
|
||||||
import '../related/index.dart';
|
import '../related/index.dart';
|
||||||
import 'widgets/group_panel.dart';
|
import 'widgets/group_panel.dart';
|
||||||
@@ -191,9 +193,7 @@ class VideoIntroController extends GetxController {
|
|||||||
title: const Text('提示'),
|
title: const Text('提示'),
|
||||||
content: const Text('一键三连 给UP送温暖'),
|
content: const Text('一键三连 给UP送温暖'),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(onPressed: () => Get.back(), child: const Text('点错了')),
|
||||||
onPressed: () => Get.back(),
|
|
||||||
child: const Text('点错了')),
|
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Get.back();
|
Get.back();
|
||||||
@@ -446,82 +446,14 @@ class VideoIntroController extends GetxController {
|
|||||||
// 关注/取关up
|
// 关注/取关up
|
||||||
Future actionRelationMod(BuildContext context) async {
|
Future actionRelationMod(BuildContext context) async {
|
||||||
feedBack();
|
feedBack();
|
||||||
if (userInfo == null) {
|
int mid = videoDetail.value.owner!.mid!;
|
||||||
SmartDialog.showToast('账号未登录');
|
MemberController _ = Get.put<MemberController>(MemberController(mid: mid),
|
||||||
return;
|
tag: mid.toString());
|
||||||
}
|
await _.getInfo();
|
||||||
final int currentStatus = followStatus['attribute'];
|
if (context.mounted) await _.actionRelationMod(context);
|
||||||
int actionStatus = 0;
|
followStatus['attribute'] = _.attribute.value;
|
||||||
switch (currentStatus) {
|
|
||||||
case 0:
|
|
||||||
actionStatus = 1;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
actionStatus = 2;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
actionStatus = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('提示'),
|
|
||||||
content: Text(currentStatus == 0 ? '关注UP主?' : '取消关注UP主?'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Get.back(),
|
|
||||||
child: Text(
|
|
||||||
'点错了',
|
|
||||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
var result = await VideoHttp.relationMod(
|
|
||||||
mid: videoDetail.value.owner!.mid!,
|
|
||||||
act: actionStatus,
|
|
||||||
reSrc: 14,
|
|
||||||
);
|
|
||||||
if (result['status']) {
|
|
||||||
switch (currentStatus) {
|
|
||||||
case 0:
|
|
||||||
actionStatus = 2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
actionStatus = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
actionStatus = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
followStatus['attribute'] = actionStatus;
|
|
||||||
followStatus.refresh();
|
followStatus.refresh();
|
||||||
if (actionStatus == 2) {
|
Get.delete<MemberController>(tag: mid.toString());
|
||||||
if (context.mounted) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: const Text('关注成功'),
|
|
||||||
duration: const Duration(seconds: 2),
|
|
||||||
action: SnackBarAction(
|
|
||||||
label: '设置分组',
|
|
||||||
onPressed: setFollowGroup,
|
|
||||||
),
|
|
||||||
showCloseIcon: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
child: const Text('确认'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改分P或番剧分集
|
// 修改分P或番剧分集
|
||||||
|
|||||||
Reference in New Issue
Block a user