message_page_old.dart 8.86 KB
// import 'package:flutter/material.dart';
// import 'package:flutter_screenutil/flutter_screenutil.dart';
// import 'package:one_key/constant/state.dart';
// import 'package:one_key/pages_sim/message/message_online_check_page.dart';
// import 'package:one_key/provider/message_dialog_model.dart';
// import 'package:one_key/provider/message_model.dart';
// import 'package:one_key/provider/user_model.dart';
// import 'package:one_key/res/colors.dart';
// import 'package:one_key/utils/event_bus.dart';
// import 'package:one_key/widgets/app_bar.dart';
// import 'package:one_key/widgets/v_empty_view.dart';
// import 'package:provider/provider.dart';
// import 'message_online_page.dart';
// import 'message_order_page.dart';

// /*
//   消息中心
// */
// class MessagePage extends StatefulWidget {
//   @override
//   State<StatefulWidget> createState() {
//     // TODO: implement createState
//     return new MessagePageState();
//   }
// }

// class MessagePageState extends State<MessagePage>
//     with TickerProviderStateMixin {
//   Color selectedColor = MyColours.color_199095;
//   Color unSelectedColor = MyColours.color_999999;

//   TabController tabController;

//   MessageModel messageModel;
//   UserModel userModel;
//   MessageDialogModel messageDialogModel;

//   @override
//   void initState() {
//     super.initState();
//     tabController = TabController(length: 3, vsync: this);
//     tabController.addListener(() {
//       //点击tab时或滑动tab回调一次
//       if (tabController.index.toDouble() == tabController.animation.value) {
//         getMessage(index: tabController.index);
//       }
//     });
//     WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
//       getMessage(index: 0);
//     });
//     //刷新未读数
//     bus.on("refresh_untreated_num", (arg) {
//       _getUnMsgNum();
//     });
//     //移除在线预订消息
//     bus.on("remove_untreated_message", (args) {
//       messageModel.removeUntreatedMessageByMid(args.toString());
//       messageDialogModel.removeMessage(args.toString());
//     });
//   }

//   //三种分类各自的未读消息数目
//   _getUnMsgNum() async {
//     if (mounted) {
//       Map<String, String> params = {"sid": userModel.user.sellerid};
//       await messageModel.getUnMsgNum(context, params);
//     }
//   }

//   //获取在线预订消息status 0未处理 1已处理
//   getMessage({bool showLoading = true, int index}) async {
//     String typeId = '';
//     if (index == 0) {
//       typeId = '10';
//     } else if (index == 1) {
//       typeId = '1';
//     } else if (index == 2) {
//       typeId = '12';
//     }
//     Map<String, String> params = {
//       "sid": userModel.user.sellerid,
//       "type_id": typeId, //1提前点餐2内部预订10在线预订
//       "status": '0',
//       "offset": '0',
//       "limit": "20",
//     };
//     await messageModel.getMessages(context, params, showLoading: showLoading);
//     _getUnMsgNum();
//   }

//   @override
//   Widget build(BuildContext context) {
//     messageModel = Provider.of<MessageModel>(context, listen: true);
//     userModel = Provider.of<UserModel>(context, listen: false);
//     messageDialogModel =
//         Provider.of<MessageDialogModel>(context, listen: false);
//     return Container(
//       width: double.infinity,
//       height: double.infinity,
//       color: MyColours.color_ffffff,
//       child: Column(
//         children: <Widget>[
//           MyAppBar(
//             "消息中心",
//             showBack: false,
//           ),
//           TabBar(
//             controller: tabController,
//             tabs: [
//               Tab(
//                 child: SizedBox(
//                   height: ScreenUtil().setWidth(60),
//                   width: ScreenUtil().setWidth(144),
//                   child: Stack(
//                     children: [
//                       Text(
//                         "在线预订",
//                         style: TextStyle(
//                             color: tabController.index == 0
//                                 ? selectedColor
//                                 : unSelectedColor,
//                             fontSize: ScreenUtil().setSp(32),
//                             fontWeight: FontWeight.bold),
//                       ),
//                       Positioned(
//                         top: 0,
//                         right: 0,
//                         child: Container(
//                           width: ScreenUtil().setWidth(16),
//                           height: ScreenUtil().setWidth(16),
//                           decoration: BoxDecoration(
//                               borderRadius: BorderRadius.circular(
//                                   ScreenUtil().setWidth(16)),
//                               color: messageModel.onlineTotal > 0
//                                   ? MyColours.color_fa5151
//                                   : MyColours.color_ffffff),
//                         ),
//                       )
//                     ],
//                   ),
//                 ),
//               ),
//               Tab(
//                 child: SizedBox(
//                   height: ScreenUtil().setWidth(60),
//                   width: ScreenUtil().setWidth(144),
//                   child: Stack(
//                     children: [
//                       Text(
//                         "提前点餐",
//                         style: TextStyle(
//                             color: tabController.index == 1
//                                 ? selectedColor
//                                 : unSelectedColor,
//                             fontSize: ScreenUtil().setSp(32),
//                             fontWeight: FontWeight.bold),
//                       ),
//                       Positioned(
//                         top: 0,
//                         right: 0,
//                         child: Container(
//                           width: ScreenUtil().setWidth(16),
//                           height: ScreenUtil().setWidth(16),
//                           decoration: BoxDecoration(
//                               borderRadius: BorderRadius.circular(
//                                   ScreenUtil().setWidth(16)),
//                               color: messageModel.orderTotal > 0
//                                   ? MyColours.color_fa5151
//                                   : MyColours.color_ffffff),
//                         ),
//                       )
//                     ],
//                   ),
//                 ),
//               ),
//               Tab(
//                 child: SizedBox(
//                   height: ScreenUtil().setWidth(60),
//                   width: ScreenUtil().setWidth(144),
//                   child: Stack(
//                     children: [
//                       Text(
//                         "在线买单",
//                         style: TextStyle(
//                             color: tabController.index == 2
//                                 ? selectedColor
//                                 : unSelectedColor,
//                             fontSize: ScreenUtil().setSp(32),
//                             fontWeight: FontWeight.bold),
//                       ),
//                       Positioned(
//                         top: 0,
//                         right: 0,
//                         child: Container(
//                           width: ScreenUtil().setWidth(16),
//                           height: ScreenUtil().setWidth(16),
//                           decoration: BoxDecoration(
//                               borderRadius: BorderRadius.circular(
//                                   ScreenUtil().setWidth(16)),
//                               color: messageModel.checkTotal > 0
//                                   ? MyColours.color_fa5151
//                                   : MyColours.color_ffffff),
//                         ),
//                       )
//                     ],
//                   ),
//                 ),
//               )
//             ],
//             indicatorColor: MyColours.color_199095,
//             indicatorSize: TabBarIndicatorSize.label,
//             indicatorPadding: EdgeInsets.only(
//                 left: ScreenUtil().setWidth(16),
//                 right: ScreenUtil().setWidth(32)),
//             indicatorWeight: ScreenUtil().setWidth(6.0),
//           ),
//           VEmptyView(11),
//           Expanded(
//             flex: 1,
//             child: TabBarView(controller: tabController, children: [
//               MessageOnlinePageSim(),
//               MessageOrderPageSim(),
//               MessageOnlineCheckPageSim()
//             ]),
//           )
//         ],
//       ),
//     );
//   }

//   @override
//   void dispose() {
//     // TODO: implement dispose
//     super.dispose();
//     bus.off("refresh_untreated_num");
//     bus.off("remove_untreated_message");
//   }
// }