opt: addUsers

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-24 10:35:39 +08:00
parent 65eecb8dcf
commit 33b8902375
2 changed files with 11 additions and 9 deletions

View File

@@ -504,12 +504,16 @@ class MemberHttp {
} }
// 设置分组 // 设置分组
static Future addUsers(int? fids, String? tagids) async { static Future addUsers(List<int?> fids, List<int?> tagids) async {
var res = await Request().post( var res = await Request().post(
Api.addUsers, Api.addUsers,
queryParameters: {
'x-bili-device-req-json':
'{"platform":"web","device":"pc","spmid":"333.1387"}'
},
data: { data: {
'fids': fids, 'fids': fids.join(','),
'tagids': tagids ?? '0', 'tagids': tagids.join(','),
'csrf': Accounts.main.csrf, 'csrf': Accounts.main.csrf,
// 'cross_domain': true // 'cross_domain': true
}, },

View File

@@ -50,21 +50,19 @@ class _GroupPanelState extends State<GroupPanel> {
// 是否有选中的 有选中的带id没选使用默认0 // 是否有选中的 有选中的带id没选使用默认0
final bool anyHasChecked = final bool anyHasChecked =
tagsList.any((MemberTagItemModel e) => e.checked == true); tagsList.any((MemberTagItemModel e) => e.checked == true);
late String tagids; late List<int> tagidList;
List<int>? tagidList;
if (anyHasChecked) { if (anyHasChecked) {
final List<MemberTagItemModel> checkedList = final List<MemberTagItemModel> checkedList =
tagsList.where((MemberTagItemModel e) => e.checked == true).toList(); tagsList.where((MemberTagItemModel e) => e.checked == true).toList();
tagidList = checkedList.map<int>((e) => e.tagid!).toList(); tagidList = checkedList.map<int>((e) => e.tagid!).toList();
tagids = tagidList.join(',');
} else { } else {
tagids = '0'; tagidList = [0];
} }
// 保存 // 保存
final res = await MemberHttp.addUsers(widget.mid, tagids); final res = await MemberHttp.addUsers([widget.mid], tagidList);
SmartDialog.showToast(res['msg']); SmartDialog.showToast(res['msg']);
if (res['status']) { if (res['status']) {
Get.back(result: tagidList ?? []); Get.back(result: tagidList);
} }
} }