消息:通知公告接新接口

pull/1/head
戴余标 2 years ago
parent c5152e379f
commit 59f3ccc21c

@ -144,6 +144,9 @@ class _Message {
/// ///
String get allComment => '/app/user/message/commentMessage'; String get allComment => '/app/user/message/commentMessage';
///app
String get list => '/app/user/message/list';
} }
class _Community { class _Community {

@ -0,0 +1,71 @@
import 'package:common_utils/common_utils.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'message_list_model.g.dart';
@JsonSerializable()
class MessageListModel extends Equatable {
final int id;
final int type;
final int status;
final String title;
final String content;
final String sendDate;
final int jumpId;
final int onlyId;
DateTime? get sendDt => DateUtil.getDateTime(sendDate);
int? get month => sendDt?.month;
int? get year => sendDt?.year;
factory MessageListModel.fromJson(Map<String, dynamic> json) =>
_$MessageListModelFromJson(json);
@override
List<Object?> get props => [
id,
type,
status,
title,
content,
sendDate,
jumpId,
onlyId,
];
const MessageListModel({
required this.id,
required this.type,
required this.status,
required this.title,
required this.content,
required this.sendDate,
required this.jumpId,
required this.onlyId,
});
MessageListModel copyWith({
int? id,
int? type,
int? status,
String? title,
String? content,
String? sendDate,
int? jumpId,
int? onlyId,
}) {
return MessageListModel(
id: id ?? this.id,
type: type ?? this.type,
status: status ?? this.status,
title: title ?? this.title,
content: content ?? this.content,
sendDate: sendDate ?? this.sendDate,
jumpId: jumpId ?? this.jumpId,
onlyId: onlyId ?? this.onlyId,
);
}
}

@ -0,0 +1,19 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'message_list_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
MessageListModel _$MessageListModelFromJson(Map<String, dynamic> json) =>
MessageListModel(
id: json['id'] as int,
type: json['type'] as int,
status: json['status'] as int,
title: json['title'] as String,
content: json['content'] as String,
sendDate: json['sendDate'] as String,
jumpId: json['jumpId'] as int,
onlyId: json['onlyId'] as int,
);

@ -12,6 +12,8 @@ import 'package:aku_new_community/pages/message_center_page/announce/announce_vi
import 'package:aku_new_community/ui/community/notice/notice_detail_page.dart'; import 'package:aku_new_community/ui/community/notice/notice_detail_page.dart';
import 'package:aku_new_community/widget/bee_image_network.dart'; import 'package:aku_new_community/widget/bee_image_network.dart';
import '../../../models/message/message_list_model.dart';
class AnnounceCard extends StatelessWidget { class AnnounceCard extends StatelessWidget {
final ListDateModel modelList; final ListDateModel modelList;
final int index; final int index;
@ -50,7 +52,7 @@ class AnnounceCard extends StatelessWidget {
); );
} }
Widget _card(HomeAnnounceModel model) { Widget _card(MessageListModel model) {
return InkWell( return InkWell(
onTap: () { onTap: () {
Get.to(() => NoticeDetailPage(id: model.id)); Get.to(() => NoticeDetailPage(id: model.id));
@ -68,21 +70,21 @@ class AnnounceCard extends StatelessWidget {
children: [ children: [
'${DateUtil.formatDateStr(model.createDate, format: 'dd日 HH:mm')}' '${DateUtil.formatDateStr(model.sendDate, format: 'dd日 HH:mm')}'
.text .text
.size(28.sp) .size(28.sp)
.color(ktextSubColor) .color(ktextSubColor)
.make(), .make(),
32.w.heightBox, 32.w.heightBox,
Container( // Container(
width: double.infinity, // width: double.infinity,
height: 258.w, // height: 258.w,
clipBehavior: Clip.antiAliasWithSaveLayer, // clipBehavior: Clip.antiAliasWithSaveLayer,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(16.w)), // decoration: BoxDecoration(borderRadius: BorderRadius.circular(16.w)),
child: BeeImageNetwork( // child: BeeImageNetwork(
imgs: model.imgList, // imgs: model.imgList,
), // ),
), // ),
32.w.heightBox, 32.w.heightBox,
'${model.title}'.text.size(36.sp).black.bold.make(), '${model.title}'.text.size(36.sp).black.bold.make(),

@ -1,3 +1,5 @@
import 'package:aku_new_community/models/message/message_list_model.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -6,7 +8,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:scroll_to_index/scroll_to_index.dart'; import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:aku_new_community/constants/saas_api.dart'; import 'package:aku_new_community/constants/saas_api.dart';
import 'package:aku_new_community/models/home/home_announce_model.dart';
import 'package:aku_new_community/pages/message_center_page/announce/announce_card.dart'; import 'package:aku_new_community/pages/message_center_page/announce/announce_card.dart';
import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:aku_new_community/utils/network/net_util.dart';
@ -14,7 +15,7 @@ class ListDateModel {
final String month; final String month;
final int index; final int index;
final String year; final String year;
final List<HomeAnnounceModel> models; final List<MessageListModel> models;
ListDateModel(this.month, this.models, this.index, this.year); ListDateModel(this.month, this.models, this.index, this.year);
} }
@ -33,10 +34,10 @@ class _AnnounceViewState extends State<AnnounceView> {
late AutoScrollController _autoScrollController; late AutoScrollController _autoScrollController;
List<ListDateModel> _modelLists = []; List<ListDateModel> _modelLists = [];
List<HomeAnnounceModel> _innerModelList = []; List<MessageListModel> _innerModelList = [];
String _headMonth = ''; String _headMonth = '';
void monthListDepart(List<HomeAnnounceModel> models) { void monthListDepart(List<MessageListModel> models) {
for (var item in models) { for (var item in models) {
var index = var index =
_modelLists.indexWhere((element) => element.month == item.month); _modelLists.indexWhere((element) => element.month == item.month);
@ -114,13 +115,13 @@ class _AnnounceViewState extends State<AnnounceView> {
_page = 1; _page = 1;
_modelLists.clear(); _modelLists.clear();
_innerModelList.clear(); _innerModelList.clear();
var base = var base = await NetUtil().getList(SAASAPI.message.list, params: {
await NetUtil().getList(SAASAPI.announce.list, params: {
'pageNum': _page, 'pageNum': _page,
'size': _size, 'size': _size,
'type': null,
}); });
_innerModelList = _innerModelList =
base.rows.map((e) => HomeAnnounceModel.fromJson(e)).toList(); base.rows.map((e) => MessageListModel.fromJson(e)).toList();
monthListDepart(_innerModelList); monthListDepart(_innerModelList);
if (_modelLists.isNotEmpty) { if (_modelLists.isNotEmpty) {
_headMonth = _modelLists[0].month; _headMonth = _modelLists[0].month;
@ -130,15 +131,14 @@ class _AnnounceViewState extends State<AnnounceView> {
}, },
onLoad: () async { onLoad: () async {
_page++; _page++;
var base = var base = await NetUtil().getList(SAASAPI.message.list, params: {
await NetUtil().getList(SAASAPI.announce.list, params: {
'pageNum': _page, 'pageNum': _page,
'size': _size, 'size': _size,
'type': null,
}); });
if (base.total > _modelLists.length) { if (base.total > _modelLists.length) {
_innerModelList = base.rows _innerModelList =
.map((e) => HomeAnnounceModel.fromJson(e)) base.rows.map((e) => MessageListModel.fromJson(e)).toList();
.toList();
monthListDepart(_innerModelList); monthListDepart(_innerModelList);
setState(() {}); setState(() {});
} else { } else {

Loading…
Cancel
Save