diff --git a/assets/applications/transfer.png b/assets/applications/transfer.png new file mode 100644 index 00000000..76b2f03d Binary files /dev/null and b/assets/applications/transfer.png differ diff --git a/lib/const/resource.dart b/lib/const/resource.dart index 4f561a1e..3702742d 100644 --- a/lib/const/resource.dart +++ b/lib/const/resource.dart @@ -91,6 +91,10 @@ class R { static const String ASSETS_APPLICATIONS_TOY_PNG = 'assets/applications/toy.png'; + /// ![preview](file:///Users/akufe/Documents/aku_community/assets/applications/transfer.png) + static const String ASSETS_APPLICATIONS_TRANSFER_PNG = + 'assets/applications/transfer.png'; + /// ![preview](file:///Users/akufe/Documents/aku_community/assets/applications/visitor_invite.png) static const String ASSETS_APPLICATIONS_VISITOR_INVITE_PNG = 'assets/applications/visitor_invite.png'; diff --git a/lib/constants/application_objects.dart b/lib/constants/application_objects.dart index 7322e2f2..01719ee6 100644 --- a/lib/constants/application_objects.dart +++ b/lib/constants/application_objects.dart @@ -56,8 +56,8 @@ class AO extends Equatable { ///所有应用 List appObjects = [ if (false) AO('一键开门', R.ASSETS_APPLICATIONS_OEPN_DOOR_PNG, () => Scaffold()), - if (false) - AO('开门码', R.ASSETS_APPLICATIONS_DOOR_CODE_PNG, () => OpeningCodePage()), + + AO('开门码', R.ASSETS_APPLICATIONS_DOOR_CODE_PNG, () => OpeningCodePage()), AO('访客邀请', R.ASSETS_APPLICATIONS_VISITOR_INVITE_PNG, () => VisitorAccessPage()), AO('报事报修', R.ASSETS_APPLICATIONS_FIX_PNG, () => FixedSubmitPage()), @@ -76,7 +76,7 @@ List appObjects = [ AO('借还管理', R.ASSETS_APPLICATIONS_BORROW_PNG, () => SelectBorrowReturnPage()), AO('一键报警', R.ASSETS_APPLICATIONS_POLICE_PNG, () => AlarmPage()), AO('设施预约', R.ASSETS_ICONS_TOOL_FACILITY_PNG, () => FacilityAppointmentPage()), - AO('快递包裹', R.ASSETS_IMAGES_PLACEHOLDER_WEBP, () => ExpressPackagePage()), + AO('快递包裹', R.ASSETS_APPLICATIONS_TRANSFER_PNG, () => ExpressPackagePage()), // AO( // '小区教育', // R.ASSETS_IMAGES_PLACEHOLDER_WEBP, @@ -135,7 +135,7 @@ List get recommendApp => _recommendApp.map((e) => AO.fromRaw(e)).toList(); ///智慧管家 original value List _smartManagerApp = [ - '一键开门', + if (false) '一键开门', '开门码', '访客邀请', '报事报修', diff --git a/lib/main_initialize.dart b/lib/main_initialize.dart index c2b91288..6f3144ed 100644 --- a/lib/main_initialize.dart +++ b/lib/main_initialize.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:aku_community/provider/app_provider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -8,12 +9,14 @@ import 'package:flutter/services.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:fluwx/fluwx.dart'; +import 'package:get/get.dart'; import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:power_logger/power_logger.dart'; import 'package:aku_community/constants/app_theme.dart'; import 'package:aku_community/constants/config.dart'; import 'package:aku_community/utils/message_parser.dart'; +import 'package:provider/provider.dart'; class MainInitialize { ///初始化firebase @@ -52,6 +55,9 @@ class MainInitialize { onReceiveNotification: (message) async { LoggerData.addData(message, tag: 'onReceiveNotification'); await MessageParser(message).shot(); + final appProvider = + Provider.of(Get.context!, listen: false); + appProvider.getMessageCenter(); }, onOpenNotification: jPushLogger('onOpenNotification'), onReceiveMessage: jPushLogger('onReceiveMessage'), diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index c626658a..3a8196de 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -69,8 +69,12 @@ class _HomePageState extends State actions: [ Badge( elevation: 0, - showBadge: appProvider.messageCenterModel.sysCount == 0, - position: BadgePosition.topEnd(), + showBadge: appProvider.messageCenterModel.commentCount != 0 || + appProvider.messageCenterModel.sysCount != 0, + position: BadgePosition.topEnd( + top: 8, + end: 8, + ), child: ColumnActionButton( onPressed: () { if (LoginUtil.isNotLogin) return; @@ -79,7 +83,7 @@ class _HomePageState extends State title: '消息', path: R.ASSETS_ICONS_ALARM_PNG, ), - ) + ), ], ), body: EasyRefresh( diff --git a/lib/pages/message_center_page/message_center_page.dart b/lib/pages/message_center_page/message_center_page.dart index ed24e456..a2fb8d49 100644 --- a/lib/pages/message_center_page/message_center_page.dart +++ b/lib/pages/message_center_page/message_center_page.dart @@ -21,16 +21,11 @@ class MessageCenterPage extends StatefulWidget { } class _MessageCenterPageState extends State { - EasyRefreshController? _refreshController; - @override - void initState() { - super.initState(); - _refreshController = EasyRefreshController(); - } + EasyRefreshController _refreshController = EasyRefreshController(); @override void dispose() { - _refreshController?.dispose(); + _refreshController.dispose(); super.dispose(); } @@ -80,7 +75,7 @@ class _MessageCenterPageState extends State { MaterialButton( onPressed: () async { await NetUtil().dio!.get(API.message.allRead); - _refreshController!.callRefresh(); + _refreshController.callRefresh(); setState(() {}); }, child: '全部已读'.text.size(28.sp).black.make(), @@ -90,6 +85,7 @@ class _MessageCenterPageState extends State { body: EasyRefresh( header: MaterialHeader(), firstRefresh: true, + controller: _refreshController, onRefresh: () async { appProvider.getMessageCenter(); }, @@ -100,7 +96,12 @@ class _MessageCenterPageState extends State { title: '系统通知', content: appProvider.messageCenterModel.sysTitle ?? '无系统通知消息', count: appProvider.messageCenterModel.sysCount ?? 0, - onTap: () => Get.to(() => SystemMessagePage()), + onTap: () async { + await NetUtil().dio!.get(API.message.allReadComment); + await Get.to(() => SystemMessagePage()); + _refreshController.callRefresh(); + setState(() {}); + }, ), _buildCard( path: R.ASSETS_ICONS_COMMENT_NOTICE_PNG, @@ -110,7 +111,8 @@ class _MessageCenterPageState extends State { count: appProvider.messageCenterModel.commentCount ?? 0, onTap: () async { await NetUtil().dio!.get(API.message.allReadComment); - Get.to(() => CommentMessagePage()); + await Get.to(() => CommentMessagePage()); + _refreshController.callRefresh(); setState(() {}); }, ), diff --git a/lib/pages/visitor_access_page/visitor_access_page.dart b/lib/pages/visitor_access_page/visitor_access_page.dart index 33e81a2e..3e3ee0cd 100644 --- a/lib/pages/visitor_access_page/visitor_access_page.dart +++ b/lib/pages/visitor_access_page/visitor_access_page.dart @@ -1,3 +1,4 @@ +import 'package:aku_community/constants/api.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -255,8 +256,7 @@ class _VisitorAccessPageState extends State { tel: tel, ); if (result != null) - Share.share( - 'http://test.akuhotel.com:8804/static/dist/index.html#/visitor?$result'); + Share.share('${API.host}/static/dist/index.html#/visitor?$result'); }, minWidth: double.infinity, height: 96.w, diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart index 3edaeaf1..224ba09f 100644 --- a/lib/provider/app_provider.dart +++ b/lib/provider/app_provider.dart @@ -139,12 +139,15 @@ class AppProvider extends ChangeNotifier { } } - Map? _location; - Map? get location => _location; + Map? _location; + Map? get location => _location; late AMapFlutterLocation _aMapFlutterLocation; startLocation() { - if (kIsWeb || Platform.isMacOS) return; + if (kIsWeb || Platform.isMacOS) { + getWeather(); + return; + } _aMapFlutterLocation = AMapFlutterLocation(); _aMapFlutterLocation.onLocationChanged().listen((event) { _location = event; @@ -164,11 +167,19 @@ class AppProvider extends ChangeNotifier { _aMapFlutterLocation.destroy(); } - // Location _location; - // Location get location => _location; getWeather() async { + late num longitude; + late num latitude; + if (kIsWeb || Platform.isMacOS) { + longitude = 116.46; + latitude = 39.92; + } else { + longitude = _location!['longitude']; + latitude = _location!['latitude']; + } + Response response = await Dio().get( - 'https://api.caiyunapp.com/v2.5/${AppConfig.caiYunAPI}/${_location!['longitude']},${_location!['latitude']}/realtime.json', + 'https://api.caiyunapp.com/v2.5/${AppConfig.caiYunAPI}/$longitude,$latitude/realtime.json', ); LoggerData.addData(response); _weatherModel = RealTimeWeatherModel.fromJson(response.data); diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index bfdaacb1..6d8fb6e4 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flustars/flustars.dart'; import 'package:get/get.dart'; +import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:provider/provider.dart'; import 'package:aku_community/constants/api.dart'; @@ -31,6 +32,7 @@ class UserProvider extends ChangeNotifier { } logout() { + JPush().deleteAlias(); final appProvider = Provider.of(Get.context!, listen: false); appProvider.setCurrentHouse(null); _isLogin = false; @@ -46,6 +48,9 @@ class UserProvider extends ChangeNotifier { Future updateProfile() async { _userInfoModel = await SignFunc.getUserInfo(); + if (_userInfoModel != null) { + await JPush().setAlias(_userInfoModel!.id.toString()); + } notifyListeners(); } diff --git a/lib/ui/community/community_views/community_page.dart b/lib/ui/community/community_views/community_page.dart index 54e20ebd..ef1dcb63 100644 --- a/lib/ui/community/community_views/community_page.dart +++ b/lib/ui/community/community_views/community_page.dart @@ -1,3 +1,5 @@ +import 'package:aku_community/provider/app_provider.dart'; +import 'package:badges/badges.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -53,16 +55,26 @@ class _CommunityPageState extends State Widget build(BuildContext context) { super.build(context); final userProvider = Provider.of(context); + final appProvider = Provider.of(context); return BeeScaffold( title: '社区', actions: [ - ColumnActionButton( - onPressed: () { - if (LoginUtil.isNotLogin) return; - Get.to(() => MessageCenterPage()); - }, - title: '消息', - path: R.ASSETS_ICONS_ALARM_PNG, + Badge( + elevation: 0, + showBadge: appProvider.messageCenterModel.commentCount != 0 || + appProvider.messageCenterModel.sysCount != 0, + position: BadgePosition.topEnd( + top: 8, + end: 8, + ), + child: ColumnActionButton( + onPressed: () { + if (LoginUtil.isNotLogin) return; + Get.to(() => MessageCenterPage()); + }, + title: '消息', + path: R.ASSETS_ICONS_ALARM_PNG, + ), ), ], fab: FloatingActionButton( diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index 1761b619..6d260a29 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -1,7 +1,8 @@ -import 'package:aku_community/base/base_style.dart'; +// import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/models/market/goods_item.dart'; -import 'package:aku_community/ui/market/goods/goods_detail_page.dart'; +import 'package:aku_community/ui/market/goods/goods_card.dart'; +// import 'package:aku_community/ui/market/goods/goods_detail_page.dart'; import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; import 'package:flutter/cupertino.dart'; @@ -18,7 +19,8 @@ import 'package:aku_community/ui/market/category/category_page.dart'; import 'package:aku_community/ui/market/search/search_goods_page.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; -import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart'; +import 'package:waterfall_flow/waterfall_flow.dart'; +// import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart'; class MarketPage extends StatefulWidget { MarketPage({Key? key}) : super(key: key); @@ -28,8 +30,7 @@ class MarketPage extends StatefulWidget { } class _MarketPageState extends State - with AutomaticKeepAliveClientMixin, TickerProviderStateMixin { - late TabController _tabController; + with AutomaticKeepAliveClientMixin { List _marketModels = []; List _hotItems = []; @@ -45,7 +46,6 @@ class _MarketPageState extends State @override void initState() { super.initState(); - _tabController = TabController(length: 2, vsync: this); updateMarketInfo().then((_) { setState(() {}); }); @@ -111,8 +111,11 @@ class _MarketPageState extends State //AppBar top Widget height //bottom height: 48 // flexibleSpace的高为 (设备宽 - 边距)/4*2 + 外边距 + bottom高 + top热搜栏 - expandedHeight: - (mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2 + 48 + 68.w, + // * 热搜栏 + //expandedHeight: + //(mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2 + 48 + 68.w, + // + expandedHeight: (mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2, backgroundColor: Colors.transparent, elevation: 0, flexibleSpace: FlexibleSpaceBar( @@ -122,55 +125,55 @@ class _MarketPageState extends State top: 16.w, left: 32.w, right: 32.w, - bottom: 16.w + 48, //底部边距需要加上bottom高 + bottom: 16.w, //底部边距需要加上bottom高 ), child: Column( children: [ - SizedBox( - height: 58.w, - child: Row( - children: [ - Text( - '热搜:', - style: TextStyle( - fontSize: 20.sp, - ), - ), - 20.wb, - ListView.separated( - scrollDirection: Axis.horizontal, - separatorBuilder: (_, __) => 20.wb, - itemBuilder: (context, index) { - final item = _hotItems[index]; - return MaterialButton( - padding: - EdgeInsets.symmetric(horizontal: 40.w), - minWidth: 0, - shape: StadiumBorder( - side: BorderSide( - color: ktextSubColor, - width: 1, - ), - ), - materialTapTargetSize: - MaterialTapTargetSize.shrinkWrap, - onPressed: () { - Get.to(() => GoodsDetailPage(id: item.id)); - }, - child: Text( - item.title, - style: TextStyle( - color: ktextSubColor, - ), - ), - ); - }, - itemCount: _hotItems.length, - ).expand(), - ], - ), - ), - 10.hb, + // SizedBox( + // height: 58.w, + // child: Row( + // children: [ + // Text( + // '热搜:', + // style: TextStyle( + // fontSize: 20.sp, + // ), + // ), + // 20.wb, + // ListView.separated( + // scrollDirection: Axis.horizontal, + // separatorBuilder: (_, __) => 20.wb, + // itemBuilder: (context, index) { + // final item = _hotItems[index]; + // return MaterialButton( + // padding: + // EdgeInsets.symmetric(horizontal: 40.w), + // minWidth: 0, + // shape: StadiumBorder( + // side: BorderSide( + // color: ktextSubColor, + // width: 1, + // ), + // ), + // materialTapTargetSize: + // MaterialTapTargetSize.shrinkWrap, + // onPressed: () { + // Get.to(() => GoodsDetailPage(id: item.id)); + // }, + // child: Text( + // item.title, + // style: TextStyle( + // color: ktextSubColor, + // ), + // ), + // ); + // }, + // itemCount: _hotItems.length, + // ).expand(), + // ], + // ), + // ), + // 10.hb, gridItems.expand(), ], ), @@ -178,29 +181,35 @@ class _MarketPageState extends State ), pinned: true, toolbarHeight: 0, - bottom: PreferredSize( - child: Material( - color: Color(0xFFF9F9F9), - child: Align( - alignment: Alignment.centerLeft, - child: BeeTabBar( - scrollable: true, - controller: _tabController, - tabs: ['社区商城', '二手市场'], - ), - ), - ), - preferredSize: Size.fromHeight(48), - ), + // bottom: PreferredSize( + // child: Material( + // color: Color(0xFFF9F9F9), + // child: Align( + // alignment: Alignment.centerLeft, + // child: BeeTabBar( + // scrollable: true, + // controller: _tabController, + // tabs: ['社区商城', '二手市场'], + // ), + // ), + // ), + // preferredSize: Size.fromHeight(48), + // ), ), ]; }, - body: TabBarView( - children: [ - SizedBox(), - SizedBox(), - ], - controller: _tabController, + body: WaterfallFlow.builder( + gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 20.w, + crossAxisSpacing: 20.w, + ), + padding: EdgeInsets.all(32.w), + itemBuilder: (context, index) { + final item = _hotItems[index]; + return GoodsCard(item: item); + }, + itemCount: _hotItems.length, ), ), );