import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:ysairplane2/code/YSChoosePoint.dart'; import 'package:ysairplane2/code/YSCity.dart'; import 'package:ysairplane2/code/YSContractPlaneDetail.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSTools.dart'; class YSContractPlane extends StatefulWidget { @override _YSContractPlaneState createState() => _YSContractPlaneState(); } class _YSContractPlaneState extends State { int _type = 0; int _selected = 0; int _plansIndex = 0; int _page = 1; List _dataArray = []; Map _siftDict,_siftDict2; Map _startCity,_endCity,_startCity2,_endCity2,_startCity3,_endCity3; int _priceIndex = 0; int _dateIndex = 0; int _dateIndex2 = 0; String _timeStr; MethodChannel _channel; var _endId,_arriveId; List _endPoints = []; int _endIndex = 0; // int _distanceIndex = 0; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _refreshData(); _getSiftData(); }); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( endDrawer: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width*0.85, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(10),bottomLeft: Radius.circular(10)) ), child: Column( children: [ Container( height: MediaQuery.of(context).size.height-hsp(100), width: MediaQuery.of(context).size.width*0.85, child: SingleChildScrollView( padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(30),bottom: hsp(30)), child: _type==2?Column( children: [ Container( padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('航线',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),), ListView.separated( shrinkWrap: true, itemBuilder: (context,index){ return Container( child: Row( children: [ Text('出发地',style: TextStyle(fontSize: zsp(24),color: Color(0xFF2C7CF6)),), Container( margin: EdgeInsets.only(left: wsp(40)), padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), height: hsp(60), decoration: BoxDecoration( color: Color(0xFFF4F4F4), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('西安',style: TextStyle(fontSize: zsp(24),color: Colors.black),), Icon(Icons.keyboard_arrow_right,size: hsp(40),color: Color(0xFF2C7CF6),) ], ) ) ], ), ); }, itemCount: 2, padding: EdgeInsets.only(top: hsp(30),bottom: hsp(30)), separatorBuilder: (BuildContext context, int index) { return Divider(height: hsp(30),thickness: hsp(30),color: Colors.white,); }, ), ], ), ), Divider(height: hsp(10),thickness: hsp(10),color: Color(0xFFF4F4F4),), Container( width: MediaQuery.of(context).size.width*0.85, padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: wsp(20),bottom: wsp(30)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('行程距离',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),), Container( margin: EdgeInsets.only(top: hsp(30),bottom: hsp(30)), child: Row( children: [ Container( height: hsp(60), width: wsp(180), decoration: BoxDecoration( color: Color(0xFFF4F4F4), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text('最小距离',style: TextStyle(fontSize: zsp(24),color: Colors.black),), ), Container( height: hsp(3), width: wsp(30), color: Color(0xFFF4F4F4), margin: EdgeInsets.only(left: wsp(33),right: wsp(33)), ), Container( height: hsp(60), width: wsp(180), decoration: BoxDecoration( color: Color(0xFFF4F4F4), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text('最大距离',style: TextStyle(fontSize: zsp(24),color: Colors.black),), ) ], ), ), ListView.separated( itemBuilder: (context,index){ return Container( height: hsp(60), width: MediaQuery.of(context).size.width, decoration: BoxDecoration( color: Color(0xFFF4F4F4), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text('100公里 -300公里 30%的选择',style: TextStyle(fontSize: zsp(24),color: Colors.black),), ); }, separatorBuilder: (context,index){ return Divider(color: Colors.white,height: hsp(30),thickness: hsp(30),); }, itemCount: 3, shrinkWrap: true, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), ) ], ), ), Divider(height: hsp(10),thickness: hsp(10),color: Color(0xFFF4F4F4),), Container( width: MediaQuery.of(context).size.width*0.85, padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: wsp(20),bottom: wsp(30)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Text('出发时间',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),), Icon(Icons.keyboard_arrow_right,size: hsp(40),color: Color(0xFF2C7CF6),) ], ), Container( width: MediaQuery.of(context).size.width*0.85, padding: EdgeInsets.only(top: hsp(30)), height: hsp(90), child: ListView.separated( itemBuilder: (context,index){ return Container( height: hsp(60), width: wsp(200), decoration: BoxDecoration( color: Color(0xFFF4F4F4), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text('2020.09.18',style: TextStyle(fontSize: zsp(24),color: Colors.black),), ); }, separatorBuilder: (context,index){ return Container(color: Colors.white,width: wsp(24),); }, itemCount: 3, // shrinkWrap: true, scrollDirection: Axis.horizontal, padding: EdgeInsets.all(0), ), ) ], ), ) ], ):Column( children: [ Container( padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('航线',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),), ListView.separated( shrinkWrap: true, itemBuilder: (context,index){ return GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSCity(); } ) ).then((value){ if(value!=null){ if(index==0){ _startCity = value; }else{ _endCity = value; } setState(() { }); } }); }, child: Container( child: Row( children: [ Text('出发地',style: TextStyle(fontSize: zsp(24),color: Color(0xFF2C7CF6)),), Container( margin: EdgeInsets.only(left: wsp(40)), padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), height: hsp(60), decoration: BoxDecoration( color: Color(0xFFF4F4F4), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(index==0?'${_startCity!=null?_startCity['display']:'请选择'}':'${_endCity!=null?_endCity['display']:'请选择'}',style: TextStyle(fontSize: zsp(24),color: Colors.black),), Icon(Icons.keyboard_arrow_right,size: hsp(40),color: Color(0xFF2C7CF6),) ], ) ) ], ), ), ); }, itemCount: 2, padding: EdgeInsets.only(top: hsp(30),bottom: hsp(30)), separatorBuilder: (BuildContext context, int index) { return Divider(height: hsp(30),thickness: hsp(30),color: Colors.white,); }, ), ], ), ), Divider(height: hsp(10),thickness: hsp(10),color: Color(0xFFF4F4F4),), Container( width: MediaQuery.of(context).size.width*0.85, padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: wsp(20),bottom: wsp(30)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('价格区间',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),), Container( margin: EdgeInsets.only(top: hsp(30),bottom: hsp(30)), child: Row( children: [ Container( height: hsp(60), width: wsp(180), decoration: BoxDecoration( color: Color(0xFFF4F4F4), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text(_siftDict==null?'':'${_siftDict['price'][_priceIndex]['min']}元',style: TextStyle(fontSize: zsp(24),color: Colors.black),), ), Container( height: hsp(3), width: wsp(30), color: Color(0xFFF4F4F4), margin: EdgeInsets.only(left: wsp(33),right: wsp(33)), ), Container( height: hsp(60), width: wsp(180), decoration: BoxDecoration( color: Color(0xFFF4F4F4), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text(_siftDict==null?'':'${_siftDict['price'][_priceIndex]['max']}元',style: TextStyle(fontSize: zsp(24),color: Colors.black),), ) ], ), ), ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ setState(() { _priceIndex = index; }); }, child: Container( height: hsp(60), width: MediaQuery.of(context).size.width, decoration: BoxDecoration( color: _priceIndex==index?Color(0xFFECF4FF):Color(0xFFF4F4F4), border: Border.all(color: _priceIndex==index?Color(0xFF2C7CF6):Colors.transparent,width: 1), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text('${_siftDict['price'][index]['min']}元 - ${_siftDict['price'][index]['max']}元 ${_siftDict['price'][index]['rate']}的选择', style: TextStyle(fontSize: zsp(24),color: _priceIndex==index?Color(0xFF2C7CF6):Colors.black),), ), ); }, separatorBuilder: (context,index){ return Divider(color: Colors.white,height: hsp(30),thickness: hsp(30),); }, itemCount: _siftDict!=null?_siftDict['price'].length:0, shrinkWrap: true, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), ) ], ), ), Divider(height: hsp(10),thickness: hsp(10),color: Color(0xFFF4F4F4),), Container( width: MediaQuery.of(context).size.width*0.85, padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: wsp(20),bottom: wsp(30)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ GestureDetector( onTap: (){ dateChooseAlert(context,dateValue: (dateValue){ timeChooseAlert(context,timeValue: (timeValue){ DateTime date = DateTime.parse('$dateValue $timeValue'); String timeStr = '${date.year}.${date.month}.${date.day}'; if(_siftDict['date'].contains(timeStr)==true){ _siftDict['date'].remove(timeStr); } _siftDict['date'].insert(0, timeStr); _dateIndex = 0; setState(() { }); }); }); }, child: Row( children: [ Text('出发时间',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),), Icon(Icons.keyboard_arrow_right,size: hsp(40),color: Color(0xFF2C7CF6),) ], ), ), Container( width: MediaQuery.of(context).size.width*0.85, padding: EdgeInsets.only(top: hsp(30)), height: hsp(90), child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ setState(() { _dateIndex = index; }); }, child: Container( height: hsp(60), width: wsp(200), decoration: BoxDecoration( color: _dateIndex==index?Color(0xFFECF4FF):Color(0xFFF4F4F4), border: Border.all(color: _dateIndex==index?Color(0xFF2C7CF6):Colors.transparent,width: 1), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text('${_siftDict['date'][index]}',style: TextStyle(fontSize: zsp(24),color: _dateIndex==index?Color(0xFF2C7CF6):Colors.black),), ), ); }, separatorBuilder: (context,index){ return Container(color: Colors.white,width: wsp(24),); }, itemCount: _siftDict!=null?_siftDict['date'].length:0, // shrinkWrap: true, scrollDirection: Axis.horizontal, padding: EdgeInsets.all(0), ), ) ], ), ), Divider(height: hsp(10),thickness: hsp(10),color: Color(0xFFF4F4F4),), Container( width: MediaQuery.of(context).size.width*0.85, padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: wsp(20),bottom: wsp(30)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('航空公司',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),), Icon(Icons.keyboard_arrow_down,size: hsp(40),color: Color(0xFF2C7CF6),) ], ), if(_siftDict!=null)Container( width: MediaQuery.of(context).size.width*0.85, padding: EdgeInsets.only(top: hsp(20)), child: Wrap( alignment: WrapAlignment.start, children: [ for (int i =0;i<(_siftDict['partner']).length;i++ ) GestureDetector( behavior: HitTestBehavior.opaque, onTap: (){ setState(() { _plansIndex = i; }); }, child: Container( margin: EdgeInsets.symmetric(vertical: hsp(16), horizontal: hsp(16)), decoration: BoxDecoration( color: _plansIndex==i?Color(0xFFECF4FF):Color(0xFFF4F4F4), border: Border.all(color: _plansIndex==i?Color(0xFF2C7CF6):Colors.transparent,width: 1), borderRadius: BorderRadius.all(Radius.circular(50)) ), padding: EdgeInsets.only(left: wsp(30), right: wsp(30),top: hsp(10),bottom: hsp(10)), child: Text('${_siftDict['partner'][i]['partnerName']}', style: TextStyle(fontSize: zsp(26),color: _plansIndex==i?Color(0xFF2C7CF6):Colors.black), textAlign: TextAlign.center,), ), ) ] ), ) ], ), ) ], ), ), ), Container( height: hsp(100), padding: EdgeInsets.only(left: wsp(40),right: wsp(40)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( onTap: (){ _plansIndex = 0; _priceIndex = 0; _dateIndex = 0; _startCity = null; _endCity = null; _siftDict2 = _siftDict; _siftDict = null; _refreshData(); Navigator.pop(context); }, child: Container( child: Text('重置',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(26),color: Colors.black),), width: (MediaQuery.of(context).size.width*0.85-wsp(100))/2, height: hsp(70), alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50)), border: Border.all(color: Color(0xFFB2B2B2),width: 1) ), ), ), GestureDetector( onTap: (){ _refreshData(); Navigator.pop(context); }, child: Container( child: Text('确定',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(26),color: Colors.white),), width: (MediaQuery.of(context).size.width*0.85-wsp(100))/2, height: hsp(70), alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50)), color: Color(0xFF2C7CF6) ), ), ) ], ), ) ], ), ), backgroundColor: Color(0xFFF1F2F3), body: SingleChildScrollView( child: Container( width: MediaQuery.of(context).size.width, child: Column( children: [ Container( height: MediaQuery.of(context).padding.top+hsp(20)+hsp(100), color: Colors.white, padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: MediaQuery.of(context).padding.top+hsp(20),bottom: hsp(20)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector(child: Icon(Icons.arrow_back_ios,size: wsp(40),color: Color(0xFF000000),),onTap: (){Navigator.pop(context);},), Container( width: MediaQuery.of(context).size.width-wsp(200), height: hsp(60), decoration: BoxDecoration( color: Color(0xFFF7F7F7), border: Border.all(color: Color(0xFF2C7CF6),width: hsp(2)), borderRadius: BorderRadius.all(Radius.circular(5)), ), child: ListView.separated( padding: EdgeInsets.all(0), itemBuilder: (context,index){ return GestureDetector( onTap: (){ _type = index; if(_type!=2){ _refreshData(); }else{ setState(() { }); } }, child: Container( width: (MediaQuery.of(context).size.width-wsp(200))/3, height: hsp(60), alignment: Alignment.center, child: Text(index==0?'整机':index==1?'拼座':'任意飞',style: TextStyle(color: _type==index?Colors.white:Color(0xFF2C7CF6),fontSize: zsp(26)),), decoration: BoxDecoration( color: _type==index?Color(0xFF2C7DF7):Colors.transparent, borderRadius: index==0?BorderRadius.only(bottomLeft: Radius.circular(2),topLeft: Radius.circular(2)): index==2?BorderRadius.only(topRight: Radius.circular(5),bottomRight: Radius.circular(5)):BorderRadius.all(Radius.circular(0)) ), ), ); }, separatorBuilder: (context,index){ return Container( height: hsp(60), width: hsp(2), color: Color(0xFF2C7CF6), ); }, itemCount: 3, scrollDirection: Axis.horizontal, ), ), Icon(Icons.search,size: wsp(40),color: Color(0xFF000000),) ], ), ), if (_type!=2) Column( children: [ Container( width: MediaQuery.of(context).size.width, height: hsp(80), color: Colors.white, child: ListView.builder( itemBuilder: (context,index){ return GestureDetector( behavior: HitTestBehavior.opaque, onTap: (){ if(index==2){ if(_siftDict==null&&_siftDict2!=null){ setState(() { _siftDict = _siftDict2; }); } Scaffold.of(context).openEndDrawer(); }else{ _selected = index; _refreshData(); } }, child: Container( alignment: Alignment.center, width: MediaQuery.of(context).size.width/3, height: hsp(80), child: Text(index==0?'综合':index==1?'销量':'筛选',style: TextStyle(fontSize: zsp(26),color: _selected==index?Color(0xFF007EFF):Color(0xFF222222),fontWeight: _selected==index?FontWeight.bold:FontWeight.normal),), ), ); }, itemCount: 3, scrollDirection: Axis.horizontal, ), ), Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(200), child: 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 YSContractPlaneDetail(contractId: _dataArray[index]['id'],isWhole: _type,); } ) ); }, behavior: HitTestBehavior.opaque, child: Container( padding: EdgeInsets.only(bottom: hsp(30)), margin: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(5)) ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( height: hsp(50), width: wsp(200), alignment: Alignment.center, child: Text(_getDateStr('${_dataArray[index]['flightTime']}'),style: TextStyle(color: Color(0xFF007AFF),fontSize: zsp(24)),), decoration: BoxDecoration( color: Color(0xFFF3F9FF), borderRadius: BorderRadius.only(topLeft: Radius.circular(5)) ), ), Row( children: [ Container( width: (MediaQuery.of(context).size.width-wsp(56))*0.65, padding: EdgeInsets.only(top: hsp(30),left: wsp(40),right: wsp(40)), child: ListView.builder( itemBuilder: (context,indexSub){ return Stack( children: [ Container( width: (MediaQuery.of(context).size.width-wsp(56))*0.65-wsp(80), child: Column( children: [ Text('${_dataArray[index][indexSub==0?'setoutInfo':'arriveInfo']['display']}',style: TextStyle(fontSize: zsp(30),color: Colors.black),), Text('${_dataArray[index][indexSub==0?'setoutInfo':'arriveInfo']['airplaneName']}',style: TextStyle(fontSize: zsp(22),color: Color(0xFF999999)),), ], crossAxisAlignment: CrossAxisAlignment.start, ), decoration: BoxDecoration( border: Border(left: BorderSide(width: 1,color: indexSub==1?Colors.transparent:Color(0xFFEFEFEE))) ), padding: EdgeInsets.only(left: 15,bottom: hsp(28)), margin: EdgeInsets.only(left: hsp(14)), ), Positioned( left: 0, width: 12, top: 0, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(50)), border: Border.all(color: indexSub==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6)) ), margin: EdgeInsets.only(top: 5), ), height: 17, ), Positioned( left: 4, width: 5, top: 0, child: Container(color: Colors.white), height: 5, ), Positioned( left: 4, width: 5, top: 17, child: Container(color: Colors.white), height: 5, ), ], ); }, itemCount: 2, shrinkWrap: true, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), ) ), Container( width: (MediaQuery.of(context).size.width-wsp(56))*0.35, child: Column( children: [ RichText( text: TextSpan( text: '¥ ', style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.normal), children: [ TextSpan( text: '${_dataArray[index]['discountPrice']}', style: TextStyle(fontSize: zsp(42),fontWeight: FontWeight.bold), ), TextSpan( text: ' 元起', ) ] ), ), Container( child: Text('原价: ${_dataArray[index]['price']}元起/座',style: TextStyle(fontSize: zsp(24),color: Color(0xFFA2A2A2),decoration: TextDecoration.lineThrough),), margin: EdgeInsets.only(top: hsp(10)), ) ], ), ), ], ) ], ), ), ); }, separatorBuilder: (context,index){ return Divider(height: hsp(20),thickness: hsp(20),color: Color(0xFFF1F2F3),); }, itemCount: _dataArray.length, padding: EdgeInsets.all(0), ), ) ) ], ) else Stack( children: [ Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150), width: MediaQuery.of(context).size.width, color: Color(0xFFF1F2F3), child: platformView( platforms: (value){ value.setMethodCallHandler((call) { if(call.method=='endPoint'){ setState(() { _endCity3 = call.arguments; String str = '${_endCity3['id']}'; _endId = str.split(',')[0]; _arriveId = str.split(',')[1]; }); } return; }); _channel = value; } ) ), Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(5)), ), height: hsp(200)+1, margin: EdgeInsets.only(left: hsp(24),top: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(400),right: hsp(24)), child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ if(index==2){ dateChooseAlert(context,dateValue: (date){ timeChooseAlert(context,timeValue: (time){ setState(() { _timeStr = '$date $time'; }); }); }); }else if(index==0){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSChoosePoint(); } ) ).then((value){ if(value!=null){ _startCity3 = value; _getEndPointsData(); } }); }else{ if(_startCity3==null)return; if(_endCity3!=null){ for(int i = 0;i<_endPoints.length;i++){ if(_endPoints[i]['title']==_endCity3['title']){ _endIndex = i; } } } showModalBottomSheet( context: context, isScrollControlled: true, backgroundColor: Colors.transparent, barrierColor: Colors.transparent, builder: (context){ return StatefulBuilder( builder: (context,chooseSet){ return Container( height: hsp(750), width: MediaQuery.of(context).size.width, child: Column( children: [ Container( margin: EdgeInsets.only(left: hsp(30),right: hsp(30),bottom: hsp(30)), height: hsp(600), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(5)) ), child: ListView.separated( itemCount: _endPoints.length, padding: EdgeInsets.all(0), itemBuilder: (context,indexSub){ return GestureDetector( onTap: (){ chooseSet(() { _endIndex = indexSub; }); }, child: Container( height: hsp(99), padding: EdgeInsets.only(left: hsp(30),right: hsp(30)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${_endPoints[indexSub]['title']}',style: TextStyle(fontSize: zsp(30),color: Colors.black),), Icon(_endIndex==indexSub?Icons.check_box: Icons.check_box_outline_blank,size: hsp(50),color: _endIndex==indexSub?Color(0xFF2B7CF6):Color(0xFF818181),) ], ), ), ); }, separatorBuilder: (context,indexSub){ return Divider(height: 1,thickness: 1,color: Color(0xFFF5F6F7),); }, ), ), GestureDetector( child: Container( height: hsp(100), margin: EdgeInsets.only(left: hsp(30),right: hsp(30)), child: Text('确认',style: TextStyle(fontSize: zsp(36),color: Colors.white,fontWeight: FontWeight.bold),), alignment: Alignment.center, decoration: BoxDecoration( color: Color(0xFF2B7CF6), borderRadius: BorderRadius.all(Radius.circular(5)) ), ), onTap: (){ Navigator.pop(context); setState(() { _endCity3 = _endPoints[_endIndex]; String str = '${_endCity3['id']}'; _endId = str.split(',')[0]; _arriveId = str.split(',')[1]; }); }, ) ], ), ); }, ); } ); } }, behavior: HitTestBehavior.opaque, child: Container( height: hsp(100), padding: EdgeInsets.only(left: hsp(30),right: hsp(30)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(index==0?'出发地点':index==1?'目的地点':'出发时间',style: TextStyle(fontSize: zsp(30),color: Color(0xFFA7A7A7)),), Container( width: MediaQuery.of(context).size.width-hsp(350), child: Text(index==0?(_startCity3==null?'请选择出发地点':'${_startCity3['setoutInfo']['introduce']}'): index==1?(_endCity3==null?'请选择目的地点':'${_endCity3['title']}'): (_timeStr==null?'请选择出发时间':_timeStr),style: TextStyle(fontSize: zsp(30),color: Color(0xFF443F3F),fontWeight: FontWeight.bold),), ), Icon(Icons.chevron_right,size: hsp(50),color: Color(0xFFC1C1C1),) ], ), ), ); }, separatorBuilder: (context,index){ return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF5F6F7),); }, itemCount: 2, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), ), ), GestureDetector( onTap: (){ if(_startCity3==null){ ysFlutterToast(context, '请选择出发地点'); return; } if(_endId==null){ ysFlutterToast(context, '请选择目的地点'); return; } // if(_timeStr==null){ // ysFlutterToast(context, '请选择出发时间'); // return; // } Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSContractPlaneDetail(contractId: _endId,isWhole: _type,arriveId: _arriveId,); } ) ); }, child: Container( height: hsp(110), margin: EdgeInsets.only(left: hsp(24),top: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150),right: hsp(24)), child: Text('任意飞',style: TextStyle(fontSize: zsp(36),color: Colors.white,fontWeight: FontWeight.bold),), alignment: Alignment.center, decoration: BoxDecoration( color: Color(0xFF2B7CF6), borderRadius: BorderRadius.all(Radius.circular(5)) ), ), ) ], ) ], ), ), ), ); } Future _refreshData() async{ _page = 1; Map request = {}; request['category'] = 8; request['type'] = _type+1; request['pageNo'] = _page; request['pageSize'] = 10; if(_siftDict!=null&&_siftDict2!=null){ if(_type==2){ if(_startCity2!=null)request['setout'] = _startCity2['display']; if(_endCity2!=null)request['arrive'] = _endCity2['display']; request['maxDistance'] = _siftDict['distance'][_priceIndex]['max']; request['minDistance'] = _siftDict['distance'][_priceIndex]['min']; request['time'] = _siftDict['date'][_dateIndex2].replaceAll('.', '-'); }else{ request['time'] = _siftDict['date'][_dateIndex].replaceAll('.', '-'); request['maxPrice'] = _siftDict['price'][_priceIndex]['max']; request['minPrice'] = _siftDict['price'][_priceIndex]['min']; if(_startCity!=null)request['setout'] = _startCity['display']; if(_endCity!=null)request['arrive'] = _endCity['display']; request['partnerId'] = _siftDict['partner'][_plansIndex]['id']; } } if(_selected==1){ request['sales'] = 1; } Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: request,isLoading: false,isToken: false); if(dict!=null){ setState(() { _dataArray = dict['data']['resultList']; }); } } Future _loadMoreData() async{ _page++; Map request = {}; request['category'] = 8; request['type'] = _type+1; request['pageNo'] = _page; request['pageSize'] = 10; if(_siftDict!=null&&_siftDict2!=null){ if(_type==2){ if(_startCity2!=null)request['setout'] = _startCity2['display']; if(_endCity2!=null)request['arrive'] = _endCity2['display']; request['maxDistance'] = _siftDict['distance'][_priceIndex]['max']; request['minDistance'] = _siftDict['distance'][_priceIndex]['min']; request['time'] = _siftDict['date'][_dateIndex2].replaceAll('.', '-'); }else{ request['time'] = _siftDict['date'][_dateIndex].replaceAll('.', '-'); request['maxPrice'] = _siftDict['price'][_priceIndex]['max']; request['minPrice'] = _siftDict['price'][_priceIndex]['min']; if(_startCity!=null)request['setout'] = _startCity['display']; if(_endCity!=null)request['arrive'] = _endCity['display']; request['partnerId'] = _siftDict['partner'][_plansIndex]['id']; } } if(_selected==1){ request['sales'] = 1; } Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: request,isLoading: false,isToken: false); if(dict!=null){ setState(() { _dataArray.addAll(dict['data']['resultList']); }); } } _getDateStr(String date) { DateTime time = DateTime.parse(date); String timeStr = '${time.month}月${time.day}日 '+time.hour.toString().padLeft(2,'0')+':'+time.minute.toString().padLeft(2,'0'); return timeStr; } _getSiftData() async{ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/preferential/filter',parameter: {},isLoading: false,isToken: false); if(dict!=null){ _siftDict = dict['data']; List array = []; DateTime date = DateTime.now(); for(int i = 0;i<7;i++){ String timeStr = '${date.year}.${date.month}.${date.day}'; array.add(timeStr); date = date.add(Duration(days: 1)); } _siftDict['date'] = array; setState(() { }); } } _getEndPointsData() async{ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/getFreedomFlyByPartnerId', parameter: {'partnerId':_startCity3['partnerId'],'airportIdSetout':_startCity3['airportIdSetout']},isLoading: false,refresh: (){},isToken: true); if(dict!=null){ _endPoints.clear(); dict['data'].forEach((element) { Map temp = {}; temp['lat'] = element['arriveInfo']['latitude']; temp['lng'] = element['arriveInfo']['longitude']; temp['title'] = element['arriveInfo']['airplaneName']; temp['content'] = element['arriveInfo']['introduce']; temp['id'] = "${element['id']},${element['airportIdArrive']}"; _endPoints.add(temp); }); _channel.invokeMethod('setPoints', {'points':_endPoints,'startPoint':{'lat':_startCity3['setoutInfo']['latitude'],'lng':_startCity3['setoutInfo']['longitude'] ,'title':_startCity3['setoutInfo']['airplaneName'],'content':_startCity3['setoutInfo']['introduce'],'range':1000}}); setState(() {}); } } }