feat: 搜索计数
This commit is contained in:
@ -1,8 +1,11 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/search.dart';
|
||||
import 'package:pilipala/models/common/search_type.dart';
|
||||
|
||||
class SearchResultController extends GetxController {
|
||||
String? keyword;
|
||||
int tabIndex = 0;
|
||||
RxList searchTabs = [].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -10,5 +13,21 @@ class SearchResultController extends GetxController {
|
||||
if (Get.parameters.keys.isNotEmpty) {
|
||||
keyword = Get.parameters['keyword'];
|
||||
}
|
||||
searchTabs.value = SearchType.values
|
||||
.map((type) => {'label': type.label, 'id': type.type})
|
||||
.toList();
|
||||
querySearchCount();
|
||||
}
|
||||
|
||||
Future querySearchCount() async {
|
||||
var result = await SearchHttp.searchCount(keyword: keyword!);
|
||||
if (result['status']) {
|
||||
for (var i in searchTabs) {
|
||||
final count = result['data'].topTList[i['id']];
|
||||
i['count'] = count > 99 ? '99+' : count.toString();
|
||||
}
|
||||
searchTabs.refresh();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user