diff --git a/circle_app/assets/images/circle/chat_icon.png b/circle_app/assets/images/circle/chat_icon.png new file mode 100644 index 0000000..f7498a9 Binary files /dev/null and b/circle_app/assets/images/circle/chat_icon.png differ diff --git a/circle_app/assets/images/circle/clocked_icon.png b/circle_app/assets/images/circle/clocked_icon.png new file mode 100644 index 0000000..bb09c55 Binary files /dev/null and b/circle_app/assets/images/circle/clocked_icon.png differ diff --git a/circle_app/assets/images/circle/like_icon.png b/circle_app/assets/images/circle/like_icon.png new file mode 100644 index 0000000..e8b1c9a Binary files /dev/null and b/circle_app/assets/images/circle/like_icon.png differ diff --git a/circle_app/assets/images/circle/love_gift_icon.png b/circle_app/assets/images/circle/love_gift_icon.png new file mode 100644 index 0000000..64f004b Binary files /dev/null and b/circle_app/assets/images/circle/love_gift_icon.png differ diff --git a/circle_app/assets/images/circle/love_icon.png b/circle_app/assets/images/circle/love_icon.png new file mode 100644 index 0000000..38d22b0 Binary files /dev/null and b/circle_app/assets/images/circle/love_icon.png differ diff --git a/circle_app/assets/images/circle/no_look_icon.png b/circle_app/assets/images/circle/no_look_icon.png new file mode 100644 index 0000000..e5fff0d Binary files /dev/null and b/circle_app/assets/images/circle/no_look_icon.png differ diff --git a/circle_app/assets/images/circle/nor_like_icon.png b/circle_app/assets/images/circle/nor_like_icon.png new file mode 100644 index 0000000..c76c8a0 Binary files /dev/null and b/circle_app/assets/images/circle/nor_like_icon.png differ diff --git a/circle_app/assets/images/circle/right_icon.png b/circle_app/assets/images/circle/right_icon.png new file mode 100644 index 0000000..e505f8b Binary files /dev/null and b/circle_app/assets/images/circle/right_icon.png differ diff --git a/circle_app/assets/images/circle/today_heart_icon.png b/circle_app/assets/images/circle/today_heart_icon.png new file mode 100644 index 0000000..9edd220 Binary files /dev/null and b/circle_app/assets/images/circle/today_heart_icon.png differ diff --git a/circle_app/assets/images/circle/unclock_icon.png b/circle_app/assets/images/circle/unclock_icon.png new file mode 100644 index 0000000..d54a598 Binary files /dev/null and b/circle_app/assets/images/circle/unclock_icon.png differ diff --git a/circle_app/assets/images/circle/wx.png b/circle_app/assets/images/circle/wx.png new file mode 100644 index 0000000..e36abd7 Binary files /dev/null and b/circle_app/assets/images/circle/wx.png differ diff --git a/circle_app/assets/images/home/wx_close.png b/circle_app/assets/images/home/wx_close.png new file mode 100644 index 0000000..30fb55f Binary files /dev/null and b/circle_app/assets/images/home/wx_close.png differ diff --git a/circle_app/assets/images/home/wx_tip_bg.png b/circle_app/assets/images/home/wx_tip_bg.png new file mode 100644 index 0000000..1b3884c Binary files /dev/null and b/circle_app/assets/images/home/wx_tip_bg.png differ diff --git a/circle_app/assets/images/home/wx_tip_title.png b/circle_app/assets/images/home/wx_tip_title.png new file mode 100644 index 0000000..f987db0 Binary files /dev/null and b/circle_app/assets/images/home/wx_tip_title.png differ diff --git a/circle_app/assets/images/mine/icon_recharge_first.png b/circle_app/assets/images/mine/icon_recharge_first.png new file mode 100644 index 0000000..0e9e59f Binary files /dev/null and b/circle_app/assets/images/mine/icon_recharge_first.png differ diff --git a/circle_app/assets/images/mine/icon_recharge_fourth.png b/circle_app/assets/images/mine/icon_recharge_fourth.png new file mode 100644 index 0000000..a2381ec Binary files /dev/null and b/circle_app/assets/images/mine/icon_recharge_fourth.png differ diff --git a/circle_app/assets/images/mine/icon_recharge_second.png b/circle_app/assets/images/mine/icon_recharge_second.png new file mode 100644 index 0000000..cd9f1c8 Binary files /dev/null and b/circle_app/assets/images/mine/icon_recharge_second.png differ diff --git a/circle_app/assets/images/mine/icon_recharge_third.png b/circle_app/assets/images/mine/icon_recharge_third.png new file mode 100644 index 0000000..e8c50d8 Binary files /dev/null and b/circle_app/assets/images/mine/icon_recharge_third.png differ diff --git a/circle_app/assets/images/mine/icon_yaoqing_xin_left.png b/circle_app/assets/images/mine/icon_yaoqing_xin_left.png new file mode 100644 index 0000000..804794a Binary files /dev/null and b/circle_app/assets/images/mine/icon_yaoqing_xin_left.png differ diff --git a/circle_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/circle_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index f3d88ac..c87d15a 100644 --- a/circle_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/circle_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -40,7 +40,7 @@ new _DiscoverPageState(); +} + +class _DiscoverPageState extends State { + // TODO: add state variables and methods + + @override + Widget build(BuildContext context) { + // TODO: add widget build method + return Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage(getBaseImage("bg")), + fit: BoxFit.cover, + ), + ), + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: const MyAppBar( + centerTitle: '已解锁的圈友', + // actionWdiget: , + ), + + body: Discover(1), + )); + } +} diff --git a/circle_app/lib/app/circle/logic.dart b/circle_app/lib/app/circle/logic.dart index cdc9461..41ec4a7 100644 --- a/circle_app/lib/app/circle/logic.dart +++ b/circle_app/lib/app/circle/logic.dart @@ -33,6 +33,7 @@ class CircleLogic extends GetxController { int page = 1; int vicinityPage = 1; + int currentPage = 0; bool isMore = true; int myVip = 0; @@ -79,6 +80,13 @@ class CircleLogic extends GetxController { List roleList = []; + + List dis_genderList = []; + + List dis_orientationList = []; + + List dis_roleList = []; + void initGerder() async { var data1 = await DioManager.instance.get(url: Api.getCircleList, params: {}); @@ -89,13 +97,17 @@ class CircleLogic extends GetxController { configBean.genderMap.forEach((key, value) { genderList.add(MyConfigData(key, value, false)); + dis_genderList.add(MyConfigData(key, value, false)); }); configBean.orientationMap.forEach((key, value) { orientationList.add(MyConfigData(key, value, false)); + dis_orientationList.add(MyConfigData(key, value, false)); }); configBean.roleMap.forEach((key, value) { roleList.add(MyConfigData(key, value, false)); + dis_roleList.add(MyConfigData(key, value, false)); + }); } diff --git a/circle_app/lib/app/circle/view.dart b/circle_app/lib/app/circle/view.dart index 7b1c011..290a20e 100644 --- a/circle_app/lib/app/circle/view.dart +++ b/circle_app/lib/app/circle/view.dart @@ -1,22 +1,21 @@ import 'dart:math'; import 'package:cached_network_image/cached_network_image.dart'; +import 'package:circle_app/app/circle/widgets/discover.dart'; import 'package:circle_app/app/circle/widgets/info_list_view.dart'; +import 'package:circle_app/app/circle/widgets/vicinity.dart'; import 'package:circle_app/app/dialog/ScreenBottomSheetDialog.dart'; -import 'package:circle_app/app/msg/view.dart'; -import 'package:circle_app/common/Widgets/open_vip_tip/view.dart'; import 'package:circle_app/router/app_routers.dart'; +import 'package:circle_app/util/eventBus.dart'; import 'package:circle_app/util/util.dart'; import 'package:flutter/material.dart'; import 'package:flutter_pickers/pickers.dart'; -import 'package:flutter_pickers/style/default_style.dart'; import 'package:flutter_pickers/style/picker_style.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:get/get.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import '../../util/eventBus.dart'; import '../select_circle/logic.dart'; import '../userinfo/logic.dart'; import 'logic.dart'; @@ -32,7 +31,7 @@ class CirclePage extends StatefulWidget { } class _CirclePageState extends State - with SingleTickerProviderStateMixin { + with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { late TabController _tabController; late PageController _pageController; @@ -42,8 +41,9 @@ class _CirclePageState extends State @override void initState() { super.initState(); - _pageController = PageController(); - _tabController = TabController(length: 1, vsync: this); + int initIndex = Random().nextInt(3); + _pageController = PageController(initialPage: initIndex); + _tabController = TabController(length: 3, vsync: this, initialIndex: initIndex); _tabController.addListener(_handleTabChange); } @@ -73,13 +73,10 @@ class _CirclePageState extends State @override Widget build(BuildContext context) { getContext = context; - return GetBuilder(builder: (logic) - { + return GetBuilder(builder: (logic) { return Scaffold( backgroundColor: Colors.transparent, - body: - - SafeArea( + body: SafeArea( child: GetBuilder(builder: (CircleLogic controller) { return Stack( children: [ @@ -100,35 +97,29 @@ class _CirclePageState extends State }, children: [ circleList(controller), - // vicinityList(controller), + Vicinity(controller), + Discover(0) ], ), ), - logic.isShowCircle - ? - Positioned( - bottom: 36.sp, - right: 10.sp, - child: GestureDetector( - onTap: () async { - List numbers = []; - numbers.add(MyConfigData( - logic - .getCircleIndex() - .id - .toString(), - logic - .getCircleIndex() - .title!, - false)); - var data = await Get.toNamed( - AppRoutes.Call_out, - arguments: {'numbers': numbers}); - }, - child: Image.asset( - getCircleImage('send_msg'), - width: 60.sp, - ))) + _tabController.index == 0 + ? Positioned( + bottom: 36.sp, + right: 10.sp, + child: GestureDetector( + onTap: () async { + List numbers = []; + numbers.add(MyConfigData( + logic.getCircleIndex().id.toString(), + logic.getCircleIndex().title!, + false)); + var data = await Get.toNamed(AppRoutes.Call_out, + arguments: {'numbers': numbers}); + }, + child: Image.asset( + getCircleImage('send_msg'), + width: 60.sp, + ))) : Center() ], ); @@ -562,11 +553,11 @@ class _CirclePageState extends State infoList = statistics.lastVisitUsers; if (infoList.isNotEmpty) { for (var element in infoList) { - if(element["avatar"]!=null&&element["avatar"].contains("http")){ - urlList.add(element["avatar"]); - } + if (element["avatar"] != null && element["avatar"].contains("http")) { + urlList.add(element["avatar"]); + } - // urlList.add(element["avatar"]); + // urlList.add(element["avatar"]); } } } @@ -594,71 +585,84 @@ class _CirclePageState extends State child: Stack( alignment: Alignment.center, children: [ - // logic.isShowCircle - // ? Positioned( - // left: 0, - // child: GestureDetector( - // onTap: () { - // Get.toNamed(AppRoutes.Invite); - // }, - // child: Container( - // 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.6.sp), - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(17.0), - // color: const Color(0xFF392D53), - // ), - // child: Padding( - // padding: EdgeInsets.only( - // top: 5.sp, - // bottom: 4.sp, - // left: 8.sp, - // right: 8.sp, - // ), - // child: const Center( - // child: Text( - // "邀请得会员", - // style: TextStyle( - // fontSize: 11, - // color: Colors.white, - // ), - // ), - // ), - // ), - // ), - // ), - // )) - // - // : GestureDetector( - // onTap: () { - // showCityPiker(context); - // }, - // child: Row( - // children: [ - // Image.asset( - // getCircleImage('icon_city'), - // width: 24.sp, - // ), - // Container( - // margin: EdgeInsets.only(left: 4.sp, top: 4.sp), - // child: Text( - // modifyCityName(logic.cityName), - // style: - // TextStyle(color: Colors.white, fontSize: 16.sp), - // )) - // ], - // ), - // ), + _tabController.index == 0 + ? Positioned( + left: 0, + child: GestureDetector( + onTap: () { + Get.toNamed(AppRoutes.Invite); + }, + child: Container( + 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.6.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17.0), + color: const Color(0xFF392D53), + ), + child: Padding( + padding: EdgeInsets.only( + top: 5.sp, + bottom: 4.sp, + left: 8.sp, + right: 8.sp, + ), + child: const Center( + child: Text( + "邀请得会员", + style: TextStyle( + fontSize: 11, + color: Colors.white, + ), + ), + ), + ), + ), + ), + )) + : _tabController.index == 1 + ? Positioned( + left: 0, + child: GestureDetector( + onTap: () { + showCityPiker(context); + }, + child: Row( + children: [ + Image.asset( + getCircleImage('icon_city'), + width: 24.sp, + ), + Container( + margin: EdgeInsets.only(left: 4.sp, top: 4.sp), + child: Text( + modifyCityName(logic.cityName), + style: TextStyle( + color: Colors.white, fontSize: 16.sp), + )) + ], + ), + )) + : Positioned( + left: 0, + child: GestureDetector( + onTap: () { + Get.toNamed(AppRoutes.DisCover); + }, + child: Image.asset( + getCircleImage('clocked_icon'), + width: 60.sp, + ), + )), Container( alignment: Alignment.center, //padding: EdgeInsets.symmetric(horizontal: 10.sp), @@ -674,17 +678,34 @@ class _CirclePageState extends State indicator: UnderlineTabIndicator( borderSide: BorderSide( color: const Color(0xFF00FFF4), - width: 2.sp, + width: 1.5.sp, ), insets: EdgeInsets.symmetric(horizontal: 6.0.sp), borderRadius: BorderRadius.circular(18.0), ), indicatorColor: const Color(0xFF00FFF4), - indicatorWeight: 2.sp, + indicatorWeight: 1.sp, labelColor: const Color(0xFF00FFF4), unselectedLabelColor: const Color(0xB3FFFFFF), indicatorSize: TabBarIndicatorSize.label, + indicatorPadding: EdgeInsets.only(left: 6.sp, right: 6.sp), tabs: [ + Tab( + child: Text( + '圈子', + style: TextStyle( + fontSize: 18.sp, + ), + ), + ), + Tab( + child: Text( + '附近', + style: TextStyle( + fontSize: 18.sp, + ), + ), + ), Tab( child: Text( '发现', @@ -693,14 +714,6 @@ class _CirclePageState extends State ), ), ), - // Tab( - // child: Text( - // '附近', - // style: TextStyle( - // fontSize: 18.sp, - // ), - // ), - // ), ], labelStyle: TextStyle( color: const Color(0xFF00FFF4), @@ -731,35 +744,18 @@ class _CirclePageState extends State duration: const Duration(milliseconds: 300), // 动画时长 curve: Curves.ease, // 动画曲线 ); + if (index == 2) { + EventBusManager.fire(DiscovrScrollTap()); + } else if (index == 1) { + EventBusManager.fire(NearScrollTap()); + } else if (index == 0) { + EventBusManager.fire(ScrollToTop()); + } }, ), ], ), ), - - // ShaderMask( - // shaderCallback: (Rect bounds) { - // return const LinearGradient( - // begin: Alignment(0.0, -1.0), - // end: Alignment.bottomCenter, - // colors: [Color(0xff71F3F2), Color(0xffF657FF)], - // ).createShader(Offset.zero & bounds.size); - // }, - // child: GestureDetector( - // onTap: (){ - // - // }, - // child: Text( - // '发现', - // style: TextStyle( - // fontSize: 18.sp, - // fontWeight: FontWeight.w600, - // color: Colors.white, - // shadows: const [Shadow(color: Color(0xffF657FF), offset: Offset(0.0, -1))], - // ), - // ), - // ), - // ), Positioned( right: 0, child: logic.isShowCircle @@ -793,11 +789,32 @@ class _CirclePageState extends State backgroundColor: Colors.transparent, builder: (BuildContext context) { return ScreenBottomSheetDialog( - genderList: logic.genderList, - orientationList: logic.orientationList, - roleList: logic.roleList, + genderList: _tabController.index == 1 ? logic.genderList : logic.dis_genderList, + orientationList: _tabController.index == 1 ? logic.orientationList : logic.dis_orientationList, + roleList: _tabController.index == 1 ? logic.roleList : logic.dis_roleList, callback: (genderList, orientationList, roleList) { - _onRefresh(); + if (_tabController.index == 1) { + _onRefresh(); + } else { + + List genders = []; + logic.dis_genderList.forEach((element) { + if (element.isSelect) { + genders.add(element.id); + } + }); + List roles = []; + logic.dis_orientationList.forEach((element) { + if (element.isSelect) roles.add(element.id); + }); + + List orientations = []; + logic.dis_roleList.forEach((element) { + if (element.isSelect) orientations.add(element.id); + }); + + EventBusManager.fire(OptionFindclass(genders,roles,orientations)); + } }, ); // Use your custom widget here }, @@ -1112,3 +1129,14 @@ class DefaultPickerStyle extends PickerStyle { this.textColor = Colors.white; } } + +class DiscovrScrollTap {} +class NearScrollTap {} +class CircleScrollTap {} + +class OptionFindclass { + List? genderList;List? orientationList;List? roleList; + + OptionFindclass(this.genderList,this.orientationList,this.roleList); + +} diff --git a/circle_app/lib/app/circle/widgets/discover.dart b/circle_app/lib/app/circle/widgets/discover.dart new file mode 100644 index 0000000..235a826 --- /dev/null +++ b/circle_app/lib/app/circle/widgets/discover.dart @@ -0,0 +1,956 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:circle_app/app/circle/view.dart'; +import 'package:circle_app/common/Widgets/genderview.dart'; +import 'package:circle_app/common/colors/app_color.dart'; +import 'package:circle_app/common/const.dart'; +import 'package:circle_app/main.dart'; +import 'package:circle_app/network/api.dart'; +import 'package:circle_app/network/dio_manager.dart'; +import 'package:circle_app/router/app_routers.dart'; +import 'package:circle_app/util/SharedPreferencesHelper.dart'; +import 'package:circle_app/util/util.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_swiper/flutter_swiper.dart'; +import 'package:get/get.dart'; +import 'package:intl/intl.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; +import '../../../../util/eventBus.dart'; + +const String todayAddWxStatus = 'todayAddWxStatus'; + +class Discover extends StatefulWidget { + int unlockWxNum; + Discover(this.unlockWxNum, {super.key}); + @override + _DiscoverState createState() => _DiscoverState(); +} + +class _DiscoverState extends State + with AutomaticKeepAliveClientMixin { +// TODO: add state variables and methods + @override + bool get wantKeepAlive => true; + // TODO: add state variables and methods + ScrollController _scrollController = ScrollController(); + RefreshController refreshController = RefreshController(); + var refreshSignSub; + var sub; + var sub1; + var subscripition; + List list = []; + List giftList = []; + bool isMore = true; + int index = 1; + List tagList = []; + + List genderList = [];List orientationList= [];List roleList= []; + bool isPop = false; +//获取屏幕宽度 + + Offset pointerStart = Offset.zero; + Offset pointerEnd = Offset.zero; + double touchRangeY = 0; + double nextOffset = 0; + int lastPage = 0; + + double screenHeight = Get.height - + Get.bottomBarHeight - + Get.statusBarHeight - + ((Get.height > 750 ? 115.sp : 155.sp) - Get.statusBarHeight); + + void animateToOffset(ScrollController controller, double offset, + void Function() onScrollCompleted) { + controller + .animateTo(offset, + duration: const Duration(milliseconds: 200), curve: Curves.easeIn) + .then((value) { + if (onScrollCompleted != null) { + onScrollCompleted(); + } + }).catchError((e) { + print(e); + }); + } +// 按下时保存当前的点 + +// 按下时保存当前的点 + PointerDownEventListener getPointDownListenerInHorizontal() { + return (event) { + pointerStart = event.position; + }; + } + +// 抬起时触发 + PointerUpEventListener getPointUpListenerInHorizontal() { + return (event) { + pointerEnd = event.position; + touchRangeY = pointerStart.dy - pointerEnd.dy; + + if (touchRangeY.abs() < screenHeight / 3) { + // 滑动距离大于屏幕宽度的1/8就可以继续翻页了 + nextOffset = (screenHeight + 10.sp) * lastPage; + animateToOffset(_scrollController, nextOffset, () {}); + return; + } + if (touchRangeY < 0 && lastPage > 0) { + // 手指从下向上滑动 + lastPage--; + animateToOffset( + _scrollController, lastPage * (screenHeight + 10.sp), () {}); + } else if (touchRangeY > 0 && lastPage < list.length - 1) { + // 从上向下 + lastPage++; + animateToOffset( + _scrollController, lastPage * (screenHeight + 10.sp), () {}); + if (lastPage == 3 && isPop == false && widget.unlockWxNum == 0) { + isPop = true; + //弹窗提示 + checkIsPopWxTip(); + } + } + }; + } + + @override + void dispose() { + // TODO: implement dispose + super.dispose(); + if (widget.unlockWxNum == 0) { + subscripition.cancel(); + } + sub.cancel(); + sub1.cancel(); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + loadData(); + if (widget.unlockWxNum == 0) { + subscripition = EventBusManager.on().listen((event) { + refreshData(); + }); + } + + + sub = EventBusManager.on().listen((event) { + _scrollController.animateTo(0, + duration: const Duration(milliseconds: 300), curve: Curves.easeInOut); + }); + sub1 = EventBusManager.on().listen((event) { + genderList = event.genderList!; + orientationList = event.orientationList!; + roleList = event.roleList!; + index = 1; + loadData(); + }); + + refreshSignSub = EventBusManager.on().listen((event) { + loadSignDiscoverData(event.userId); + }); + } + + setLike(String userId, bool isLike, Function callBack) async { + // if (isBlack || isDestroy) { + // showOKToast("喜欢失败,存在拉黑关系或者该账户已注销"); + // return; + // } + + var data = await DioManager.instance.post( + url: "${Api.setLike + userId}/follow", + params: {'status': isLike ? "0" : "1"}); + var bean = BaseResponse.fromJson( + data, + (jsonData) => jsonData, + ); + if (bean.isSuccess()) { + callBack(); + } + showOKToast(bean.msg); + } + + loadSignDiscoverData(String userId) async { + try { + var result = await DioManager.instance + .get(url: Api.getFindPageUserByUserId, params: { + 'userId': userId, + 'lat': '0', + 'lng': '0', + }); + + int initIndex = 0; + list.forEach((element) { + if (element['id'].toString() == userId) { + initIndex = list.indexOf(element); + } + }); + + list[initIndex] = result['data']; + setState(() {}); + } catch (e) { + + } + } + + loadGiftListData() async { + // var result = await DioManager.instance.get(url: Api.giftList); + // if (result['code'] == 10000) { + // giftList = result['data']; + // await loadData(); + // setState(() {}); + // } + } + + loadData() async { + var data = await DioManager.instance.post(url: Api.findPage, params: { + 'page': index, + 'pageSize': 8, + 'unlockWxNum': widget.unlockWxNum, + "genders": genderList, + "roles": roleList, + "orientations": orientationList, + 'lat': '0', + 'lng': '0', + }); + // + if (data['code'] == 200) { + List dataList = data['data']; + + if (dataList.isNotEmpty) { + if (index == 1) { + list = dataList; + refreshController.refreshCompleted(); + } else { + list.addAll(dataList); + } + + index = index + 1; + isMore = true; + refreshController.loadComplete(); + } else { + isMore = false; + refreshController.loadNoData(); + } + if (mounted) { + setState(() {}); + } + } + } + + void refreshData() { + index = 1; + loadData(); + } + + _onLoading() { + loadData(); + } + + @override + Widget build(BuildContext context) { + // TODO: add widget build method + return list.isEmpty + ? isMore + ? loaddingWidget(true) + : noResultWidget(tip: '已解锁微信的圈友会展示在这里哦~') + : Listener( + onPointerDown: getPointDownListenerInHorizontal(), + onPointerUp: getPointUpListenerInHorizontal(), + child: SmartRefresher( + onRefresh: refreshData, + controller: refreshController, + onLoading: _onLoading, + enablePullUp: true, + child: ListView.builder( + itemBuilder: (context, index) { + var user = Users.fromJson(list[index]); + + String onLineStr = ''; + if (user.online! ?? false) { + onLineStr = '当前在线'; + if (user.distance != null) { + if (user.distance! < 100) { + onLineStr = '当前在线 · ${user.distance!}km'; + } + } + } else { + if (user.distance != null) { + if ((user.distance! ?? 10) < 100) { + onLineStr = '${user.distance!}km'; + } + } + } + + return Container( + height: screenHeight, + width: Get.width, + margin: EdgeInsets.only( + top: 10.sp, left: 16.sp, right: 16.sp), + child: Stack( + children: [ + Container( + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(10.sp), + image: DecorationImage( + fit: BoxFit.fill, + image: AssetImage( + getCircleImage('open_vip_bg'), + ))), + height: screenHeight, + width: Get.width, + child: ClipRRect( + borderRadius: BorderRadius.circular(18), + clipBehavior: Clip.hardEdge, + child: Container( + padding: EdgeInsets.all(2.sp), + child: Swiper( + autoplay: + user.images!.length == 1 ? false : true, + itemBuilder: + (BuildContext context, int index) { + // print(index); + return GestureDetector( + onTap: () { + List imgList = []; + user.images!.forEach((element) { + imgList.add(element); + }); + + Get.toNamed(AppRoutes.Swiper, + arguments: { + 'imaglist': imgList, + 'index': index + }); + }, + child: CachedNetworkImage( + imageUrl: user.images![index], + fit: BoxFit.cover, + width: Get.width, + height: screenHeight, + )); + }, + itemCount: user.images!.length, + ), + )), + ), + Positioned( + left: 16.sp, + top: 20.sp, + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (user.both_cities!.isNotEmpty) + Row( + children: [ + Container( + width: 6.sp, + height: 6.sp, + margin: + EdgeInsets.only(right: 4.sp), + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(3.sp), + color: const Color(0xFFCE51FF), + ), + ), + // if (logic.online) + Text( + "你们都来过${user.both_cities!.first}", + style: TextStyle( + color: Colors.white, + fontSize: 14.sp), + ), + ], + ), + if (user.both_cities!.isNotEmpty) + SizedBox( + height: 8.sp, + ), + if (onLineStr.isNotEmpty) + Row( + children: [ + Container( + width: 6.sp, + height: 6.sp, + margin: + EdgeInsets.only(right: 4.sp), + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(3.sp), + color: const Color(0xFFCE51FF), + ), + ), + // if (logic.online) + Text( + onLineStr, + style: TextStyle( + color: Colors.white, + fontSize: 14.sp), + ), + ], + ), + ], + ), + )), + Positioned( + right: 16.sp, + top: 16.sp, + child: GestureDetector( + onTap: () { + Get.toNamed(AppRoutes.UserInfoActivity, + arguments: user.userId!.toString()); + }, + child: Container( + width: 73.sp, + height: 25.sp, + decoration: BoxDecoration( + gradient: AppColor.mainLinearGradient, + borderRadius: + BorderRadius.circular(12.5.sp)), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.only(left: 5.sp), + child: Text( + '查看主页', + style: TextStyle( + color: Colors.white, + fontSize: 10.sp, + ), + ), + ), + Image( + width: 15.sp, + image: AssetImage( + getDisCoverImage("right_icon")), + // width: 44.sp, + ), + ], + ), + ), + )), + Positioned( + left: 6.sp, + bottom: 6.sp, + child: Container( + width: Get.width - 32.sp, + padding: EdgeInsets.only(right: 0.sp), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (user.wxNum != null) + wxStatusWidget( + user.unLockWxNum == 1, + user.wxNum!, + user.userId.toString(), + user.avatarUrl!, () { + loadSignDiscoverData( + user.userId.toString()); + }), + SizedBox( + height: 10.sp, + ), + Row( + children: [ + Text( + user.nickname ?? '', + style: TextStyle( + fontSize: 18.sp, + color: Color(0XFFF7FAFA), + fontWeight: FontWeight.bold), + ), + Container( + margin: EdgeInsets.only(left: 5.sp), + alignment: Alignment.center, + height: 18.sp, + padding: EdgeInsets.only( + left: 6.sp, right: 6.sp), + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(9.sp), + gradient: const LinearGradient( + begin: Alignment(0.25, 0.5), + end: Alignment(0.75, 0.5), + colors: [ + Color(0xff8DFFF8), + Color(0xffB5D3FF) + ])), + child: Text( + getAgeCOntent( + user!.gender ?? 0, + user!.age ?? 0, + user!.role ?? 0, + user!.orientation ?? 0), + style: TextStyle( + color: Colors.black, + fontSize: 12.sp, + ), + ), + ), + if (user.vip! > 0) + Container( + margin: EdgeInsets.only( + left: 4.sp, + ), + child: Image.asset( + getCircleImage(user!.vip == 1 + ? 'vip' + : 'year_vip'), + width: 36.sp, + ), + ), + ], + ), + Container( + width: Get.width - 120.sp, + margin: EdgeInsets.only(top: 5.sp), + child: Text( + user.signature! ?? '', + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 15.sp, + color: const Color(0XFFF7FAFA)), + ), + ), + Container( + width: Get.width - 110.sp, + height: 35.sp, + child: tagItem(user.interests!), + ), + ], + ), + )), + Positioned( + bottom: 5.sp, + right: 15.sp, + child: Container( + child: Column( + children: [ + GestureDetector( + onTap: () { + pushChatPage( + user.userId.toString(), + user.imAccid!.toString(), + user.nickname!); + }, + child: Image.asset( + getCircleImage( + 'chat_icon', + ), + width: 40.sp, + ), + ), + SizedBox( + height: 8.sp, + ), + GestureDetector( + onTap: () { + setLike(user.userId!.toString(), + user.is_follow!, () { + list[index]['is_follow'] = + !user.is_follow!; + setState(() {}); + }); + }, + child: Image.asset( + getCircleImage( + user.is_follow! + ? 'like_icon' + : 'nor_like_icon', + ), + width: 40.sp, + ), + ), + GestureDetector( + onTap: () { + sendNoLookData(user.userId!,index); + }, + child: Image.asset( + getCircleImage( + 'no_look_icon', + ), + width: 40.sp, + ), + ) + ], + ), + )) + ], + )); + }, + itemCount: list.length, + physics: BouncingScrollPhysics(), + controller: _scrollController, + ), + ), + ); + } + + tagItem(List item) { + return Container( + width: Get.width, + margin: EdgeInsets.only(top: 5.sp, bottom: 5.sp), + // color: Colors.red, + // height: 45.sp, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: item.length, + itemBuilder: (context, index) { + return tagWidget(item[index]['title'], item[index]['id']); + }), + ); + } + + tagWidget(String tagName, int id) { + return GestureDetector( + onTap: () { + Get.toNamed(AppRoutes.Signal_circle_list, arguments: id); + }, + child: Container( + margin: EdgeInsets.only(right: 6.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: 10.sp, + right: 10.sp, + ), + child: Center( + child: Text( + tagName, + style: const TextStyle( + fontSize: 11.0, + color: Colors.white, + ), + ), + ), + ), + ), + ), + ); + } + + addWxPicker() { + return Get.bottomSheet( + Container(), + isScrollControlled: false, + enableDrag: false, + ); + } + + void checkIsPopWxTip() async { + SharedPreferencesHelper sp = await SharedPreferencesHelper.getInstance(); + var date = DateTime.now(); + final dateFormat = DateFormat("yyyy-MM-dd"); + final date2 = dateFormat.format(date); + if (sp.preferences!.containsKey(todayAddWxStatus)) { + var lastDate = sp.preferences!.getString(todayAddWxStatus); + if (lastDate != date2) { + loadWxNumData(); + sp.preferences!.setString(todayAddWxStatus, date2); + } + } else { + sp.preferences!.setString(todayAddWxStatus, date2); + loadWxNumData(); + } + } + + loadWxNumData() async { + // var data = await DioManager.instance.post(url: Api.myMainPage); + // + // if (data['code'] == 10000) { + // if (data['userBase']['wxNum'] == null) { + // showAddWxPicker(false); + // } else if (data['userBase']['wxNum'].toString().isEmpty) { + // showAddWxPicker(false); + // } + // + // } + } + + void sendNoLookData(int userId,int index) async { + var data = await DioManager.instance.post(url: Api.uninterested + userId.toString()); + if (data['code'] == 200) { + list.removeAt(index); + setState(() { + + }); + } + } +} + + +class DiscoverDataRefresh { + String userId; + DiscoverDataRefresh(this.userId); +} + +class Users { + int? age; + bool? auth; + String? avatarUrl; + String? bgPicUrl; + String? birthday; + bool? blacklist; + String? city; + double? distance; + bool? dust; + String? email; + bool? followBag; + int? followStatus; + int? gender; + String? genderName; + String? heartbeatValue; + int? height; + int? hugCount; + String? imAccid; + List? images; + List? interests; + String? inviteCode; + int? kyNum; + String? lastLoginLog; + String? lastLoginTime; + int? level; + List? litGifts; + int? lvType; + MapUserJumpAo? mapUserJumpAo; + String? nickname; + String? nicknameNote; + bool? online; + String? openId; + bool? partner; + bool? is_follow; + String? phoneNum; + int? popularityValue; + bool? realPersonAuth; + int? relationshipStatus; + String? signature; + bool? specialConcern; + int? storyCount; + List? tags; + int? touchTime; + int? unLockWxNum; + int? userId; + int? weight; + int? orientation; + int? role; + int? vip; + String? wxNum; + List? both_cities; + + Users( + {this.age, + this.auth, + this.avatarUrl, + this.bgPicUrl, + this.birthday, + this.blacklist, + this.city, + this.distance, + this.dust, + this.email, + this.is_follow, + this.vip, + this.followBag, + this.followStatus, + this.gender, + this.genderName, + this.heartbeatValue, + this.height, + this.hugCount, + this.imAccid, + this.role, + this.images, + this.interests, + this.inviteCode, + this.kyNum, + this.lastLoginLog, + this.lastLoginTime, + this.level, + this.litGifts, + this.lvType, + this.mapUserJumpAo, + this.nickname, + this.nicknameNote, + this.online, + this.openId, + this.partner, + this.phoneNum, + this.popularityValue, + this.realPersonAuth, + this.relationshipStatus, + this.signature, + this.specialConcern, + this.storyCount, + this.tags, + this.touchTime, + this.unLockWxNum, + this.both_cities, + this.userId, + this.orientation, + this.weight, + this.wxNum}); + + Users.fromJson(Map json) { + age = json['age']; + vip = json['vip']; + role = json['role']; + auth = json['auth']; + both_cities = json['both_cities'] ?? []; + is_follow = json['is_follow']; + interests = json['interests']; + avatarUrl = json['avatar']; + bgPicUrl = json['bgPicUrl']; + birthday = json['birthday']; + blacklist = json['blacklist']; + city = json['city']; + orientation = json['orientation']; + distance = json['distance']; + dust = json['dust']; + email = json['email']; + followBag = json['followBag']; + followStatus = json['followStatus']; + gender = json['gender']; + genderName = json['genderName']; + heartbeatValue = json['heartbeatValue'].toString(); + height = json['height']; + hugCount = json['hugCount']; + imAccid = json['account_id']; + images = json['images']; + inviteCode = json['inviteCode']; + kyNum = json['kyNum']; + lastLoginLog = json['lastLoginLog']; + lastLoginTime = json['lastLoginTime']; + level = json['level']; + litGifts = json['litGifts']; + lvType = json['lvType']; + mapUserJumpAo = json['mapUserJumpAo'] != null + ? new MapUserJumpAo.fromJson(json['mapUserJumpAo']) + : null; + nickname = json['nickname']; + nicknameNote = json['nicknameNote']; + online = json['isOnline']; + openId = json['openId']; + partner = json['partner']; + phoneNum = json['phoneNum']; + popularityValue = json['popularityValue']; + realPersonAuth = json['realPersonAuth']; + relationshipStatus = json['relationshipStatus']; + signature = json['signature']; + specialConcern = json['specialConcern']; + storyCount = json['storyCount']; + tags = json['tags']; + touchTime = json['touchTime']; + unLockWxNum = json['unLockWxNum']; + userId = json['id']; + weight = json['weight']; + wxNum = json['wx_num']; + } + + Map toJson() { + final Map data = new Map(); + data['age'] = this.age; + data['auth'] = this.auth; + data['avatarUrl'] = this.avatarUrl; + data['bgPicUrl'] = this.bgPicUrl; + data['birthday'] = this.birthday; + data['blacklist'] = this.blacklist; + data['city'] = this.city; + data['distance'] = this.distance; + data['dust'] = this.dust; + data['email'] = this.email; + data['followBag'] = this.followBag; + data['followStatus'] = this.followStatus; + data['gender'] = this.gender; + data['genderName'] = this.genderName; + data['heartbeatValue'] = this.heartbeatValue; + data['height'] = this.height; + data['hugCount'] = this.hugCount; + data['imAccid'] = this.imAccid; + if (this.images != null) { + data['images'] = this.images!.map((v) => v.toJson()).toList(); + } + data['inviteCode'] = this.inviteCode; + data['kyNum'] = this.kyNum; + data['lastLoginLog'] = this.lastLoginLog; + data['lastLoginTime'] = this.lastLoginTime; + data['level'] = this.level; + if (this.litGifts != null) { + data['litGifts'] = this.litGifts!.map((v) => v.toJson()).toList(); + } + data['lvType'] = this.lvType; + if (this.mapUserJumpAo != null) { + data['mapUserJumpAo'] = this.mapUserJumpAo!.toJson(); + } + data['nickname'] = this.nickname; + data['nicknameNote'] = this.nicknameNote; + data['online'] = this.online; + data['openId'] = this.openId; + data['partner'] = this.partner; + data['phoneNum'] = this.phoneNum; + data['popularityValue'] = this.popularityValue; + data['realPersonAuth'] = this.realPersonAuth; + data['relationshipStatus'] = this.relationshipStatus; + data['signature'] = this.signature; + data['specialConcern'] = this.specialConcern; + data['storyCount'] = this.storyCount; + if (this.tags != null) { + data['tags'] = this.tags!.map((v) => v.toJson()).toList(); + } + data['touchTime'] = this.touchTime; + data['unLockWxNum'] = this.unLockWxNum; + data['userId'] = this.userId; + data['weight'] = this.weight; + data['wxNum'] = this.wxNum; + return data; + } +} + +class MapUserJumpAo { + int? id; + String? roomId; + String? title; + int? type; + + MapUserJumpAo({this.id, this.roomId, this.title, this.type}); + + MapUserJumpAo.fromJson(Map json) { + id = json['id']; + roomId = json['roomId']; + title = json['title']; + type = json['type']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['roomId'] = this.roomId; + data['title'] = this.title; + data['type'] = this.type; + return data; + } +} + +class msgPageRefresh {} diff --git a/circle_app/lib/app/circle/widgets/info_list_view.dart b/circle_app/lib/app/circle/widgets/info_list_view.dart index 1eea8a4..f654b61 100644 --- a/circle_app/lib/app/circle/widgets/info_list_view.dart +++ b/circle_app/lib/app/circle/widgets/info_list_view.dart @@ -100,11 +100,14 @@ class InfoListViewState extends State with AutomaticKeepAliveClien scroToTop = EventBusManager.on().listen((event) { - scrollController.animateTo( - 0.0, - duration: Duration(milliseconds: 300), - curve: Curves.easeInOut, - ); + if (widget.logic.state.index == widget.index) { + scrollController.animateTo( + 0.0, + duration: Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + } + }); // widget.back(widget.createState()); diff --git a/circle_app/lib/app/circle/widgets/vicinity.dart b/circle_app/lib/app/circle/widgets/vicinity.dart new file mode 100644 index 0000000..11cfcfe --- /dev/null +++ b/circle_app/lib/app/circle/widgets/vicinity.dart @@ -0,0 +1,469 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:circle_app/app/circle/logic.dart'; +import 'package:circle_app/app/circle/view.dart'; +import 'package:circle_app/app/circle/widgets/info_list_view.dart'; +import 'package:circle_app/app/userinfo/logic.dart'; +import 'package:circle_app/router/app_routers.dart'; +import 'package:circle_app/util/eventBus.dart'; +import 'package:circle_app/util/util.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_swiper/flutter_swiper.dart'; +import 'package:get/get.dart'; +import 'package:get/get_core/src/get_main.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; + +class Vicinity extends StatefulWidget { + CircleLogic logic; + // TODO: add state variables, methods and constructor params + Vicinity(this.logic); + + @override + State createState() => _VicinityState(); +} + +class _VicinityState extends State with AutomaticKeepAliveClientMixin { + var sub; + ScrollController _scrollController = ScrollController(); + @override + void initState() { + // TODO: implement initState + super.initState(); + sub = EventBusManager.on().listen((event) { + _scrollController.animateTo(0, + duration: const Duration(milliseconds: 300), curve: Curves.easeInOut); + }); + } + + @override + void dispose() { + // TODO: implement dispose + super.dispose(); + _scrollController.dispose(); + sub.cancel(); + } + + @override + Widget build(BuildContext context) { + // TODO: add widget build method + return widget.logic.vicinityList.isNotEmpty ? SmartRefresher( + controller: widget.logic.refreshController, + onRefresh: _onRefresh, + onLoading: _onLoading, + enablePullUp: widget.logic.myVip > 0, + child: ListView.builder( + controller: _scrollController, + padding: EdgeInsets.all(10.sp), + itemCount: widget.logic.myVip == 0 + ? widget.logic.vicinityList.length + 2 + : widget.logic.vicinityList.length + 1, + itemBuilder: (context, index) { + if (index == 0) { + return bannerView(widget.logic); + } else { + if (widget.logic.myVip == 0 && index == widget.logic.vicinityList.length + 1) { + return showVipView(); + } else { + return ListItem(widget.logic.vicinityList[index - 1], index - 1); + } + } + }, + ), + ) : loaddingWidget(true); + } + + Widget bannerView(CircleLogic controller) { + return SizedBox( + height: 160.sp, + // margin: EdgeInsets.symmetric(horizontal: 16.sp), + child: Swiper( + autoplay: widget.logic.bannerList.length > 1, + controller: widget.logic.swiperController, + autoplayDelay: 6000, + loop: widget.logic.bannerList.length > 1 ? true : false, + // index:logic.index, + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () async { + // print(logic.bannerList[index].param); + navigateToCustomRoute(widget.logic.bannerList[index]); + }, + child: SizedBox( + width: Get.width, + child: ClipRRect( + borderRadius: BorderRadius.circular(15.sp), + child: CachedNetworkImage( + imageUrl: widget.logic.bannerList[index].picUrl, + fit: BoxFit.fill, + width: Get.width, + ), + )), + ); + }, + itemCount: widget.logic.bannerList.length, + pagination: SwiperPagination( + margin: EdgeInsets.all(5.0.sp), // 设置外边距 + alignment: Alignment.bottomCenter, + builder: DotSwiperPaginationBuilder( + color: Color(0x00FFFFFF), // 小圆点的颜色 + activeColor: widget.logic.bannerList.length == 1 + ? Color(0x00FFFFFF) + : Color(0x00FFFFFF), // 当前索引小圆点的颜色 + ), + ), +// control: new SwiperControl(), //左右的那个箭头,在某模拟器中会出现蓝线 + ), + ); + } + + Widget circleList(CircleLogic controller) { + return Swiper( + itemBuilder: (BuildContext context, int index) { + var bean = widget.logic.circle.lists[index]; + // final GlobalKey infoListViewKey = GlobalKey(); + return InfoListView(index, bean, widget.logic); + }, + onIndexChanged: (index) { + controller.state.index = index; + if (index == widget.logic.circle.lists.length - 1) { + widget.logic.loadMore(); + } + print(index.toString()); + }, + index: controller.state.index, + itemCount: widget.logic.circle.lists.length, + viewportFraction: 0.93, + // scale: 0.9, + loop: false, + // key: UniqueKey(), + // pagination: new SwiperPagination(),//如果不填则不显示指示点 + // control: new SwiperControl(),//如果不填则不显示左右按钮 + ); + } + + Widget showVipView() { + return Container( + margin: EdgeInsets.only(top: 10.sp), + color: const Color(0xB30B011B), + padding: EdgeInsets.symmetric(vertical: 14.sp, horizontal: 20.sp), + child: Column( + children: [ + Center( + child: Text( + "VIP特权", + style: TextStyle(color: Colors.white, fontSize: 16.sp), + ), + ), + Container( + padding: EdgeInsets.only(top: 18.sp), + child: Text( + "开通VIP后,才能查看更多附近的圈友,也可以根据您的喜好、属性、角色、取向等筛选出想要认识的人,还可以获得其他十几种会员特权,拥有更多不一样的体验", + style: TextStyle(color: Colors.white, fontSize: 12.sp), + ), + ), + GestureDetector( + onTap: () async { + widget.logic.showRechargeDialog(); + }, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 14.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17), + gradient: const LinearGradient( + colors: [ + Color(0xFF06F9FA), + Color(0xFFDC5BFD), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + ), + padding: EdgeInsets.symmetric( + vertical: 10.sp, + horizontal: 55.sp, + ), + child: const Text( + "前往开通VIP", + style: TextStyle( + color: Colors.white, + fontSize: 12, + ), + ), + ), + )) + ], + )); + } + + 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, + 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], + ), + ), + 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), + ), + ), + Expanded( + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Container( + 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: Text( + item.onlineFlag.toString(), + 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( + 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 ListAlbumItem(String item, int index) { + return Container( + margin: EdgeInsets.symmetric(horizontal: 2.sp), + child: CachedNetworkImage( + width: 88.sp, + height: 88.sp, + fit: BoxFit.cover, + imageUrl: item + "?imageView2/1/w/176/h/176/q/75", + ), + ); + } + + Widget _buildInfoRow(VicinityItemBean item) { + String ageMsg = + getAgeCOntent(item!.gender, item!.age, item!.role, item!.orientation); + return Row( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17), + gradient: const 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: const TextStyle( + color: Colors.black, + fontSize: 10, + ), + ), + ), + const SizedBox(width: 6), + if (item.vip > 0) + Image( + image: AssetImage(getBaseImage(item.vip == 1 ? "vip" : 'year_vip')), + width: 44.sp, + height: 18.sp, + ), + ], + ); + } + + 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, + ), + ), + ), + ), + ), + ), + ), + ], + ), + ), + ); + } + + void _onRefresh() async { + widget.logic.vicinityPage = 1; + widget.logic.offset = 0; + widget.logic.getNearByList(); + // logic.refreshController.refreshCompleted(); + } + + void _onLoading() async { + if (widget.logic.myVip > 0) { + widget.logic.vicinityPage = widget.logic.vicinityPage + 1; + // logic.offset = 0; + // + widget.logic.getNearByList(); + } else { + widget.logic.refreshController.loadComplete(); + } + } + + @override + // TODO: implement wantKeepAlive + bool get wantKeepAlive => true; +} diff --git a/circle_app/lib/app/login/complete_material/logic.dart b/circle_app/lib/app/login/complete_material/logic.dart index bfe21e6..a900f18 100644 --- a/circle_app/lib/app/login/complete_material/logic.dart +++ b/circle_app/lib/app/login/complete_material/logic.dart @@ -32,6 +32,8 @@ class Complete_materialLogic extends GetxController { var quToken = ''; var headUrl = ''; + int unLockWxNum = 0; + late ConfigBean configBean; List numbers = []; @@ -51,7 +53,10 @@ class Complete_materialLogic extends GetxController { var bean = BaseResponse.fromJson( data, (data) => ResponseBean.fromJson(data)); if(bean.isSuccess()){ + unLockWxNum = bean.data.unLockWxNum; + userInfoBean = bean.data.user; + state.wxEditingController.text = userInfoBean!.wx_num ; state.nickName = userInfoBean!.nickname; state.sex = getGenderContent(userInfoBean!.gender); state.genderId = userInfoBean!.gender.toString(); @@ -225,6 +230,26 @@ class Complete_materialLogic extends GetxController { showOKToast('请上传头像'); return; } + + if (state.wxEditingController.text.isNotEmpty) { + bool isPass = false; + if (state.wxEditingController.text.length == 11) { + RegExp exp = RegExp( + r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$'); + isPass = exp.hasMatch(state.wxEditingController.text); + } + + if (state.wxEditingController.text.isNotEmpty && !isPass) { + RegExp wxReg = RegExp(r'^[a-zA-Z][-_a-zA-Z0-9]{5,19}$'); + if (!wxReg.hasMatch(state.wxEditingController.text)) { + showOKToast('请输入正确的微信号'); + return; + } + } + + var result = await DioManager().post(url: Api.updateWxNum,params: {'type':2,'wxNum':state.wxEditingController.text}); + print(result); + } //TODO 强制获取经纬度 // LatLng location = await getLocation(); List interestsList = []; diff --git a/circle_app/lib/app/login/complete_material/state.dart b/circle_app/lib/app/login/complete_material/state.dart index 32a000d..6179c9d 100644 --- a/circle_app/lib/app/login/complete_material/state.dart +++ b/circle_app/lib/app/login/complete_material/state.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; class Complete_materialState { TextEditingController textEditingController = TextEditingController(); + TextEditingController wxEditingController = TextEditingController(); TextEditingController descEditingController = TextEditingController(); String nickName = ''; String sex = ''; diff --git a/circle_app/lib/app/login/complete_material/view.dart b/circle_app/lib/app/login/complete_material/view.dart index fb439cf..ece378f 100644 --- a/circle_app/lib/app/login/complete_material/view.dart +++ b/circle_app/lib/app/login/complete_material/view.dart @@ -111,6 +111,33 @@ class Complete_materialPage extends StatelessWidget { ), () {}, img: 'edit'), + if (Get.arguments == 'user') + funcWidget( + '微信', + TextField( + controller: controller.state.wxEditingController, + maxLength: 19, + inputFormatters: [ + FilteringTextInputFormatter.deny( + RegExp("[^-_a-zA-Z0-9]")), + ], + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w500, + fontSize: 14.sp), + decoration: InputDecoration( + counterText:'', + hintText: '请输入微信号', + hintStyle: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w500, + fontSize: 14.sp), + border: InputBorder.none, + ), + ), + () {}, + img: 'edit'), + funcWidget( '属性', Text( diff --git a/circle_app/lib/app/login/login/logic.dart b/circle_app/lib/app/login/login/logic.dart index fc15aec..d6a3de1 100644 --- a/circle_app/lib/app/login/login/logic.dart +++ b/circle_app/lib/app/login/login/logic.dart @@ -68,8 +68,10 @@ class LoginLogic extends GetxController { showOKToast('发送成功!'); if (kDebugMode) { //print("验证码:${bean.data!.code}"); - // codeEditingController.text = bean.data!.code.toString(); - // update(); + if (bean.data!.code != null) { + codeEditingController.text = bean.data!.code.toString(); + update(); + } } t = Timer.periodic(const Duration(milliseconds: 1000), (timer) { diff --git a/circle_app/lib/app/userinfo/logic.dart b/circle_app/lib/app/userinfo/logic.dart index 479bccb..c8cd717 100644 --- a/circle_app/lib/app/userinfo/logic.dart +++ b/circle_app/lib/app/userinfo/logic.dart @@ -42,6 +42,8 @@ class UserinfoLogic extends GetxController { bool isBlack = false; bool isBlackBeen = false; bool isDestroy = false; + + int unLockWxNum = 0; final startTime = DateTime.now(); SharedPreferences? sharedPreferences; @override @@ -111,7 +113,7 @@ class UserinfoLogic extends GetxController { if (bean.isSuccess()) { isMe = userId.isEmpty; isLike = bean.data.isFollow; - + unLockWxNum = bean.data.unLockWxNum; isLikeFoMsg = "${bean.data.likeMeCount}位圈友感兴趣,其中${bean.data.imageUrgeCount}位已催您更新"; userInfoBean = bean.data.user; @@ -322,6 +324,7 @@ class UserBean { String nickname; String avatar; String birthday; + String wx_num; int age; String signature; int vip; @@ -340,6 +343,7 @@ class UserBean { required this.id, required this.nickname, required this.avatar, + required this.wx_num, required this.birthday, required this.age, required this.signature, @@ -359,6 +363,7 @@ class UserBean { factory UserBean.fromJson(Map json) { return UserBean( id: json['id'], + wx_num: json['wx_num'] ?? '', nickname: json['nickname'], avatar: json['avatar'], birthday: json['birthday'], @@ -404,6 +409,7 @@ class ResponseBean { UserBean user; int likeMeCount; int imageUrgeCount; + int unLockWxNum; bool isFollow; bool isBlock; bool isDestroy; @@ -413,6 +419,7 @@ class ResponseBean { {required this.user, required this.likeMeCount, required this.imageUrgeCount, + required this.unLockWxNum, required this.accountId, required this.isBlock, required this.isDestroy, @@ -421,6 +428,7 @@ class ResponseBean { factory ResponseBean.fromJson(Map json) { return ResponseBean( accountId: json['account_id'], + unLockWxNum : json['unLockWxNum'], user: UserBean.fromJson(json['user']), likeMeCount: json['like_me_count'], imageUrgeCount: json['image_urge_count'], diff --git a/circle_app/lib/app/userinfo/view.dart b/circle_app/lib/app/userinfo/view.dart index 78a2b2b..04c6f52 100644 --- a/circle_app/lib/app/userinfo/view.dart +++ b/circle_app/lib/app/userinfo/view.dart @@ -1,5 +1,8 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:circle_app/app/userinfo/widgets/home_call_out.dart'; +import 'package:circle_app/common/Widgets/base_tip_widget.dart'; +import 'package:circle_app/common/colors/app_color.dart'; +import 'package:circle_app/common/const.dart'; import 'package:circle_app/main.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -78,6 +81,60 @@ class MyTabbedScreenState extends State centerTitle: logic.userInfoBean != null ? "${logic.userInfoBean!.nickname}的主页" : "个人主页", + actionWdiget: logic.isMe ? GestureDetector( + onTap: () { + showAddWxPicker(logic.userInfoBean!.wx_num!.isNotEmpty ?? false); + }, + child:Stack( + alignment: Alignment.center, + children: [ + Container( + width: 90.sp, + height: 24.sp, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12.sp), + gradient: LinearGradient( + colors: [ Color(0xFF30FFD9),Color(0xFFDD3DF4)], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + ), + ), + Container( + width: 88.sp, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(11.sp), + color: Color(0xFF240F3B) + + ), + alignment: Alignment.center, + height: 22.sp, + child: Text( + '填写微信号', + style: TextStyle( + color: Colors.white, fontSize: 12.sp), + ), + ) + ], + ), + // Container( + // alignment: Alignment.center, + // // width: 90.sp, + // height: 24.sp, + // padding: + // EdgeInsets.only(left: 6.sp, right: 6.sp), + // decoration: BoxDecoration( + // color: AppColor.mainColor, + // borderRadius: + // BorderRadiusDirectional.circular( + // 11.sp)), + // child: Text( + // '填写微信号', + // style: TextStyle( + // color: Colors.white, fontSize: 13.sp), + // ), + // ), + ) : Container() ), body: Stack( children: [ @@ -327,7 +384,21 @@ class MyTabbedScreenState extends State ? Container() : _buildInterestsListView(interests), ), + + if (!logic.isMe) + logic.userInfoBean != null ? logic.userInfoBean!.wx_num!.isNotEmpty ? Container( + alignment: Alignment.centerLeft, + // width: 200.sp, + // color: Colors.red, + margin: EdgeInsets.only(left: 20.sp,bottom: 15.sp), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + wxStatusWidget(logic.unLockWxNum == 1,logic.userInfoBean!.wx_num, logic.userInfoBean!.id.toString(),logic.userInfoBean!.avatar!, (){}), + ], + )) : Container() : Container(), titleTab(controller), + Expanded( child: PageView( controller: _pageController, @@ -469,6 +540,7 @@ class MyTabbedScreenState extends State child: Visibility( // visible: logic.isShowAlbum, child: Container( + margin: EdgeInsets.only(left: 10.sp), decoration: BoxDecoration( borderRadius: BorderRadius.circular(17), gradient: const LinearGradient( diff --git a/circle_app/lib/common/Widgets/add_wx_tip.dart b/circle_app/lib/common/Widgets/add_wx_tip.dart new file mode 100644 index 0000000..eec81ff --- /dev/null +++ b/circle_app/lib/common/Widgets/add_wx_tip.dart @@ -0,0 +1,199 @@ +import 'package:circle_app/common/colors/app_color.dart'; +import 'package:circle_app/network/api.dart'; +import 'package:circle_app/network/dio_manager.dart'; +import 'package:circle_app/router/app_routers.dart'; +import 'package:circle_app/util/util.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:get/get.dart'; + +class AddWxTip extends StatefulWidget { + bool isHaveWx; + // TODO: add state variables, methods and constructor params + AddWxTip(this.isHaveWx); + + @override + State createState() => _AddWxTipState(); +} + +class _AddWxTipState extends State { + bool isAuth = false; + String desc = ''; + String tip = ''; + String title = ''; + @override + void initState() { + // TODO: implement initState + super.initState(); + loadData(); + } + + @override + Widget build(BuildContext context) { + // TODO: add widget build method + return Scaffold( + backgroundColor: Colors.transparent, + body: Center( + child: Container( + margin: EdgeInsets.only(left: 15.sp, right: 15.sp), + + height: Get.height * 0.65, + + child: Column( + children: [ + Expanded( + child: Container( + decoration: BoxDecoration( + color: Color(0x99000000), + image: DecorationImage( + image: AssetImage(getHomeImage("wx_tip_bg")), + + fit: BoxFit.fill, + ), + ), + child: Container( + color: Color(0x99000000).withOpacity(0.4), + padding: EdgeInsets.all(6.sp), + child: Column( + children: [ + Expanded( + child: Container( + + child: RawScrollbar( + radius: Radius.circular(20), + // isAlwaysShown: true, + thickness: 2, + thumbColor: Colors.white, + child: SingleChildScrollView( + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 10.sp,bottom: 5.sp), + + child: Image.asset(getHomeImage('wx_tip_title'),height: 18.sp,)), + Container( + padding: EdgeInsets.only(left: 15.sp, right: 15.sp), + child: Text( + desc, + style: TextStyle( + color: Colors.white, + fontSize: 14.sp, + fontWeight: FontWeight.w500, + height: 2.0, + ), + )), + Container( + padding: EdgeInsets.only(left: 15.sp, right: 15.sp), + child: Text( + tip, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w500, + fontSize: 14.sp, + height: 2.0, + ), + )) + ], + ), + ), + ), + )), + Container( + margin: EdgeInsets.only(top: 15.sp, right: 15.sp, left: 15.sp,bottom: 15.sp), + child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Expanded(child: Container()), + GestureDetector( + onTap: () async { + showOKToast('为了维护站内的社交环境,微信填写必须真实哦~'); + + var result = await DioManager() + .post(url: Api.updateWxNum, params: {'type': 1}); + if (result['code'] == 200) { + Future.delayed(Duration(seconds: 2),() {showOKToast('填写微信成功');}); + Get.back(result: '1'); + } + + }, + child: Container( + alignment: Alignment.center, + height: 30.sp, + width: 100.sp, + decoration: BoxDecoration( + color: Colors.blue.withOpacity(0.9), + borderRadius: BorderRadius.circular(4.sp)), + child: Text( + '手机号即微信', + style: + TextStyle(color: Colors.white, fontSize: 14.sp), + ), + ), + ), + Expanded(child: Container()), + GestureDetector( + onTap: () { + showOKToast('为了维护站内的社交环境,微信填写必须真实哦~'); + Get.back(); + Get.toNamed( + AppRoutes.Complete_materialPage, + arguments: "user", + ); + }, + child: Container( + height: 30.sp, + width: 100.sp, + + // padding: EdgeInsets.only(left: 6.sp, right: 6.sp), + alignment: Alignment.center, + decoration: BoxDecoration( + color: AppColor.mainColor, + borderRadius: BorderRadius.circular(4.sp)), + child: Text( + widget.isHaveWx ? ' 更新微信 ':' 填写微信 ', + style: + TextStyle(color: Colors.white, fontSize: 14.sp), + ), + ), + ), + Expanded(child: Container()), + ], + ), + ), + ], + ), + ), + ), + ), + + GestureDetector( + onTap: () { + Get.back(); + }, + child: Container( + margin: EdgeInsets.only(bottom: 5.sp,top: 10.sp), + alignment: Alignment.center, + child: Image.asset( + getHomeImage('wx_close'), + width: 24.sp, + )), + ) + ], + ), + ), + ), + ); + } + + void loadData() async { + var data1 = await DioManager.instance.get(url: Api.popWxNumStr); + + desc = data1['content'] ?? ''; + title = data1['title'] ?? ''; + tip = data1['tip'] ?? ''; + setState(() {}); + + + } +} diff --git a/circle_app/lib/common/Widgets/base_tip_widget.dart b/circle_app/lib/common/Widgets/base_tip_widget.dart index caf1949..8b2eeac 100644 --- a/circle_app/lib/common/Widgets/base_tip_widget.dart +++ b/circle_app/lib/common/Widgets/base_tip_widget.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:circle_app/common/Widgets/add_wx_tip.dart'; import 'package:circle_app/util/paymentUtil.dart'; import 'package:circle_app/util/util.dart'; import 'package:flutter/material.dart'; @@ -266,3 +267,9 @@ showJoinCiclePiker(String cicleId, String pirce, String oldPrice, int type, isScrollControlled: true, enableDrag: false); } + + + +Future showAddWxPicker(bool isHaveWx) { + return Get.bottomSheet(AddWxTip(isHaveWx),isScrollControlled: true,enableDrag: false); +} \ No newline at end of file diff --git a/circle_app/lib/common/Widgets/genderview.dart b/circle_app/lib/common/Widgets/genderview.dart new file mode 100644 index 0000000..7e06c86 --- /dev/null +++ b/circle_app/lib/common/Widgets/genderview.dart @@ -0,0 +1,186 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + + +Widget getGender(String name) { + if (name == "CD") { + return getCd(); + } else if (name == "MTF") { + return getMTF(); + } + else if(name == "Queer"){ + return getQueer(); + } + else if(name == "FTM"){ + return getFTM(); + } + else if(name == "直男"||name == "男"){ + return getZN(); + } + else if(name == "真女"||name == "女"){ + return getNV(); + }else{ + return getCd(); + } +} +Color getGenderColor(String name){ + if (name == "CD") { + return cd; + } else if (name == "MTF") { + return mtf; + } + else if(name == "Queer"){ + return queer; + } + else if(name == "FTM"){ + return ftm; + } + else if(name == "直男"||name == "男"){ + return nan; + } + else if(name == "真女"||name == "女"){ + return nv; + }else{ + return cd; + } +} + +Color cd = const Color(0xFFF7FAFA); +Color mtf = const Color(0xFFFAA5B8); +Color queer = const Color(0xFF876FE7); +Color ftm = const Color(0xFF42C6FF); +Color nan = const Color(0xFF3994FF); +Color nv = const Color(0xFFFC65ED); + +Widget getCd() { + return Container( + padding: EdgeInsets.only(left: 3.sp, right: 3.sp, top: 3.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(22), + color: const Color(0xFFF7FAFA), + + // border: Border.all( + // color: logic.wantKnowData[index].isSelect ? const Color(0xFFCE51FF) : const Color(0x1AFFFFFF), + // ), + ), + margin: EdgeInsets.only(left: 10.0.sp), + child: Text( + "CD", + style: TextStyle( + color: const Color(0xFF898F99), + fontSize: 12.0.sp, + ), + ), + ); +} + +Widget getMTF() { + return Container( + padding: EdgeInsets.only(left: 3.sp, right: 3.sp, top: 3.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(22), + color: const Color(0xFFFAA5B8), + + // border: Border.all( + // color: logic.wantKnowData[index].isSelect ? const Color(0xFFCE51FF) : const Color(0x1AFFFFFF), + // ), + ), + margin: EdgeInsets.only(left: 10.0.sp), + child: Text( + "MTF", + style: TextStyle( + color: const Color(0xFFF7FAFA), + fontSize: 12.0.sp, + ), + ), + ); +} + +Widget getQueer() { + return Container( + padding: EdgeInsets.only(left: 3.sp, right: 3.sp, top: 3.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(22), + color: const Color(0xFF876FE7), + + // border: Border.all( + // color: logic.wantKnowData[index].isSelect ? const Color(0xFFCE51FF) : const Color(0x1AFFFFFF), + // ), + ), + margin: EdgeInsets.only(left: 10.0.sp), + child: Text( + "Queer", + style: TextStyle( + color: const Color(0xFFF7FAFA), + fontSize: 12.0.sp, + ), + ), + ); +} + +Widget getFTM() { + return Container( + padding: EdgeInsets.only(left: 3.sp, right: 3.sp, top: 3.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(22), + color: const Color(0xFF42C6FF), + + // border: Border.all( + // color: logic.wantKnowData[index].isSelect ? const Color(0xFFCE51FF) : const Color(0x1AFFFFFF), + // ), + ), + margin: EdgeInsets.only(left: 10.0.sp), + child: Text( + "FTM", + style: TextStyle( + color: const Color(0xFFF7FAFA), + fontSize: 12.0.sp, + ), + ), + ); +} + +Widget getZN() { + return Container( + padding: EdgeInsets.only(left: 3.sp, right: 3.sp, top: 3.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(22), + color: const Color(0xFF3994FF), + + // border: Border.all( + // color: logic.wantKnowData[index].isSelect ? const Color(0xFFCE51FF) : const Color(0x1AFFFFFF), + // ), + ), + margin: EdgeInsets.only(left: 10.0.sp), + child: Text( + "直男", + style: TextStyle( + color: const Color(0xFFF7FAFA), + fontSize: 12.0.sp, + ), + ), + ); +} + +Widget getNV() { + return Container( + padding: EdgeInsets.only(left: 3.sp, right: 3.sp, top: 3.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(22), + color: const Color(0xFFFC65ED), + + // border: Border.all( + // color: logic.wantKnowData[index].isSelect ? const Color(0xFFCE51FF) : const Color(0x1AFFFFFF), + // ), + ), + margin: EdgeInsets.only(left: 10.0.sp), + child: Text( + "真女", + style: TextStyle( + color: const Color(0xFFF7FAFA), + fontSize: 12.0.sp, + ), + ), + ); +} \ No newline at end of file diff --git a/circle_app/lib/common/Widgets/unlock_wx_tip.dart b/circle_app/lib/common/Widgets/unlock_wx_tip.dart new file mode 100644 index 0000000..aa8bd91 --- /dev/null +++ b/circle_app/lib/common/Widgets/unlock_wx_tip.dart @@ -0,0 +1,442 @@ +import 'dart:io'; + +import 'package:circle_app/common/Widgets/open_vip_tip/logic.dart'; +import 'package:circle_app/network/api.dart'; +import 'package:circle_app/network/dio_manager.dart'; +import 'package:circle_app/util/PaymentUtils.dart'; +import 'package:circle_app/util/paymentUtil.dart'; +import 'package:circle_app/util/util.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:get/get.dart'; + +import 'base_tip_widget.dart'; + +class UnlockWxTip extends StatefulWidget { + String userId; + String avatarUrl; + UnlockWxTip(this.userId,this.avatarUrl); + @override + _UnlockWxTipState createState() => _UnlockWxTipState(); + +} + +class _UnlockWxTipState extends State { + // TODO: add state variables and methods + List prices = []; + int selectedIndex = 0; + + bool isZfbPrice = false; + + @override + void initState() { + // TODO: implement initState + super.initState(); + loadData(); + } + + @override + Widget build(BuildContext context) { + // TODO: add widget build method + return Scaffold( + backgroundColor: Colors.transparent, + body: Stack( + alignment: Alignment.center, + children:[ + Container(width: Get.width,height: Get.height,), + Stack( + children: [ + Container( + margin: EdgeInsets.only(left: 20.sp,right: 20.sp), + padding: EdgeInsets.all(15.sp), + height: !Platform.isIOS ? 440.sp : 410.sp, + decoration: BoxDecoration( + color: const Color(0xFF393949), + borderRadius: BorderRadius.circular(10.sp) + ), + child: Column( + children: [ + Container( + margin: EdgeInsets.only(bottom: 10.sp), + alignment: Alignment.center, + child: ClipOval(child: Image.network(widget.avatarUrl,width: 60.sp,height: 60.sp,fit: BoxFit.cover,)), + ), + + Text( + '解锁TA的微信之外,还可以解锁更多微信哦~', + style: TextStyle( + color: const Color(0xFFF7FAFA), fontSize: 13.0.sp), + ), + SizedBox(height: 10.0.sp), + + Expanded(child: Container( + // color: Colors.red, + child: ListView.builder( + // shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: prices.length, + itemBuilder: (context, index) { + return itemView( + context,prices[index], index); + }, + ), + ),), + Platform.isIOS + ? Container( + ) + : Container( + padding: EdgeInsets.only(bottom: 12.0.sp,top: 12.sp), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + onTap: () { + setState(() { + isZfbPrice = true; + }); + }, + child: Row( + children: [ + Image.asset( + isZfbPrice + ? getMineImage("icon_pay_select") + : getMineImage("icon_pay_is_no_select"), + width: 20.0.sp, + height: 20.0.sp, + ), + SizedBox(width: 8.0.sp), + Image.asset( + getMineImage('icon_cooperate_ali'), + width: 20.0.sp, + height: 20.0.sp, + ), + SizedBox(width: 4.0.sp), + Text( + '支付宝支付', + style: TextStyle( + color: const Color(0xFFF7FAFA), + fontSize: 14.0.sp, + ), + ), + SizedBox(width: 4.0.sp), + Image.asset( + getMineImage('icon_recommend_pay_way'), + width: 32.0.sp, + height: 16.0.sp, + ), + ], + ), + ), + SizedBox(width: 24.0.sp), + GestureDetector( + onTap: () { + setState(() { + isZfbPrice = false; + }); + }, + child: Row( + children: [ + Image.asset( + !isZfbPrice + ? getMineImage("icon_pay_select") + : getMineImage("icon_pay_is_no_select"), + width: 20.0.sp, + height: 20.0.sp, + ), + SizedBox(width: 8.0.sp), + Image.asset( + getMineImage('icon_cooperate_wx'), + width: 20.0.sp, + height: 20.0.sp, + ), + SizedBox(width: 4.0.sp), + Text( + '微信支付', + style: TextStyle( + color: const Color(0xFFF7FAFA), + fontSize: 14.0.sp, + ), + ), + ], + ), + ), + ], + ), + ), + GestureDetector( + onTap: () { + SmartDialog.showLoading(); + String itemId = prices[selectedIndex].itemId!; + if (Platform.isIOS ) { + IOSPayment.instance.iosPay(itemId,itemId,3,userId:widget.userId); + } else { + unlockingPayment(prices[selectedIndex].id.toString(), (){ + Get.back(); + unLockWxSuccessResult(widget.userId); + }); + } + }, + child: Container( + height: 40.sp, + width: Get.width, + decoration: BoxDecoration( + + gradient: const LinearGradient( + colors: [ + Color(0xFF06F9FA), + Color(0xFFDC5BFD), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + borderRadius: BorderRadius.circular(21.0), + ), + child: Center( + child: Text( + '立即解锁', + style: TextStyle( + color: const Color(0xFFF7FAFA), + fontSize: 14.0.sp), + ), + ), + ), + ), + + ], + ), + ), + Positioned( + top: 8.sp, + right: 20.sp, + child: IconButton( + icon: const Icon(Icons.close, color: Colors.white), + onPressed: () => Get.back(result: 1), + ), + ), + ], + ), + ] , + + ), + ); + } + + Widget itemView(BuildContext context,Prices price, int index) { + // int present_bean = item.note['present_bean']; + + String iconIv = ''; + switch (index) { + case 0: + iconIv = getMineImage("icon_recharge_first"); + break; + case 1: + iconIv = getMineImage("icon_recharge_second"); + break; + case 2: + iconIv = getMineImage("icon_recharge_third"); + break; + case 3: + iconIv = getMineImage("icon_recharge_fourth"); + break; + } + + return GestureDetector( + onTap: () { + selectedIndex = index; + setState(() { + + }); + }, + child: Container( + height: 49.sp, + margin: const EdgeInsets.only(bottom: 10), + decoration: BoxDecoration( + color: index == selectedIndex + ? const Color(0xFF464556) + : const Color(0xFF464556), + borderRadius: BorderRadius.circular(6), + border: index == selectedIndex + ? Border.all(color: const Color(0xFF21BEAB), width: 1.sp) + : null, + ), + child: Container( + margin: EdgeInsets.only(left: 6.sp, right: 6.sp), + child: Row( + children: [ + Image.asset( + iconIv, // Replace this with the actual image path + width: 31.sp, + height: 29.sp, + ), + SizedBox(width: 8.sp), + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + price.desc!, + + style: TextStyle(color: Colors.white, fontSize: 14.sp), + ), + + Text( + + "同时对方可获得${price.bonus}跨豆", + style: TextStyle( + color: const Color(0xFFEFD84E), fontSize: 10.0.sp), + ), + ],), + Expanded(child: Container()), + // To push the next widget to the right edge + Text( + '${price.curPrice}元', + style: TextStyle(color: Colors.white, fontSize: 14.sp), + ), + ], + ), + ), + )); + } + + + unlockingPayment(String cicleId, Function resultCallback) async { + SmartDialog.showLoading(); + if (isZfbPrice) { + var data = await DioManager.instance.post( + url: Api.postAliPayOrder, params: {"product_id": cicleId, "type": 3,'target_id':widget.userId}); + var bean = BaseResponse.fromJson( + data, (data) => PayUrlBean.fromJson(data)); + if (bean.isSuccess()) { + openAliPay(bean.data.payUrl, (isSuccess, errorMsg) { + if (isSuccess) { + resultCallback(true); + } + }); + // showToast(data.toString()); + } else { + showOKToast(bean.msg); + } + } else { + var data = await DioManager.instance + .post(url: Api.postWxOrder, params: {"product_id": cicleId, "type": 3,'target_id':widget.userId}); + var bean = BaseResponse.fromJson( + data, (data) => PaymentData.fromJson(data)); + if (bean.isSuccess()) { + openWxPay(bean.data, (bool isSuccess, String? errorMessage) { + if (isSuccess) { + resultCallback(true); + } else { + // 处理支付失败,errorMessage 可能为 null + } + }); + } else { + showOKToast(bean.msg); + } + + } + SmartDialog.dismiss(); + } + + + void loadData() async { + var result = await DioManager().get(url: Api.queryUnlockPrice); + if (result['code'] == 200) { + var data = Autogenerated.fromJson(result); + if (data.prices != null) { + prices = data.prices!; + setState(() { + + }); + } + } + } +} + + +class Autogenerated { + int? code; + String? msg; + List? prices; + + Autogenerated({this.code, this.msg, this.prices}); + + Autogenerated.fromJson(Map json) { + code = json['code']; + msg = json['msg']; + if (json['data'] != null) { + prices = []; + json['data'].forEach((v) { + prices!.add(new Prices.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['code'] = this.code; + data['msg'] = this.msg; + if (this.prices != null) { + data['prices'] = this.prices!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class Prices { + int? bonus; + double? curPrice; + String? desc; + int? expireTime; + int? expireType; + int? id; + String? itemId; + int? oldPrice; + int? show; + int? timesNum; + int? timesNumType; + + Prices( + {this.bonus, + this.curPrice, + this.desc, + this.expireTime, + this.expireType, + this.id, + this.itemId, + this.oldPrice, + this.show, + this.timesNum, + this.timesNumType}); + + Prices.fromJson(Map json) { + bonus = json['bonus']; + curPrice = double.parse(json['curPrice'].toString()); + desc = json['desc']; + expireTime = json['expireTime']; + expireType = json['expireType']; + id = json['id']; + itemId = json['itemId']; + oldPrice = json['oldPrice']; + show = json['show']; + timesNum = json['timesNum']; + timesNumType = json['timesNumType']; + } + + Map toJson() { + final Map data = new Map(); + data['bonus'] = this.bonus; + data['curPrice'] = this.curPrice; + data['desc'] = this.desc; + data['expireTime'] = this.expireTime; + data['expireType'] = this.expireType; + data['id'] = this.id; + data['itemId'] = this.itemId; + data['oldPrice'] = this.oldPrice; + data['show'] = this.show; + data['timesNum'] = this.timesNum; + data['timesNumType'] = this.timesNumType; + return data; + } +} + diff --git a/circle_app/lib/common/colors/app_color.dart b/circle_app/lib/common/colors/app_color.dart new file mode 100644 index 0000000..2df2bf4 --- /dev/null +++ b/circle_app/lib/common/colors/app_color.dart @@ -0,0 +1,16 @@ +import 'dart:ui'; + +import 'package:flutter/material.dart'; + +class AppColor { + static Color mainColor = Color(0xFFCE51FF); + + static Gradient mainLinearGradient = const LinearGradient( + colors: [ + Color(0xFF06F9FA), + Color(0xFFDC5BFD), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ); +} diff --git a/circle_app/lib/common/const.dart b/circle_app/lib/common/const.dart new file mode 100644 index 0000000..db4224a --- /dev/null +++ b/circle_app/lib/common/const.dart @@ -0,0 +1,91 @@ +import 'package:circle_app/common/Widgets/unlock_wx_tip.dart'; +import 'package:circle_app/network/api.dart'; +import 'package:circle_app/network/dio_manager.dart'; +import 'package:circle_app/util/util.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:oktoast/oktoast.dart'; + +const bgAssetImage = DecorationImage( + image: AssetImage('assets/images/base/bg.png'), + fit: BoxFit.cover, +); + +const bgBoxDecoration = BoxDecoration(image: bgAssetImage); + +wxStatusWidget(bool isUnclock, String wx, String userId, String avatarUrl, + Function callBack) { + double textWidth = boundingTextSize(Get.context!, wx, TextStyle(color: Colors.white, fontSize: 16.sp)).width; + return GestureDetector( + onTap: () async { + if (!isUnclock) { + var result = await DioManager() + .post(url: Api.UnlockWx, params: {'targetUserId': userId}); + if (result['code'] == 200) { + callBack(); + } else { + Get.bottomSheet(UnlockWxTip(userId, avatarUrl), + isScrollControlled: true, enableDrag: false) + .then((value) { + if (value != null) { + callBack(); + } + }); + } + } else { + Clipboard.setData(ClipboardData(text: wx)); + showToast('微信号复制成功'); + } + }, + child: Container( + height: 42.sp, + width: (isUnclock ? 60.sp : 100.sp) + textWidth, + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: [ + Color(0xFF06F9FA), + Color(0xFFDC5BFD), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + borderRadius: BorderRadius.circular(4.sp)), + child: Container( + // width: 88.sp, + margin: EdgeInsets.all(1.sp), + padding: EdgeInsets.only(left: 10.sp, right: 10.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4.sp), + color: Color(0xFF240F3B)), + alignment: Alignment.center, + + child: Row( + children: [ + Image.asset( + getDisCoverImage('wx'), + width: 30.sp, + ), + SizedBox( + width: 4.sp, + ), + // Expanded( + Text( + wx, + style: TextStyle(color: Colors.white, fontSize: 16.sp), + ), + if (!isUnclock) + SizedBox( + width: 14.sp, + ), + if (!isUnclock) + Image.asset( + getDisCoverImage('unclock_icon'), + width: 30.sp, + ) + ], + ), + ), + )); +} diff --git a/circle_app/lib/common/values/values.dart b/circle_app/lib/common/values/values.dart index aca74c3..e229336 100644 --- a/circle_app/lib/common/values/values.dart +++ b/circle_app/lib/common/values/values.dart @@ -8,6 +8,6 @@ abstract class Values { static const String mine_images = 'assets/images/mine/'; static const String msg_images = 'assets/images/msg/'; static const String circle_images = 'assets/images/circle/'; - + static const String discover_images = 'assets/images/circle/'; } diff --git a/circle_app/lib/network/api.dart b/circle_app/lib/network/api.dart index c5cd958..bd99b30 100644 --- a/circle_app/lib/network/api.dart +++ b/circle_app/lib/network/api.dart @@ -1,10 +1,10 @@ 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/'; // 获取验证码 @@ -32,6 +32,10 @@ class Api { static const getVipPrice = 'mall-service/vips'; + //微信解锁配置信息 + static const queryUnlockPrice = '/mall-service/wxNum/unlock/queryUnlockPrice'; + + //支付宝支付 @@ -265,6 +269,24 @@ class Api { //填写邀请码 static const inviteFillIn = 'user-service/invite/fillin'; + //微信解锁 + static const UnlockWx = 'user-service/wxNum/unlock'; + //微信号填写文案 + static const popWxNumStr = 'user-service/content/popup/wxNum'; + + //微信号修改 + static const updateWxNum = 'user-service/updateWxNum'; + + + //发现数据 + static const findPage = 'user-service/findPage/userList'; + + + //不感兴趣 + static const uninterested = 'user-service/findPage/uninterested/'; + + //发现单个用户数据 + static const getFindPageUserByUserId = 'user-service/findPage/getUserByUserId'; } \ No newline at end of file diff --git a/circle_app/lib/router/app_pages.dart b/circle_app/lib/router/app_pages.dart index 14895eb..f23fe93 100644 --- a/circle_app/lib/router/app_pages.dart +++ b/circle_app/lib/router/app_pages.dart @@ -9,6 +9,7 @@ import 'package:circle_app/app/call_out/binding.dart'; import 'package:circle_app/app/call_out/view.dart'; import 'package:circle_app/app/chat/binding.dart'; import 'package:circle_app/app/chat/view.dart'; +import 'package:circle_app/app/circle/discover_page.dart'; import 'package:circle_app/app/circle/view.dart'; import 'package:circle_app/app/feedback/binding.dart'; import 'package:circle_app/app/feedback/view.dart'; @@ -121,12 +122,12 @@ class AppPages { ), GetPage( name: AppRoutes.UserInfoActivity, - page: () => UserinfoPage(), + page: () => UserinfoPage(), binding: UserinfoBinding(), ), GetPage( name: AppRoutes.Call_out, - page: () => Call_outPage() , + page: () => Call_outPage(), binding: Call_outBinding(), ), GetPage(name: AppRoutes.Login, page: () => LoginPage()), @@ -215,6 +216,6 @@ class AppPages { page: () => InvitePage(), binding: InviteBinding(), ), - + GetPage(name: AppRoutes.DisCover, page: () => DiscoverPage()) ]; } diff --git a/circle_app/lib/router/app_routers.dart b/circle_app/lib/router/app_routers.dart index 8b68f87..16495c0 100644 --- a/circle_app/lib/router/app_routers.dart +++ b/circle_app/lib/router/app_routers.dart @@ -36,6 +36,10 @@ abstract class AppRoutes { static const Invite = '/mine/invite'; + static const DisCover = '/DisCover'; + + + } \ No newline at end of file diff --git a/circle_app/lib/util/paymentUtil.dart b/circle_app/lib/util/paymentUtil.dart index ec12395..0b0fbab 100644 --- a/circle_app/lib/util/paymentUtil.dart +++ b/circle_app/lib/util/paymentUtil.dart @@ -37,11 +37,13 @@ class IOSPayment { // iOS订阅监听 StreamSubscription>? subscription; - //1圈子 2会员 + //1圈子 2会员 3解锁微信 int type = 0; //可以为解锁圈子ID、会员标识ID String typeId = ''; + String target_id = ''; + /// 判断是否可以使用支付 Future isAvailable() async => await _inAppPurchase.isAvailable(); @@ -77,13 +79,19 @@ class IOSPayment { if (purchaseDetails.status == PurchaseStatus.error) { showOKToast('支付发生错误'); } else if (purchaseDetails.status == PurchaseStatus.purchased) { - var result = await DioManager.getInstance() - .post(url: Api.applePayCallBack, params: { + Map params = { 'payload': purchaseDetails.verificationData.serverVerificationData, 'transaction_id': purchaseDetails.purchaseID, 'type': type, 'product_id': int.parse(typeId) - }); + }; + + if (type == 3) { + params['target_id'] = target_id; + } + + var result = await DioManager.getInstance() + .post(url: Api.applePayCallBack, params:params); SmartDialog.dismiss(); if (result['code'] == 200) { @@ -103,8 +111,11 @@ class IOSPayment { } logic.update(); } - } else { + } else if (type == 2) { showOKToast('开通会员成功'); + } else { + showOKToast('解锁微信号成功'); + unLockWxSuccessResult(target_id); } } await _inAppPurchase.completePurchase(purchaseDetails); @@ -153,7 +164,7 @@ class IOSPayment { } /// 启动支付 - void iosPay(String skuInfo, String typeID, int productType) async { + void iosPay(String skuInfo, String typeID, int productType,{String userId = ''}) async { if (!await isAvailable()) { SmartDialog.dismiss(); showOKToast('无法连接AppStore,请稍后再试'); @@ -174,6 +185,7 @@ class IOSPayment { return; } + target_id = userId; type = productType; typeId = typeID; diff --git a/circle_app/lib/util/util.dart b/circle_app/lib/util/util.dart index 0a271a6..126b8ad 100644 --- a/circle_app/lib/util/util.dart +++ b/circle_app/lib/util/util.dart @@ -2,9 +2,13 @@ import 'dart:convert'; import 'dart:io'; import 'dart:ui'; +import 'package:circle_app/app/circle/widgets/discover.dart'; +import 'package:circle_app/app/userinfo/logic.dart'; import 'package:circle_app/common/values/values.dart'; import 'package:circle_app/main.dart'; +import 'package:circle_app/network/api.dart'; import 'package:circle_app/router/app_routers.dart'; +import 'package:circle_app/util/eventBus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -29,6 +33,10 @@ String getHomeImage(String image) { return '${Values.home_images}${image}.png'; } +String getDisCoverImage(String image) { + return '${Values.discover_images}${image}.png'; +} + String getLoginImage(String image) { return '${Values.login_images}${image}.png'; } @@ -57,6 +65,7 @@ String getCircleImage(String image) { showOKToast(String msg) { showToast( msg, + duration: Duration(seconds: msg.length > 10 ? 3 : 2), position: ToastPosition.center, backgroundColor: Colors.black.withOpacity(0.8), radius: 13.0, @@ -90,7 +99,7 @@ loaddingWidget(bool isMore) { ); } -noResultWidget() { +noResultWidget({String tip = '正在等待被填充~'}) { return Container( width: Get.width, child: Column( @@ -104,7 +113,7 @@ noResultWidget() { height: 8.sp, ), Text( - '正在等待被填充~', + tip, style: TextStyle(color: Color(0xffdbdbdb), fontSize: 15.sp), ), ], @@ -193,9 +202,9 @@ List orientationList = []; List roleList = []; String getGenderContent(int number) { - if(genderList.length!=0){ - return genderList[number-1]; - }else { + if (genderList.length != 0) { + return genderList[number - 1]; + } else { switch (number) { case 1: return "男"; @@ -216,9 +225,9 @@ String getGenderContent(int number) { } String getOrientationContent(int number) { - if(orientationList.length!=0){ - return orientationList[number-1]; - }else { + if (orientationList.length != 0) { + return orientationList[number - 1]; + } else { switch (number) { case 1: return "异性恋"; @@ -241,9 +250,9 @@ String getOrientationContent(int number) { } String getRoleContent(int number) { - if(roleList.length!=0){ - return roleList[number-1]; - }else { + if (roleList.length != 0) { + return roleList[number - 1]; + } else { switch (number) { case 1: return "Sado"; @@ -397,11 +406,12 @@ void navigateToCustomRoute(BannerItem bannerItem) { switch (bannerItem.scene) { case "scene_2": List numbers = []; - if(bannerItem.param!.isNotEmpty){ + if (bannerItem.param!.isNotEmpty) { String paramJson = bannerItem.param.toString(); paramJson = paramJson.replaceAll(r'\', ''); // 去除反斜杠转义 Map jsonData = json.decode(paramJson); - numbers.add(MyConfigData(jsonData['id'].toString(), jsonData['name'], false)); + numbers.add(MyConfigData( + jsonData['id'].toString(), jsonData['name'], false)); } Get.toNamed(AppRoutes.Call_out, arguments: {'numbers': numbers}); break; @@ -416,13 +426,38 @@ void navigateToCustomRoute(BannerItem bannerItem) { Get.toNamed(AppRoutes.Invite); break; case "scene_4": - if(bannerItem.param!.isEmpty){ + if (bannerItem.param!.isEmpty) { Get.toNamed(AppRoutes.UserInfoActivity); - }else{ - Get.toNamed(AppRoutes.UserInfoActivity, arguments: bannerItem.param.toString()); + } else { + Get.toNamed(AppRoutes.UserInfoActivity, + arguments: bannerItem.param.toString()); } break; } break; } } + +unLockWxSuccessResult(String userId) { + String currentRoute = Get.currentRoute; + if (currentRoute == AppRoutes.Home) { + EventBusManager.fire(DiscoverDataRefresh(userId)); + } else if (currentRoute == AppRoutes.UserInfoActivity) { + var logic = Get.find(); + logic.fetchUserInfo("${Api.getUserInfoTA + userId}/home"); + } +} + +Size boundingTextSize(BuildContext context, String text, TextStyle style, + {int maxLines = 2 ^ 31, double maxWidth = double.infinity}) { + if (text == null || text.isEmpty) { + return Size.zero; + } + final TextPainter textPainter = TextPainter( + textDirection: TextDirection.ltr, + locale: Localizations.localeOf(context), + text: TextSpan(text: text, style: style), + maxLines: maxLines) + ..layout(maxWidth: maxWidth); + return textPainter.size; +}