对接消息中心

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

@ -15,6 +15,7 @@ class API {
static _User user = _User();
static _Manage manage = _Manage();
static _Upload upload = _Upload();
static _Message message = _Message();
}
class _Auth {
@ -155,3 +156,12 @@ class _Upload {
///
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:
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';
// Package imports:
import 'package:aku_ui/aku_ui.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/instance_manager.dart';
@ -22,6 +26,9 @@ class Message extends StatefulWidget {
}
class _MessageState extends State<Message> {
int _messageCount = 0;
int _commentCount = 0;
EasyRefreshController _refreshController = EasyRefreshController();
Widget _messageTypeImage(String type) {
String path;
Color ca;
@ -47,10 +54,8 @@ class _MessageState extends State<Message> {
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
ca,
cb,
]),
colors: [ca, cb],
),
),
child: Image.asset(
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
Widget build(BuildContext context) {
return AkuScaffold(
title: '消息',
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),
children: [
_messageListTile('2020-10-23 9:00', _messageTypeImage('系统消息'), '系统消息',
'你有一条新的报事报修待处理', 5, onpressed: () {
_messageListTile(
'',
_messageTypeImage('系统消息'),
'系统消息',
'你有一条新的报事报修待处理',
_messageCount,
onpressed: () {
Get.to(SystemMessage());
}),
},
),
Divider(
height: 1.w,
),
_messageListTile(
'2020-10-23 10:00',
'',
_messageTypeImage('评论消息'),
'评论消息',
'你有一条新的评论回复',
7,
_commentCount,
onpressed: () {
Get.to(CommentMessage());
},
),
],
),
),
);
}
}

Loading…
Cancel
Save