import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:ysairplane/tools/YSNetWorking.dart'; import 'package:ysairplane/tools/YSTools.dart'; import 'YSPay.dart'; class YSOrderOne extends StatefulWidget { final msgDict,confirmDict,orderDict; const YSOrderOne({Key key, this.msgDict, this.confirmDict, this.orderDict}) : super(key: key); @override _YSOrderOneState createState() => _YSOrderOneState(); } class _YSOrderOneState extends State { bool _isShow = false; bool _isDetail = false; List _packList = []; List _chooses = []; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _getPackData(); }); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( child: Column( children: [ Stack( children: [ Container( height: MediaQuery.of(context).size.height-hsp(120), width: MediaQuery.of(context).size.width, color: Color(0xFFF1F2F4), child: SingleChildScrollView( child: Stack( children: [ Container( height: MediaQuery.of(context).padding.top+hsp(380), width: MediaQuery.of(context).size.width, child: Image( image: widget.msgDict==null?AssetImage('lib/images/home3.png'):NetworkImage('${widget.msgDict['background']}'), fit: BoxFit.fill, ), ), GestureDetector( onTap: (){Navigator.pop(context);}, child: Container( margin: EdgeInsets.only(left: wsp(32),top: MediaQuery.of(context).padding.top+hsp(30)), child: Icon(Icons.arrow_back_ios,size: hsp(40),color: Colors.white,), ), ), if(widget.msgDict!=null)Container( margin: EdgeInsets.only(left: wsp(32),top: MediaQuery.of(context).padding.top+hsp(130),right: wsp(32)), width: MediaQuery.of(context).size.width-wsp(64), alignment: Alignment.center, child: Text('${widget.msgDict['name']}',style: TextStyle(fontSize: zsp(40),color: Colors.white,fontWeight: FontWeight.bold),) ), if(widget.msgDict!=null)Container( margin: EdgeInsets.only(left: wsp(32),top: MediaQuery.of(context).padding.top+hsp(200),right: wsp(32)), width: MediaQuery.of(context).size.width-wsp(64), alignment: Alignment.center, child: Text('${widget.msgDict['subtitle']}',style: TextStyle(fontSize: zsp(28),color: Colors.white.withOpacity(0.6)),) ), Container( width: MediaQuery.of(context).size.width-wsp(60), margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(300),left: wsp(30),bottom: hsp(40)), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(10)), color: Colors.white, ), child: Column( children: [ ListView.separated( shrinkWrap: true, itemBuilder: (context,index){ return Container( child: Column( children: [ widget.orderDict['charterType']==1?Container( padding: EdgeInsets.only(left: wsp(32),right: wsp(32),top: hsp(20),bottom: hsp(20)), child: Column( children: [ Row( children: [ Container( child: Text('${widget.confirmDict['itineraries'][index]['setOutInfo']['display']}', style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),), width: (MediaQuery.of(context).size.width-hsp(210))/2, ), Image(height: hsp(60),width: hsp(60),image: AssetImage('lib/images/plane.png'),), Container( child: Text('${widget.confirmDict['itineraries'][index]['arriveInfo']['display']}', style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),), width: (MediaQuery.of(context).size.width-hsp(210))/2, alignment: Alignment.centerRight, ), ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( child: Text('${widget.confirmDict['itineraries'][index]['setOutInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),), width: (MediaQuery.of(context).size.width-hsp(300))/2, ), Text('${widget.confirmDict['itineraries'][index]['time']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),), Container( child: Text('${widget.confirmDict['itineraries'][index]['arriveInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),), width: (MediaQuery.of(context).size.width-hsp(300))/2, alignment: Alignment.centerRight, ), ], ) ], ), ):Container( width: MediaQuery.of(context).size.width-hsp(100), child: ListView.builder( itemBuilder: (context,indexSub){ return Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( children: [ Container( height: hsp(30), width: hsp(30), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(50)), border: Border.all(color: indexSub%2==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6)) ), margin: EdgeInsets.only(top: hsp(10),bottom: hsp(7)), ), if(indexSub<1)Container( height: hsp(30), width: hsp(5), color: Color(0xFFCACAD4), ) ], ), Container( child: RichText( text: TextSpan( text: '${widget.confirmDict['itineraries'][index][indexSub==0?'setout':'arrive']}', style: TextStyle(color: Color(0xFF000000),fontSize: hsp(30),fontWeight: FontWeight.bold), children: [ ] ), ), margin: EdgeInsets.only(left: wsp(10),top: hsp(5)), ) ], ); }, itemCount: 2, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), padding: EdgeInsets.all(hsp(30)), ), ), Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),), Container( padding: EdgeInsets.only(left: wsp(32),right: wsp(32),top: hsp(20),bottom: hsp(20)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( children: [ Text('出发',style: TextStyle(fontSize: zsp(24),color: Color(0xFF666666)),), RichText( text: TextSpan( text: _getDateStr('${widget.confirmDict['itineraries'][index]['timeSetout']}'),style: TextStyle(fontSize: zsp(28),fontWeight: FontWeight.bold,color: Colors.black), children: [ // TextSpan( // text: '今天', // style: TextStyle(fontSize: zsp(24),fontWeight: FontWeight.normal), // ) ] ), )], crossAxisAlignment: CrossAxisAlignment.start, ), Column( children: [ Text('到达',style: TextStyle(fontSize: zsp(24),color: Color(0xFF666666)),), RichText( text: TextSpan( text: _getDateStr('${widget.confirmDict['itineraries'][index]['timeArrive']}'),style: TextStyle(fontSize: zsp(28),fontWeight: FontWeight.bold,color: Colors.black), children: [ // TextSpan( // text: '今天', // style: TextStyle(fontSize: zsp(24),fontWeight: FontWeight.normal), // ) ] ), ) ], crossAxisAlignment: CrossAxisAlignment.start, ), // Icon(Icons.keyboard_arrow_right,size: hsp(50),color: Color(0xFFC1C1C1),) ], ), ), ], ), ); }, separatorBuilder: (context,index){ return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),); }, itemCount: (widget.confirmDict['itineraries']).length, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), ), Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),), Container( width: MediaQuery.of(context).size.width-wsp(60), padding: EdgeInsets.all(wsp(32)), child: Text('出行人数 ${widget.confirmDict['travelersNumber']}人',style: TextStyle(fontSize: zsp(36),color: Colors.black),), ), Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),), Container( padding: EdgeInsets.all(wsp(32)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${widget.confirmDict['dtFlightInformation']['partnerName']}',style: TextStyle(fontSize: zsp(36),color: Colors.black),), // Icon(Icons.keyboard_arrow_right,size: hsp(50),color: Color(0xFFC1C1C1),) ], ), ), Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),), GestureDetector( onTap: (){ setState(() { _isShow = !_isShow; }); }, behavior: HitTestBehavior.opaque, child: Container( padding: EdgeInsets.all(wsp(32)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('更多服务',style: TextStyle(fontSize: zsp(36),color: Colors.black),), Icon(Icons.keyboard_arrow_down,size: hsp(50),color: Color(0xFFC1C1C1),) ], ) ), ), if(_isShow==true)Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only(bottomRight: Radius.circular(10),bottomLeft: Radius.circular(10)) ), child: ListView.builder( shrinkWrap: true, itemBuilder: (context,index){ return Container( padding: EdgeInsets.only(bottom: wsp(20),left: hsp(30),right: hsp(30)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Text('${_packList[index]['name']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),), Container( width: wsp(50), child: GestureDetector( child: Icon(Icons.error_outline,size: hsp(40),color: Color(0xFF999999)), ), ), Text('${_packList[index]['price']}元',style: TextStyle(fontSize: zsp(28),color: Colors.black),), ], ), GestureDetector( child: Container( height: hsp(60), width: hsp(100), child: Image.asset(_chooses.contains(_packList[index])==true?'lib/images/kaiguankai.png':'lib/images/kaiguanguan.png'), ), onTap: (){ setState(() { if(_chooses.contains(_packList[index])==true){ _chooses.remove(_packList[index]); }else{ _chooses.add(_packList[index]); } }); }, ) ], ), ); }, itemCount: _packList.length, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), ), ) ], ), ) ], ), ), ), if(_isDetail==true)GestureDetector( onTap: (){ setState(() { _isDetail = false; }); }, child: Container( height: MediaQuery.of(context).size.height-hsp(120), color: Colors.black45, child: Container( margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-hsp(120)-hsp(370)), height: hsp(370), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)) ), child: GestureDetector( onTap: (){}, behavior: HitTestBehavior.opaque, child: Column( children: [ Container( height: hsp(100), padding: EdgeInsets.only(left: 15,right: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( child: Text('关闭',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none),), onTap: (){ setState(() { _isDetail = false; }); }, ), Text('明细',style: TextStyle(fontSize: 15,color: Color(0xFF000000),decoration: TextDecoration.none,fontWeight: FontWeight.bold),), Container(width: wsp(50),), ], ), ), Container( height: hsp(100), color: Color(0xFFF7F8F9), padding: EdgeInsets.only(left: wsp(40),right: wsp(40),bottom: hsp(20),top: hsp(20)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('座位',style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000),decoration: TextDecoration.none),), Text('¥ ${widget.confirmDict['price']}x ${widget.confirmDict['travelersNumber']}人',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none),), ], ), ), Container( color: Color(0xFFF7F8F9), height: hsp(170), child: ListView.builder( padding: EdgeInsets.all(0), itemBuilder: (context,index){ return Container( padding: EdgeInsets.only(left: wsp(40),right: wsp(40),bottom: hsp(10)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${_chooses[index]['name']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF9A9A9A)),), Text('¥ ${_chooses[index]['price']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF9A9A9A)),), ], ), ); }, itemCount: _chooses.length, ), ) ], ), ), ), ), ) ], ), Container( height: hsp(120), width: MediaQuery.of(context).size.width, color: Colors.white, padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ RichText( text: TextSpan( text: '参考价(¥)', style: TextStyle(fontSize: zsp(22),color: Color(0xFF181818)), children: [ TextSpan( text: ' ${_getPrice()}', style: TextStyle(fontSize: zsp(40),color: Color(0xFFFF6600)), ) ] ), ), GestureDetector( child: Row( children: [ Text('明细',style: TextStyle(fontSize: zsp(22),color: Color(0xFF181818)),), Icon(Icons.keyboard_arrow_up,size: hsp(30),color: Color(0xFF007EFF),), ], ), onTap: (){ setState(() { _isDetail = !_isDetail; }); }, ), GestureDetector( onTap: (){ _postPlaneOrderData(); }, child: Container( height: hsp(70), padding: EdgeInsets.only(left: wsp(50),right: wsp(50)), decoration: BoxDecoration( color: Color(0xFF007EFF), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text('立即预约',style: TextStyle(fontSize: zsp(30),color: Colors.white,fontWeight: FontWeight.bold),), ), ) ], ), ) ], ), ), ); } _postPlaneOrderData() async{ widget.orderDict['price'] = '${_getPrice()}'; List array = []; _chooses.forEach((element) { array.add(element['id']); }); widget.orderDict['serviceIds'] = array.join(','); Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/applets/airplaneorder/createOrder',parameter: widget.orderDict,isLoading: true,isToken: true); if(dict!=null){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSPay(orderDict: dict['data'],type: payType.business,); } ) ); } } _getPackData() async{ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneservice/get',parameter: {'type':7},isLoading: true,isToken: false); if(dict!=null){ _packList = dict['data']; } } _getDateStr(String date){ return date.substring(0,date.length-3); } _getPrice(){ double price = double.parse('${widget.confirmDict['price']}')*int.parse('${widget.confirmDict['travelersNumber']}'); _chooses.forEach((element) { price+=double.parse('${element['price']}'); }); return price; } }