对接消息中心

hmxc
小赖 4 years ago
parent 07c4517c70
commit 9e8129de0b

@ -15,6 +15,7 @@ class API {
static _User user = _User(); static _User user = _User();
static _Manage manage = _Manage(); static _Manage manage = _Manage();
static _Upload upload = _Upload(); static _Upload upload = _Upload();
static _Message message = _Message();
} }
class _Auth { class _Auth {
@ -155,3 +156,12 @@ class _Upload {
/// ///
String get uploadArtical => '/user/upload/uploadArticle'; String get uploadArtical => '/user/upload/uploadArticle';
} }
class _Message {
///
String get messageCenter => '/user/message/messageCenter';
///
String get systemList => '/user/message/sysMessageList';
///
String get commentList => '/user/message/sysCommentMessageList';
}

@ -1,8 +1,12 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
import 'package:aku_ui/aku_ui.dart'; import 'package:aku_ui/aku_ui.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get/instance_manager.dart'; import 'package:get/instance_manager.dart';
@ -22,6 +26,9 @@ class Message extends StatefulWidget {
} }
class _MessageState extends State<Message> { class _MessageState extends State<Message> {
int _messageCount = 0;
int _commentCount = 0;
EasyRefreshController _refreshController = EasyRefreshController();
Widget _messageTypeImage(String type) { Widget _messageTypeImage(String type) {
String path; String path;
Color ca; Color ca;
@ -47,10 +54,8 @@ class _MessageState extends State<Message> {
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.topCenter, begin: Alignment.topCenter,
end: Alignment.bottomCenter, end: Alignment.bottomCenter,
colors: [ colors: [ca, cb],
ca, ),
cb,
]),
), ),
child: Image.asset( child: Image.asset(
path, path,
@ -127,33 +132,55 @@ class _MessageState extends State<Message> {
); );
} }
Future _updateMessageCenter() async {
Response response = await NetUtil().dio.get(API.message.messageCenter);
if (response == null || response.data == null) return;
_messageCount = response.data['sysCount'] ?? 0;
_commentCount = response.data['commentCount'] ?? 0;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AkuScaffold( return AkuScaffold(
title: '消息', title: '消息',
titleStyle: AppStyle().barTitleStyle, titleStyle: AppStyle().barTitleStyle,
body: ListView( body: EasyRefresh(
controller: _refreshController,
firstRefresh: true,
onRefresh: () async {
await _updateMessageCenter();
setState(() {});
},
header: MaterialHeader(),
child: ListView(
padding: EdgeInsets.only(top: 16.w), padding: EdgeInsets.only(top: 16.w),
children: [ children: [
_messageListTile('2020-10-23 9:00', _messageTypeImage('系统消息'), '系统消息', _messageListTile(
'你有一条新的报事报修待处理', 5, onpressed: () { '',
_messageTypeImage('系统消息'),
'系统消息',
'你有一条新的报事报修待处理',
_messageCount,
onpressed: () {
Get.to(SystemMessage()); Get.to(SystemMessage());
}), },
),
Divider( Divider(
height: 1.w, height: 1.w,
), ),
_messageListTile( _messageListTile(
'2020-10-23 10:00', '',
_messageTypeImage('评论消息'), _messageTypeImage('评论消息'),
'评论消息', '评论消息',
'你有一条新的评论回复', '你有一条新的评论回复',
7, _commentCount,
onpressed: () { onpressed: () {
Get.to(CommentMessage()); Get.to(CommentMessage());
}, },
), ),
], ],
), ),
),
); );
} }
} }

Loading…
Cancel
Save