diff --git a/circle_app/lib/app/circle/logic.dart b/circle_app/lib/app/circle/logic.dart index 70a1a07..a669894 100644 --- a/circle_app/lib/app/circle/logic.dart +++ b/circle_app/lib/app/circle/logic.dart @@ -15,28 +15,31 @@ import '../../network/api.dart'; import '../../network/dio_manager.dart'; import '../../util/eventBus.dart'; import '../select_circle/logic.dart'; +import '../userinfo/logic.dart'; import 'state.dart'; import 'package:scroll_to_index/scroll_to_index.dart'; class CircleLogic extends GetxController { - PageController pageController = PageController(initialPage: 1, viewportFraction: 0.8); SwiperController swiperController = SwiperController(); final RefreshController refreshController = RefreshController(); InterestsBean circle = InterestsBean(lists: []); final CircleState state = CircleState(); - var statistics = Rx(DataModel(visitCount: 0, lastVisitUsers: [], likeMeCount: 0)); + var statistics = Rx( + DataModel(visitCount: 0, lastVisitUsers: [], likeMeCount: 0)); + //Map? statistics; int page = 1; + int vicinityPage = 1; + bool isMore = true; int myVip = 0; bool isShowCircle = true; - String cityName = "全国"; + String cityName = ""; - - var bannerList = ["http://pics5.baidu.com/feed/622762d0f703918f751ba5e950ce8d915beec4c1.jpeg?token=ed435fd18c71cf7ca7a011acb70460f7"]; + List bannerList = []; AutoScrollController scrollController = AutoScrollController(); ScrollController listScrollController = ScrollController(); @@ -44,28 +47,31 @@ class CircleLogic extends GetxController { @override void onInit() async { super.onInit(); - var data = await DioManager.instance - .get(url: Api.getCircleInterests, params: {"page": page,'page_size':20}); + var data = await DioManager.instance.get( + url: Api.getCircleInterests, params: {"page": page, 'page_size': 20}); var bean = BaseResponse.fromJson( data, (data) => InterestsBean.fromJson(data)); - if(bean.data is InterestsBean&&bean.isSuccess()){ + if (bean.data is InterestsBean && bean.isSuccess()) { circle = bean.data!; if (circle.lists.length < 20) { isMore = false; } update(); } - myVip = await getVip(); + myVip = await getVip(); loadCirclePeopleData(); initGerder(); getCityList(); + + getBanner(); + getNearByList(); + EventBusManager.on().listen((event) { myVip = event.vip; // update(); }); } - List genderList = []; List orientationList = []; @@ -73,33 +79,29 @@ class CircleLogic extends GetxController { List roleList = []; void initGerder() async { - var data1 = - await DioManager.instance.get(url: Api.getCircleList, params: {}); - var bean1 = BaseResponse.fromJson( - data1, (data1) => ConfigBean.fromJson(data1)); + var data1 = + await DioManager.instance.get(url: Api.getCircleList, params: {}); + var bean1 = BaseResponse.fromJson( + data1, (data1) => ConfigBean.fromJson(data1)); - ConfigBean configBean = bean1.data!; - - configBean.genderMap.forEach((key, value) { - genderList.add(MyConfigData(key, value, false)); - }); - - configBean.orientationMap.forEach((key, value) { - orientationList.add(MyConfigData(key, value, false)); - }); - configBean.roleMap.forEach((key, value) { - roleList.add(MyConfigData(key, value, false)); - }); + ConfigBean configBean = bean1.data!; + configBean.genderMap.forEach((key, value) { + genderList.add(MyConfigData(key, value, false)); + }); + configBean.orientationMap.forEach((key, value) { + orientationList.add(MyConfigData(key, value, false)); + }); + configBean.roleMap.forEach((key, value) { + roleList.add(MyConfigData(key, value, false)); + }); } List provinceList = []; - Map cityMap = {}; - getCityList() async { try { String jsonString = await rootBundle.loadString('assets/province.json'); @@ -111,14 +113,11 @@ class CircleLogic extends GetxController { Map areaMap = {}; for (int c = 0; c < provinceList[i].city.length; c++) { String cityName = provinceList[i].city[c].name; - List cityAreaList = []; - provinceList[i].city[c].area.forEach((element) { - cityAreaList.add(element); - }); - areaMap[cityName] = cityAreaList; + areaMap[cityName] = []; // 不再存储区域列表,直接设置为空列表 } cityMap[provinceList[i].name] = areaMap; } + } catch (e) { print('Error loading JSON file: $e'); } @@ -127,21 +126,19 @@ class CircleLogic extends GetxController { loadMore() async { if (!isMore) return; page = page + 1; - var data = await DioManager.instance - .get(url: Api.getCircleInterests, params: {"page": page,'page_size':20}); + var data = await DioManager.instance.get( + url: Api.getCircleInterests, params: {"page": page, 'page_size': 20}); var bean = BaseResponse.fromJson( data, (data) => InterestsBean.fromJson(data)); InterestsBean newcircle = bean.data!; if (newcircle.lists.isNotEmpty) { - if (newcircle.lists.length < 20) { isMore = false; } circle.lists.addAll(newcircle.lists); update(); } - } outCircle(String interest_id, bool isStatus) async { @@ -160,7 +157,7 @@ class CircleLogic extends GetxController { } updateCircleInfo(Circle circleInfo) { - for(int i = 0; i < circle.lists.length; i++) { + for (int i = 0; i < circle.lists.length; i++) { Circle temp = circle.lists[i]; if (temp.id == circleInfo.id) { circle.lists[i] = circleInfo; @@ -170,7 +167,7 @@ class CircleLogic extends GetxController { update(); } - setCircle(String circleId){ + setCircle(String circleId) { circle.lists.forEach((element) { if (element.id.toString() == circleId.toString()) { element.isJoin = true; @@ -180,13 +177,12 @@ class CircleLogic extends GetxController { //访问我的圈子人数 loadCirclePeopleData() async { - var data = await DioManager.instance - .get(url: Api.getInterestsCount); + var data = await DioManager.instance.get(url: Api.getInterestsCount); var myAlbumBean = BaseResponse.fromJson( data, (data) => DataModel.fromJson(data)); if (data['code'] == 200) { - statistics.value = myAlbumBean.data; + statistics.value = myAlbumBean.data; // update(); } } @@ -196,27 +192,28 @@ class CircleLogic extends GetxController { } void pushHome(String userId) { - Get.toNamed(AppRoutes.UserInfoActivity, arguments: userId); + Get.toNamed(AppRoutes.UserInfoActivity, arguments: userId); } void getPipeiData() async { - var data = await DioManager.instance - .get(url: Api.getMatch); - if(data['code'] == 200) { + var data = await DioManager.instance.get(url: Api.getMatch); + if (data['code'] == 200) { //发送消息 - bool isSuccess = await createCustomMsg(data['data']['account_id'].toString().split('_').last,data['data']['account_id']); + bool isSuccess = await createCustomMsg( + data['data']['account_id'].toString().split('_').last, + data['data']['account_id']); if (!isSuccess) { await sendTextMsg(data['data']['account_id']); } - } else if(data['code'] == 21201){ + } else if (data['code'] == 21201) { showOKToast(data['msg']); showRechargeDialog(); - }else{ + } else { showOKToast(data['msg']); } } - showRechargeDialog(){ + showRechargeDialog() { Get.bottomSheet( Scaffold( backgroundColor: Colors.transparent, @@ -224,21 +221,231 @@ class CircleLogic extends GetxController { ), isScrollControlled: true, enableDrag: false); - } + void getBanner() async { + bannerList.clear(); + var data = + await DioManager.instance.get(url: Api.getNearbyBeanner, params: {}); + var bean = BaseResponse.fromJson( + data, (data) => BannerList.fromJson(data)); + bannerList.addAll(bean.data.banners); + cityName = bean.data.city; + } + int offset = 0; + int deep = 0; + List vicinityList = []; + void getNearByList() async { + List genders = []; + genderList.forEach((element) { + if (element.isSelect) { + genders.add(element.id); + } + }); + List roles = []; + roleList.forEach((element) { + if (element.isSelect) roles.add(element.id); + }); + List orientations = []; + orientationList.forEach((element) { + if (element.isSelect) orientations.add(element.id); + }); + // getBanner(); + var data = await DioManager.instance.post(url: Api.postNearbyList, params: { + "offset": offset, + 'deep': deep, + 'city': cityName, + "genders": genders, + "roles": roles, + "orientations": orientations + }); + var bean = BaseResponse.fromJson( + data, (data) => VicinityBean.fromJson(data)); + try { + offset = bean.data.offset; + deep = bean.data.deep; + } catch (Exception) {} + if (vicinityPage == 1) { + vicinityList.clear(); + } + try{ + vicinityList.addAll(bean.data.users); + } catch(Exception){ + } + if (vicinityPage == 1) { + refreshController.refreshCompleted(); + } else { + refreshController.loadComplete(); + } - - + update(); + } } +class VicinityBean { + String city; + int offset; + int deep; + List users; + + VicinityBean( + {required this.city, + required this.users, + required this.offset, + required this.deep}); + + factory VicinityBean.fromJson(Map json) { + List listsJson = json['users']; + List lists = + listsJson.map((e) => VicinityItemBean.fromJson(e)).toList(); + return VicinityBean( + users: lists, + city: json['city'], + offset: json['offset'], + deep: json['deep']); + } +} + +class VicinityItemBean { + 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 List interests; + final List images; + final String avatarThumb; + final String genderName; + final String roleName; + final String orientationName; + final String bgPicUrl; + final String onlineFlag; + final bool isOnline; + + VicinityItemBean({ + 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.interests, + required this.images, + required this.avatarThumb, + required this.genderName, + required this.roleName, + required this.orientationName, + required this.bgPicUrl, + required this.onlineFlag, + required this.isOnline, + }); + + factory VicinityItemBean.fromJson(Map json) { + var interestList = json['interests'] as List; + List interests = + interestList.map((interest) => Interest.fromJson(interest)).toList(); + + return VicinityItemBean( + 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'], + interests: interests, + images: List.from(json['images']), + avatarThumb: json['avatar_thumb'], + genderName: json['genderName'], + roleName: json['roleName'], + orientationName: json['orientationName'], + bgPicUrl: json['bgPicUrl'], + onlineFlag: json['onlineFlag'], + isOnline: json['isOnline'], + ); + } +} + +// class Interest { +// final int id; +// final String title; +// final String intro; +// final String image; +// final double amount; +// final double oldAmount; +// final String iosItem; +// final DateTime lastCalloutTime; +// final DateTime lastJoinTime; +// final bool isJoin; +// final bool isLike; +// final bool isLimit; +// final int viewTotal; +// final int joinTotal; +// +// Interest({ +// required this.id, +// required this.title, +// required this.intro, +// required this.image, +// required this.amount, +// required this.oldAmount, +// required this.iosItem, +// required this.lastCalloutTime, +// required this.lastJoinTime, +// required this.isJoin, +// required this.isLike, +// required this.isLimit, +// required this.viewTotal, +// required this.joinTotal, +// }); +// factory Interest.fromJson(Map json) { +// return Interest( +// id: json['id'], +// title: json['title'], +// intro: json['intro'], +// image: json['image'], +// amount: json['amount'], +// oldAmount: json['oldAmount'], +// iosItem: json['iosItem'], +// lastCalloutTime: DateTime.parse(json['lastCalloutTime']), +// lastJoinTime: DateTime.parse(json['lastJoinTime']), +// isJoin: json['isJoin'], +// isLike: json['isLike'], +// isLimit: json['isLimit'], +// viewTotal: json['viewTotal'], +// joinTotal: json['joinTotal'], +// ); +// } +// } + class InterestsBean { List lists; @@ -349,13 +556,16 @@ class LastJoinUser { } class DataModel { - int visitCount = 0; + int visitCount = 0; List lastVisitUsers = []; int likeMeCount = 0; - DataModel({required this.visitCount, required this.lastVisitUsers, required this.likeMeCount}); + DataModel( + {required this.visitCount, + required this.lastVisitUsers, + required this.likeMeCount}); factory DataModel.fromJson(Map json) { return DataModel( @@ -366,8 +576,6 @@ class DataModel { } } - - class Province { String name; List city; @@ -377,7 +585,7 @@ class Province { factory Province.fromJson(Map json) { List cityData = json['city']; List cityList = - cityData.map((dynamic item) => CityBean.fromJson(item)).toList(); + cityData.map((dynamic item) => CityBean.fromJson(item)).toList(); return Province( name: json['name'], @@ -400,11 +608,52 @@ class CityBean { factory CityBean.fromJson(Map json) { List areaData = json['area']; List areaList = - areaData.map((dynamic item) => item.toString()).toList(); + areaData.map((dynamic item) => item.toString()).toList(); return CityBean( name: json['name'], area: areaList, ); } -} \ No newline at end of file +} + +class BannerItem { + final String name; + final int type; + final String? param; + final String scene; + final String picUrl; + + BannerItem({ + required this.name, + required this.type, + this.param, + required this.scene, + required this.picUrl, + }); + + factory BannerItem.fromJson(Map json) { + return BannerItem( + name: json['name'], + type: json['type'], + param: json['param'], + scene: json['scene'], + picUrl: json['pic_url'], + ); + } +} + +class BannerList { + final String city; + final List banners; + + BannerList({required this.banners, required this.city}); + + factory BannerList.fromJson(Map json) { + final bannerList = json['banners'] as List; + final banners = + bannerList.map((item) => BannerItem.fromJson(item)).toList(); + + return BannerList(banners: banners, city: json['city']); + } +} diff --git a/circle_app/lib/app/circle/view.dart b/circle_app/lib/app/circle/view.dart index c5f3758..4a681e3 100644 --- a/circle_app/lib/app/circle/view.dart +++ b/circle_app/lib/app/circle/view.dart @@ -91,18 +91,16 @@ class _CirclePageState extends State ]), Container( margin: EdgeInsets.only(top: 45.sp), - child: Expanded( - child: PageView( - controller: _pageController, - onPageChanged: (index) { - _tabController.animateTo(index); - print("index=" + index.toString()); - }, - children: [ - circleList(controller), - vicinityList(controller), - ], - ), + child: PageView( + controller: _pageController, + onPageChanged: (index) { + _tabController.animateTo(index); + print("index=" + index.toString()); + }, + children: [ + circleList(controller), + vicinityList(controller), + ], ), ), logic.isShowCircle @@ -138,18 +136,18 @@ class _CirclePageState extends State controller: logic.refreshController, onRefresh: _onRefresh, onLoading: _onLoading, - enablePullUp: true, + enablePullUp: logic.myVip>0, child: ListView.builder( padding: EdgeInsets.all(10.sp), - itemCount: logic.myVip == 0 ? 5 + 2 : 10 + 1, + itemCount: logic.myVip == 0 ? logic.vicinityList.length + 2 : logic.vicinityList.length + 1, itemBuilder: (context, index) { if (index == 0) { return bannerView(controller); } else { - if (logic.myVip == 0 && index == 6) { + if (logic.myVip == 0 && index == logic.vicinityList.length+1) { return showVipView(); } else { - return ListItem("", index); + return ListItem(logic.vicinityList[index-1], index-1); } } }, @@ -160,7 +158,7 @@ class _CirclePageState extends State Widget showVipView() { return Container( margin: EdgeInsets.only(top: 10.sp), - color: Color(0xB30B011B), + color: const Color(0xB30B011B), padding: EdgeInsets.symmetric(vertical: 14.sp, horizontal: 20.sp), child: Column( children: [ @@ -212,191 +210,206 @@ class _CirclePageState extends State )); } - Widget ListItem(String item, int index) { - return Container( - margin: EdgeInsets.only(top: 10.sp), - // padding: EdgeInsets.only( left: 8.sp, right: 8.sp), - width: Get.width, - height: 200.sp, - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.fill, - image: AssetImage( - getCircleImage('pic_bg'), - ))), - child: Stack( - children: [ - Container( - margin: EdgeInsets.only(top: 1.sp, left: 1.sp, right: 1.sp), - child: ClipRRect( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10.sp), - topRight: Radius.circular(10.sp), - ), - child: Image( - image: AssetImage(getCircleImage("icon_list_null")), - width: Get.width, + Widget ListItem(VicinityItemBean item, int index) { + return GestureDetector( + onTap: (){ + Get.toNamed(AppRoutes.UserInfoActivity, arguments: item.id.toString()); + }, + child: Container( + margin: EdgeInsets.only(top: 10.sp), + // padding: EdgeInsets.only( left: 8.sp, right: 8.sp), + width: Get.width, + height: 200.sp, + decoration: BoxDecoration( + image: DecorationImage( fit: BoxFit.fill, - height: 92.sp, + image: AssetImage( + getCircleImage('pic_bg'), + ))), + child: Stack( + children: [ + Container( + margin: EdgeInsets.only(top: 1.sp, left: 1.sp, right: 1.sp), + child: ClipRRect( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10.sp), + topRight: Radius.circular(10.sp), + ), + child: item.images.length==0? Image( + image: AssetImage(getCircleImage("icon_list_null")), + width: Get.width, + fit: BoxFit.fill, + height: 92.sp, + ):Container(), ), ), - ), - Column(children: [ - Container( - margin: EdgeInsets.only(right: 2.sp), - child: Row( - children: [ - Container( - margin: EdgeInsets.only(top: 6.sp, left: 8.sp), - width: 88.sp, - height: 88.sp, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8.0), - gradient: const LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Color(0xFF71F3F2), - Color(0xFFF558FF), - ], - stops: [0.0365, 0.9427], + Column(children: [ + Container( + margin: EdgeInsets.only(right: 2.sp), + child: Row( + children: [ + Container( + margin: EdgeInsets.only(top: 6.sp, left: 8.sp), + width: 88.sp, + height: 88.sp, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.0), + gradient: const LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Color(0xFF71F3F2), + Color(0xFFF558FF), + ], + stops: [0.0365, 0.9427], + ), + ), + padding: EdgeInsets.all(2.sp), + child: ClipRRect( + borderRadius: BorderRadius.circular(8.0), + child: Image.network(item.avatarThumb, + width: 88.sp, height: 88.sp, fit: BoxFit.cover), ), ), - padding: EdgeInsets.all(2.sp), - child: ClipRRect( - borderRadius: BorderRadius.circular(8.0), - child: Image.network(logic.bannerList[0], - width: 88.sp, height: 88.sp, fit: BoxFit.cover), - ), - ), - Expanded( - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Container( + Expanded( + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Container( - margin: EdgeInsets.only(top: 6.sp), - child: Row( - children: [ - for (int i = 0; i < 5; i++) - ListAlbumItem(logic.bannerList[0], i), - ], + margin: EdgeInsets.only(top: 6.sp), + child: Row( + children: [ + for (int i = 0; i < item.images.length; i++) + GestureDetector( + onTap: (){ + Get.toNamed(AppRoutes.Swiper, + arguments: {'imaglist': item.images, 'index': i}); + }, + child: ListAlbumItem(item.images[i], i)), + ], + ), + ), + ), + ), + ], + ), + ), + Container( + margin: EdgeInsets.only(top: 6.sp, left: 9.sp), + child: Row( + children: [ + Text( + item.nickname, + style: TextStyle( + fontWeight: FontWeight.bold, + color: const Color.fromRGBO(247, 250, 250, 1.0), + fontSize: 16.sp, + ), + ), + SizedBox(width: 8.sp), + _buildInfoRow(item), + const Spacer(), + Container( + margin: EdgeInsets.only(right: 8.sp), + child:item.isOnline==1? Text( + "当前在线", + style: TextStyle( + color: const Color.fromRGBO(247, 250, 250, 1.0), + fontSize: 12.sp, + ), + ):Container(), + ), + + + ], + ), + ), + Container( + height: 50.sp, // 设置固定高度 + width: Get.width, + margin: EdgeInsets.symmetric( horizontal: 8.0), + child: Align( + alignment: Alignment.centerLeft, // 文本左对齐,垂直居中 + child: Text( + item.signature, + maxLines: 2, + style: TextStyle(color: Colors.white,fontSize: 14.sp), + overflow: TextOverflow.ellipsis, + ), + ), + ), + + Container( + margin: EdgeInsets.only(left: 8.sp,right: 3.sp), + child: _buildInterestsListView(item.interests)) + ]), + ], + )), + ); + } + + Widget _buildInterestsListView(List interests) { + return Align( + alignment: Alignment.centerLeft, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + for (int index = 0; index < interests.length; index++) + GestureDetector( + onTap: () { + Get.toNamed(AppRoutes.Signal_circle_list, + arguments: interests[index].id); + }, + child: Container( + margin: EdgeInsets.only(right: 11.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17.0), + gradient: const LinearGradient( + colors: [ + Color(0xFF06F9FA), + Color(0xFFDC5BFD), + ], + ), + color: const Color(0xFF392D53), + ), + child: Container( + margin: EdgeInsets.all(0.2.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17.0), + color: const Color(0xFF392D53), + ), + child: Padding( + padding: EdgeInsets.only( + top: 2.sp, + bottom: 2.sp, + left: 15.sp, + right: 15.sp, + ), + child: Center( + child: Text( + interests[index].title, + style: const TextStyle( + fontSize: 13.0, + color: Colors.white, ), ), ), ), - ], - ), - ), - Container( - margin: EdgeInsets.only(top: 6.sp, left: 9.sp), - child: Row( - children: [ - Text( - "nickname", - style: TextStyle( - fontWeight: FontWeight.bold, - color: const Color.fromRGBO(247, 250, 250, 1.0), - fontSize: 16.sp, - ), - ), - SizedBox(width: 8.sp), - _buildInfoRow(), - const Spacer(), - Container( - margin: EdgeInsets.only(right: 8.sp), - child: Text( - "当前在线", - style: TextStyle( - color: const Color.fromRGBO(247, 250, 250, 1.0), - fontSize: 12.sp, - ), - ), - ), - - - ], - ), - ), - Container( - height: 50.sp, // 设置固定高度 - width: Get.width, - margin: EdgeInsets.symmetric( horizontal: 8.0), - child: Align( - alignment: Alignment.centerLeft, // 文本左对齐,垂直居中 - child: Text( - "123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123", - maxLines: 2, - style: TextStyle(color: Colors.white,fontSize: 14.sp), - overflow: TextOverflow.ellipsis, ), ), ), - - Container( - margin: EdgeInsets.only(left: 8.sp,right: 3.sp), - child: _buildInterestsListView([Interest(id: 0,title: "圈子名称"),Interest(id: 0,title: "圈子名称"),Interest(id: 0,title: "圈子名称"),Interest(id: 0,title: "圈子名称"),Interest(id: 0,title: "圈子名称"),Interest(id: 0,title: "圈子名称")])) - ]), ], - )); - } - - Widget _buildInterestsListView(List interests) { - return SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: [ - for (int index = 0; index < interests.length; index++) - GestureDetector( - onTap: () { - Get.toNamed(AppRoutes.Signal_circle_list, - arguments: interests[index].id); - }, - child: Container( - margin: EdgeInsets.only(right: 11.sp), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(17.0), - gradient: const LinearGradient( - colors: [ - Color(0xFF06F9FA), - Color(0xFFDC5BFD), - ], - ), - color: const Color(0xFF392D53), - ), - child: Container( - margin: EdgeInsets.all(0.2.sp), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(17.0), - color: const Color(0xFF392D53), - ), - child: Padding( - padding: EdgeInsets.only( - top: 2.sp, - bottom: 2.sp, - left: 15.sp, - right: 15.sp, - ), - child: Center( - child: Text( - interests[index].title, - style: const TextStyle( - fontSize: 13.0, - color: Colors.white, - ), - ), - ), - ), - ), - ), - ), - ], + ), ), ); } - Widget _buildInfoRow() { + Widget _buildInfoRow(VicinityItemBean item) { + String ageMsg = getAgeCOntent(item!.gender, item!.age, + item!.role, item!.orientation); return Row( children: [ Container( @@ -418,7 +431,7 @@ class _CirclePageState extends State right: 10.sp, ), child: Text( - "agm", + ageMsg, style: const TextStyle( color: Colors.black, fontSize: 10, @@ -426,9 +439,9 @@ class _CirclePageState extends State ), ), const SizedBox(width: 6), - // if (controller.isVip > 0) + if (item.vip > 0) Image( - image: AssetImage(getBaseImage(1 == 1 ? "vip" : 'year_vip')), + image: AssetImage(getBaseImage(item.vip == 1 ? "vip" : 'year_vip')), width: 44.sp, height: 18.sp, ), @@ -439,25 +452,27 @@ class _CirclePageState extends State Widget ListAlbumItem(String item, int index) { return Container( margin: EdgeInsets.symmetric(horizontal: 2.sp), - child: Image.network(item, width: 88.sp, height: 88.sp, fit: BoxFit.cover), + child: CachedNetworkImage( width: 88.sp, height: 88.sp, fit: BoxFit.cover, imageUrl: item+"?imageView2/1/w/176/h/176/q/75",), ); } void _onRefresh() async { - logic.page = 1; - // logic.initList(); - logic.refreshController.refreshCompleted(); + logic.vicinityPage = 1; + logic.offset = 0; + logic.getNearByList(); + // logic.refreshController.refreshCompleted(); } - // if (page == 1) { - // refreshController.refreshCompleted(); - // } else { - // refreshController.loadComplete(); - // } + void _onLoading() async { - logic.page = logic.page + 1; - logic.refreshController.loadComplete(); - // logic.initList(); + if(logic.myVip>0){ + logic.vicinityPage = logic.vicinityPage + 1; + // + logic.getNearByList(); + }else{ + logic.refreshController.loadComplete(); + } + } Widget bannerView(CircleLogic controller) { @@ -472,13 +487,19 @@ class _CirclePageState extends State itemBuilder: (BuildContext context, int index) { // print(index); return GestureDetector( - onTap: () async {}, + onTap: () async { + print(logic.bannerList[index].param); + Get.toNamed(AppRoutes.WebViewActivity, arguments: { + 'title': "", + "url": logic.bannerList[index].param.toString() + }); + }, child: SizedBox( width: Get.width, child: ClipRRect( borderRadius: BorderRadius.circular(15.sp), child: CachedNetworkImage( - imageUrl: logic.bannerList[index], + imageUrl: logic.bannerList[index].picUrl, fit: BoxFit.fill, width: Get.width, ), @@ -502,19 +523,18 @@ class _CirclePageState extends State } Widget circleList(CircleLogic controller) { - return Expanded( - child: Swiper( + return Swiper( itemBuilder: (BuildContext context, int index) { - var bean = logic.circle.lists[index]; - // final GlobalKey infoListViewKey = GlobalKey(); - return InfoListView(index, bean, logic); + var bean = logic.circle.lists[index]; + // final GlobalKey infoListViewKey = GlobalKey(); + return InfoListView(index, bean, logic); }, onIndexChanged: (index) { - controller.state.index = index; - if (index == logic.circle.lists.length - 1) { - logic.loadMore(); - } - print(index.toString()); + controller.state.index = index; + if (index == logic.circle.lists.length - 1) { + logic.loadMore(); + } + print(index.toString()); }, index: controller.state.index, itemCount: logic.circle.lists.length, @@ -524,7 +544,7 @@ class _CirclePageState extends State key: UniqueKey(), // pagination: new SwiperPagination(),//如果不填则不显示指示点 // control: new SwiperControl(),//如果不填则不显示左右按钮 - )); + ); } Widget navigatorItem(DataModel statistics) { @@ -739,7 +759,10 @@ class _CirclePageState extends State genderList: logic.genderList, orientationList: logic.orientationList, roleList: logic.roleList, - callback: (genderList, orientationList, roleList) {}, + callback: (genderList, orientationList, roleList) { + logic.offset = 0; + logic.getNearByList(); + }, ); // Use your custom widget here }, ); @@ -972,14 +995,16 @@ class _CirclePageState extends State showCityPiker(context) { Pickers.showMultiLinkPicker(context, - pickerStyle: DefaultPickerStyle.dark(), data: logic.cityMap, columeNum: 3, + pickerStyle: DefaultPickerStyle.dark(), data: logic.cityMap, columeNum: 2, onConfirm: (List res, List position){ print(res); - print(logic.cityMap[res[0]][res[1]][0]); + // print(logic.cityMap[res[0]][res[1]][0]); // controller.state.city = controller.cityMap[res[0]][res[1]][0]; // logic.state.city = res[1]; - logic.cityName = res[2]; - logic.update(); + logic.cityName = res[1]; + + logic.offset = 0; + logic.getNearByList(); // logic.getSuccess(); // logic.update(); } diff --git a/circle_app/lib/app/dialog/ScreenBottomSheetDialog.dart b/circle_app/lib/app/dialog/ScreenBottomSheetDialog.dart index 9b44595..f52d27b 100644 --- a/circle_app/lib/app/dialog/ScreenBottomSheetDialog.dart +++ b/circle_app/lib/app/dialog/ScreenBottomSheetDialog.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -5,6 +7,7 @@ import 'package:get/get.dart'; import '../../common/Widgets/open_vip_tip/view.dart'; import '../../util/device.dart'; +import '../../util/eventBus.dart'; import '../../util/util.dart'; import '../select_circle/logic.dart'; @@ -41,9 +44,21 @@ class _ScreenBottomSheetDialogState extends State { super.initState(); initGerder(); } - + StreamSubscription? subscription = null; void initGerder() async { myVip = await getVip(); + subscription = EventBusManager.on().listen((event) { + myVip = event.vip; + }); + } + + @override + void dispose() { + // TODO: implement dispose + if (null != subscription) { + EventBusManager.cancelSubscription(subscription!); + } + super.dispose(); } @override @@ -95,6 +110,7 @@ class _ScreenBottomSheetDialogState extends State { onTap: (){ widget.callback([],[],[]); + Navigator.pop(context); }, child: Container( margin: EdgeInsets.only(right: 16.sp), diff --git a/circle_app/lib/common/Widgets/open_vip_tip/view.dart b/circle_app/lib/common/Widgets/open_vip_tip/view.dart index f7546bd..c7761ba 100644 --- a/circle_app/lib/common/Widgets/open_vip_tip/view.dart +++ b/circle_app/lib/common/Widgets/open_vip_tip/view.dart @@ -7,6 +7,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:get/get.dart'; +import '../../../util/eventBus.dart'; import 'logic.dart'; class Open_vip_tipPage extends StatelessWidget { @@ -71,6 +72,7 @@ class Open_vip_tipPage extends StatelessWidget { right: 12.sp, child: GestureDetector( onTap: () { + // EventBusManager.fire(CommentVipEvent(1)); Get.back(); }, child: Image.asset( diff --git a/circle_app/lib/network/api.dart b/circle_app/lib/network/api.dart index f4ec783..97b17fc 100644 --- a/circle_app/lib/network/api.dart +++ b/circle_app/lib/network/api.dart @@ -1,9 +1,9 @@ class Api { - static const baseUrl = 'https://leyuan666.com/zuul-service/'; + // static const baseUrl = 'https://leyuan666.com/zuul-service/'; - // static const baseUrl = 'http://192.168.3.55:2000/' ; + static const baseUrl = 'http://192.168.3.55:2000/' ; // 获取验证码 @@ -192,12 +192,14 @@ class Api { + //附近banner + static const getNearbyBeanner = 'user-service/nearby/banner'; - - + //附近列表 + static const postNearbyList = 'user-service/nearby/queryNearByUserList';