王子贤 2 months ago
parent
commit
f9e0ca5550
8 changed files with 431 additions and 246 deletions
  1. 4
      lib/controller/home/event_list_controller.dart
  2. 50
      lib/controller/home/user_information_controller.dart
  3. 3
      lib/network/api_urls.dart
  4. 8
      lib/network/user_api.dart
  5. 39
      lib/network/user_api.g.dart
  6. 2
      lib/pages/home/all_timeline.dart
  7. 43
      lib/pages/home/event_list.dart
  8. 528
      lib/pages/home/user_information_page.dart

4
lib/controller/home/event_list_controller.dart

@ -12,6 +12,8 @@ class EventListController extends GetxController {
final page = 1.obs;
final size = 10.obs;
final tab = 0.obs;
final eventList = <Records>[].obs;
late final EasyRefreshController listRefreshController;
@ -34,7 +36,7 @@ class EventListController extends GetxController {
final response = await _homeApi.userGetSiteActivityPage(
pageNum: page.value,
pageSize: size.value,
queryType: 2
queryType: tab.value == 0 ? 1 : 2
);
if (response.data.isSuccess && response.data.data != null) {
final data = response.data.data?.records ?? [];

50
lib/controller/home/user_information_controller.dart

@ -1,9 +1,12 @@
import 'package:dating_touchme_app/controller/global.dart';
import 'package:dating_touchme_app/model/home/user_info_data.dart';
import 'package:dating_touchme_app/network/user_api.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import '../../model/home/post_data.dart';
class UserInformationController extends GetxController {
final String miId;
@ -28,10 +31,24 @@ class UserInformationController extends GetxController {
late UserApi _userApi;
final page = 1.obs;
final size = 10.obs;
final postList = <Records>[].obs;
late final EasyRefreshController listRefreshController;
@override
void onInit() {
super.onInit();
listRefreshController = EasyRefreshController(
controlFinishRefresh: true,
controlFinishLoad: true,
);
//
if (miId.isEmpty) {
errorMessage.value = '用户ID无效';
@ -55,6 +72,37 @@ class UserInformationController extends GetxController {
isLoading.value = false;
SmartDialog.showToast('初始化失败,请稍后重试');
}
getPostList();
}
getPostList() async {
try{
final response = await _userApi.userPageAuthorPost(
pageNum: page.value,
pageSize: size.value,
authorUserId: userId
);
if (response.data.isSuccess && response.data.data != null) {
final data = response.data.data?.records ?? [];
postList.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;
}
}
int calculateAge(String birthdayStr) {

3
lib/network/api_urls.dart

@ -134,6 +134,9 @@ class ApiUrls {
static const String userGetSiteActivityDetails =
'dating-agency-service/user/get/site/activity/details';
static const String userPageAuthorPost =
'dating-agency-service/user/page/author-post';
// API端点
static const String listMatchmakerProduct =
'dating-agency-mall/user/page/product/by/matchmaker';

8
lib/network/user_api.dart

@ -1,4 +1,5 @@
import 'package:dating_touchme_app/model/common/oss_data.dart';
import 'package:dating_touchme_app/model/home/post_data.dart';
import 'package:dating_touchme_app/model/home/user_info_data.dart';
import 'package:dating_touchme_app/model/mine/bank_card_data.dart';
import 'package:dating_touchme_app/model/mine/bank_card_ocr_data.dart';
@ -269,4 +270,11 @@ abstract class UserApi {
@Body() Map<String, dynamic> data,
);
@GET(ApiUrls.userPageAuthorPost)
Future<HttpResponse<BaseResponse<PostData>>> userPageAuthorPost({
@Query('pageNum') required int pageNum,
@Query('pageSize') required int pageSize,
@Query('authorUserId') required String authorUserId,
});
}

39
lib/network/user_api.g.dart

@ -1635,6 +1635,45 @@ class _UserApi implements UserApi {
return httpResponse;
}
@override
Future<HttpResponse<BaseResponse<PostData>>> userPageAuthorPost({
required int pageNum,
required int pageSize,
required String authorUserId,
}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{
r'pageNum': pageNum,
r'pageSize': pageSize,
r'authorUserId': authorUserId,
};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<HttpResponse<BaseResponse<PostData>>>(
Options(method: 'GET', headers: _headers, extra: _extra)
.compose(
_dio.options,
'dating-agency-service/user/page/author-post',
queryParameters: queryParameters,
data: _data,
)
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
);
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late BaseResponse<PostData> _value;
try {
_value = BaseResponse<PostData>.fromJson(
_result.data!,
(json) => PostData.fromJson(json as Map<String, dynamic>),
);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
final httpResponse = HttpResponse(_value, _result);
return httpResponse;
}
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
if (T != dynamic &&
!(requestOptions.responseType == ResponseType.bytes ||

2
lib/pages/home/all_timeline.dart

@ -148,7 +148,7 @@ class _AllTimelineState extends State<AllTimeline>
return const SizedBox(height: 12);
},
// item
itemCount: controller.postList.length,
itemCount: controller.postList.isEmpty ? 1 : controller.postList.length,
)
);
});

43
lib/pages/home/event_list.dart

@ -69,38 +69,67 @@ class EventList extends StatelessWidget {
height: 50.w,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(width: 1, color: Colors.black)
bottom: BorderSide(width: 1, color: controller.tab.value == 0 ? const Color.fromRGBO(117, 98, 249, 1) : Colors.black)
)
),
child: Center(
child: Text(
"我的活动"
"我的活动",
style: TextStyle(
color: controller.tab.value == 0 ? const Color.fromRGBO(117, 98, 249, 1) : const Color.fromRGBO(51, 51, 51, 1)
),
),
),
),
).onTap(() async {
if(controller.tab.value == 0) return;
controller.tab.value = 0;
controller.page.value = 1;
controller.eventList.clear();
await controller.getEventList();
}),
),
Expanded(
child: Container(
height: 50.w,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(width: 1, color: Colors.black)
bottom: BorderSide(width: 1, color: controller.tab.value == 1 ? const Color.fromRGBO(117, 98, 249, 1) : Colors.black)
)
),
child: Center(
child: Text(
"我的活动"
"全部活动",
style: TextStyle(
color: controller.tab.value == 1 ? const Color.fromRGBO(117, 98, 249, 1) : const Color.fromRGBO(51, 51, 51, 1)
),
),
),
),
).onTap(() async {
if(controller.tab.value == 1) return;
controller.tab.value = 1;
controller.page.value = 1;
controller.eventList.clear();
await controller.getEventList();
}),
),
],
),
SizedBox(height: 15.w,),
Expanded(
child: ListView.builder(
itemCount: controller.eventList.length,
itemCount: controller.eventList.isEmpty ? 1 : controller.eventList.length,
itemBuilder: (_, index) {
if(controller.eventList.isEmpty){
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('暂无数据'),
],
),
);
}
return EventItem(item: controller.eventList[index],);
},
),

528
lib/pages/home/user_information_page.dart

@ -4,7 +4,9 @@ import 'package:dating_touchme_app/controller/home/user_information_controller.d
import 'package:dating_touchme_app/generated/assets.dart';
import 'package:dating_touchme_app/model/home/marriage_data.dart';
import 'package:dating_touchme_app/pages/home/report_page.dart';
import 'package:dating_touchme_app/pages/home/timeline_item.dart';
import 'package:dating_touchme_app/pages/message/chat_page.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@ -96,215 +98,313 @@ class UserInformationPage extends StatelessWidget {
height: 384.w,
fit: BoxFit.cover,
),
SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(top: 361.w),
child: Container(
height: 812.h - 361.w - 50,
width: 375.w,
padding: EdgeInsets.only(
top: 31.w,
left: 15.w,
right: 24.w
),
decoration: BoxDecoration(
borderRadius: BorderRadius.vertical(
top: Radius.circular(23.w)
),
color: Colors.white
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Text(
controller.userData.value.nickName ?? "",
style: TextStyle(
fontSize: 22.w,
color: const Color.fromRGBO(51, 51, 51, 1),
fontWeight: FontWeight.w600
),
Positioned(
left: 15.w,
top: 310.w,
width: 345.w,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
...controller.userData.value.photoList!.asMap().entries.map((entry){
return Container(
margin: EdgeInsets.only(right: 7.w),
child: InkWell(
onTap: (){
controller.nowSelect.value = entry.key;
},
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(7.w)),
child: Container(
width: 40.w,
height: 40.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(7.w)),
border: controller.nowSelect.value == entry.key ? Border.all(width: 2.w, color: Colors.white) : null
),
SizedBox(width: 13.w,),
if(controller.myUserData.value?.genderCode == 0) Container(
width: 33.w,
height: 13.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13.w)),
color: const Color.fromRGBO(255, 237, 255, 1)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
Assets.imagesFemale,
width: 8.w,
height: 8.w,
),
SizedBox(width: 2.w,),
Text(
"${
controller.calculateAge(
(controller.userData.value.birthDate != null && controller.userData.value.birthDate!.isNotEmpty) ?
(controller.userData.value.birthDate ?? "") : controller.userData.value.birthYear != null && controller.userData.value.birthYear!.isNotEmpty ?
"${controller.userData.value.birthYear}-01-01" : "")
}",
style: TextStyle(
fontSize: 11.w,
color: const Color.fromRGBO(255, 66, 236, 1)
),
)
],
child: Center(
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(7.w)),
child: CachedNetworkImage(
imageUrl: "${entry.value.photoUrl}?x-oss-process=image/format,webp/resize,w_76",
width: 38.w,
height: 38.w,
fit: BoxFit.cover,
),
),
),
SizedBox(width: 3.w,),
Container(
width: 33.w,
height: 13.w,
margin: EdgeInsets.only(right: 2.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13.w)),
color: const Color.fromRGBO(234, 255, 219, 1)
),
child: Center(
child: Text(
"在线",
style: TextStyle(
fontSize: 11.w,
color: const Color.fromRGBO(38, 199, 124, 1)
),
),
),
),
);
}),
],
),
),
),
EasyRefresh(
controller: controller.listRefreshController,
header: const ClassicHeader(
dragText: '下拉刷新',
armedText: '释放刷新',
readyText: '刷新中...',
processingText: '刷新中...',
processedText: '刷新完成',
failedText: '刷新失败',
noMoreText: '没有更多数据',
showMessage: false
),
footer: ClassicFooter(
dragText: '上拉加载',
armedText: '释放加载',
readyText: '加载中...',
processingText: '加载中...',
processedText: '加载完成',
failedText: '加载失败',
noMoreText: '没有更多数据',
showMessage: false
),
//
onRefresh: () async {
print('推荐列表下拉刷新被触发');
controller.page.value = 1;
controller.postList.clear();
await controller.getPostList();
controller.listRefreshController.finishRefresh(IndicatorResult.success);
controller.listRefreshController.finishLoad(IndicatorResult.none);
},
//
onLoad: () async {
print('推荐列表上拉加载被触发, hasMore: ');
controller.page.value += 1;
await controller.getPostList();
},
child: SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(top: 361.w),
child: Container(
width: 375.w,
padding: EdgeInsets.only(
top: 31.w,
left: 15.w,
right: 24.w
),
decoration: BoxDecoration(
borderRadius: BorderRadius.vertical(
top: Radius.circular(23.w)
),
color: Colors.white
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Text(
controller.userData.value.nickName ?? "",
style: TextStyle(
fontSize: 22.w,
color: const Color.fromRGBO(51, 51, 51, 1),
fontWeight: FontWeight.w600
),
),
),
SizedBox(width: 4.w,),
if (controller.userData.value.identityCard != "" && controller.userData.value.identityCard != null) Container(
width: 43.w,
height: 13.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13.w)),
color: const Color.fromRGBO(246, 237, 255, 1)
SizedBox(width: 13.w,),
if(controller.myUserData.value?.genderCode == 0) Container(
width: 33.w,
height: 13.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13.w)),
color: const Color.fromRGBO(255, 237, 255, 1)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
Assets.imagesFemale,
width: 8.w,
height: 8.w,
),
SizedBox(width: 2.w,),
Text(
"${
controller.calculateAge(
(controller.userData.value.birthDate != null && controller.userData.value.birthDate!.isNotEmpty) ?
(controller.userData.value.birthDate ?? "") : controller.userData.value.birthYear != null && controller.userData.value.birthYear!.isNotEmpty ?
"${controller.userData.value.birthYear}-01-01" : "")
}",
style: TextStyle(
fontSize: 11.w,
color: const Color.fromRGBO(255, 66, 236, 1)
),
)
],
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
Assets.imagesRealName,
width: 8.w,
height: 7.w,
),
SizedBox(width: 2.w,),
Text(
"实名",
SizedBox(width: 3.w,),
Container(
width: 33.w,
height: 13.w,
margin: EdgeInsets.only(right: 2.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13.w)),
color: const Color.fromRGBO(234, 255, 219, 1)
),
child: Center(
child: Text(
"在线",
style: TextStyle(
fontSize: 11.w,
color: const Color.fromRGBO(160, 92, 255, 1)
color: const Color.fromRGBO(38, 199, 124, 1)
),
)
],
),
),
),
),
SizedBox(width: 4.w,),
if(controller.myUserData.value?.genderCode == 1) Container(
width: 33.w,
height: 13.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13.w)),
color: const Color.fromRGBO(237, 245, 255, 1)
SizedBox(width: 4.w,),
if (controller.userData.value.identityCard != "" && controller.userData.value.identityCard != null) Container(
width: 43.w,
height: 13.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13.w)),
color: const Color.fromRGBO(246, 237, 255, 1)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
Assets.imagesRealName,
width: 8.w,
height: 7.w,
),
SizedBox(width: 2.w,),
Text(
"实名",
style: TextStyle(
fontSize: 11.w,
color: const Color.fromRGBO(160, 92, 255, 1)
),
)
],
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
Assets.imagesMale,
width: 8.w,
height: 8.w,
),
SizedBox(width: 2.w,),
Text(
"${controller.calculateAge(controller.userData.value.birthDate ?? (controller.userData.value.birthYear != null && controller.userData.value.birthYear!.isNotEmpty ? "${controller.userData.value.birthYear}-01-01" : ""))}",
style: TextStyle(
fontSize: 11.w,
color: const Color.fromRGBO(120, 140, 255, 1)
SizedBox(width: 4.w,),
if(controller.myUserData.value?.genderCode == 1) Container(
width: 33.w,
height: 13.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13.w)),
color: const Color.fromRGBO(237, 245, 255, 1)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
Assets.imagesMale,
width: 8.w,
height: 8.w,
),
)
],
SizedBox(width: 2.w,),
Text(
"${controller.calculateAge(controller.userData.value.birthDate ?? (controller.userData.value.birthYear != null && controller.userData.value.birthYear!.isNotEmpty ? "${controller.userData.value.birthYear}-01-01" : ""))}",
style: TextStyle(
fontSize: 11.w,
color: const Color.fromRGBO(120, 140, 255, 1)
),
)
],
),
),
),
],
],
),
//
// Container(
// width: 63.w,
// height: 27.w,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.all(Radius.circular(27.w)),
// color: const Color.fromRGBO(117, 98, 249, .1)
// ),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Image.asset(
// Assets.imagesPlayer,
// width: 15.w,
// height: 15.w,
// ),
// SizedBox(width: 4.w,),
// Image.asset(
// Assets.imagesVoice,
// width: 15.w,
// height: 13.w,
// ),
// SizedBox(width: 4.w,),
// Text(
// "6'",
// style: TextStyle(
// fontSize: 11.w,
// color: const Color.fromRGBO(117, 98, 249, 1)
// ),
// )
// ],
// ),
// )
],
),
SizedBox(height: 8.w,),
Text(
"父母催婚找个结婚的",
style: TextStyle(
fontSize: 14.w,
color: const Color.fromRGBO(144, 144, 144, 1)
),
//
// Container(
// width: 63.w,
// height: 27.w,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.all(Radius.circular(27.w)),
// color: const Color.fromRGBO(117, 98, 249, .1)
// ),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Image.asset(
// Assets.imagesPlayer,
// width: 15.w,
// height: 15.w,
// ),
// SizedBox(width: 4.w,),
// Image.asset(
// Assets.imagesVoice,
// width: 15.w,
// height: 13.w,
// ),
// SizedBox(width: 4.w,),
// Text(
// "6'",
// style: TextStyle(
// fontSize: 11.w,
// color: const Color.fromRGBO(117, 98, 249, 1)
// ),
// )
// ],
// ),
// )
],
),
SizedBox(height: 8.w,),
Text(
"父母催婚找个结婚的",
style: TextStyle(
fontSize: 14.w,
color: const Color.fromRGBO(144, 144, 144, 1)
),
),
SizedBox(height: 11.w,),
Wrap(
spacing: 12.w,
runSpacing: 12.w,
children: [
...controller.tagList.map((e){
return TagItem(label: e);
}),
],
),
SizedBox(height: 16.w,),
if ((controller.userData.value.provinceName?.isNotEmpty ?? false)) Text(
"IP属地:${controller.userData.value.provinceName}",
style: TextStyle(
fontSize: 12.w,
color: const Color.fromRGBO(144, 144, 144, 1)
SizedBox(height: 11.w,),
Wrap(
spacing: 12.w,
runSpacing: 12.w,
children: [
...controller.tagList.map((e){
return TagItem(label: e);
}),
],
),
),
Text(
"趣恋恋ID:${userId}",
style: TextStyle(
fontSize: 12.w,
color: const Color.fromRGBO(144, 144, 144, 1)
SizedBox(height: 16.w,),
if ((controller.userData.value.provinceName?.isNotEmpty ?? false)) Text(
"IP属地:${controller.userData.value.provinceName}",
style: TextStyle(
fontSize: 12.w,
color: const Color.fromRGBO(144, 144, 144, 1)
),
),
),
],
Text(
"趣恋恋ID:${userId}",
style: TextStyle(
fontSize: 12.w,
color: const Color.fromRGBO(144, 144, 144, 1)
),
),
SizedBox(height: 10.w,),
if(controller.postList.isNotEmpty) Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"动态",
style: TextStyle(
fontSize: 18.w
),
)
],
),
SizedBox(height: 10.w,),
...controller.postList.map((e){
return TimelineItem(item: e);
})
],
),
),
),
),
@ -378,50 +478,6 @@ class UserInformationPage extends StatelessWidget {
),
),
),
Positioned(
left: 15.w,
top: 310.w,
width: 345.w,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
...controller.userData.value.photoList!.asMap().entries.map((entry){
return Container(
margin: EdgeInsets.only(right: 7.w),
child: InkWell(
onTap: (){
controller.nowSelect.value = entry.key;
},
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(7.w)),
child: Container(
width: 40.w,
height: 40.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(7.w)),
border: controller.nowSelect.value == entry.key ? Border.all(width: 2.w, color: Colors.white) : null
),
child: Center(
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(7.w)),
child: CachedNetworkImage(
imageUrl: "${entry.value.photoUrl}?x-oss-process=image/format,webp/resize,w_76",
width: 38.w,
height: 38.w,
fit: BoxFit.cover,
),
),
),
),
),
),
);
}),
],
),
),
),
],
),
bottomNavigationBar: miId != GlobalData().userData!.id ? SafeArea(

Loading…
Cancel
Save