import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:qhd_prevention/pages/mine/webViewPage.dart'; import 'package:qhd_prevention/pages/my_appbar.dart'; import 'package:webview_flutter/webview_flutter.dart'; import '../../http/ApiService.dart'; class NotifDetailPage extends StatefulWidget { const NotifDetailPage(this.item, this.selectedTab, {super.key,required this.onClose}); final Function(String) onClose; // 回调函数 final dynamic item; final int selectedTab; @override State createState() => _NotifDetailPageState(item,selectedTab,onClose); } class _NotifDetailPageState extends State { _NotifDetailPageState(this.item, this.selectedTab,this.onClose); final Function(String) onClose; // 回调函数 final dynamic item; final int selectedTab; String title=""; String time=""; String text=""; @override void initState() { super.initState(); if(0==selectedTab){ _getNotifDetail(); }else{ _getNotifEnterpriseDetail(); } } Future _getNotifDetail() async { // LoadingDialogHelper.show(context); try { final result = await ApiService.getNotifDetail(item['NOTICE_ID']); if (result['result'] == 'success') { final dynamic newList = result['pd'] ; setState(() { title= newList['SYNOPSIS']; time= newList['CREATTIME']; text= newList['CONTENT']; }); } } catch (e) { print('加载出错: $e'); } } Future _getNotifEnterpriseDetail() async { // LoadingDialogHelper.show(context); try { final result = await ApiService.getNotifEnterpriseDetail(item['NOTICECORPUSERID_ID']); if (result['result'] == 'success') { final dynamic newList = result['pd'] ; setState(() { title= newList['SYNOPSIS']; time= newList['CREATTIME']; text= newList['CONTENT']; }); } } catch (e) { print('加载出错: $e'); } } @override Widget build(BuildContext context) { return Scaffold( appBar: MyAppbar(title: "通知详情"), body: SafeArea( child: Container( width: double.infinity, // 铺满父容器 color: Colors.white, padding: const EdgeInsets.all(15), child: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, // 左对齐 children: [ Padding( padding: EdgeInsets.only(left: 10,right: 10), child: Text(title,style: TextStyle(color: Colors.black,fontSize: 16,fontWeight: FontWeight.bold),), ), SizedBox(height: 8), Padding( padding: EdgeInsets.only(left: 10,right: 10), child: Text(time,), ), SizedBox(height: 8), Html( data: text, ), // Text(item['CONTENT'],), ], ), ), ), ), ); } @override void dispose() { // TODO: implement dispose super.dispose(); onClose('关闭详情'); // 触发回调 } }