You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
534 lines
18 KiB
534 lines
18 KiB
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:dating_touchme_app/controller/global.dart';
|
|
import 'package:dating_touchme_app/controller/mine/mine_controller.dart';
|
|
import 'package:dating_touchme_app/extension/ex_widget.dart';
|
|
import 'package:dating_touchme_app/model/mine/user_count_data.dart';
|
|
import 'package:dating_touchme_app/network/user_api.dart';
|
|
import 'package:dating_touchme_app/pages/mine/edit_info_page.dart';
|
|
import 'package:dating_touchme_app/pages/mine/my_friend_page.dart';
|
|
import 'package:dating_touchme_app/pages/mine/vip_page.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:dating_touchme_app/generated/assets.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../discover/visitor_list_page.dart';
|
|
|
|
class MinePage extends StatefulWidget {
|
|
const MinePage({super.key});
|
|
|
|
@override
|
|
State<MinePage> createState() => _MinePageState();
|
|
}
|
|
|
|
class _MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin{
|
|
|
|
|
|
late MineController controller;
|
|
|
|
final countData = UserCountData(friendNum: 0, friendApplyNum: 0, visitorNum:0).obs;
|
|
late UserApi _userApi;
|
|
|
|
final infoList = <Map>[
|
|
{"label": "好友", "num": 0, "type": 1},
|
|
{"label": "好友申请", "num": 0, "type": 2},
|
|
{"label": "访客", "num": 0, "type": 3},
|
|
].obs;
|
|
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
// 确保 HomeController 已注册
|
|
if (!Get.isRegistered<MineController>()) {
|
|
controller = Get.put(MineController());
|
|
} else {
|
|
controller = Get.find<MineController>();
|
|
}
|
|
|
|
_userApi = Get.find<UserApi>();
|
|
|
|
getUserCount();
|
|
}
|
|
|
|
|
|
getUserCount() async {
|
|
try {
|
|
final response = await _userApi.userGetDongwoOwnUserCount();
|
|
if (response.data.isSuccess && response.data.data != null) {
|
|
countData.value = response.data.data ?? UserCountData(friendNum: 0, friendApplyNum: 0, visitorNum:0);
|
|
infoList.value = [
|
|
{"label": "好友", "num": countData.value.friendNum, "type": 1},
|
|
{"label": "好友申请", "num": countData.value.friendApplyNum, "type": 2},
|
|
{"label": "访客", "num": countData.value.visitorNum, "type": 3},
|
|
];
|
|
setState(() {
|
|
|
|
});
|
|
} else {
|
|
|
|
// 响应失败,抛出异常
|
|
throw Exception(response.data.message ?? '获取数据失败');
|
|
}
|
|
} catch(e){
|
|
print('用户数据获取失败: $e');
|
|
SmartDialog.showToast('用户数据获取失败');
|
|
rethrow;
|
|
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
super.build(context);
|
|
return GetX<MineController>(
|
|
init: MineController(),
|
|
builder: (controller) {
|
|
|
|
controller.userData.value = GlobalData().userData;
|
|
controller.userId.value = GlobalData().userId;
|
|
return Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 9.w),
|
|
constraints: BoxConstraints(minHeight: ScreenUtil().setHeight(800)),
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color.fromRGBO(248, 242, 255, 1.0), // rgba(248, 242, 255, 1)
|
|
Color.fromRGBO(247, 247, 247, 1.0), // rgba(247, 247, 247, 1)
|
|
],
|
|
stops: [0.0, 1.0],
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
height: MediaQuery.of(context).padding.top + 54.w,
|
|
),
|
|
Container(
|
|
width: 356.w,
|
|
padding: EdgeInsets.only(
|
|
left: 6.w,
|
|
right: 5.w
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.all(Radius.circular(60.w)),
|
|
child: (controller.userData.value?.profilePhoto?.isNotEmpty ?? false) ? CachedNetworkImage(
|
|
imageUrl: "${controller.userData.value?.profilePhoto ?? ""}?x-oss-process=image/format,webp/resize,w_120",
|
|
width: 60.w,
|
|
height: 60.w,
|
|
imageBuilder: (context, imageProvider) => Container(
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: imageProvider,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
) : Image.asset(
|
|
Assets.imagesUserAvatar,
|
|
width: 60.w,
|
|
height: 60.w,
|
|
)
|
|
),
|
|
SizedBox(width: 14.w,),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxWidth: 120.w, // 最大宽度
|
|
),
|
|
child: Text(
|
|
"${controller.userData.value?.nickName ?? ""}",
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
fontSize: 18.w,
|
|
color: const Color.fromRGBO(51, 51, 51, 1),
|
|
fontWeight: FontWeight.w700
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: 8.w,),
|
|
// Image.asset(
|
|
// Assets.imagesVip,
|
|
// width: 44.w,
|
|
// height: 16.w,
|
|
// )
|
|
Container(
|
|
width: 32.w,
|
|
height: 16.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(16.w)),
|
|
color: const Color.fromRGBO(201, 201, 201, 1)
|
|
),
|
|
child: Center(
|
|
child: Image.asset(
|
|
Assets.imagesVipFont,
|
|
width: 20.w,
|
|
height: 8.w,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
SizedBox(height: 11.w,),
|
|
Text(
|
|
"ID:${controller.userId.value ?? ""}",
|
|
style: TextStyle(
|
|
fontSize: 12.w,
|
|
color: const Color.fromRGBO(51, 51, 51, 1),
|
|
fontWeight: FontWeight.w500
|
|
),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
InkWell(
|
|
onTap: (){
|
|
Get.to(() => EditInfoPage());
|
|
},
|
|
child: Row(
|
|
children: [
|
|
Image.asset(
|
|
Assets.imagesEdit,
|
|
width: 10.w,
|
|
height: 10.w,
|
|
),
|
|
SizedBox(width: 4.w,),
|
|
Text(
|
|
"编辑资料",
|
|
style: TextStyle(
|
|
fontSize: 12.w,
|
|
color: const Color.fromRGBO(55, 57, 72, 1),
|
|
fontWeight: FontWeight.w500
|
|
),
|
|
)
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 16.w,),
|
|
Container(
|
|
height: 57.w,
|
|
padding: EdgeInsets.only(
|
|
top: 11.w,
|
|
right: 42.w,
|
|
bottom: 8.w,
|
|
left: 42.w
|
|
),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(9.w)),
|
|
color: Colors.white,
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
...infoList.map((e){
|
|
return InfoItem(item: e, getUserCount: getUserCount,);
|
|
}),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 12.w,),
|
|
if(false) Stack(
|
|
children: [
|
|
Image.asset(
|
|
Assets.imagesVipBanner,
|
|
width: 356.w,
|
|
height: 64.w,
|
|
),
|
|
Positioned(
|
|
top: 0.w,
|
|
left: 0.w,
|
|
child: InkWell(
|
|
child: SizedBox(
|
|
width: 356.w,
|
|
height: 64.w,
|
|
).onTap((){
|
|
Get.to(() => VipPage());
|
|
}),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
if(false) SizedBox(height: 12.w,),
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.all(Radius.circular(9.w)),
|
|
child: Column(
|
|
children: [
|
|
...controller.blockList.map((e){
|
|
return BlockItem(item: e, showWaring: e["title"] == "认证中心" && (GlobalData().userData?.identityCard == null || GlobalData().userData?.profilePhoto == null), path: e["path"],);
|
|
}),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 12.w,),
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.all(Radius.circular(9.w)),
|
|
child: Column(
|
|
children: [
|
|
...controller.settingList.map((e){
|
|
return SettingItem(item: e, path: e["path"],);
|
|
})
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
|
|
@override
|
|
// TODO: implement wantKeepAlive
|
|
bool get wantKeepAlive => true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InfoItem extends StatefulWidget {
|
|
final Map item;
|
|
final Function getUserCount;
|
|
const InfoItem({super.key, required this.item, required this.getUserCount});
|
|
|
|
@override
|
|
State<InfoItem> createState() => _InfoItemState();
|
|
}
|
|
|
|
class _InfoItemState extends State<InfoItem> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Expanded(
|
|
child: Container(
|
|
alignment: widget.item["type"] == 1 ? Alignment.centerLeft : widget.item["type"] == 2 ? Alignment.center : Alignment.centerRight,
|
|
child: Column(
|
|
children: [
|
|
Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
Text(
|
|
"${widget.item["num"]}",
|
|
style: TextStyle(
|
|
fontSize: 15.w,
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.w700
|
|
),
|
|
),
|
|
if(widget.item["type"] == 2 && widget.item["num"] != 0)Positioned(
|
|
right: -5.w,
|
|
top: 0,
|
|
child: Container(
|
|
width: 5.w,
|
|
height: 5.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(5.w)),
|
|
color: const Color.fromRGBO(255, 87, 51, 1)
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Text(
|
|
widget.item["label"],
|
|
style: TextStyle(
|
|
fontSize: 10.w,
|
|
color: const Color.fromRGBO(166, 166, 166, 1),
|
|
),
|
|
)
|
|
],
|
|
)
|
|
).onTap((){
|
|
if(widget.item['type'] == 3){
|
|
Get.to(()=> VisitorListPage())?.then((w) async {
|
|
await widget.getUserCount();
|
|
setState(() {
|
|
|
|
});
|
|
});
|
|
} else {
|
|
Get.to(()=> MyFriendPage())?.then((w) async {
|
|
await widget.getUserCount();
|
|
setState(() {
|
|
|
|
});
|
|
});
|
|
}
|
|
})
|
|
);
|
|
}
|
|
}
|
|
|
|
class BlockItem extends StatefulWidget {
|
|
final Map item;
|
|
final bool showWaring;
|
|
final Function path;
|
|
const BlockItem({super.key, required this.item, this.showWaring = false, required this.path});
|
|
|
|
@override
|
|
State<BlockItem> createState() => _BlockItemState();
|
|
}
|
|
|
|
class _BlockItemState extends State<BlockItem> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
onTap: (){
|
|
// context.pushNamed(widget.path);
|
|
if(widget.path() != null){
|
|
Get.to(widget.path)?.then((e){
|
|
setState(() {
|
|
|
|
});
|
|
});
|
|
} else {
|
|
|
|
SmartDialog.showToast('功能暂未开放');
|
|
}
|
|
// RouteGuardService.to.toWithAuth(widget.path, null);
|
|
},
|
|
child: Container(
|
|
height: 48.w,
|
|
padding: EdgeInsets.only(left: 16.w),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white
|
|
),
|
|
child: Container(
|
|
padding: EdgeInsets.only(right: 16.w),
|
|
decoration: BoxDecoration(
|
|
border: widget.item["title"] != "红娘等级" ? Border(
|
|
bottom: BorderSide(width: 1, color: const Color.fromRGBO(238, 238, 238, 1))
|
|
) : null
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Image.asset(
|
|
widget.item["icon"],
|
|
height: 22.w,
|
|
width: 22.w,
|
|
),
|
|
SizedBox(width: 16.w,),
|
|
Text(
|
|
widget.item["title"],
|
|
style: TextStyle(
|
|
fontSize: 14.w,
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.w500
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
if(widget.showWaring) Container(
|
|
width: 5.w,
|
|
height: 5.w,
|
|
margin: EdgeInsets.only(right: 4.w),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(5.w)),
|
|
color: const Color.fromRGBO(255, 87, 51, 1)
|
|
),
|
|
),
|
|
if(widget.item["title"] == "认证中心") Text(
|
|
widget.item["subTitle"],
|
|
style: TextStyle(
|
|
fontSize: 11.w,
|
|
color: const Color.fromRGBO(166, 166, 166, 1)
|
|
),
|
|
),
|
|
SizedBox(width: 10.w,),
|
|
Image.asset(
|
|
Assets.imagesArrow,
|
|
width: 4.w,
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class SettingItem extends StatefulWidget {
|
|
final Map item;
|
|
final Function path;
|
|
const SettingItem({super.key, required this.item, required this.path});
|
|
|
|
@override
|
|
State<SettingItem> createState() => _SettingItemState();
|
|
}
|
|
|
|
class _SettingItemState extends State<SettingItem> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
onTap: (){
|
|
if(widget.path() == null){
|
|
SmartDialog.showToast('功能暂未开放');
|
|
return;
|
|
}
|
|
// context.pushNamed(widget.path);
|
|
Get.to(widget.path);
|
|
// RouteGuardService.to.toWithAuth(widget.path, null);
|
|
},
|
|
child: Container(
|
|
height: 48.w,
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
color: Colors.white,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Image.asset(
|
|
widget.item["icon"],
|
|
width: 24.w,
|
|
height: 24.w,
|
|
),
|
|
SizedBox(width: 14.w,),
|
|
Text(
|
|
widget.item["title"],
|
|
style: TextStyle(
|
|
fontSize: 14.w,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.black
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Image.asset(
|
|
Assets.imagesArrow,
|
|
width: 4.w,
|
|
height: 8.w,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|