From f719669208894c72eeff0ac6b97bbf7ce5c66091 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Mon, 24 May 2021 18:47:06 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B6=88=E6=81=AF=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E7=9A=84model=E7=B1=BB=E6=8A=A5=E9=94=99=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../message_notice_page.dart | 20 +++++++++---------- .../model/message_notice_data_model.dart | 13 ++++++++---- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/pages/message_notice_page/message_notice_page.dart b/lib/pages/message_notice_page/message_notice_page.dart index 92d3cca..6c39d57 100644 --- a/lib/pages/message_notice_page/message_notice_page.dart +++ b/lib/pages/message_notice_page/message_notice_page.dart @@ -56,7 +56,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine void _onMainItemClick(MainNotificationStyleItem styleModel, MessageNoticeDataItemModel dataModel) { /// 消除消息红点 BlocProvider.of(context).add(MessageNoticeClearPointEvent(selectId: dataModel?.id.toString())); - + print('NoticePageType = ' + styleModel?.type + ', NoticePageName = ' + styleModel?.name); /// 如果是消息中心,则重新打开页面加载 Navigator.push(context, CupertinoPageRoute(builder: (_) => MessageNoticePage({'NoticePageType': styleModel?.type, 'NoticePageTitle': styleModel?.name}))); } @@ -259,7 +259,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine padding: const EdgeInsets.only(right: 22), child: Text( //'2020年6月23日4:00至6月30日4:00关闭提现aaa', - dataModel?.messageContent.title ?? '', + dataModel?.messageContent?.title ?? '', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex(styleModel?.value_color ?? '#999999'), fontSize: 12), @@ -304,14 +304,14 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine children: [ /// 标题 Text( - dataModel?.messageContent.title ?? '', + dataModel?.messageContent?.title ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold), ), const SizedBox(height: 5), /// 内容 Text( - dataModel?.messageContent.title ?? '', + dataModel?.messageContent?.title ?? '', maxLines: 3, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11), @@ -361,14 +361,14 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine children: [ /// 标题 Text( - dataModel?.messageContent.title ?? '', + dataModel?.messageContent?.title ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold), ), const SizedBox(height: 5), /// 内容 Text( - dataModel?.messageContent.title ?? '', + dataModel?.messageContent?.title ?? '', maxLines: 3, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11), @@ -406,7 +406,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine children: [ /// 标题 Text( - dataModel?.messageContent.title ?? '', + dataModel?.messageContent?.title ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontWeight: FontWeight.bold, fontSize: 14), maxLines: 1, overflow: TextOverflow.ellipsis, @@ -464,7 +464,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine crossAxisAlignment: CrossAxisAlignment.start, children: [ /// 标题 - Text(dataModel?.messageContent.title ?? '', + Text(dataModel?.messageContent?.title ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold)), const SizedBox(height: 5), @@ -512,7 +512,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine children: [ /// 标题 Text( - dataModel?.messageContent.title ?? '', + dataModel?.messageContent?.title ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold), ), const SizedBox(height: 5), @@ -565,7 +565,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine crossAxisAlignment: CrossAxisAlignment.start, children: [ /// 标题 - Text(dataModel?.messageContent.title ?? '', + Text(dataModel?.messageContent?.title ?? '', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold)), const SizedBox(height: 3), diff --git a/lib/pages/message_notice_page/model/message_notice_data_model.dart b/lib/pages/message_notice_page/model/message_notice_data_model.dart index 27c6ac0..1fed1a3 100644 --- a/lib/pages/message_notice_page/model/message_notice_data_model.dart +++ b/lib/pages/message_notice_page/model/message_notice_data_model.dart @@ -1,4 +1,6 @@ -import 'dart:convert' as Con; +// import 'dart:convert' as Con; +import 'dart:convert'; +import 'package:zhiying_comm/zhiying_comm.dart'; class MessageNoticeDataModel { List list; @@ -45,9 +47,12 @@ class MessageNoticeDataItemModel { skipIdentifier = json['skip_identifier']; status = json['status']; dateTime = json['date_time']; - if(json['content']!=null){ - messageContent=MessageContent.fromJson(Con.json.decode(json['content'])); - } + // if(json['content']!=null){ + // messageContent=MessageContent.fromJson(Con.json.decode(json['content'])); + // } + messageContent = !EmptyUtil.isEmpty(json['content']) && jsonDecode(json['content']) != null ? + MessageContent.fromJson(jsonDecode(json['content'])) : + null; } Map toJson() {