对接接口:消息中心

添加首页消息红点提示
hmxc
张萌 4 years ago
parent bcd5a8949c
commit 47500111f0

@ -228,5 +228,6 @@ class _Upload {
}
class _Message {
///
String get center => '/user/message/messageCenter';
}

@ -1,14 +1,14 @@
// Dart imports:
import 'dart:async';
import 'dart:convert';
// Flutter imports:
import 'package:akuCommunity/provider/app_provider.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart';
// Project imports:
@ -19,7 +19,6 @@ import 'package:akuCommunity/model/community/activity_item_model.dart';
import 'package:akuCommunity/model/community/board_model.dart';
import 'package:akuCommunity/pages/home/widget/animate_app_bar.dart';
import 'package:akuCommunity/pages/message_center_page/message_center_page.dart';
import 'package:akuCommunity/service/base_model.dart';
import 'package:akuCommunity/ui/community/activity/activity_card.dart';
import 'package:akuCommunity/ui/community/activity/activity_list_page.dart';
import 'package:akuCommunity/ui/community/community_func.dart';
@ -30,7 +29,6 @@ import 'package:akuCommunity/widget/buttons/column_action_button.dart';
import 'package:akuCommunity/widget/views/application_box.dart';
import 'package:akuCommunity/widget/views/application_view.dart';
import 'widget/home_search.dart';
import 'widget/home_swiper.dart';
class HomePage extends StatefulWidget {
HomePage({Key key}) : super(key: key);
@ -67,16 +65,31 @@ class _HomePageState extends State<HomePage>
super.build(context);
ScreenUtil.init(context,
designSize: Size(750, 1334), allowFontScaling: true);
AppProvider appProvider = Provider.of<AppProvider>(context);
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AnimateAppBar(
scrollController: _scrollController,
actions: [
ColumnActionButton(
onPressed: MessageCenterPage().to,
title: '消息',
path: R.ASSETS_ICONS_ALARM_PNG,
),
Stack(children: [
ColumnActionButton(
onPressed: MessageCenterPage().to,
title: '消息',
path: R.ASSETS_ICONS_ALARM_PNG,
),
Positioned(
top: 0,
right: 0,
child: appProvider.messageCenterModel.sysCount == 0
? SizedBox()
: Container(
width: 2.w,
height: 2.w,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(1.w)),
))
]),
],
),
body: EasyRefresh(
@ -86,6 +99,7 @@ class _HomePageState extends State<HomePage>
onRefresh: () async {
_activityItemModel = await CommunityFunc.activity();
_boardItemModels = await CommunityFunc.board();
appProvider.getMessageCenter();
setState(() {});
},
child: CustomScrollView(

@ -1,5 +1,4 @@
// Package imports:
import 'dart:convert';
import 'package:akuCommunity/model/manager/article_QR_code_model.dart';
import 'package:akuCommunity/model/manager/moving_company_model.dart';

@ -0,0 +1,11 @@
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/message/message_center_model.dart';
import 'package:akuCommunity/service/net.dart';
import 'package:dio/dio.dart';
class MessageFunc {
// static Future<MessageCenterModel> messageCenter() async {
// Response response = await Net().dio.get(API.message.center);
// return MessageCenterModel.fromJson(response.data);
// }
}

@ -1,5 +1,6 @@
// Flutter imports:
import 'package:akuCommunity/model/common/real_time_weather_model.dart';
import 'package:akuCommunity/model/message/message_center_model.dart';
import 'package:amap_location_fluttify/amap_location_fluttify.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
@ -138,4 +139,13 @@ class AppProvider extends ChangeNotifier {
_weatherModel = RealTimeWeatherModel.fromJson(response.data);
notifyListeners();
}
///
MessageCenterModel _messageCenterModel;
MessageCenterModel get messageCenterModel => _messageCenterModel??MessageCenterModel.zero();
getMessageCenter() async {
Response response = await NetUtil().dio.get(API.message.center);
_messageCenterModel=MessageCenterModel.fromJson(response.data);
notifyListeners();
}
}

Loading…
Cancel
Save