From 303a47604ab6b3245f3e093ec4af3d53b1ff2adc Mon Sep 17 00:00:00 2001 From: YangYuhao Date: Tue, 4 Jul 2023 09:23:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E6=B3=A8=E5=92=8C=E8=AE=BF=E5=AE=A2?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=20=E5=88=97=E8=A1=A8=20=20=20=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- circle_app/lib/app/friendslist/logic.dart | 146 ++++++++ circle_app/lib/app/friendslist/view.dart | 199 ++++++++--- circle_app/lib/app/minefragment/logic.dart | 153 +++++---- circle_app/lib/app/minefragment/view.dart | 14 +- circle_app/lib/app/report/logic.dart | 31 ++ circle_app/lib/app/report/view.dart | 11 +- circle_app/lib/app/userinfo/logic.dart | 112 ++++--- circle_app/lib/app/userinfo/view.dart | 372 ++++++++++++--------- circle_app/lib/network/api.dart | 29 ++ 9 files changed, 747 insertions(+), 320 deletions(-) diff --git a/circle_app/lib/app/friendslist/logic.dart b/circle_app/lib/app/friendslist/logic.dart index 61ebfd1..f39465f 100644 --- a/circle_app/lib/app/friendslist/logic.dart +++ b/circle_app/lib/app/friendslist/logic.dart @@ -1,7 +1,153 @@ import 'package:get/get.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; +import '../../network/api.dart'; +import '../../network/dio_manager.dart'; import 'state.dart'; class FriendslistLogic extends GetxController { + + final RefreshController refreshController = RefreshController(); final FriendslistState state = FriendslistState(); + final type = Get.arguments as String; + int page = 1; + int isVip = 0; + List lists = []; + @override + void onInit() async{ + super.onInit(); + initList(); + } + + + initList() async{ + if(page==1){ + lists.clear(); + } + switch(type){ + case "0": + var data = + await DioManager.instance.get(url: Api.followList, params: { + 'page':page + }); + var bean = BaseResponse.fromJson(data, (data) => User.fromJson(data)); + if (bean.isSuccess()) { + lists.addAll(bean.data.lists); + } + update(); + if(page == 1){ + refreshController.refreshCompleted(); + }else{ + refreshController.loadComplete(); + } + return ; + case "1": + var data = + await DioManager.instance.get(url: Api.fansList, params: { + 'page':page + }); + var bean = BaseResponse.fromJson(data, (data) => User.fromJson(data)); + if (bean.isSuccess()) { + lists.addAll(bean.data.lists); + } + update(); + if(page == 1){ + refreshController.refreshCompleted(); + }else{ + refreshController.loadComplete(); + } + return ; + case "2": + var data = + await DioManager.instance.get(url: Api.visitList, params: { + 'page':page + }); + var bean = BaseResponse.fromJson(data, (data) => User.fromJson(data)); + if (bean.isSuccess()) { + lists.addAll(bean.data.lists); + } + update(); + if(page == 1){ + refreshController.refreshCompleted(); + }else{ + refreshController.loadComplete(); + } + return ; + } + + + } + } + + + + +class User { + final List lists; + final int total; + + User({required this.lists, required this.total}); + + factory User.fromJson(Map json) { + final List userList = json['lists']; + final List users = userList.map((user) => UserInfo.fromJson(user)).toList(); + final int total = json['total']; + return User(lists: users, total: total); + } +} + +class UserInfo { + final int id; + final String nickname; + final String avatar; + final String signature; + final String birthday; + final int age; + final int vip; + final int gender; + final int role; + final int orientation; + + final double lng; + final double lat; + final String city; + final String avatarThumb; + + UserInfo({ + required this.id, + required this.nickname, + required this.avatar, + required this.signature, + required this.birthday, + required this.age, + required this.vip, + required this.gender, + required this.role, + required this.orientation, + required this.lng, + required this.lat, + required this.city, + required this.avatarThumb, + }); + + factory UserInfo.fromJson(Map json) { + return UserInfo( + id: json['id'], + nickname: json['nickname'], + avatar: json['avatar'], + signature: json['signature'], + birthday: json['birthday'], + age: json['age'], + vip: json['vip'], + gender: json['gender'], + role: json['role'], + orientation: json['orientation'], + lng: json['lng'], + lat: json['lat'], + city: json['city'], + avatarThumb: json['avatar_thumb'], + ); + } +} + diff --git a/circle_app/lib/app/friendslist/view.dart b/circle_app/lib/app/friendslist/view.dart index 108036f..c7d54cb 100644 --- a/circle_app/lib/app/friendslist/view.dart +++ b/circle_app/lib/app/friendslist/view.dart @@ -1,9 +1,11 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import '../../components/my_app_bar.dart'; +import '../../router/app_routers.dart'; import '../../util/util.dart'; import 'logic.dart'; @@ -15,39 +17,162 @@ class FriendslistPage extends StatelessWidget { @override Widget build(BuildContext context) { - final type = Get.arguments as String; - - return Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage(getBaseImage("home_back")), - fit: BoxFit.cover, - ), - ), - child: Scaffold( - backgroundColor: Colors.transparent, - appBar: MyAppBar(centerTitle: _getTitleName(type),), - body: SafeArea( - child: SmartRefresher( - controller: _refreshController, - child: ListView.builder( - padding: EdgeInsets.all(16.sp), - itemCount: itemCount, - itemBuilder: (context, index) { - return ListTile( - title: Text('Item $index'), - ); - }, - ), - onRefresh: _onRefresh, - onLoading: _onLoading, + return GetBuilder(builder: (logic) { + return Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage(getBaseImage("home_back")), + fit: BoxFit.cover, ), - ),), - ); + ), + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: MyAppBar( + centerTitle: _getTitleName(logic.type), + ), + body: SafeArea( + child: SmartRefresher( + controller: logic.refreshController, + onRefresh: _onRefresh, + onLoading: _onLoading, + child: ListView.builder( + padding: EdgeInsets.all(16.sp), + itemCount: logic.lists.length, + itemBuilder: (context, index) { + return ListItem(logic.lists[index]); + }, + ), + ), + ), + ), + ); + }); + } + + Widget ListItem(UserInfo item) { + return GestureDetector( + onTap: (){ + Get.toNamed(AppRoutes.UserInfoActivity, arguments: item.id); + }, + child: Container( + margin: EdgeInsets.only(bottom: 21), + child: Row( + children: [ + Stack(children: [ + ClipOval( + child: GestureDetector( + onTap: () { + var imgList = []; + imgList.add(item.avatar); + Get.toNamed(AppRoutes.Swiper, arguments: { + 'imaglist': imgList, + 'index': 0 + }); + }, + child: CachedNetworkImage( + imageUrl: item.avatar, + width: 53.sp, + height: 53.sp, + ), + ), + ), + Positioned( + right: 0, + left: 0, + bottom: 0, + + child: item.vip>0 ? + Image( + image: AssetImage(getBaseImage("vip")), + width: 44.sp, + height: 18.sp, + ):Container(),) + ],), + SizedBox(width: 10.sp), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + item.nickname, + style: const TextStyle(color :Colors.white70,fontSize: 14, fontWeight: FontWeight.bold), + ), + SizedBox(width: 4.sp), + // SizedBox(height: 8.sp), + _buildInfoRow(item), + // Placeholder image + ], + ), + + SizedBox(height: 8.sp), + Container( + width: 150.sp, + child: Text( + item.signature, + style: TextStyle(fontSize: 12.sp, color: Color(0xFFB7BECC)), + ), + ), + ], + ), + // Pla + Spacer(), + GestureDetector(onTap: (){ + showToast("私聊"); + }, + child: Container( + width: 60, + height: 28, + decoration: BoxDecoration( + color: Color(0xFFFF4D7C), + borderRadius: BorderRadius.circular(14), + ), + child: Center( + child: Text( + "私聊", + style: TextStyle(fontSize: 14, color: Colors.white), + ), + ), + ),), + ], + ), + ),); } + Widget _buildInfoRow(UserInfo userInfoBean) { + String ageMsg = getAgeCOntent(userInfoBean!.gender, userInfoBean!.age, + userInfoBean!.role, userInfoBean!.orientation); + return Row( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17), + gradient: LinearGradient( + colors: [ + Color.fromRGBO(141, 255, 248, 1.0), + Color.fromRGBO(181, 211, 255, 1.0), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + ), + padding: EdgeInsets.only( + top: 2.sp, bottom: 2.sp, left: 10.sp, right: 10.sp), + child: Text( + ageMsg , + style: TextStyle( + color: Colors.black, + fontSize: 10, + ), + ), + ), + SizedBox(width: 6.sp), + + ], + ); + } String _getTitleName(String type) { switch (type) { case "0": @@ -61,23 +186,13 @@ class FriendslistPage extends StatelessWidget { } } - - final RefreshController _refreshController = RefreshController(); - int itemCount = 20; - void _onRefresh() async { - // Perform your refresh logic here - // For example, make an API call to fetch new data - await Future.delayed(Duration(seconds: 2)); - itemCount = 20; - _refreshController.refreshCompleted(); + logic.page = 1; + logic.initList(); } void _onLoading() async { - // Perform your loading logic here - // For example, make an API call to fetch more data - await Future.delayed(Duration(seconds: 2)); - itemCount += 10; - _refreshController.loadComplete(); + logic.page = logic.page + 1; + logic.initList(); } } diff --git a/circle_app/lib/app/minefragment/logic.dart b/circle_app/lib/app/minefragment/logic.dart index 4c6bbe6..4335e0b 100644 --- a/circle_app/lib/app/minefragment/logic.dart +++ b/circle_app/lib/app/minefragment/logic.dart @@ -1,70 +1,95 @@ - -import 'dart:ffi'; - import 'package:get/get.dart'; import '../../network/api.dart'; import '../../network/dio_manager.dart'; import '../../router/app_routers.dart'; import '../../util/util.dart'; +import '../userinfo/logic.dart'; import 'state.dart'; import 'package:shared_preferences/shared_preferences.dart'; class MinefragmentLogic extends GetxController { final MinefragmentState state = MinefragmentState(); - UserData? userInfoBean = null; + User? userInfoBean = null; String ageMsg = ""; var isVip = 0; + var like_count = "0"; + var like_me_count = "0"; + var recent_visit_count = "0"; + num like_me_count_new = 0; + num recent_visit_count_new = 0; + @override - void onInit() async{ + void onInit() async { super.onInit(); - var data = await DioManager.instance - .get(url: Api.getUserMine); - var bean = BaseResponse.fromJson( - data, (data) => UserData.fromJson(data)); - if(bean.isSuccess()){ - userInfoBean = bean.data; - if(userInfoBean!=null){ + var data = await DioManager.instance.get(url: Api.getUserMine); + var bean = BaseResponse.fromJson( + data, (data) => ResponseBean.fromJson(data)); + if (bean.isSuccess()) { + SharedPreferences prefs = await SharedPreferences.getInstance(); + int likeMeCount = prefs.getInt("likeMeCount") ?? 0; + int recentVisitCount = prefs.getInt("recentVisitCount") ?? 0; + + like_count = bean.data.likeCount.toString(); + like_me_count = bean.data.likeMeCount.toString(); + recent_visit_count = bean.data.recentVisitCount.toString(); + + + // like_me_count_new = recentVisitCount.toInt() - bean.data.likeMeCount.toInt(); + + like_me_count_new = (likeMeCount as int) - (bean.data.likeMeCount).toInt(); + + + recent_visit_count_new = recentVisitCount-bean.data.recentVisitCount; + prefs.setInt("likeMeCount", bean.data.likeMeCount); + prefs.setInt("recentVisitCount", bean.data.recentVisitCount); + + + userInfoBean = bean.data.user; + + if (userInfoBean != null) { isVip = userInfoBean!.vip; SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setInt('vip', isVip); prefs.setInt('userId', userInfoBean!.id); - ageMsg = getAgeCOntent(userInfoBean!.gender, userInfoBean!.age, userInfoBean!.role, userInfoBean!.orientation); + ageMsg = getAgeCOntent(userInfoBean!.gender, userInfoBean!.age, + userInfoBean!.role, userInfoBean!.orientation); } update(); - }else{ + } else { showToast(bean.msg); } - } jumpSetUp() { Get.toNamed(AppRoutes.SetUpActivity); } - - } -class UserData { - final int id; - final String nickname; - final String avatar; - final String birthday; - final int age; - final int vip; - final int gender; - final int role; - final int orientation; - final double lng; - final double lat; - final String city; - UserData({ +class User { + int id; + String nickname; + String avatar; + String signature; + String birthday; + int age; + int vip; + int gender; + int role; + int orientation; + double lng; + double lat; + String city; + String avatarThumb; + + User({ required this.id, required this.nickname, required this.avatar, + required this.signature, required this.birthday, required this.age, required this.vip, @@ -74,42 +99,54 @@ class UserData { required this.lng, required this.lat, required this.city, + required this.avatarThumb, }); - factory UserData.fromJson(Map json) { - return UserData( - id: json['user']['id'], - nickname: json['user']['nickname'], - avatar: json['user']['avatar'], - birthday: json['user']['birthday'], - age: json['user']['age'], - vip: json['user']['vip'], - gender: json['user']['gender'], - role: json['user']['role'], - orientation: json['user']['orientation'], - lng: json['user']['lng'], - lat: json['user']['lat'], - city: json['user']['city'], + factory User.fromJson(Map json) { + return User( + id: json['id'], + nickname: json['nickname'], + avatar: json['avatar'], + signature: json['signature'], + birthday: json['birthday'], + age: json['age'], + vip: json['vip'], + gender: json['gender'], + role: json['role'], + orientation: json['orientation'], + lng: json['lng'], + lat: json['lat'], + city: json['city'], + avatarThumb: json['avatar_thumb'], ); } } -class UserResponse { - final int code; - final String msg; - final UserData data; +class ResponseBean { + User user; + int likeCount; + int likeMeCount; + int recentVisitCount; + String? vipExpireDate; + int? vipExpireDays; - UserResponse({ - required this.code, - required this.msg, - required this.data, + ResponseBean({ + required this.user, + required this.likeCount, + required this.likeMeCount, + required this.recentVisitCount, + this.vipExpireDate, + this.vipExpireDays, }); - factory UserResponse.fromJson(Map json) { - return UserResponse( - code: json['code'], - msg: json['msg'], - data: UserData.fromJson(json['data']), + factory ResponseBean.fromJson(Map json) { + return ResponseBean( + user: User.fromJson(json['user']), + likeCount: json['like_count'], + likeMeCount: json['like_me_count'], + recentVisitCount: json['recent_visit_count'], + vipExpireDate: json['vip_expire_date'], + vipExpireDays: json['vip_expire_days'], ); } } diff --git a/circle_app/lib/app/minefragment/view.dart b/circle_app/lib/app/minefragment/view.dart index e48e16a..b3dd923 100644 --- a/circle_app/lib/app/minefragment/view.dart +++ b/circle_app/lib/app/minefragment/view.dart @@ -43,7 +43,7 @@ class MinefragmentPage extends StatelessWidget { child: Column( children: [ _buildAvatarRow(logic), - _FriendsRow(), + _FriendsRow(logic), Container( child: Image( image: AssetImage(getHomeImage("icon_vip")), @@ -194,7 +194,7 @@ class MinefragmentPage extends StatelessWidget { ); } - Widget _FriendsRow() { + Widget _FriendsRow(MinefragmentLogic logic) { return Center( child: Container( width: Get.width, @@ -214,7 +214,7 @@ class MinefragmentPage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - "0", + logic.like_count, style: TextStyle( color: Colors.white, fontSize: 16.sp, @@ -254,7 +254,7 @@ class MinefragmentPage extends StatelessWidget { children: [ Container( child: Text( - "0", + logic.like_me_count, style: TextStyle( color: Colors.white, fontSize: 16.sp, @@ -287,7 +287,7 @@ class MinefragmentPage extends StatelessWidget { right: 0.sp, top: 15.sp, child: Text( - "+123", + logic.like_me_count_new>0 ? logic.like_me_count_new.toString():"", style: TextStyle(color: Color.fromRGBO(0, 255, 210, 1.0)), ), ) @@ -309,7 +309,7 @@ class MinefragmentPage extends StatelessWidget { children: [ Container( child: Text( - "0", + logic.recent_visit_count, style: TextStyle( color: Colors.white, fontSize: 16.sp, @@ -342,7 +342,7 @@ class MinefragmentPage extends StatelessWidget { right: 0.sp, top: 15.sp, child: Text( - "+123", + logic.recent_visit_count_new>0 ? logic.recent_visit_count_new.toString():"", style: TextStyle(color: Color.fromRGBO(0, 255, 210, 1.0)), ), ) diff --git a/circle_app/lib/app/report/logic.dart b/circle_app/lib/app/report/logic.dart index 59bdb8b..540075e 100644 --- a/circle_app/lib/app/report/logic.dart +++ b/circle_app/lib/app/report/logic.dart @@ -1,3 +1,4 @@ +import 'package:circle_app/util/util.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; @@ -7,10 +8,13 @@ import '../../common/config.dart'; import '../../network/api.dart'; import '../../network/dio_manager.dart'; import '../../util/qiniu.dart'; +import '../call_out/logic.dart'; import 'state.dart'; class ReportLogic extends GetxController { final ReportState state = ReportState(); + var userId = Get.arguments["userId"] ?? ""; + int myPosition = -1; TextEditingController textEditingController = TextEditingController(); List arrList = [ MyObject("涉嫌欺诈", false), @@ -26,6 +30,33 @@ class ReportLogic extends GetxController { List getItemList() { return arrList; } + + onSubmit()async{ + if(myPosition== -1){ + showToast("请选择举报类目"); + return; + } + List myBean = []; + state.imaglist.forEach((element) { + myBean.add(MyBean(type: 1, url: element).toJson()); + }); + + + var data = await DioManager.instance.post(url: Api.postReport, params: { + "user_id" : userId, + "words" : textEditingController.text, + "obj_type" :1, + "obj_id":userId, + "reason":arrList[myPosition].name, + "album" :myBean + }); + var bean = BaseResponse.fromJson(data, (data) => data); + if(bean.isSuccess()){ + Get.back(); + } + showToast(bean.msg); + } + final ImagePicker _picker = ImagePicker(); var quToken = ''; diff --git a/circle_app/lib/app/report/view.dart b/circle_app/lib/app/report/view.dart index 73ee520..13b591b 100644 --- a/circle_app/lib/app/report/view.dart +++ b/circle_app/lib/app/report/view.dart @@ -32,7 +32,7 @@ class ReportPage extends StatelessWidget { style: TextStyle(color: Colors.white), ), onPressed: () { - showToast("提交"); + logic.onSubmit(); }, ), body: Column( @@ -112,7 +112,7 @@ class ReportPage extends StatelessWidget { ), ), Positioned( - right: 15.sp, + // right: 1.sp, top: 160.sp, child: Text( '${controller.textEditingController.text.length}/200', @@ -169,8 +169,11 @@ class ReportPage extends StatelessWidget { itemBuilder: (BuildContext context, int index) { return GestureDetector( onTap: () { - controller.arrList[index].isSelect = - !controller.arrList[index].isSelect; + if(controller.myPosition != -1){ + controller.arrList[controller.myPosition].isSelect = false; + } + controller.myPosition = index; + controller.arrList[index].isSelect = true; controller.update(); }, child: _getItemSelect(controller.arrList[index]), diff --git a/circle_app/lib/app/userinfo/logic.dart b/circle_app/lib/app/userinfo/logic.dart index 44dd370..2af73a2 100644 --- a/circle_app/lib/app/userinfo/logic.dart +++ b/circle_app/lib/app/userinfo/logic.dart @@ -1,6 +1,6 @@ - import 'dart:convert'; +import 'package:flutter/cupertino.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:image_picker/image_picker.dart'; @@ -28,8 +28,8 @@ class UserinfoLogic extends GetxController { bool isUrgeStatus = false; bool isOnline = false; - bool isShowAlbum = true; + bool isLike = false; @override void onInit() async { @@ -56,18 +56,16 @@ class UserinfoLogic extends GetxController { showToast(bean.msg); } - var myAlbumData = await DioManager.instance.get(url: Api.getMyAlbum,); - var myAlbumBean = BaseResponse.fromJson( - myAlbumData, (myAlbumData) => AlbumResponseBean.fromJson(myAlbumData)); - if(myAlbumBean.isSuccess()){ + var myAlbumData = await DioManager.instance.get( + url: Api.getMyAlbum, + ); + var myAlbumBean = BaseResponse.fromJson(myAlbumData, + (myAlbumData) => AlbumResponseBean.fromJson(myAlbumData)); + if (myAlbumBean.isSuccess()) { myAlbumBean.data.lists.forEach((element) { state.imaglist.add(element); }); } - - - - } else { isMe = false; var data = await DioManager.instance @@ -75,10 +73,11 @@ class UserinfoLogic extends GetxController { var bean = BaseResponse.fromJson( data, (data) => ResponseBean.fromJson(data)); if (bean.isSuccess()) { - isLikeFoMsg = - "${bean.data.imageUrgeCount}位圈友感兴趣,其中${bean.data.likeMeCount}位已催您更新"; + isLike = bean.data.is_follow; + isLikeFoMsg = "${bean.data.imageUrgeCount}位圈友感兴趣,其中${bean.data.likeMeCount}位已催您更新"; userInfoBean = bean.data!.user; isVip = userInfoBean!.vip; + onLineCity = userInfoBean!.isOnline == true ? "在线" : "离线"; if (userInfoBean!.city != null) { onLineCity = "$onLineCity·${userInfoBean!.city}"; @@ -90,22 +89,24 @@ class UserinfoLogic extends GetxController { showToast(bean.msg); } - - var myAlbumData = await DioManager.instance.get(url: Api.getTaAlbum+userId+"/albums"); - var myAlbumBean = BaseResponse.fromJson( - myAlbumData, (myAlbumData) => AlbumResponseBean.fromJson(myAlbumData)); - if(myAlbumBean.isSuccess()){ + var myAlbumData = await DioManager.instance + .get(url: Api.getTaAlbum + userId + "/albums"); + var myAlbumBean = BaseResponse.fromJson(myAlbumData, + (myAlbumData) => AlbumResponseBean.fromJson(myAlbumData)); + if (myAlbumBean.isSuccess()) { myAlbumBean.data.lists.forEach((element) { - state.imaglist.add(AlbumListItem(id: element.id,type: element.type,url:element.url)); + state.imaglist.add(AlbumListItem( + id: element.id, type: element.type, url: element.url)); }); } - - - var urgedata = await DioManager.instance.get(url: Api.getUrgeStatus+userId+"/urge/album/status"); + var urgedata = await DioManager.instance + .get(url: Api.getUrgeStatus + userId + "/urge/album/status"); var urgeBean = BaseResponse.fromJson( urgedata, (urgedata) => UrgentStatus.fromJson(urgedata)); - isUrgeStatus = urgeBean.data.isUrgent; + //if(urgedata.isSuccess()){ + isUrgeStatus = urgeBean.data.isUrgent; + //} } update(); @@ -119,26 +120,51 @@ class UserinfoLogic extends GetxController { } } - urgeChange() async{ - var data = await DioManager.instance.post(url: Api.urgeAlbum+userId+"/urge/album"); + urgeChange() async { + var data = await DioManager.instance + .post(url: "${Api.urgeAlbum + userId}/urge/album"); var bean = BaseResponse.fromJson(data, (data) => data); - if(bean.isSuccess()){ + if (bean.isSuccess()) { showToast("催更成功"); isUrgeStatus = true; update(); } + } + + delAlbumImage(int index) async { + var data = await DioManager.instance + .get(url: Api.deleteAlbum + state.imaglist[index].id.toString()); + var bean = BaseResponse.fromJson(data, (data) => data); + if (bean.code == 200) { + state.imaglist.removeAt(index); + Navigator.pop(Get.context!); + update(); + } + } + + setLike() async { + var data = await DioManager.instance + .post(url: "${Api.setBlock + userId}/follow", params: { + 'status': isLike?"0":"1" + }); + var bean = BaseResponse.fromJson(data, (jsonData) => jsonData,); + if(bean.isSuccess()){ + isLike = !isLike; + update(); + } + showToast(bean.msg); } - delAlbumImage(int index) async{ - var data = await DioManager.instance.delete(url: Api.deleteAlbum+state.imaglist[index].id.toString()); - var bean = BaseResponse.fromJson(data, (data) => data); - if(bean.code == 200){ - state.imaglist.removeAt(index); + setBlock() async { + var data = await DioManager.instance + .post(url: "${Api.setBlock + userId}/block", params: {}); + var bean = BaseResponse.fromJson(data, (jsonData) => jsonData,); + if(bean.isSuccess()){ + Navigator.pop(Get.context!); update(); } - - + showToast(bean.msg); } Future getImageFile() async { @@ -152,23 +178,22 @@ class UserinfoLogic extends GetxController { SmartDialog.showLoading(); upDataImage(quToken, pickedFile, CONFIG.USER_ALBUM_IMAGE, (result) async { - var data = await DioManager.instance.post(url: Api.updataAlbum,params: { - "type" :1, - "url": result - }); + var data = await DioManager.instance + .post(url: Api.updataAlbum, params: {"type": 1, "url": result}); var myAlbumBean = BaseResponse.fromJson( data, (data) => AddAlbum.fromJson(data)); if (myAlbumBean.code == 200) { SmartDialog.dismiss(); - state.imaglist.add(AlbumListItem(id:myAlbumBean.data.id,type:myAlbumBean.data.type,url: result)); + state.imaglist.add(AlbumListItem( + id: myAlbumBean.data.id, + type: myAlbumBean.data.type, + url: result)); update(); } - }); } catch (e) {} } - } class UserBean { @@ -258,11 +283,13 @@ class ResponseBean { UserBean user; int likeMeCount; int imageUrgeCount; + bool is_follow; ResponseBean({ required this.user, required this.likeMeCount, required this.imageUrgeCount, + required this.is_follow }); factory ResponseBean.fromJson(Map json) { @@ -270,6 +297,7 @@ class ResponseBean { user: UserBean.fromJson(json['user']), likeMeCount: json['like_me_count'], imageUrgeCount: json['image_urge_count'], + is_follow: json['is_follow'], ); } } @@ -285,7 +313,8 @@ class AlbumResponseBean { factory AlbumResponseBean.fromJson(Map json) { return AlbumResponseBean( - lists: List.from(json['lists'].map((x) => AlbumListItem.fromJson(x))), + lists: List.from( + json['lists'].map((x) => AlbumListItem.fromJson(x))), total: json['total'], ); } @@ -311,7 +340,6 @@ class AlbumListItem { } } - class AddAlbum { int id; int type; @@ -345,5 +373,3 @@ class UrgentStatus { ); } } - - diff --git a/circle_app/lib/app/userinfo/view.dart b/circle_app/lib/app/userinfo/view.dart index ef5fe81..436a651 100644 --- a/circle_app/lib/app/userinfo/view.dart +++ b/circle_app/lib/app/userinfo/view.dart @@ -23,12 +23,13 @@ class _MyTabbedScreenState extends State ScrollController scrollController = ScrollController(); bool isShowBlackTitle = false; - @override void initState() { super.initState(); - _tabController = TabController(length: 2, vsync: this,animationDuration: Duration(seconds: 0)); - _tabController.addListener(_handleTabChange); + _tabController = TabController( + length: 2, vsync: this, animationDuration: Duration(milliseconds: 200)); + _tabController.animation!.addListener(_handleTabChange); + // _tabController.addListener(_handleTabChange); // _tabController } @@ -47,6 +48,7 @@ class _MyTabbedScreenState extends State _tabController.dispose(); super.dispose(); } + void _onScroll(offset) { if (offset > 100) { setState(() { @@ -79,7 +81,9 @@ class _MyTabbedScreenState extends State child: Scaffold( backgroundColor: Colors.transparent, appBar: MyAppBar( - centerTitle: logic.userInfoBean!=null? logic.userInfoBean!.nickname+"的主页":"个人主页", + centerTitle: logic.userInfoBean != null + ? logic.userInfoBean!.nickname + "的主页" + : "个人主页", ), body: Stack( children: [ @@ -89,7 +93,7 @@ class _MyTabbedScreenState extends State Positioned( bottom: 27.sp, width: Get.width, - child: _MeInfoButton(logic), + child: logic.isShowAlbum ? _MeInfoButton(logic) : Container(), ) ], ), @@ -98,38 +102,8 @@ class _MyTabbedScreenState extends State } Widget _MeInfoButton(UserinfoLogic controller) { - if (controller.userId == "") { - return GestureDetector( - onTap: () { - // showToast("完善资料"); - Get.toNamed(AppRoutes.Complete_materialPage, arguments: "user"); - // controller.onInit(); - }, - child: Center( - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(17), - gradient: LinearGradient( - colors: [ - Color(0xFF06F9FA), - Color(0xFFDC5BFD), - ], - begin: Alignment.centerLeft, - end: Alignment.centerRight, - ), - ), - padding: EdgeInsets.only( - top: 10.sp, bottom: 10.sp, left: 55.sp, right: 55.sp), - child: Text( - "完善个人形象", - style: TextStyle( - color: Colors.white, - fontSize: 12, - ), - ), - ), - ), - ); + if (controller.isMe) { + return Container(); } else { return Container( margin: EdgeInsets.only(left: 18.sp, right: 18.sp), @@ -149,9 +123,11 @@ class _MyTabbedScreenState extends State ), GestureDetector( onTap: () { - showToast("喜欢"); + logic.setLike(); }, child: Container( + width: 130.sp, + height: 34.sp, decoration: BoxDecoration( borderRadius: BorderRadius.circular(17.sp), gradient: LinearGradient( @@ -163,13 +139,13 @@ class _MyTabbedScreenState extends State end: Alignment.centerRight, ), ), - padding: EdgeInsets.only( - top: 10.sp, bottom: 10.sp, left: 52.sp, right: 52.sp), - child: Text( - "喜欢", - style: TextStyle( - color: Colors.white, - fontSize: 12.sp, + child: Center( + child: Text( + logic.isLike ? "取消喜欢" : "喜欢", + style: TextStyle( + color: Colors.white, + fontSize: 12.sp, + ), ), ), ), @@ -179,6 +155,8 @@ class _MyTabbedScreenState extends State showToast("私聊"); }, child: Container( + width: 130.sp, + height: 34.sp, decoration: BoxDecoration( borderRadius: BorderRadius.circular(17.sp), gradient: LinearGradient( @@ -190,13 +168,13 @@ class _MyTabbedScreenState extends State end: Alignment.centerRight, ), ), - padding: EdgeInsets.only( - top: 10.sp, bottom: 10.sp, left: 52.sp, right: 52.sp), - child: Text( - "私聊", - style: TextStyle( - color: Colors.white, - fontSize: 12.sp, + child: Center( + child: Text( + "私聊", + style: TextStyle( + color: Colors.white, + fontSize: 12.sp, + ), ), ), ), @@ -226,7 +204,9 @@ class _MyTabbedScreenState extends State Row( children: [ Text( - controller.userInfoBean!=null ?controller.userInfoBean!.nickname:"" , + controller.userInfoBean != null + ? controller.userInfoBean!.nickname + : "", style: TextStyle( color: Color.fromRGBO(247, 250, 250, 1.0), fontSize: 16, @@ -240,16 +220,21 @@ class _MyTabbedScreenState extends State children: [ Container( margin: EdgeInsets.only(right: 5.sp), - width:5.sp, + width: 5.sp, height: 5.sp, decoration: BoxDecoration( shape: BoxShape.circle, - color: logic.isOnline? Color(0xFF00FFF4): Color(0xFF787575), + color: logic.isOnline + ? Color(0xFF00FFF4) + : Color(0xFF787575), ), ), Text( controller.onLineCity, - style: TextStyle(color: logic.isOnline? Color(0xFF00FFF4): Color(0xFF787575)), + style: TextStyle( + color: logic.isOnline + ? Color(0xFF00FFF4) + : Color(0xFF787575)), ) ], ), @@ -259,7 +244,9 @@ class _MyTabbedScreenState extends State // margin: EdgeInsets.only(top: 18.sp, bottom: 18.sp), height: 59.sp, child: ListView.builder( - itemCount: controller.userInfoBean==null ? 0 : controller.userInfoBean!.interests.length, + itemCount: controller.userInfoBean == null + ? 0 + : controller.userInfoBean!.interests.length, // 替换为实际的 item 数量 scrollDirection: Axis.horizontal, // 设置为水平方向 @@ -283,7 +270,7 @@ class _MyTabbedScreenState extends State margin: EdgeInsets.all(0.2.sp), decoration: BoxDecoration( borderRadius: BorderRadius.circular(17.0), - // shape: BoxShape.circle, + // shape: BoxShape.circle, color: Color(0xFF392D53), ), child: Padding( @@ -306,14 +293,6 @@ class _MyTabbedScreenState extends State ), ), titleTab(controller), - Visibility( - visible: logic.isShowAlbum, - child: Container( - margin: EdgeInsets.only(top: 18.sp, bottom: 14.sp), - child: controller.isMe? Text( - controller.isLikeFoMsg, - style: TextStyle(color: Colors.white30), - ) :Container())) , Expanded( child: Container( // color: Colors.blue, @@ -329,7 +308,8 @@ class _MyTabbedScreenState extends State ), ); } - Widget titleTab(UserinfoLogic controller){ + + Widget titleTab(UserinfoLogic controller) { return Container( alignment: Alignment.centerLeft, height: 27.sp, @@ -351,15 +331,17 @@ class _MyTabbedScreenState extends State Tab(text: "喊话") ], ), - - GestureDetector(onTap: (){ - controller.isMe? controller.isEdit = !controller.isEdit : controller.urgeChange(); - controller.update(); - // controller.updataImage(); - }, - child: Visibility( - visible: logic.isShowAlbum, - child: Container( + GestureDetector( + onTap: () { + controller.isMe + ? controller.isEdit = !controller.isEdit + : controller.urgeChange(); + controller.update(); + // controller.updataImage(); + }, + child: Visibility( + visible: logic.isShowAlbum, + child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(17), gradient: const LinearGradient( @@ -374,65 +356,128 @@ class _MyTabbedScreenState extends State padding: EdgeInsets.only( top: 2.sp, bottom: 2.sp, left: 12.sp, right: 12.sp), child: Text( - controller.isMe? controller.isEdit?"完成": "管理" : controller.isUrgeStatus? "已催更":"催更", + controller.isMe + ? controller.isEdit + ? "完成" + : "管理" + : controller.isUrgeStatus + ? "已催更" + : "催更", style: const TextStyle( color: Colors.white, fontSize: 12, ), - ), - ),),), + ), + ), + ), ], )); } - Widget _imageAdapter(UserinfoLogic controller) { - return GridView.builder( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, // 每行显示的项目数量 - ), - itemCount:controller.isMe? - controller.isEdit? controller.state.imaglist.length+1 : controller.state.imaglist.length: - controller.state.imaglist.length, // 项目的总数量,包括固定图片和接口获取的项目 - itemBuilder: (BuildContext context, int index) { - if(controller.isMe&&controller.isEdit){ - if (index == 0) { - // 第一个项目,显示固定的图片 - return GestureDetector( - onTap: () { - controller.getImageFile(); + + + Widget _imageAdapter(UserinfoLogic controller) { + return Stack(children: [ + Container( + child: Column( + // mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.only(top: 18.sp, bottom: 14.sp), + child: controller.isMe + ? Text( + controller.isLikeFoMsg, + style: const TextStyle(color: Colors.white30), + ) + : Container()), + GridView.builder( + shrinkWrap: true, + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, // 每行显示的项目数量 + ), + itemCount: controller.isMe + ? controller.isEdit + ? controller.state.imaglist.length + 1 + : controller.state.imaglist.length + : controller.state.imaglist.length, // 项目的总数量,包括固定图片和接口获取的项目 + itemBuilder: (BuildContext context, int index) { + if (controller.isMe && controller.isEdit) { + if (index == 0) { + // 第一个项目,显示固定的图片 + return GestureDetector( + onTap: () { + controller.getImageFile(); + }, + child: Container( + margin: EdgeInsets.all(5.sp), + child: Image( + image: AssetImage(getMineImage("icon_img_add")), + ), + ), + ); + } else { + return Container( + margin: EdgeInsets.all(5.sp), + child: Center( + child: _buildImageItem( + controller.state.imaglist[index - 1].url, + controller, + index - 1)), + ); + } + } else { + return Container( + margin: EdgeInsets.all(5.sp), + child: Center( + child: _buildImageItem( + controller.state.imaglist[index].url, + controller, + index)), + ); + } }, + ) + ], + ), + ), + Positioned( + left: 0, + right: 0, + bottom: 27.sp, + child: GestureDetector( + onTap: () { + // showToast("完善资料"); + Get.toNamed(AppRoutes.Complete_materialPage, arguments: "user"); + // controller.onInit(); + }, + child: Center( child: Container( - margin: EdgeInsets.all(5.sp), - child: Image( - image: AssetImage(getMineImage("icon_img_add")), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17), + gradient: LinearGradient( + colors: [ + Color(0xFF06F9FA), + Color(0xFFDC5BFD), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + ), + padding: EdgeInsets.only( + top: 10.sp, bottom: 10.sp, left: 55.sp, right: 55.sp), + child: Text( + "完善个人形象", + style: TextStyle( + color: Colors.white, + fontSize: 12, + ), ), ), - ); - } else { - return Container( - margin: EdgeInsets.all(5.sp), - child: Center( - child: _buildImageItem( - controller.state.imaglist[index-1].url, - controller,index-1)), - ); - } - }else{ - return Container( - margin: EdgeInsets.all(5.sp), - child: Center( - child: _buildImageItem( - controller.state.imaglist[index].url, - controller,index)), - ); - } - - - - }, - ); + ), + )) + ],); } Widget _buildInfoRow(UserinfoLogic controller) { @@ -453,7 +498,7 @@ class _MyTabbedScreenState extends State padding: EdgeInsets.only( top: 2.sp, bottom: 2.sp, left: 10.sp, right: 10.sp), child: Text( - controller.ageMsg , + controller.ageMsg, style: TextStyle( color: Colors.black, fontSize: 10, @@ -461,12 +506,13 @@ class _MyTabbedScreenState extends State ), ), SizedBox(width: 6.sp), - controller.isVip>0 ? - Image( - image: AssetImage(getBaseImage("vip")), - width: 44.sp, - height: 18.sp, - ):Container(), + controller.isVip > 0 + ? Image( + image: AssetImage(getBaseImage("vip")), + width: 44.sp, + height: 18.sp, + ) + : Container(), ], ); } @@ -485,7 +531,9 @@ class _MyTabbedScreenState extends State margin: EdgeInsets.only(left: 24.sp), child: Center( child: Text( - controller.userInfoBean!=null ? controller.userInfoBean!.signature:"", + controller.userInfoBean != null + ? controller.userInfoBean!.signature + : "", maxLines: 2, style: TextStyle(color: Colors.white), overflow: TextOverflow.ellipsis, @@ -521,24 +569,22 @@ class _MyTabbedScreenState extends State } Widget _buildAvatar1(UserinfoLogic controller) { - if(controller.userInfoBean==null){ - return Container( - width: 66.sp, - height: 66.sp, - ); - }else { + if (controller.userInfoBean == null) { + return Container( + width: 66.sp, + height: 66.sp, + ); + } else { return ClipOval( child: GestureDetector( onTap: () { var imgList = []; imgList.add(controller.userInfoBean!.avatar); - Get.toNamed(AppRoutes.Swiper, arguments: { - 'imaglist': imgList, - 'index': 0 - }); + Get.toNamed(AppRoutes.Swiper, + arguments: {'imaglist': imgList, 'index': 0}); }, child: CachedNetworkImage( - imageUrl: controller.userInfoBean != null + imageUrl: controller.userInfoBean != null ? controller.userInfoBean!.avatar : "", width: 66.sp, @@ -549,7 +595,7 @@ class _MyTabbedScreenState extends State } } - Widget _buildImageItem(String url, UserinfoLogic controller,int index) { + Widget _buildImageItem(String url, UserinfoLogic controller, int index) { return Stack( children: [ Container( @@ -563,10 +609,8 @@ class _MyTabbedScreenState extends State controller.state.imaglist.forEach((element) { imaglist.add(element.url); }); - Get.toNamed(AppRoutes.Swiper, arguments: { - 'imaglist':imaglist, - 'index':index - }); + Get.toNamed(AppRoutes.Swiper, + arguments: {'imaglist': imaglist, 'index': index}); }, child: Image.network( fit: BoxFit.cover, @@ -581,15 +625,16 @@ class _MyTabbedScreenState extends State right: 0, child: GestureDetector( onTap: () { - // showToast("删除"); - _showDelImgDialog(context,controller,index); - + // showToast("删除"); + _showDelImgDialog(context, controller, index); }, - child:controller.isEdit? Image( - image: AssetImage(getMineImage("icon_img_del")), - width: 20.sp, - height: 20.sp, - ):Container(), + child: controller.isEdit + ? Image( + image: AssetImage(getMineImage("icon_img_del")), + width: 20.sp, + height: 20.sp, + ) + : Container(), )) ], ); @@ -626,7 +671,8 @@ class _MyTabbedScreenState extends State GestureDetector( onTap: () { Navigator.pop(context); - Get.toNamed(AppRoutes.ReportActivity); + Get.toNamed(AppRoutes.ReportActivity, + arguments: {"userId": logic.userId}); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -677,9 +723,8 @@ class _MyTabbedScreenState extends State ); } - - - void _showDelImgDialog(BuildContext context,UserinfoLogic controller,int index) { + void _showDelImgDialog( + BuildContext context, UserinfoLogic controller, int index) { showDialog( context: context, builder: (BuildContext context) { @@ -721,7 +766,7 @@ class _MyTabbedScreenState extends State child: Text( "提示", style: - TextStyle(color: Colors.white, fontSize: 16.sp), + TextStyle(color: Colors.white, fontSize: 16.sp), ), ), Container( @@ -775,9 +820,6 @@ class _MyTabbedScreenState extends State onTap: () { Navigator.pop(context); controller.delAlbumImage(index); - - - }, child: Container( margin: EdgeInsets.only(top: 24.sp), @@ -819,10 +861,6 @@ class _MyTabbedScreenState extends State ); } - - - - void _showReportDialog(BuildContext context) { showDialog( context: context, @@ -925,7 +963,9 @@ class _MyTabbedScreenState extends State ), SizedBox(width: 24.sp), GestureDetector( - onTap: () {}, + onTap: () { + logic.setBlock(); + }, child: Container( margin: EdgeInsets.only(top: 24.sp), decoration: BoxDecoration( diff --git a/circle_app/lib/network/api.dart b/circle_app/lib/network/api.dart index 8f8cdfe..4f597c9 100644 --- a/circle_app/lib/network/api.dart +++ b/circle_app/lib/network/api.dart @@ -86,6 +86,35 @@ class Api { static const getUrgeStatus = 'up-service/user/'; + //拉黑 + static const setBlock = 'user-service/user/'; + + + //喜欢 + static const setLike = 'user-service/user/'; + + + + //关注列表 + static const followList = 'user-service/follow/users'; + + + + + //被关注列表 + static const fansList = 'user-service/fans/users'; + + + //被关注列表 + static const visitList = 'user-service/visit/users'; + + + + //举报 + static const postReport = 'up-service/report'; + + +