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