import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:ysairplane2/code/YSCommnetAdd.dart'; import 'package:ysairplane2/code/YSCourseDetail.dart'; import 'package:ysairplane2/code/YSRefund.dart'; import 'package:ysairplane2/code/YSTicketChange.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSTools.dart'; import 'YSTableCalendar.dart'; class YSCourse extends StatefulWidget { @override _YSCourseState createState() => _YSCourseState(); } class _YSCourseState extends State{ int _selected = 0; int _page = 1; List _dataArray = []; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _refreshData(); }); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xFFF5F5F5), appBar: CupertinoNavigationBar( leading: Text(''), trailing: Text(''), transitionBetweenRoutes: false, backgroundColor: Colors.white, border: Border(), middle: Container( width: MediaQuery.of(context).size.width-wsp(300), child: ListView.builder( itemBuilder: (context,index){ return GestureDetector( onTap: (){ _selected = index; _refreshData(); }, child: Container( width: (MediaQuery.of(context).size.width-wsp(300))/3, alignment: Alignment.center, child: Text('${index==0?'全部':index==1?'未出行':'已完成'}', style: TextStyle(color: _selected==index?Color(0xFF2674ED):Color(0xFF999999),fontWeight: _selected==index?FontWeight.bold:FontWeight.normal,fontSize: zsp(34)),), ), ); }, itemCount: 3, padding: EdgeInsets.all(0), scrollDirection: Axis.horizontal, ), ), ), body: EasyRefresh( onRefresh: _refreshData, onLoad: _loadMoreData, header: TaurusHeader( ), footer: TaurusFooter( ), child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSCourseDetail(orderStr: _dataArray[index]['orderSn'],); } ) ); }, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(10)) ), child: Column( children: [ Container( padding: EdgeInsets.all(hsp(20)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${_dataArray[index]['name']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF141416),fontWeight: FontWeight.bold),), Text(_dataArray[index]['isExpire']==2?'已过期':_dataArray[index]['consumed']==1?'未出行':'已完成',style: TextStyle(fontSize: zsp(30),color: Color(0xFF2B7BF6)),) ], ), ), Divider(height: 1,thickness: 1,color: Color(0xFFF5F5F5),), Container( padding: EdgeInsets.all(hsp(20)), child: Row( children: [ Icon(Icons.access_time,color: Color(0xFFBABAC6),size: hsp(28),), Text(' ${_dataArray[index]['time']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF24242B)),) ], ), ), _dataArray[index]['setout']!=null?Container( width: MediaQuery.of(context).size.width-hsp(80), child: ListView.builder( itemBuilder: (context,indexSub2){ return Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( children: [ Container( height: hsp(28), width: hsp(28), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(50)), border: Border.all(color: indexSub2==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6)) ), margin: EdgeInsets.only(top: hsp(7),bottom: hsp(7)), ), if(indexSub2<1)Container( height: hsp(28), child: DashedRect( color: Color(0xFFCACAD4), strokeWidth: 1, gap: 1 ), ) ], ), Container( child: indexSub2==0?Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(_dataArray[index]['setout']!=null?' ${_dataArray[index]['setout']}':' ', style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))), // Icon(Icons.keyboard_arrow_right,size: hsp(50),color: Color(0xFF999999),) ], ):Text(_dataArray[index]['arrive']!=null?' ${_dataArray[index]['arrive']}':' ',style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))), width: MediaQuery.of(context).size.width-hsp(120), ), ], ); }, itemCount: 2, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), padding: EdgeInsets.only(bottom: hsp(20)), ), ):Container( child: Text('${_dataArray[index]['title']}',style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))), width: MediaQuery.of(context).size.width-hsp(80), alignment: Alignment.centerLeft, padding: EdgeInsets.only(bottom: hsp(20)), ), if(_dataArray[index]['refundStatus']!=-1)Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ _dataArray[index]['endorseStatus']!=null?Container( height: hsp(50), width: hsp(180), decoration: BoxDecoration( borderRadius: BorderRadius.only(bottomRight: Radius.circular(50),topRight: Radius.circular(50)), color: Color( _dataArray[index]['endorseStatus']==0?0xFFF76B1C: _dataArray[index]['endorseStatus']==1?0xFF43C38E:0xFFD0021B ).withOpacity(0.2) ), alignment: Alignment.center, child: Text( _dataArray[index]['endorseStatus']==0?'改签中': _dataArray[index]['endorseStatus']==1?'改签成功':'改签失败', style: TextStyle(fontSize: zsp(26),color: Color( _dataArray[index]['endorseStatus']==0?0xFFF76B1C: _dataArray[index]['endorseStatus']==1?0xFF43C38E:0xFFD0021B )), ), ):Container(), if (_dataArray[index]['isExpire']==2) Container() else Row( children: [ if(_dataArray[index]['endorseDisplay']==true)GestureDetector( onTap: (){ showModalBottomSheet( backgroundColor: Colors.transparent, isScrollControlled: true, context: context, builder: (context){ return YSTableCalendar(orderSn: _dataArray[index]['orderSn'],postDate: (value){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSTicketChange(title: _dataArray[index]['name'],dateStr: value,orderSn: _dataArray[index]['orderSn'],); } ) ).then((value){ if(value!=null){ _refreshData(); } }); },); } ); }, child: Container( padding: EdgeInsets.only(left: hsp(30),right: hsp(30),top: hsp(10),bottom: hsp(10)), child: Text('改签',style: TextStyle(fontSize: zsp(26),color: Color(0xFF5A5A5A)),), margin: EdgeInsets.only(bottom: hsp(30),right: hsp(20)), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50)), border: Border.all(color: Color(0xFFE6E6E7),width: 1) ), ), ), GestureDetector( onTap: (){ if(_dataArray[index]['consumed']==1){ if(_dataArray[index]['refundStatus']==0){ Navigator.of(context).push( CupertinoPageRoute(builder: (context){ return YSRefund(msgDict: _dataArray[index],); }) ).then((value){ if(value!=null){ _refreshData(); } }); } }else{ if(_dataArray[index]['isScoring']==false){ Navigator.of(context).push( CupertinoPageRoute(builder: (context){ return YSCommentAdd(orderStr: _dataArray[index]['orderSn'],); }) ).then((value){ if(value!=null){ _refreshData(); } }); } } }, child: Container( padding: EdgeInsets.only(left: hsp(30),right: hsp(30),top: hsp(10),bottom: hsp(10)), child: Text(_dataArray[index]['consumed']==1?(_dataArray[index]['refundStatus']==0?'退款':'已退款'): (_dataArray[index]['isScoring']==false?'评价服务':'已评价'),style: TextStyle(fontSize: zsp(26),color: Color(0xFF5A5A5A)),), margin: EdgeInsets.only(bottom: hsp(30),right: hsp(20)), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50)), border: Border.all(color: Color(0xFFE6E6E7),width: 1) ), ), ) ], ) ], ) ], ), ), ); }, separatorBuilder: (context,index){ return Divider(height: hsp(16),thickness: hsp(16),color: Color(0xFFF5F5F5),); }, itemCount: _dataArray.length, padding: EdgeInsets.all(hsp(20)), shrinkWrap: true, ), ), ); } Future _refreshData() async{ _page = 1; Map request = {}; request['type'] = _selected+1; request['pageNum'] = _page; request['pageSize'] = 10; Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/orderList', parameter: request,isLoading: false,isToken: true,refresh: _refreshData); if(dict!=null){ setState(() { _dataArray = dict['data']['resultList']; }); } } Future _loadMoreData() async{ _page++; Map request = {}; request['type'] = _selected+1; request['pageNum'] = _page; request['pageSize'] = 10; Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/orderList', parameter: request,isLoading: false,isToken: true,refresh: _refreshData); if(dict!=null){ setState(() { _dataArray.addAll(dict['data']['resultList']); }); } } }