import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_alipay/flutter_alipay.dart'; import 'package:ysairplane2/base/YSBase.dart'; import 'package:ysairplane2/code/YSCourseDetail.dart'; import 'package:ysairplane2/code/YSMoney.dart'; import 'package:ysairplane2/code/YSSetPayPass.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSPayKeybord.dart'; import 'package:ysairplane2/tools/YSTools.dart'; import 'package:fluwx/fluwx.dart' as fluwx; import 'YSTabbar.dart'; enum payType{ doctor, help, goods, marry, sport, short, business,//商务 preferential,//特惠 sightseeing//游览 } class YSPay extends StatefulWidget { final orderDict; final payType type; const YSPay({Key key, this.orderDict, this.type}) : super(key: key); @override _YSPayState createState() => _YSPayState(); } class _YSPayState extends State { int _selected = 0; bool _isSucceed = false; @override void initState() { fluwx.weChatResponseEventHandler.listen((res) { if (res is fluwx.WeChatPaymentResponse) { // print('---------------->${res.isSuccessful}'); if(res.isSuccessful==true){ if(mounted){ setState(() { _isSucceed = true; }); } } } }); if(widget.type==payType.help){ setState(() { _isSucceed = true; }); } super.initState(); } @override Widget build(BuildContext context) { return YSBase( ystitle: '支付方式', yschild: _isSucceed==true?Column( children: [ Container( color: Colors.white, width: MediaQuery.of(context).size.width, padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: hsp(60),bottom: hsp(60)), child: Column( children: [ Image( image: AssetImage('lib/images/succeed.png'), height: hsp(130), width: wsp(130) ), Container( child: Text(widget.type==payType.help?'预约成功':'支付成功',style: TextStyle(fontSize: zsp(40),color: Color(0xFF333333)),), margin: EdgeInsets.only(top: hsp(40),bottom: hsp(33)), ), if(widget.type!=payType.help)Text('本次支付金额${widget.orderDict['price']}元',style: TextStyle(fontSize: zsp(28),color: Color(0xFF878787)),), ], ), ), GestureDetector( onTap: (){ // Navigator.popUntil(context, ModalRoute.withName('/')); // Navigator.of(context).popUntil(ModalRoute.withName('/home')); // Navigator.of(context).pushNamedAndRemoveUntil('/home', (route) => false); // Navigator.of(context).pop(); // Navigator.of(context).pop(); Navigator.of(context).pushAndRemoveUntil( CupertinoPageRoute( builder: (context){ return YSTabbar(); } ),(route) => false); }, child: Container( height: hsp(94), width: MediaQuery.of(context).size.width-wsp(24)*2, alignment: Alignment.center, margin: EdgeInsets.only(top: hsp(58)), decoration: BoxDecoration( color: Color(0xFF0079FF), borderRadius: BorderRadius.all(Radius.circular(5)) ), child: Text('完成',style: TextStyle(color: Colors.white,fontSize: zsp(34)),), ), ), GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSCourseDetail(orderStr: widget.orderDict['orderSn'],); } )); }, child: Container( height: hsp(94), width: MediaQuery.of(context).size.width-wsp(24)*2, alignment: Alignment.center, margin: EdgeInsets.only(top: hsp(58)), decoration: BoxDecoration( color: Color(0xFF0079FF), borderRadius: BorderRadius.all(Radius.circular(5)) ), child: Text('查看订单',style: TextStyle(color: Colors.white,fontSize: zsp(34)),), ), ) ], ):Column( children: [ Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(120), width: MediaQuery.of(context).size.width, color: Color(0xFFF1F2F3), child: SingleChildScrollView( child: Column( children: [ Container( width: MediaQuery.of(context).size.width, padding: EdgeInsets.all(hsp(30)), color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( child: Text('未支付',style: TextStyle(fontSize: zsp(32),color: Color(0xFFFF4747),fontWeight: FontWeight.bold),), margin: EdgeInsets.only(top: hsp(10),bottom: hsp(10)), ), Text('请在${_getMin('${widget.orderDict['expiredtime']}')}分钟内完成支付, 否则该订单将被自动取消',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),)//${int.parse('${(widget.orderDict['expireHour'])*60}')} ], ), ), widget.type==payType.doctor?Column( children: [ Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: MediaQuery.of(context).size.width*0.6, child: ListView.builder( itemBuilder: (context,index){ 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: index==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6)) ), margin: EdgeInsets.only(top: hsp(7),bottom: hsp(7)), ), if(index<1)Container( height: hsp(30), width: hsp(5), color: Color(0xFFCACAD4), ) ], ), Container( child: RichText( text: TextSpan( text: '${widget.orderDict[index==0?'citySetout':'cityArrive']}', style: TextStyle(color: Color(0xFF000000),fontSize: zsp(32),fontWeight: FontWeight.bold), children: [ TextSpan( text: ' ${widget.orderDict[index==0?'setoutInfo':'arriveInfo']['airplaneName']}', style: TextStyle(color: Color(0xFF999999),fontSize: zsp(20),fontWeight: FontWeight.normal), ) ] ), ), margin: EdgeInsets.only(left: wsp(10),top: hsp(5)), ) ], ); }, itemCount: 2, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), ), ), Container( child: Text('¥ ${widget.orderDict['retailPrice']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFFA2A2A2)),), padding: EdgeInsets.only(top: hsp(10)), ) ], ), ), Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ RichText( text: TextSpan( text: '乘机人数 ', style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)), children: [ TextSpan( text: '${widget.orderDict['travelersNumber']}人', style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)), ) ] ), ), Container(height: 0.5,color: Color(0xFFE5E5E5),margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20),left: hsp(170)),), RichText( text: TextSpan( text: '出发时间 ', style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)), children: [ TextSpan( text: '${widget.orderDict['flightTime']}', style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)), ) ] ), ), ], ), ), ], ):widget.type==payType.help?Column( children: [ Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: MediaQuery.of(context).size.width*0.6, child: ListView.builder( itemBuilder: (context,index){ 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: index==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6)) ), margin: EdgeInsets.only(top: hsp(7),bottom: hsp(7)), ), if(index<1)Container( height: hsp(30), width: hsp(5), color: Color(0xFFCACAD4), ) ], ), Container( child: RichText( text: TextSpan( text: '${widget.orderDict[index==0?'citySetout':'cityArrive']}', style: TextStyle(color: Color(0xFF000000),fontSize: zsp(32),fontWeight: FontWeight.bold), ), ), margin: EdgeInsets.only(left: wsp(10),top: hsp(5)), ) ], ); }, itemCount: 2, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), ), ), Container( child: Text('¥ ${widget.orderDict['retailPrice']} x ${widget.orderDict['travelersNumber']}人',style: TextStyle(fontSize: zsp(28),color: Color(0xFFA2A2A2)),), padding: EdgeInsets.only(top: hsp(10)), ) ], ), ), Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ RichText( text: TextSpan( text: '人数 ', style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)), children: [ TextSpan( text: '${widget.orderDict['travelersNumber']}人', style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)), ) ] ), ), Container(height: 0.5,color: Color(0xFFE5E5E5),margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20),left: hsp(120)),), RichText( text: TextSpan( text: '电话 ', style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)), children: [ TextSpan( text: '${widget.orderDict['phone']}', style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)), ) ] ), ), Container(height: 0.5,color: Color(0xFFE5E5E5),margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20),left: hsp(120)),), RichText( text: TextSpan( text: '描述 ', style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)), children: [ TextSpan( text: '${widget.orderDict['des']==null?'无':widget.orderDict['des']}', style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)), ) ] ), ), ], ), ), ], ):widget.type==payType.goods?Column( children: [ Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( child: Text('费用明细',style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),), ), Container( width: (MediaQuery.of(context).size.width-hsp(280))*0.55, padding: EdgeInsets.only(right: wsp(30)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(widget.orderDict['sourceType']==1?'整机':'拼机',style: TextStyle(fontSize: zsp(32),color: Colors.black,fontWeight: FontWeight.bold),), Container( margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20)), child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: [ Text('${widget.orderDict['dtAirplaneGoods']['goodsPlace']} ',style: TextStyle(fontSize: zsp(25),color: Color(0xFF9A9A9A))), Container( height: 1, width: wsp(20), color: Color(0xFFCCCCCC), ), Text(' ${widget.orderDict['dtAirplaneGoods']['goodsUnloadingPlace']}',style: TextStyle(fontSize: zsp(25),color: Color(0xFF9A9A9A))) ], ), ), ), // RichText( // text: TextSpan( // text: '预订须知', // style: TextStyle(fontSize: zsp(24),color: Color(0xFF348AE1)), // children: [ // TextSpan( // text: ' >', // style: TextStyle(color: Color(0xFF000000)) // ), // ] // ), // ) ], ), ), Container( width: (MediaQuery.of(context).size.width-wsp(280))*0.4, alignment: Alignment.centerRight, child: Text('¥ ${widget.orderDict['price']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFFA2A2A2)),), padding: EdgeInsets.only(top: hsp(10)), ) ], ), ), Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: wsp(150), alignment: Alignment.center, child: Text('联系人 ',style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),), ), Container( width: MediaQuery.of(context).size.width-hsp(60)-wsp(150), child: ListView.separated( itemBuilder: (context,index){ return Container( width: MediaQuery.of(context).size.width-hsp(60)-wsp(150), padding: EdgeInsets.only(bottom: index==1?0:hsp(20),top: index==0?0:hsp(20)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('${widget.orderDict['dtAirplaneGoods']['contactPerson']}',style: TextStyle(fontSize: zsp(32),color: Color(0xFF343434),fontWeight: FontWeight.bold),), Text('联系方式 ${widget.orderDict['dtAirplaneGoods']['phone']}',style: TextStyle(fontSize: zsp(25),color: Color(0xFF666666),)) ], ), ); }, separatorBuilder: (context,index){ return Divider(color: Color(0xFFE5E5E5),height: 0.5,thickness: 0.5,); }, itemCount: 1, padding: EdgeInsets.all(0), shrinkWrap: true, ), ), ], ), ), ], ):widget.type==payType.marry||widget.type==payType.sport||widget.type==payType.sightseeing?Column( children: [ Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${widget.orderDict['orderName']}',style: TextStyle(fontSize: zsp(40),color: Color(0xFF000000)),), Text('¥${widget.orderDict['price']}',style: TextStyle(fontSize: zsp(40),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),) ], ), ), Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(2)), width: MediaQuery.of(context).size.width, color: Colors.white, child: RichText( text: TextSpan( text: '联系方式 ', style: TextStyle(color: Colors.black,fontWeight: FontWeight.bold,fontSize: zsp(30)), children: [ TextSpan( text: '${widget.orderDict['phone']}', style: TextStyle(fontWeight: FontWeight.normal,color: Color(0xFF666666)) ) ] ), ), ), if(widget.type==payType.marry)Container( padding: EdgeInsets.only(top: hsp(30),left: hsp(30),right: hsp(30),bottom: hsp(10)), margin: EdgeInsets.only(top: hsp(2)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Text('贺卡备注',style: TextStyle(color: Colors.black,fontWeight: FontWeight.bold,fontSize: zsp(30)),), ), if(widget.type==payType.marry)Container( padding: EdgeInsets.only(left: hsp(40),right: hsp(30),bottom: hsp(30)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Text(widget.orderDict['des']==null?'':'${widget.orderDict['des']}',style: TextStyle(color: Color(0xFF666666),fontWeight: FontWeight.normal,fontSize: zsp(30)),), ) ], ):widget.type==payType.short?Column( children: [ Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: MediaQuery.of(context).size.width*0.6, child: ListView.builder( itemBuilder: (context,index){ 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: index==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6)) ), margin: EdgeInsets.only(top: hsp(10),bottom: hsp(7)), ), if(index<1)Container( height: hsp(30), width: hsp(5), color: Color(0xFFCACAD4), ) ], ), Container( child: RichText( text: TextSpan( text: '${widget.orderDict[index==0?'setoutInfo':'arriveInfo']['display']}', style: TextStyle(color: Color(0xFF000000),fontSize: zsp(32),fontWeight: FontWeight.bold), children: [ TextSpan( text: ' ${widget.orderDict[index==0?'setoutInfo':'arriveInfo']['airplaneName']}', style: TextStyle(color: Color(0xFF999999),fontSize: zsp(20),fontWeight: FontWeight.normal), ) ] ), ), margin: EdgeInsets.only(left: wsp(10)), ) ], ); }, itemCount: 2, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), ), ), Container( child: Text('¥ ${widget.orderDict['unitPrice']} x ${widget.orderDict['travelersNumber']}人',style: TextStyle(fontSize: zsp(28),color: Color(0xFFA2A2A2)),), padding: EdgeInsets.only(top: hsp(10)), ) ], ), ) ], ):widget.type==payType.business?Container( margin: EdgeInsets.only(top: hsp(10)), child: Column( children: [ ListView.separated( shrinkWrap: true, itemBuilder: (context,index){ return Container( color: Colors.white, 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: SingleChildScrollView( child: Text('${widget.orderDict['itineraries'][index]['setOutInfo']['display']}', style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),maxLines: 1,), scrollDirection: Axis.horizontal, ), width: (MediaQuery.of(context).size.width-hsp(240))/2, ), Image(height: hsp(60),width: hsp(60),image: AssetImage('lib/images/plane.png'),), Container( child: SingleChildScrollView( child: Text('${widget.orderDict['itineraries'][index]['arriveInfo']['display']}', style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),maxLines: 1,), scrollDirection: Axis.horizontal, ), width: (MediaQuery.of(context).size.width-hsp(240))/2, alignment: Alignment.centerRight, ), ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( child: Text('${widget.orderDict['itineraries'][index]['setOutInfo']['airplaneName']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),), width: (MediaQuery.of(context).size.width-hsp(300))/2, ), // Text('${widget.orderDict['itineraries'][index]['time']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),), Container( child: Text('${widget.orderDict['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(60), 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.orderDict['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.only(top: hsp(10),bottom: hsp(10)), ), ), 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.orderDict['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.orderDict['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.orderDict['itineraries']).length, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), ), ], ), ):Column( children: [ Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: (MediaQuery.of(context).size.width-hsp(280)), padding: EdgeInsets.only(right: wsp(30)), child: ListView.builder( itemBuilder: (context,indexSub){ return Stack( children: [ Container( width: MediaQuery.of(context).size.width-hsp(280)-wsp(60), child: Column( children: [ Text('${widget.orderDict[indexSub==0?'setoutInfo':'arriveInfo']['display']}',style: TextStyle(fontSize: zsp(30),color: Colors.black),), Text('${widget.orderDict[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(280))*0.35, child: Text('¥ ${widget.orderDict['price']}x ${(widget.orderDict['travelersNumber']==null?1:widget.orderDict['travelersNumber'])}人',style: TextStyle(fontSize: zsp(28),color: Color(0xFFA2A2A2)),), padding: EdgeInsets.only(top: hsp(10)), ) ], ), ), if(widget.orderDict['travelersNumber']!=null)Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: wsp(150), alignment: Alignment.center, child: Text('乘机人',style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),), ), Container( width: MediaQuery.of(context).size.width-hsp(60)-wsp(150), child: ListView.separated( itemBuilder: (context,index){ return Container( width: MediaQuery.of(context).size.width-hsp(60)-wsp(150), padding: EdgeInsets.only(bottom: index==1?0:hsp(20),top: index==0?0:hsp(20)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('${widget.orderDict['personnelInfo'][index]['username']} ${widget.orderDict['personnelInfo'][index]['phone']}',style: TextStyle(fontSize: zsp(32),color: Color(0xFF343434),fontWeight: FontWeight.bold),), Text('身份证 ${widget.orderDict['personnelInfo'][index]['cardid']}',style: TextStyle(fontSize: zsp(25),color: Color(0xFF666666),)) ], ), ); }, separatorBuilder: (context,index){ return Divider(color: Color(0xFFE5E5E5),height: 0.5,thickness: 0.5,); }, itemCount: widget.orderDict['personnelInfo']!=null?widget.orderDict['personnelInfo'].length:0, padding: EdgeInsets.all(0), shrinkWrap: true, ), ), ], ), ), ], ), Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: RichText( text: TextSpan( text: '应付总额:', style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)), children: [ TextSpan( text: '¥${widget.orderDict['price']}', style: TextStyle(color: Color(0xFF007EFF),fontWeight: FontWeight.bold), ) ] ), ), ), Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Text('订单编号:${widget.orderDict['orderSn']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF9A9A9A)),), ), Container( padding: EdgeInsets.all(hsp(30)), margin: EdgeInsets.only(top: hsp(12)), width: MediaQuery.of(context).size.width, color: Colors.white, child: Text('支付方式',style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),), ), ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ setState(() { _selected = index; }); }, behavior: HitTestBehavior.opaque, child: Container( height: hsp(92), color: Colors.white, padding: EdgeInsets.only(left: hsp(30),right: hsp(30)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Container( height: hsp(50), width: hsp(50), margin: EdgeInsets.only(right: hsp(25)), child: Image.asset(index==0?'lib/images/余额.png':index==1?'lib/images/wexinLogo.png':'lib/images/aliLogo.png'), ), Text(index==0?'余额':index==1?'微信支付':'支付宝',style: TextStyle(fontSize: zsp(30),color: Color(0xFF343434),)), ], ), Icon(Icons.check,color:index==_selected?Color(0xFF007EFF):Colors.transparent,size: hsp(40),), ], ), ), ); }, separatorBuilder: (context,index){ return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F3),); }, itemCount: 3, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), shrinkWrap: true, ) ], ), ), ), Container( height: hsp(120), width: MediaQuery.of(context).size.width, color: Colors.white, padding: EdgeInsets.only(left: wsp(60),right: wsp(60)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( onTap: (){ showDialog( context: context, builder: (context) { return AlertDialog( actionsPadding: EdgeInsets.all(0), title: Text('提示',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(36)),), content: Text('确认取消订单吗?',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(30))), actions: [ FlatButton(child: Text('取消',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(30))),onPressed: (){ Navigator.pop(context); },), FlatButton(child: Text('确认',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(30))),onPressed: (){ Navigator.pop(context); _postCancelOrderData(); },), ], ); } ); }, child: Container( height: hsp(88), width: wsp(300), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50)), border: Border.all(color: Color(0xFFD9D9D9),width: 1) ), alignment: Alignment.center, child: Text('取消订单',style: TextStyle(fontSize: zsp(34),color: Color(0xFF343434)),), ), ), GestureDetector( onTap: () { _postOrderData(); }, child: Container( height: hsp(88), width: wsp(300), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50)), color: Color(0xFF007EFF) ), alignment: Alignment.center, child: Text('去付款',style: TextStyle(fontSize: zsp(34),color: Colors.white),), ), ) ], ), ) ], ), ); } _postOrderData() async{ if(_selected==0){ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/balance/wx/checkBalance',parameter: {},isLoading: true,isToken: true, refresh: (){}); if(dict!=null){ if(dict['code']==801){ _showAlertView(1); }else{ showDialog(context: context,builder: (context){ return AlertDialog( contentPadding: EdgeInsets.all(0), actionsPadding: EdgeInsets.all(0), buttonPadding: EdgeInsets.all(0), insetPadding: EdgeInsets.all(0), titlePadding: EdgeInsets.all(0), backgroundColor: Colors.transparent, content: ysPayKeybord(context,(value){ _postPayData(value); },'${widget.orderDict['orderName']}', '${widget.orderDict['price']}') ); }); } } }else{ Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/applets/createPayOrder', parameter: {'id':widget.orderDict['orderSn'],'way':_selected+1,'type':2},isLoading: true, isToken: true,refresh: (){}); if(dict!=null){ if(_selected==2){ var payResult = await FlutterAlipay.pay('${dict['data']}'); String payResultStatus = payResult.resultStatus; if (payResultStatus == "9000") { print('=================================订单支付成功'); setState(() { _isSucceed = true; }); } else if (payResultStatus == "6001") { print('=================================支付取消'); } else if (payResultStatus == "4000") { print('=================================支付失败'); } else if (payResultStatus == "8000") { print('=================================等待支付'); } else if (payResultStatus == "6002") { print('=================================无网络'); } else if (payResultStatus == "5000") { print('=================================重复支付'); } else { print('=================================支付失败,未知错误'); } }else if(_selected==1){ Map result = dict['data']; fluwx.payWithWeChat( appId: result['appId'].toString(), partnerId: result['partnerId'].toString(), prepayId: result['prepayId'].toString(), packageValue: result['package'].toString(), nonceStr: result['nonceStr'].toString(), timeStamp: int.parse('${result['timeStamp']}'), sign: result['paySign'].toString(), ).then((data) {}); } } } } _getMin(String hours){ DateTime day1 = DateTime.parse(hours); DateTime day2 = DateTime.now(); return day1.difference(day2).inMinutes; } _postCancelOrderData() async{ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/cancelOrder', parameter: {'orderSn':widget.orderDict['orderSn']},isLoading: false,isToken: true); if(dict!=null){ Navigator.pop(context); } } _postPayData(String pass) async{ var dict = await ysRequestHttpEncrypt(context,type: requestType.post,api: '/app/applets/balance/balancePay', parameter: {'orderSn':widget.orderDict['orderSn'],'price':widget.orderDict['price'],'password': pass},isLoading: true,isToken: true); if(dict!=null){ if(dict==''){ setState(() { _isSucceed = true; }); }else if(dict['code']==804){ _showAlertView(2); }else if(dict['code']==801){ _showAlertView(1); } } } _showAlertView (int type) async{ showCupertinoDialog( context: context, builder: (context) { return CupertinoAlertDialog( title: Text('提示\n'), content: Text(type==1?'未设置支付密码':'余额不足请充值'), actions: [ CupertinoDialogAction(child: Text('取消'),onPressed: (){Navigator.pop(context);},), CupertinoDialogAction(child: Text(type==1?'去设置':'去充值'),onPressed: (){ Navigator.pop(context); Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return type==1?YSSetPayPass():YSMoney(); } ) ); },), ], ); } ); } _getDateStr(String date){ return date.substring(0,date.length-3); } }