diff --git a/circle_app/assets/images/mine/im_toggle.png b/circle_app/assets/images/mine/im_toggle.png new file mode 100644 index 0000000..b8f8b61 Binary files /dev/null and b/circle_app/assets/images/mine/im_toggle.png differ diff --git a/circle_app/assets/images/mine/im_toggle_true.png b/circle_app/assets/images/mine/im_toggle_true.png new file mode 100644 index 0000000..e28afd3 Binary files /dev/null and b/circle_app/assets/images/mine/im_toggle_true.png differ diff --git a/circle_app/lib/app/call_out/logic.dart b/circle_app/lib/app/call_out/logic.dart index 1ab5643..d0dcf61 100644 --- a/circle_app/lib/app/call_out/logic.dart +++ b/circle_app/lib/app/call_out/logic.dart @@ -17,6 +17,7 @@ import '../../network/api.dart'; import '../../network/dio_manager.dart'; import '../../router/app_routers.dart'; import '../../util/SharedPreferencesHelper.dart'; +import '../../util/eventBus.dart'; import '../../util/qiniu.dart'; import '../circle/logic.dart'; import '../select_circle/logic.dart'; @@ -76,6 +77,14 @@ class Call_outLogic extends GetxController { var qiniuBean = BaseResponse.fromJson( quniuData, (quniuData) => QnTokenData.fromJson(quniuData)); quToken = qiniuBean.data!.token.toString(); + + + + + StreamSubscription subscription = EventBusManager.on().listen((event) { + vip = event.vip; + }); + } 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 5991868..4acac5f 100644 --- a/circle_app/lib/app/circle/widgets/info_list_view.dart +++ b/circle_app/lib/app/circle/widgets/info_list_view.dart @@ -266,7 +266,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie children: [ Row( children: [ - Container( + SizedBox( height: 30.sp, width: 30.0.sp + 15.sp * @@ -379,7 +379,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie '${convertToTenThousand(widget.bean.viewTotal)}人看过', textAlign: TextAlign.left, style: TextStyle( - color: Color(0xff03FEFB), + color: const Color(0xff03FEFB), fontSize: 12.sp, ), ), @@ -433,7 +433,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie backgroundColor: Colors.transparent, child: Container( height: 300.sp, - padding: EdgeInsets.all(1.0), + padding: const EdgeInsets.all(1.0), child: Stack( children: [ Container( @@ -469,7 +469,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie msg, textAlign: TextAlign.center, style: TextStyle( - color: Color(0xCCF7FAFA), fontSize: 16.sp), + color: const Color(0xCCF7FAFA), fontSize: 16.sp), ),), ), ) @@ -548,12 +548,13 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie Positioned( left: 0, top: 2.sp, - child: Image.asset(getCircleImage('vip_say')), height: 18.sp, + child: Image.asset(getCircleImage('vip_say')), ), Positioned( right: 2.sp, top: 2.sp, + height: 18.sp, child: Stack( alignment: Alignment.center, children: [ @@ -567,7 +568,6 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie ) ], ), - height: 18.sp, ), Container( height: widgetHeight, @@ -575,7 +575,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie padding: EdgeInsets.only(top: 12.sp, left: 12.sp, right: 12.sp), child: Column( children: [ - Container( + SizedBox( height: 72.sp, child: Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -589,7 +589,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie Get.toNamed(AppRoutes.UserInfoActivity); return; } - if (widget.bean.is_limit) { + if (widget.bean.is_limit&&widget.bean.amount>0) { showJoinCiclePiker(widget.bean.id.toString(),widget.bean.amount.toString(),widget.bean.oldAmount.toString(),1,(payResult){ widget.bean.is_limit = false; }); @@ -727,7 +727,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie // ), // ), errorWidget: (context, url, error) => - Icon(Icons.error), + const Icon(Icons.error), fit: BoxFit.cover, ), ), @@ -747,7 +747,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie child: Row( children: [ widgets.isNotEmpty - ? Container( + ? SizedBox( width: 24 + 12.sp * widgets.length - 12.sp, height: 24.sp, child: Stack(children: widgets), @@ -871,7 +871,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie padding: EdgeInsets.only(left: 12.sp, right: 12.sp), child: Column( children: [ - Container( + SizedBox( height: 72.sp, child: Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -1032,7 +1032,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie // ), // ), errorWidget: (context, url, error) => - Icon(Icons.error), + const Icon(Icons.error), fit: BoxFit.cover, ), ), @@ -1052,7 +1052,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie child: Row( children: [ widgets.isNotEmpty - ? Container( + ? SizedBox( width: 24 + 12.sp * widgets.length - 12.sp, height: 24.sp, child: Stack(children: widgets), @@ -1127,14 +1127,14 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie backgroundColor: Colors.transparent, child: Container( height: 160.sp, - padding: EdgeInsets.all(1.0), + padding: const EdgeInsets.all(1.0), child: Stack( children: [ Container( decoration: BoxDecoration( shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(10.0), - gradient: LinearGradient( + gradient: const LinearGradient( colors: [Color(0xFFDD3DF4), Color(0xFF30FFD9)], begin: Alignment.topCenter, end: Alignment.bottomCenter, @@ -1146,7 +1146,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie decoration: BoxDecoration( shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(10.0), - gradient: LinearGradient( + gradient: const LinearGradient( colors: [Color(0xFF4C3E5F), Color(0xFF324140)], begin: Alignment.topCenter, end: Alignment.bottomCenter, @@ -1172,7 +1172,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie "是否确认退出该圈子。", textAlign: TextAlign.center, style: TextStyle( - color: Color(0xCCF7FAFA), fontSize: 16.sp), + color: const Color(0xCCF7FAFA), fontSize: 16.sp), ), ), Row( @@ -1187,7 +1187,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie margin: EdgeInsets.only(top: 30.sp), decoration: BoxDecoration( borderRadius: BorderRadius.circular(17), - gradient: LinearGradient( + gradient: const LinearGradient( colors: [ Color(0x26FFFFFF), Color(0x26FFFFFF), @@ -1205,7 +1205,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie "否", style: TextStyle( color: Colors.white, - fontSize: 12, + fontSize: 12.sp, ), ), ), @@ -1222,7 +1222,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie margin: EdgeInsets.only(top: 24.sp), decoration: BoxDecoration( borderRadius: BorderRadius.circular(17), - gradient: LinearGradient( + gradient: const LinearGradient( colors: [ Color(0xFF06F9FA), Color(0xFFDC5BFD), @@ -1240,7 +1240,7 @@ class _InfoListViewState extends State with AutomaticKeepAliveClie "是", style: TextStyle( color: Colors.white, - fontSize: 12, + fontSize: 12.sp, ), ), ), diff --git a/circle_app/lib/app/minefragment/logic.dart b/circle_app/lib/app/minefragment/logic.dart index b679be2..69f259f 100644 --- a/circle_app/lib/app/minefragment/logic.dart +++ b/circle_app/lib/app/minefragment/logic.dart @@ -45,9 +45,14 @@ class MinefragmentLogic extends GetxController { like_me_count = bean.data.likeMeCount ?? 0; recent_visit_count = bean.data.recentVisitCount ?? 0; joinedCircle = "${"加入了${bean.data.joininterestcount}"}个圈子"; + + + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); - + if(bean.data.user.vip>0){ + vipMsg = "会员时长剩余${bean.data.vipExpireDays}天"; + } int likeMeCount = sharedPreferences.getInt(SharedPreferencesHelper.LIKEMECOUNT)??0; int recentVisitCount = sharedPreferences.getInt(SharedPreferencesHelper.RECENTVISITCOUNT)??0; diff --git a/circle_app/lib/app/privacy/binding.dart b/circle_app/lib/app/privacy/binding.dart new file mode 100644 index 0000000..71062ce --- /dev/null +++ b/circle_app/lib/app/privacy/binding.dart @@ -0,0 +1,10 @@ +import 'package:get/get.dart'; + +import 'logic.dart'; + +class PrivacyBinding extends Bindings { + @override + void dependencies() { + Get.lazyPut(() => PrivacyLogic()); + } +} diff --git a/circle_app/lib/app/privacy/logic.dart b/circle_app/lib/app/privacy/logic.dart new file mode 100644 index 0000000..fbee286 --- /dev/null +++ b/circle_app/lib/app/privacy/logic.dart @@ -0,0 +1,29 @@ +import 'dart:async'; + +import 'package:get/get.dart'; + +import '../../util/SharedPreferencesHelper.dart'; +import '../../util/eventBus.dart'; +import 'state.dart'; + +class PrivacyLogic extends GetxController { + int vip = 0; + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + SharedPreferencesHelper.getInstance().then((sharedPreferences) { + vip = sharedPreferences.getInt(SharedPreferencesHelper.VIP); + update(); + }); + + + + StreamSubscription subscription = EventBusManager.on().listen((event) { + vip = event.vip; + }); + } + bool isOpen = false; + final PrivacyState state = PrivacyState(); +} diff --git a/circle_app/lib/app/privacy/state.dart b/circle_app/lib/app/privacy/state.dart new file mode 100644 index 0000000..234fbe9 --- /dev/null +++ b/circle_app/lib/app/privacy/state.dart @@ -0,0 +1,5 @@ +class PrivacyState { + PrivacyState() { + ///Initialize variables + } +} diff --git a/circle_app/lib/app/privacy/view.dart b/circle_app/lib/app/privacy/view.dart new file mode 100644 index 0000000..7da4877 --- /dev/null +++ b/circle_app/lib/app/privacy/view.dart @@ -0,0 +1,117 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; + +import '../../common/Widgets/open_vip_tip/view.dart'; +import '../../components/my_app_bar.dart'; +import '../../util/util.dart'; +import 'logic.dart'; + +class PrivacyPage extends StatelessWidget { + PrivacyPage({Key? key}) : super(key: key); + + final logic = Get.find(); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + // _getFormat(context); + return GetBuilder(builder: (logic) { + return Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage(getBaseImage("home_back")), + fit: BoxFit.cover, + ), + ), + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: const MyAppBar(centerTitle: '隐私设置',), + body: SafeArea( + child: Container( + height: 60.sp, + margin: EdgeInsets.only(left: 16.sp, top: 16.sp, right: 16.sp), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + '神秘隐身', + style: TextStyle( + color: const Color(0xFFF7FAFA), + fontSize: 16.sp, + ), + ), + Padding( + padding: EdgeInsets.only(left: 4.sp), + child: Image.asset( + getBaseImage("vip"), + width: 24, + height: 24, + // Set visibility based on your logic + // For example, `visibility: isVisible ? Visibility.visible : Visibility.gone` + // replace `isVisible` with your actual variable or condition + // visibility: isVisible ? Visibility.visible : Visibility.gone, + // use `visible` instead of `Visibility.visible` if using flutter_svg package + ), + ), + ], + ), + Padding( + padding: EdgeInsets.only(top: 8.sp), + child: Text( + '开启后,其他人无法看见您', + style: TextStyle( + color: const Color(0xFFB7BECC), + fontSize: 12.sp, + ), + ), + ), + ], + ), + Expanded( + child: Align( + alignment: Alignment.centerRight, + child: GestureDetector( + onTap: (){ + if(logic.vip>0){ + logic.isOpen = !logic.isOpen; + logic.update(); + }else{ + showRechargeDialog(); + showToast("请先升级vip"); + } + + }, + child: Image.asset( + getMineImage(logic.isOpen? "im_toggle_true":"im_toggle"), + width: 24.sp, + height: 24.sp, + ), + ), + ), + ), + ], + ), + ), + ),), + ); + }); + } + + showRechargeDialog(){ + Get.bottomSheet( + Scaffold( + backgroundColor: Colors.transparent, + body: Open_vip_tipPage(false), + ), + isScrollControlled: true, + enableDrag: false); + + } +} + diff --git a/circle_app/lib/app/setup/view.dart b/circle_app/lib/app/setup/view.dart index e3236a5..68875e1 100644 --- a/circle_app/lib/app/setup/view.dart +++ b/circle_app/lib/app/setup/view.dart @@ -71,7 +71,14 @@ class SetupPage extends StatelessWidget { // SizedBox(height: 16.sp), // _buildItemRow('聊天设置', getHomeImage("icon_in")), // SizedBox(height: 16.sp), - + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Get.toNamed(AppRoutes.PrivacyActivity); + }, + child: _buildItemRow('隐私设置', getHomeImage("icon_in")), + ), + SizedBox(height: 16.sp), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { diff --git a/circle_app/lib/app/visitorlist/view.dart b/circle_app/lib/app/visitorlist/view.dart index c48d7fe..6670ebf 100644 --- a/circle_app/lib/app/visitorlist/view.dart +++ b/circle_app/lib/app/visitorlist/view.dart @@ -28,7 +28,7 @@ class VisitorlistPage extends StatelessWidget { ), child: Scaffold( backgroundColor: Colors.transparent, - appBar: MyAppBar( + appBar: const MyAppBar( centerTitle:"最近访客", ), body: SafeArea( @@ -58,7 +58,7 @@ class VisitorlistPage extends StatelessWidget { Get.toNamed(AppRoutes.UserInfoActivity, arguments: item.user.id.toString()); }, child: Container( - margin: EdgeInsets.only(bottom: 21), + margin: const EdgeInsets.only(bottom: 21), child: Row( children: [ Stack(children: [ @@ -134,7 +134,7 @@ class VisitorlistPage extends StatelessWidget { borderRadius: BorderRadius.circular(14), ), child: Center( - child: Text("私聊", style: TextStyle(fontSize: 14, color: Colors.white)), + child: Text("私聊", style: TextStyle(fontSize: 14.sp, color: Colors.white)), ) , @@ -154,7 +154,7 @@ class VisitorlistPage extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(17.sp), - gradient: LinearGradient( + gradient: const LinearGradient( colors: [ Color.fromRGBO(141, 255, 248, 1.0), Color.fromRGBO(181, 211, 255, 1.0), diff --git a/circle_app/lib/common/Widgets/base_tip_widget.dart b/circle_app/lib/common/Widgets/base_tip_widget.dart index aedfa1b..1edae26 100644 --- a/circle_app/lib/common/Widgets/base_tip_widget.dart +++ b/circle_app/lib/common/Widgets/base_tip_widget.dart @@ -68,7 +68,10 @@ joiinCircileTipWdiget(String cicleId, String pirce, String oldPrice, fontSize: 12.sp)), )), Platform.isIOS - ? Container() + ? Container( + height: 1, + width: 1, + ) : Positioned( bottom: 108.sp, child: Container( diff --git a/circle_app/lib/common/Widgets/open_vip_tip/logic.dart b/circle_app/lib/common/Widgets/open_vip_tip/logic.dart index 25ea9cd..189ffde 100644 --- a/circle_app/lib/common/Widgets/open_vip_tip/logic.dart +++ b/circle_app/lib/common/Widgets/open_vip_tip/logic.dart @@ -1,9 +1,12 @@ + import 'package:circle_app/util/util.dart'; import 'package:get/get.dart'; import '../../../network/api.dart'; import '../../../network/dio_manager.dart'; import '../../../util/PaymentUtils.dart'; +import '../../../util/SharedPreferencesHelper.dart'; +import '../../../util/eventBus.dart'; import 'state.dart'; class Open_vip_tipLogic extends GetxController { @@ -53,8 +56,11 @@ class Open_vip_tipLogic extends GetxController { openAliPay(bean.data.payUrl, (isSuccess, errorMsg) { if (isSuccess) { // 处理支付成功 + refreshVipStatus(); + } else { // 处理支付失败,errorMessage 可能为 null + refreshVipStatus(); } }); } else { @@ -70,6 +76,7 @@ class Open_vip_tipLogic extends GetxController { openWxPay(bean.data, (bool isSuccess, String? errorMessage) { if (isSuccess) { // 处理支付成功 + refreshVipStatus(); } else { // 处理支付失败,errorMessage 可能为 null } @@ -79,6 +86,22 @@ class Open_vip_tipLogic extends GetxController { } } } + + + refreshVipStatus()async{ + var data = await DioManager.instance.get(url: Api.getVipStatus); + var bean = BaseResponse.fromJson( + data, (data) => VipInfo.fromJson(data)); + if(bean.isSuccess()){ + SharedPreferencesHelper.getInstance().then((sharedPreferences) { + sharedPreferences.setInt(SharedPreferencesHelper.VIP,bean.data.vipLevel); + EventBusManager.fire(CommentVipEvent(bean.data.vipLevel)); + Get.back(); + }); + } + + + } } class PayUrlBean { @@ -155,3 +178,33 @@ class PriceBean { ); } } + +class VipInfo { + int? vipLevel; + String? expireDate; + int? expireDays; + + VipInfo({ + this.vipLevel, + this.expireDate, + this.expireDays, + }); + + factory VipInfo.fromJson(Map json) { + return VipInfo( + vipLevel: json['vip'] as int, + expireDate: json['vip_expire_date'] as String, + expireDays: json['vip_expire_days'] as int, + ); + } + + Map toJson() { + final Map data = {}; + data['vip'] = vipLevel; + data['vip_expire_date'] = expireDate; + data['vip_expire_days'] = expireDays; + return data; + } +} + + diff --git a/circle_app/lib/network/api.dart b/circle_app/lib/network/api.dart index 0ef9cb9..9adf271 100644 --- a/circle_app/lib/network/api.dart +++ b/circle_app/lib/network/api.dart @@ -42,6 +42,13 @@ class Api { + //vip状态 + static const getVipStatus = 'mall-service/my/vip'; + + + + + //刷新token static const refreshToken = 'user-service/login/token/refresh'; diff --git a/circle_app/lib/router/app_pages.dart b/circle_app/lib/router/app_pages.dart index 9b3fa63..c7c3ad2 100644 --- a/circle_app/lib/router/app_pages.dart +++ b/circle_app/lib/router/app_pages.dart @@ -35,6 +35,7 @@ import 'package:circle_app/app/offaccount/binding.dart'; import 'package:circle_app/app/offaccount/view.dart'; import 'package:circle_app/app/photoinfo/binding.dart'; import 'package:circle_app/app/photoinfo/view.dart'; +import 'package:circle_app/app/privacy/view.dart'; import 'package:circle_app/app/report/binding.dart'; import 'package:circle_app/app/report/view.dart'; import 'package:circle_app/app/select_circle/binding.dart'; @@ -58,6 +59,7 @@ import 'package:get/get_navigation/src/routes/get_route.dart'; import '../app/blacklist/view.dart'; import '../app/circle/binding.dart'; +import '../app/privacy/binding.dart'; import '../app/splash/view.dart'; import '../app/visitorlist/binding.dart'; import 'app_routers.dart'; @@ -200,5 +202,10 @@ class AppPages { page: () => Sys_notify_listPage(), binding: Sys_notify_listBinding(), ), + GetPage( + name: AppRoutes.PrivacyActivity, + page: () => PrivacyPage(), + binding: PrivacyBinding(), + ), ]; } diff --git a/circle_app/lib/router/app_routers.dart b/circle_app/lib/router/app_routers.dart index 80716ff..74e0e42 100644 --- a/circle_app/lib/router/app_routers.dart +++ b/circle_app/lib/router/app_routers.dart @@ -29,4 +29,9 @@ abstract class AppRoutes { static const MyFeedBackListActivity = '/mine/MyFeedBackListActivity'; static const Sys_notify_list = '/msg/Sys_notify_list'; + + static const PrivacyActivity = '/user/PrivacyActivity'; + + + } \ No newline at end of file diff --git a/circle_app/lib/util/PaymentUtils.dart b/circle_app/lib/util/PaymentUtils.dart index a4fb2a1..90e9a53 100644 --- a/circle_app/lib/util/PaymentUtils.dart +++ b/circle_app/lib/util/PaymentUtils.dart @@ -77,7 +77,7 @@ void _listenPay(AlipayResp resp) { showToast("重复请求"); break; case 6001: - showToast("取消支付"); + showToast("支付已取消"); break; case 6002: showToast("网络连接出错"); diff --git a/circle_app/lib/util/eventBus.dart b/circle_app/lib/util/eventBus.dart new file mode 100644 index 0000000..1d07bb2 --- /dev/null +++ b/circle_app/lib/util/eventBus.dart @@ -0,0 +1,34 @@ + + +import 'dart:async'; + +import 'package:event_bus/event_bus.dart'; + +class EventBusManager { + + static EventBus? _eventBus; + static EventBus get eventBus { + if (_eventBus == null) { + _eventBus = EventBus(); + } + return _eventBus!; + } + + static void fire(dynamic event) { + eventBus.fire(event); + } + + static Stream on() { + return eventBus.on(); + } + + static void cancelSubscription(StreamSubscription subscription) { + subscription.cancel(); + } +} + + +class CommentVipEvent{ + int vip = 0; + CommentVipEvent(this.vip); +} diff --git a/circle_app/pubspec.yaml b/circle_app/pubspec.yaml index af9771e..aee693b 100644 --- a/circle_app/pubspec.yaml +++ b/circle_app/pubspec.yaml @@ -90,6 +90,8 @@ dependencies: alipay_kit: 5.0.0 # 微信SDK插件 fluwx: ^3.8.1+1 + #event_bus: + event_bus: ^2.0.0