对接消息中心

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;
@ -45,12 +52,10 @@ class _MessageState extends State<Message> {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(44.w), borderRadius: BorderRadius.circular(44.w),
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,32 +132,54 @@ 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(
padding: EdgeInsets.only(top: 16.w), controller: _refreshController,
children: [ firstRefresh: true,
_messageListTile('2020-10-23 9:00', _messageTypeImage('系统消息'), '系统消息', onRefresh: () async {
'你有一条新的报事报修待处理', 5, onpressed: () { await _updateMessageCenter();
Get.to(SystemMessage()); setState(() {});
}), },
Divider( header: MaterialHeader(),
height: 1.w, child: ListView(
), padding: EdgeInsets.only(top: 16.w),
_messageListTile( children: [
'2020-10-23 10:00', _messageListTile(
_messageTypeImage('评论消息'), '',
'评论消息', _messageTypeImage('系统消息'),
'你有一条新的评论回复', '系统消息',
7, '你有一条新的报事报修待处理',
onpressed: () { _messageCount,
Get.to(CommentMessage()); onpressed: () {
}, Get.to(SystemMessage());
), },
], ),
Divider(
height: 1.w,
),
_messageListTile(
'',
_messageTypeImage('评论消息'),
'评论消息',
'你有一条新的评论回复',
_commentCount,
onpressed: () {
Get.to(CommentMessage());
},
),
],
),
), ),
); );
} }

Loading…
Cancel
Save