7 changed files with 278 additions and 121 deletions
Unified View
Diff Options
-
47lib/controller/mine/my_friend_controller.dart
-
5lib/controller/mine/rose_history_controller.dart
-
5lib/controller/mine/withdraw_history_controller.dart
-
75lib/model/mine/friend_data.dart
-
3lib/network/user_api.dart
-
31lib/network/user_api.g.dart
-
233lib/pages/mine/my_friend_page.dart
@ -1,21 +1,66 @@ |
|||||
|
import 'package:dating_touchme_app/network/user_api.dart'; |
||||
|
import 'package:easy_refresh/easy_refresh.dart'; |
||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
||||
import 'package:get/get.dart'; |
import 'package:get/get.dart'; |
||||
|
|
||||
|
import '../../model/mine/friend_data.dart'; |
||||
|
|
||||
class MyFriendController extends GetxController with GetSingleTickerProviderStateMixin { |
class MyFriendController extends GetxController with GetSingleTickerProviderStateMixin { |
||||
|
|
||||
late TabController tabController; |
late TabController tabController; |
||||
|
|
||||
final sum = 0.obs; |
final sum = 0.obs; |
||||
|
|
||||
|
final page = 1.obs; |
||||
|
final size = 10.obs; |
||||
|
|
||||
|
late UserApi _userApi; |
||||
|
|
||||
|
late final EasyRefreshController listRefreshController; |
||||
|
|
||||
|
final friendList = <Records>[].obs; |
||||
@override |
@override |
||||
void onInit() { |
void onInit() { |
||||
super.onInit(); |
super.onInit(); |
||||
|
|
||||
tabController = TabController(length: 4, vsync: this); |
|
||||
|
tabController = TabController(length: 3, vsync: this); |
||||
|
|
||||
|
listRefreshController = EasyRefreshController( |
||||
|
controlFinishRefresh: true, |
||||
|
controlFinishLoad: true, |
||||
|
); |
||||
|
_userApi = Get.find<UserApi>(); |
||||
|
|
||||
|
getFriendList(); |
||||
} |
} |
||||
|
|
||||
getFriendList() async { |
getFriendList() async { |
||||
|
try{ |
||||
|
final response = await _userApi.userPageFriendRelation( |
||||
|
pageNum: page.value, |
||||
|
pageSize: size.value, |
||||
|
); |
||||
|
if (response.data.isSuccess && response.data.data != null) { |
||||
|
final data = response.data.data?.records ?? []; |
||||
|
|
||||
|
friendList.addAll(data.toList()); |
||||
|
if((data.length ?? 0) == size.value){ |
||||
|
|
||||
|
listRefreshController.finishLoad(IndicatorResult.success); |
||||
|
} else { |
||||
|
listRefreshController.finishLoad(IndicatorResult.noMore); |
||||
|
} |
||||
|
} else { |
||||
|
|
||||
|
// 响应失败,抛出异常 |
||||
|
throw Exception(response.data.message ?? '获取数据失败'); |
||||
|
} |
||||
|
} catch(e) { |
||||
|
print('玫瑰记录获取失败: $e'); |
||||
|
SmartDialog.showToast('玫瑰记录获取失败'); |
||||
|
rethrow; |
||||
|
} |
||||
} |
} |
||||
|
|
||||
} |
} |
||||
@ -0,0 +1,75 @@ |
|||||
|
class FriendData { |
||||
|
List<Records>? records; |
||||
|
int? total; |
||||
|
int? size; |
||||
|
int? current; |
||||
|
int? pages; |
||||
|
|
||||
|
FriendData({this.records, this.total, this.size, this.current, this.pages}); |
||||
|
|
||||
|
FriendData.fromJson(Map<String, dynamic> json) { |
||||
|
if (json['records'] != null) { |
||||
|
records = <Records>[]; |
||||
|
json['records'].forEach((v) { |
||||
|
records!.add(new Records.fromJson(v)); |
||||
|
}); |
||||
|
} |
||||
|
total = json['total']; |
||||
|
size = json['size']; |
||||
|
current = json['current']; |
||||
|
pages = json['pages']; |
||||
|
} |
||||
|
|
||||
|
Map<String, dynamic> toJson() { |
||||
|
final Map<String, dynamic> data = new Map<String, dynamic>(); |
||||
|
if (this.records != null) { |
||||
|
data['records'] = this.records!.map((v) => v.toJson()).toList(); |
||||
|
} |
||||
|
data['total'] = this.total; |
||||
|
data['size'] = this.size; |
||||
|
data['current'] = this.current; |
||||
|
data['pages'] = this.pages; |
||||
|
return data; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class Records { |
||||
|
int? genderCode; |
||||
|
String? id; |
||||
|
String? miId; |
||||
|
String? nickName; |
||||
|
String? profilePhoto; |
||||
|
String? uid; |
||||
|
String? userId; |
||||
|
|
||||
|
Records( |
||||
|
{this.genderCode, |
||||
|
this.id, |
||||
|
this.miId, |
||||
|
this.nickName, |
||||
|
this.profilePhoto, |
||||
|
this.uid, |
||||
|
this.userId}); |
||||
|
|
||||
|
Records.fromJson(Map<String, dynamic> json) { |
||||
|
genderCode = json['genderCode']; |
||||
|
id = json['id']; |
||||
|
miId = json['miId']; |
||||
|
nickName = json['nickName']; |
||||
|
profilePhoto = json['profilePhoto']; |
||||
|
uid = json['uid']; |
||||
|
userId = json['userId']; |
||||
|
} |
||||
|
|
||||
|
Map<String, dynamic> toJson() { |
||||
|
final Map<String, dynamic> data = new Map<String, dynamic>(); |
||||
|
data['genderCode'] = this.genderCode; |
||||
|
data['id'] = this.id; |
||||
|
data['miId'] = this.miId; |
||||
|
data['nickName'] = this.nickName; |
||||
|
data['profilePhoto'] = this.profilePhoto; |
||||
|
data['uid'] = this.uid; |
||||
|
data['userId'] = this.userId; |
||||
|
return data; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save