feat: search user by uid
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/member.dart';
|
||||
import 'package:pilipala/http/search.dart';
|
||||
import 'package:pilipala/models/common/search_type.dart';
|
||||
import 'package:pilipala/models/search/result.dart';
|
||||
import 'package:pilipala/utils/id_utils.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
@ -39,6 +41,30 @@ class SearchPanelController extends GetxController {
|
||||
page.value++;
|
||||
onPushDetail(keyword, resultList);
|
||||
}
|
||||
if (RegExp(r'^\d+$').hasMatch(keyword!) &&
|
||||
searchType == SearchType.bili_user) {
|
||||
var res = await MemberHttp.memberInfo(mid: int.parse(keyword!));
|
||||
if (res['status']) {
|
||||
try {
|
||||
final user = SearchUserItemModel(
|
||||
mid: res['data'].mid,
|
||||
uname: res['data'].name,
|
||||
upic: res['data'].face,
|
||||
level: res['data'].level,
|
||||
fans: null,
|
||||
videos: null,
|
||||
officialVerify: res['data'].official,
|
||||
);
|
||||
if (resultList.isEmpty) {
|
||||
resultList = [user].obs;
|
||||
} else {
|
||||
resultList.insert(0, user);
|
||||
}
|
||||
} catch (err) {
|
||||
debugPrint('搜索用户信息失败: $err');
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -13,10 +13,10 @@ Widget searchUserPanel(BuildContext context, ctr, list) {
|
||||
controller: ctr!.scrollController,
|
||||
addAutomaticKeepAlives: false,
|
||||
addRepaintBoundaries: false,
|
||||
itemCount: list!.length,
|
||||
itemCount: list.length,
|
||||
itemBuilder: (context, index) {
|
||||
var i = list![index];
|
||||
String heroTag = Utils.makeHeroTag(i!.mid);
|
||||
var i = list[index];
|
||||
String heroTag = Utils.makeHeroTag(i.mid);
|
||||
return InkWell(
|
||||
onTap: () => Get.toNamed('/member?mid=${i.mid}',
|
||||
arguments: {'heroTag': heroTag, 'face': i.upic}),
|
||||
@ -43,7 +43,7 @@ Widget searchUserPanel(BuildContext context, ctr, list) {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
i!.uname,
|
||||
i.uname!,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
@ -55,15 +55,16 @@ Widget searchUserPanel(BuildContext context, ctr, list) {
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text('粉丝:${i.fans} ', style: style),
|
||||
Text(' 视频:${i.videos}', style: style)
|
||||
],
|
||||
),
|
||||
if (i.officialVerify['desc'] != '')
|
||||
if (i.fans != null && i.videos != null)
|
||||
Row(
|
||||
children: [
|
||||
Text('粉丝:${i.fans} ', style: style),
|
||||
Text(' 视频:${i.videos}', style: style)
|
||||
],
|
||||
),
|
||||
if (i.officialVerify!['desc'] != '')
|
||||
Text(
|
||||
i.officialVerify['desc'],
|
||||
i.officialVerify!['desc'],
|
||||
style: style,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user