import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:ysairplane2/base/YSBase.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSTools.dart'; import 'YSChooseLocation.dart'; import 'YSChoosePlane.dart'; import 'YSPay.dart'; class YSHelpPlane extends StatefulWidget { @override _YSHelpPlaneState createState() => _YSHelpPlaneState(); } class _YSHelpPlaneState extends State { bool _isDetail = false; bool _isOrder = false; Map _msgDict,_typeDict,_startDict,_endDict; String _numStr,_priceStr; TextEditingController _phone = TextEditingController(); TextEditingController _des = TextEditingController(); MethodChannel channel; Map _planeType; String _noticeStr = ''; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _getHelpPlaneData(); _getNoticeData(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ystitle: '召唤直升机', yschild: Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44, width: MediaQuery.of(context).size.width, color: Color(0xFFF1F2F4), child: Stack( children: [ Column( children: [ Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150), width: MediaQuery.of(context).size.width, color: Colors.white, child: Stack( children: [ Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150)-hsp(550), width: MediaQuery.of(context).size.width, color: Color(0xFFF1F2F3), child: platformView( platforms: (value){ value.setMethodCallHandler((call) { if(call.method == "address"){ print('===========================${call.arguments}'); Map point = call.arguments; channel.invokeMethod('setLocation', {'lat': point['lat'],'lng': point['lng'],'title': point['title'],'content': point['content'],'type': 0}); setState(() { _startDict = point; }); } return; }); channel = value; }, ) ), GestureDetector( onTap: (){ if(_msgDict==null){ ysFlutterToast(context, '呼叫信息获取失败'); return; } showDialog( context: context, builder: (context){ return CupertinoAlertDialog( title: Text('提示\n'), content: Text('是否拨打${_msgDict['emergencyCall']}'), actions: [ CupertinoButton( child: Container( child: Text('取消',style: TextStyle(fontSize: 16,color: Color(0xFF292929),decoration: TextDecoration.none,fontWeight: FontWeight.normal),), height: 40, alignment: Alignment.center, ), padding: EdgeInsets.all(0), onPressed: (){ Navigator.pop(context); }, ), CupertinoButton( child: Container( child: Text('确定',style: TextStyle(fontSize: 16,color: Color(0xFF292929),decoration: TextDecoration.none,fontWeight: FontWeight.normal),), height: 40, alignment: Alignment.center, ), padding: EdgeInsets.all(0), onPressed: (){ Navigator.pop(context); launch('tel:${_msgDict['emergencyCall']}'); }, ) ], ); } ); }, child: Container( margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150)-hsp(700),left: hsp(20)), width: wsp(250), height: hsp(70), alignment: Alignment.center, decoration: BoxDecoration( color: Color(0xFFF15204), borderRadius: BorderRadius.all(Radius.circular(50)) ), child: Text('SOS 紧急呼叫',style: TextStyle(fontSize: zsp(30),color: Colors.white),), ), ), Container( margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150)-hsp(700), left: MediaQuery.of(context).size.width-wsp(270)), width: wsp(250), height: hsp(70), child: Row( children: [ Container( height: hsp(70), width: hsp(70), color: Colors.white, child: Icon(Icons.flight,size: hsp(50),color: Color(0xFF3262FF),), alignment: Alignment.center, ), Container( height: hsp(70), width: hsp(170), color: Color(0xFFE8EFFD), child: Text('${_msgDict==null?0:_msgDict['airportNum']}架飞机',style: TextStyle(fontSize: zsp(26),color: Color(0xFF3856A0),fontWeight: FontWeight.bold),), alignment: Alignment.center, ), ], ) ), Container( margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150)-hsp(600)-3), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)), ), height: hsp(600)+3, child: Column( children: [ Container( child: Text('空中救援',style: TextStyle(fontSize: zsp(32),color: Color(0xFF212121),fontWeight: FontWeight.bold),), height: hsp(100), alignment: Alignment.center, ), Divider(color: Color(0xFFF1F2F4),height: 0.5,thickness: 0.5,), Container( height: hsp(500)+2.5, child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ if(index==0){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSChooseLocation(); } ) ).then((value){ if(value==null)return; setState(() { _startDict = value; }); channel.invokeMethod('setLocation', {'lat': value['lat'],'lng': value['lng'],'title': value['title'],'content': value['content'],'type': index}); }); }else if(index==1||index==2){ FocusScope.of(context).unfocus(); showModalBottomSheet( context: context, builder: (context){ return index==1?YSPicker(dataArray: _msgDict['dtRescueTypeList'],title: 'name',choose: (value){ print(value); setState(() { _typeDict = value; }); },):YSPicker(dataArray: [for(int i=0;i<30;i++){'title':'${i+1}','id':i+1}],title: 'title',choose: (value){ print(value); setState(() { _numStr = value['title']; }); },); } ); } }, behavior: HitTestBehavior.opaque, child: Container( height: hsp(100), padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), child: Row( children: [ Container(child: Text(index==0?'救援地点':index==1?'救援类型':index==2? '涉险人数':index==3?'联系方式':'描述',style: TextStyle(fontSize: zsp(30),color: Color(0xFFA7A7A7)),),width: wsp(150),), Container( margin: EdgeInsets.only(left: wsp(20)), width: MediaQuery.of(context).size.width-wsp(230), child: index==0?Text( _startDict==null?'请选择救援地点':'${_startDict['title']}', style: TextStyle(fontSize: zsp(30),color: Color(0xFF000000),fontWeight: FontWeight.bold), ):index==1||index==2?Row( children: [ Text(index==1? (_typeDict==null?'请选择救援类型':_typeDict['name']):(_numStr==null?'请选择险人数式':_numStr), style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),), Icon(Icons.keyboard_arrow_down,size: hsp(40),color: Color(0xFF999999),) ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ):CupertinoTextField( placeholder: index==3?'请输入联系方式':'请输入描述(20个字以内)', placeholderStyle: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)), style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)), decoration: BoxDecoration(), keyboardType: index==3?TextInputType.phone:TextInputType.text, maxLength: index==3?11:20, controller: index==3?_phone:_des, padding: EdgeInsets.all(0), ), ), ], ), ), ); }, separatorBuilder: (context,index){ return Divider(color: Color(0xFFF1F2F4),height: 0.5,thickness: 0.5,); }, itemCount: 5, padding: EdgeInsets.all(0), ), ) ], ), ) ], ), ), GestureDetector( onTap: (){ _getPriceData(); }, child: Container( height: hsp(100), margin: EdgeInsets.only(top: hsp(25)), width: MediaQuery.of(context).size.width-hsp(60), decoration: BoxDecoration( color: Color(0xFFF15103), borderRadius: BorderRadius.all(Radius.circular(5)) ), child: Text('一键召唤直升机',style: TextStyle(fontSize: zsp(36),color: Colors.white,fontWeight: FontWeight.bold),), alignment: Alignment.center, ), ), ], ), if(_isOrder==true)GestureDetector( onTap: (){ setState(() { _isOrder = false; }); }, child: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, color: Colors.black54, child: GestureDetector( onTap: (){}, child: Column( children: [ Container( height: (MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44)*0.8-hsp(120), width: MediaQuery.of(context).size.width, margin: EdgeInsets.only(top: (MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44)*0.2), decoration: BoxDecoration( color: Color(0xFFF1F2F3), borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)) ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( height: hsp(100), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)) ), padding: EdgeInsets.only(left: 15,right: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container(width: wsp(50),), Text('订单确认',style: TextStyle(fontSize: 15,color: Color(0xFF000000),decoration: TextDecoration.none,fontWeight: FontWeight.bold),), GestureDetector( child: Text('关闭',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none,fontWeight: FontWeight.bold),), onTap: (){ setState(() { _isOrder = false; }); }, ), ], ), ), Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE5E5E5),), Container( height: (MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44)*0.8-hsp(220)-0.5, child: SingleChildScrollView( padding: EdgeInsets.all(0), child: Column( children: [ Container( height: hsp(500)+2.5, child: ListView.separated( itemBuilder: (context,index){ return Container( height: hsp(100), color: Colors.white, padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), child: Row( children: [ Container(child: Text(index==0?'救援地点':index==1?'救援类型':index==2?'涉险人数': index==3?'联系方式':'描述',style: TextStyle(fontSize: zsp(30),color: Color(0xFFA7A7A7)),),width: wsp(150),), Container( margin: EdgeInsets.only(left: wsp(20)), width: MediaQuery.of(context).size.width-wsp(230), child: Text(index==0?'${_startDict['title']}':index==1?'${_typeDict['name']}':index==2?_numStr:index==3?_phone.text:(_des.text.isEmpty?'无':_des.text), style: TextStyle(fontSize: zsp(30),color: Color(0xFF000000),fontWeight: FontWeight.bold),) ), ], ), ); }, separatorBuilder: (context,index){ return Divider(color: Color(0xFFF1F2F4),height: 0.5,thickness: 0.5,); }, itemCount: 5, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), ), ), GestureDetector( onTap: (){ showInformAlert(context,title: '预订须知',content: _noticeStr); }, child: Container( child: RichText( text: TextSpan( text: '预订须知', style: TextStyle(fontSize: zsp(28),color: Color(0xFF348AE1)), children: [ TextSpan( text: ' >', style: TextStyle(color: Color(0xFF000000)) ), ] ), ), padding: EdgeInsets.only(left: wsp(40),right: wsp(40)), margin: EdgeInsets.only(top: hsp(10),bottom: hsp(10)), height: hsp(80), width: MediaQuery.of(context).size.width, alignment: Alignment.centerLeft, color: Colors.white, ), ), Container( height: hsp(80), padding: EdgeInsets.only(left: wsp(40),right: wsp(40)), child: Text('说明',style: TextStyle(color: Color(0xFF333333),fontSize: zsp(30),fontWeight: FontWeight.bold),), margin: EdgeInsets.only(bottom: 0.5), alignment: Alignment.centerLeft, color: Colors.white, ), Container( padding: EdgeInsets.only(left: wsp(40),right: wsp(40),top: hsp(20),bottom: hsp(20)), child: Text('信息提交后,将有我们的工作人员联系您讨论具体的救援方案,请保证手机畅通',style: TextStyle(color: Color(0xFF999999),fontSize: zsp(30)),), alignment: Alignment.centerLeft, color: Colors.white, ) ], ), ), ), ], ), ), 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: _priceStr==null?'0':_priceStr, // style: TextStyle(fontSize: zsp(40),color: Color(0xFFFF6600)), // ), // TextSpan( // text: '元' // ) // ] // ), // ), // 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: (){ showNegotiateAlertDio( context, content: _noticeStr, sure: (){ _postHelpPlaneOrderData(); } ); }, child: Container( height: hsp(100), width: MediaQuery.of(context).size.width-wsp(60), padding: EdgeInsets.only(left: wsp(50),right: wsp(50)), decoration: BoxDecoration( color: Color(0xFF007EFF), borderRadius: BorderRadius.all(Radius.circular(5)) ), alignment: Alignment.center, child: Text('立即预约',style: TextStyle(fontSize: zsp(30),color: Colors.white,fontWeight: FontWeight.bold),), ), ) ], ), ) ], ), ), ), ), if(_isDetail==true)GestureDetector( onTap: (){ setState(() { _isDetail = false; }); }, child: Container( height: (MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44)-hsp(120), color: Colors.black45, child: Container( margin: EdgeInsets.only(top: (MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44)-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('VIP尊享座位',style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000),decoration: TextDecoration.none),), Text('¥ 780x 10人',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('票价',style: TextStyle(fontSize: zsp(28),color: Color(0xFF9A9A9A)),), Text('¥ 770x 10人',style: TextStyle(fontSize: zsp(28),color: Color(0xFF9A9A9A)),), ], ), ); }, itemCount: 3, ), ) ], ), ), ), ), ) ], ), ), ); } _getHelpPlaneData() async{ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/wallconfigure/get',parameter: {'type':2},isLoading: true,isToken: false); if(dict!=null){ _msgDict = dict['data']; } } _postHelpPlaneOrderData() async{ Map request = {}; request['type'] = 2; request['travelersNumber'] = _numStr; request['phone'] = _phone.text; if(_des.text.isNotEmpty)request['des'] = _des.text; request['loactionSetout'] = '${_startDict['lat']},${_startDict['lng']}'; // request['loactionArrive'] = '${_endDict['lat']},${_endDict['lng']}'; request['citySetout'] = '${_startDict['title']}'; // request['cityArrive'] = '${_endDict['title']}'; request['rescueTypeId'] = _typeDict['id']; request['price'] = _priceStr; // request['modelId'] = _planeType['modelId']; Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/applets/airplaneorder/createOrder',parameter: request,isLoading: true,isToken: true); if(dict!=null){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSPay(orderDict: dict['data'],type: payType.help,); } ) ); } } _getPriceData() async{ FocusScope.of(context).unfocus(); if(_startDict==null){ ysFlutterToast(context,'请选择出发位置'); return; } // if(_endDict==null){ // ysFlutterToast(context,'请选择到达位置'); // return; // } // if(_startDict['title']==_endDict['title']){ // ysFlutterToast(context,'出发与到达位置不能相同'); // return; // } // if(_planeType==null){ // ysFlutterToast(context,'请选择飞机类型'); // return; // } if(_typeDict==null){ ysFlutterToast(context,'请选择救援类型'); return; } if(_numStr==null){ ysFlutterToast(context,'请选择救援人数'); return; } if(_phone.text.isEmpty){ ysFlutterToast(context,'电话号码不能为空'); return; } if(isChinaPhoneLegal(_phone.text)==false){ ysFlutterToast(context,'电话号码格式不正确'); return; } Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/wallconfigure/calculation', parameter: {'loactionSetout':'${_startDict['lat']},${_startDict['lng']}'},isLoading: true,isToken: false); if(dict!=null){ _priceStr = '${dict['data']}'; setState(() { _isOrder = true; }); } } _getNoticeData() async{ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneservice/ctrip',parameter: {'type':2}); if(dict!=null){ _noticeStr = dict['data']['value']; } } }