YSPay.dart 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter_alipay/flutter_alipay.dart';
  4. import 'package:ysairplane2/base/YSBase.dart';
  5. import 'package:ysairplane2/code/YSCourseDetail.dart';
  6. import 'package:ysairplane2/code/YSMoney.dart';
  7. import 'package:ysairplane2/code/YSSetPayPass.dart';
  8. import 'package:ysairplane2/tools/YSNetWorking.dart';
  9. import 'package:ysairplane2/tools/YSPayKeybord.dart';
  10. import 'package:ysairplane2/tools/YSTools.dart';
  11. import 'package:fluwx/fluwx.dart' as fluwx;
  12. import 'YSTabbar.dart';
  13. enum payType{
  14. doctor,
  15. help,
  16. goods,
  17. marry,
  18. sport,
  19. short,
  20. business,//商务
  21. preferential,//特惠
  22. sightseeing//游览
  23. }
  24. class YSPay extends StatefulWidget {
  25. final orderDict;
  26. final payType type;
  27. const YSPay({Key key, this.orderDict, this.type}) : super(key: key);
  28. @override
  29. _YSPayState createState() => _YSPayState();
  30. }
  31. class _YSPayState extends State<YSPay> {
  32. int _selected = 0;
  33. bool _isSucceed = false;
  34. @override
  35. void initState() {
  36. fluwx.weChatResponseEventHandler.listen((res) {
  37. if (res is fluwx.WeChatPaymentResponse) {
  38. // print('---------------->${res.isSuccessful}');
  39. if(res.isSuccessful==true){
  40. if(mounted){
  41. setState(() {
  42. _isSucceed = true;
  43. });
  44. }
  45. }
  46. }
  47. });
  48. if(widget.type==payType.help){
  49. setState(() {
  50. _isSucceed = true;
  51. });
  52. }
  53. super.initState();
  54. }
  55. @override
  56. Widget build(BuildContext context) {
  57. return YSBase(
  58. ystitle: '支付方式',
  59. yschild: _isSucceed==true?Column(
  60. children: [
  61. Container(
  62. color: Colors.white,
  63. width: MediaQuery.of(context).size.width,
  64. padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: hsp(60),bottom: hsp(60)),
  65. child: Column(
  66. children: [
  67. Image(
  68. image: AssetImage('lib/images/succeed.png'),
  69. height: hsp(130),
  70. width: wsp(130)
  71. ),
  72. Container(
  73. child: Text(widget.type==payType.help?'预约成功':'支付成功',style: TextStyle(fontSize: zsp(40),color: Color(0xFF333333)),),
  74. margin: EdgeInsets.only(top: hsp(40),bottom: hsp(33)),
  75. ),
  76. if(widget.type!=payType.help)Text('本次支付金额${widget.orderDict['price']}元',style: TextStyle(fontSize: zsp(28),color: Color(0xFF878787)),),
  77. ],
  78. ),
  79. ),
  80. GestureDetector(
  81. onTap: (){
  82. // Navigator.popUntil(context, ModalRoute.withName('/'));
  83. // Navigator.of(context).popUntil(ModalRoute.withName('/home'));
  84. // Navigator.of(context).pushNamedAndRemoveUntil('/home', (route) => false);
  85. // Navigator.of(context).pop();
  86. // Navigator.of(context).pop();
  87. Navigator.of(context).pushAndRemoveUntil(
  88. CupertinoPageRoute(
  89. builder: (context){
  90. return YSTabbar();
  91. }
  92. ),(route) => false);
  93. },
  94. child: Container(
  95. height: hsp(94),
  96. width: MediaQuery.of(context).size.width-wsp(24)*2,
  97. alignment: Alignment.center,
  98. margin: EdgeInsets.only(top: hsp(58)),
  99. decoration: BoxDecoration(
  100. color: Color(0xFF0079FF),
  101. borderRadius: BorderRadius.all(Radius.circular(5))
  102. ),
  103. child: Text('完成',style: TextStyle(color: Colors.white,fontSize: zsp(34)),),
  104. ),
  105. ),
  106. GestureDetector(
  107. onTap: (){
  108. Navigator.of(context).push(
  109. CupertinoPageRoute(
  110. builder: (context){
  111. return YSCourseDetail(orderStr: widget.orderDict['orderSn'],);
  112. }
  113. ));
  114. },
  115. child: Container(
  116. height: hsp(94),
  117. width: MediaQuery.of(context).size.width-wsp(24)*2,
  118. alignment: Alignment.center,
  119. margin: EdgeInsets.only(top: hsp(58)),
  120. decoration: BoxDecoration(
  121. color: Color(0xFF0079FF),
  122. borderRadius: BorderRadius.all(Radius.circular(5))
  123. ),
  124. child: Text('查看订单',style: TextStyle(color: Colors.white,fontSize: zsp(34)),),
  125. ),
  126. )
  127. ],
  128. ):Column(
  129. children: [
  130. Container(
  131. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(120),
  132. width: MediaQuery.of(context).size.width,
  133. color: Color(0xFFF1F2F3),
  134. child: SingleChildScrollView(
  135. child: Column(
  136. children: [
  137. Container(
  138. width: MediaQuery.of(context).size.width,
  139. padding: EdgeInsets.all(hsp(30)),
  140. color: Colors.white,
  141. child: Column(
  142. crossAxisAlignment: CrossAxisAlignment.start,
  143. children: [
  144. Container(
  145. child: Text('未支付',style: TextStyle(fontSize: zsp(32),color: Color(0xFFFF4747),fontWeight: FontWeight.bold),),
  146. margin: EdgeInsets.only(top: hsp(10),bottom: hsp(10)),
  147. ),
  148. Text('请在${_getMin('${widget.orderDict['expiredtime']}')}分钟内完成支付, 否则该订单将被自动取消',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),)//${int.parse('${(widget.orderDict['expireHour'])*60}')}
  149. ],
  150. ),
  151. ),
  152. widget.type==payType.doctor?Column(
  153. children: [
  154. Container(
  155. padding: EdgeInsets.all(hsp(30)),
  156. margin: EdgeInsets.only(top: hsp(12)),
  157. width: MediaQuery.of(context).size.width,
  158. color: Colors.white,
  159. child: Row(
  160. crossAxisAlignment: CrossAxisAlignment.start,
  161. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  162. children: [
  163. Container(
  164. width: MediaQuery.of(context).size.width*0.6,
  165. child: ListView.builder(
  166. itemBuilder: (context,index){
  167. return Row(
  168. crossAxisAlignment: CrossAxisAlignment.start,
  169. children: [
  170. Column(
  171. children: [
  172. Container(
  173. height: hsp(30),
  174. width: hsp(30),
  175. decoration: BoxDecoration(
  176. color: Colors.white,
  177. borderRadius: BorderRadius.all(Radius.circular(50)),
  178. border: Border.all(color: index==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6))
  179. ),
  180. margin: EdgeInsets.only(top: hsp(7),bottom: hsp(7)),
  181. ),
  182. if(index<1)Container(
  183. height: hsp(30),
  184. width: hsp(5),
  185. color: Color(0xFFCACAD4),
  186. )
  187. ],
  188. ),
  189. Container(
  190. child: RichText(
  191. text: TextSpan(
  192. text: '${widget.orderDict[index==0?'citySetout':'cityArrive']}',
  193. style: TextStyle(color: Color(0xFF000000),fontSize: zsp(32),fontWeight: FontWeight.bold),
  194. children: [
  195. TextSpan(
  196. text: ' ${widget.orderDict[index==0?'setoutInfo':'arriveInfo']['airplaneName']}',
  197. style: TextStyle(color: Color(0xFF999999),fontSize: zsp(20),fontWeight: FontWeight.normal),
  198. )
  199. ]
  200. ),
  201. ),
  202. margin: EdgeInsets.only(left: wsp(10),top: hsp(5)),
  203. )
  204. ],
  205. );
  206. },
  207. itemCount: 2,
  208. shrinkWrap: true,
  209. physics: NeverScrollableScrollPhysics(),
  210. ),
  211. ),
  212. Container(
  213. child: Text('¥ ${widget.orderDict['retailPrice']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFFA2A2A2)),),
  214. padding: EdgeInsets.only(top: hsp(10)),
  215. )
  216. ],
  217. ),
  218. ),
  219. Container(
  220. padding: EdgeInsets.all(hsp(30)),
  221. margin: EdgeInsets.only(top: hsp(12)),
  222. width: MediaQuery.of(context).size.width,
  223. color: Colors.white,
  224. child: Column(
  225. crossAxisAlignment: CrossAxisAlignment.start,
  226. children: [
  227. RichText(
  228. text: TextSpan(
  229. text: '乘机人数 ',
  230. style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),
  231. children: [
  232. TextSpan(
  233. text: '${widget.orderDict['travelersNumber']}人',
  234. style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)),
  235. )
  236. ]
  237. ),
  238. ),
  239. Container(height: 0.5,color: Color(0xFFE5E5E5),margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20),left: hsp(170)),),
  240. RichText(
  241. text: TextSpan(
  242. text: '出发时间 ',
  243. style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),
  244. children: [
  245. TextSpan(
  246. text: '${widget.orderDict['flightTime']}',
  247. style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)),
  248. )
  249. ]
  250. ),
  251. ),
  252. ],
  253. ),
  254. ),
  255. ],
  256. ):widget.type==payType.help?Column(
  257. children: [
  258. Container(
  259. padding: EdgeInsets.all(hsp(30)),
  260. margin: EdgeInsets.only(top: hsp(12)),
  261. width: MediaQuery.of(context).size.width,
  262. color: Colors.white,
  263. child: Row(
  264. crossAxisAlignment: CrossAxisAlignment.start,
  265. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  266. children: [
  267. Container(
  268. width: MediaQuery.of(context).size.width*0.6,
  269. child: ListView.builder(
  270. itemBuilder: (context,index){
  271. return Row(
  272. crossAxisAlignment: CrossAxisAlignment.start,
  273. children: [
  274. Column(
  275. children: [
  276. Container(
  277. height: hsp(30),
  278. width: hsp(30),
  279. decoration: BoxDecoration(
  280. color: Colors.white,
  281. borderRadius: BorderRadius.all(Radius.circular(50)),
  282. border: Border.all(color: index==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6))
  283. ),
  284. margin: EdgeInsets.only(top: hsp(7),bottom: hsp(7)),
  285. ),
  286. if(index<1)Container(
  287. height: hsp(30),
  288. width: hsp(5),
  289. color: Color(0xFFCACAD4),
  290. )
  291. ],
  292. ),
  293. Container(
  294. child: RichText(
  295. text: TextSpan(
  296. text: '${widget.orderDict[index==0?'citySetout':'cityArrive']}',
  297. style: TextStyle(color: Color(0xFF000000),fontSize: zsp(32),fontWeight: FontWeight.bold),
  298. ),
  299. ),
  300. margin: EdgeInsets.only(left: wsp(10),top: hsp(5)),
  301. )
  302. ],
  303. );
  304. },
  305. itemCount: 2,
  306. shrinkWrap: true,
  307. physics: NeverScrollableScrollPhysics(),
  308. ),
  309. ),
  310. Container(
  311. child: Text('¥ ${widget.orderDict['retailPrice']} x ${widget.orderDict['travelersNumber']}人',style: TextStyle(fontSize: zsp(28),color: Color(0xFFA2A2A2)),),
  312. padding: EdgeInsets.only(top: hsp(10)),
  313. )
  314. ],
  315. ),
  316. ),
  317. Container(
  318. padding: EdgeInsets.all(hsp(30)),
  319. margin: EdgeInsets.only(top: hsp(12)),
  320. width: MediaQuery.of(context).size.width,
  321. color: Colors.white,
  322. child: Column(
  323. crossAxisAlignment: CrossAxisAlignment.start,
  324. children: [
  325. RichText(
  326. text: TextSpan(
  327. text: '人数 ',
  328. style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),
  329. children: [
  330. TextSpan(
  331. text: '${widget.orderDict['travelersNumber']}人',
  332. style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)),
  333. )
  334. ]
  335. ),
  336. ),
  337. Container(height: 0.5,color: Color(0xFFE5E5E5),margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20),left: hsp(120)),),
  338. RichText(
  339. text: TextSpan(
  340. text: '电话 ',
  341. style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),
  342. children: [
  343. TextSpan(
  344. text: '${widget.orderDict['phone']}',
  345. style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)),
  346. )
  347. ]
  348. ),
  349. ),
  350. Container(height: 0.5,color: Color(0xFFE5E5E5),margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20),left: hsp(120)),),
  351. RichText(
  352. text: TextSpan(
  353. text: '描述 ',
  354. style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),
  355. children: [
  356. TextSpan(
  357. text: '${widget.orderDict['des']==null?'无':widget.orderDict['des']}',
  358. style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)),
  359. )
  360. ]
  361. ),
  362. ),
  363. ],
  364. ),
  365. ),
  366. ],
  367. ):widget.type==payType.goods?Column(
  368. children: [
  369. Container(
  370. padding: EdgeInsets.all(hsp(30)),
  371. margin: EdgeInsets.only(top: hsp(12)),
  372. width: MediaQuery.of(context).size.width,
  373. color: Colors.white,
  374. child: Row(
  375. crossAxisAlignment: CrossAxisAlignment.start,
  376. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  377. children: [
  378. Container(
  379. child: Text('费用明细',style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),),
  380. ),
  381. Container(
  382. width: (MediaQuery.of(context).size.width-hsp(280))*0.55,
  383. padding: EdgeInsets.only(right: wsp(30)),
  384. child: Column(
  385. crossAxisAlignment: CrossAxisAlignment.start,
  386. children: [
  387. Text(widget.orderDict['sourceType']==1?'整机':'拼机',style: TextStyle(fontSize: zsp(32),color: Colors.black,fontWeight: FontWeight.bold),),
  388. Container(
  389. margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20)),
  390. child: SingleChildScrollView(
  391. scrollDirection: Axis.horizontal,
  392. child: Row(
  393. children: [
  394. Text('${widget.orderDict['dtAirplaneGoods']['goodsPlace']} ',style: TextStyle(fontSize: zsp(25),color: Color(0xFF9A9A9A))),
  395. Container(
  396. height: 1,
  397. width: wsp(20),
  398. color: Color(0xFFCCCCCC),
  399. ),
  400. Text(' ${widget.orderDict['dtAirplaneGoods']['goodsUnloadingPlace']}',style: TextStyle(fontSize: zsp(25),color: Color(0xFF9A9A9A)))
  401. ],
  402. ),
  403. ),
  404. ),
  405. // RichText(
  406. // text: TextSpan(
  407. // text: '预订须知',
  408. // style: TextStyle(fontSize: zsp(24),color: Color(0xFF348AE1)),
  409. // children: [
  410. // TextSpan(
  411. // text: ' >',
  412. // style: TextStyle(color: Color(0xFF000000))
  413. // ),
  414. // ]
  415. // ),
  416. // )
  417. ],
  418. ),
  419. ),
  420. Container(
  421. width: (MediaQuery.of(context).size.width-wsp(280))*0.4,
  422. alignment: Alignment.centerRight,
  423. child: Text('¥ ${widget.orderDict['price']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFFA2A2A2)),),
  424. padding: EdgeInsets.only(top: hsp(10)),
  425. )
  426. ],
  427. ),
  428. ),
  429. Container(
  430. padding: EdgeInsets.all(hsp(30)),
  431. margin: EdgeInsets.only(top: hsp(12)),
  432. width: MediaQuery.of(context).size.width,
  433. color: Colors.white,
  434. child: Row(
  435. crossAxisAlignment: CrossAxisAlignment.start,
  436. children: [
  437. Container(
  438. width: wsp(150),
  439. alignment: Alignment.center,
  440. child: Text('联系人 ',style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),),
  441. ),
  442. Container(
  443. width: MediaQuery.of(context).size.width-hsp(60)-wsp(150),
  444. child: ListView.separated(
  445. itemBuilder: (context,index){
  446. return Container(
  447. width: MediaQuery.of(context).size.width-hsp(60)-wsp(150),
  448. padding: EdgeInsets.only(bottom: index==1?0:hsp(20),top: index==0?0:hsp(20)),
  449. child: Column(
  450. crossAxisAlignment: CrossAxisAlignment.start,
  451. children: [
  452. Text('${widget.orderDict['dtAirplaneGoods']['contactPerson']}',style: TextStyle(fontSize: zsp(32),color: Color(0xFF343434),fontWeight: FontWeight.bold),),
  453. Text('联系方式 ${widget.orderDict['dtAirplaneGoods']['phone']}',style: TextStyle(fontSize: zsp(25),color: Color(0xFF666666),))
  454. ],
  455. ),
  456. );
  457. },
  458. separatorBuilder: (context,index){
  459. return Divider(color: Color(0xFFE5E5E5),height: 0.5,thickness: 0.5,);
  460. },
  461. itemCount: 1,
  462. padding: EdgeInsets.all(0),
  463. shrinkWrap: true,
  464. ),
  465. ),
  466. ],
  467. ),
  468. ),
  469. ],
  470. ):widget.type==payType.marry||widget.type==payType.sport||widget.type==payType.sightseeing?Column(
  471. children: [
  472. Container(
  473. padding: EdgeInsets.all(hsp(30)),
  474. margin: EdgeInsets.only(top: hsp(12)),
  475. width: MediaQuery.of(context).size.width,
  476. color: Colors.white,
  477. child: Row(
  478. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  479. children: [
  480. Text('${widget.orderDict['orderName']}',style: TextStyle(fontSize: zsp(40),color: Color(0xFF000000)),),
  481. Text('¥${widget.orderDict['price']}',style: TextStyle(fontSize: zsp(40),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),)
  482. ],
  483. ),
  484. ),
  485. Container(
  486. padding: EdgeInsets.all(hsp(30)),
  487. margin: EdgeInsets.only(top: hsp(2)),
  488. width: MediaQuery.of(context).size.width,
  489. color: Colors.white,
  490. child: RichText(
  491. text: TextSpan(
  492. text: '联系方式 ',
  493. style: TextStyle(color: Colors.black,fontWeight: FontWeight.bold,fontSize: zsp(30)),
  494. children: [
  495. TextSpan(
  496. text: '${widget.orderDict['phone']}',
  497. style: TextStyle(fontWeight: FontWeight.normal,color: Color(0xFF666666))
  498. )
  499. ]
  500. ),
  501. ),
  502. ),
  503. if(widget.type==payType.marry)Container(
  504. padding: EdgeInsets.only(top: hsp(30),left: hsp(30),right: hsp(30),bottom: hsp(10)),
  505. margin: EdgeInsets.only(top: hsp(2)),
  506. width: MediaQuery.of(context).size.width,
  507. color: Colors.white,
  508. child: Text('贺卡备注',style: TextStyle(color: Colors.black,fontWeight: FontWeight.bold,fontSize: zsp(30)),),
  509. ),
  510. if(widget.type==payType.marry)Container(
  511. padding: EdgeInsets.only(left: hsp(40),right: hsp(30),bottom: hsp(30)),
  512. width: MediaQuery.of(context).size.width,
  513. color: Colors.white,
  514. child: Text(widget.orderDict['des']==null?'':'${widget.orderDict['des']}',style: TextStyle(color: Color(0xFF666666),fontWeight: FontWeight.normal,fontSize: zsp(30)),),
  515. )
  516. ],
  517. ):widget.type==payType.short?Column(
  518. children: [
  519. Container(
  520. padding: EdgeInsets.all(hsp(30)),
  521. margin: EdgeInsets.only(top: hsp(12)),
  522. width: MediaQuery.of(context).size.width,
  523. color: Colors.white,
  524. child: Row(
  525. crossAxisAlignment: CrossAxisAlignment.start,
  526. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  527. children: [
  528. Container(
  529. width: MediaQuery.of(context).size.width*0.6,
  530. child: ListView.builder(
  531. itemBuilder: (context,index){
  532. return Row(
  533. crossAxisAlignment: CrossAxisAlignment.start,
  534. children: [
  535. Column(
  536. children: [
  537. Container(
  538. height: hsp(30),
  539. width: hsp(30),
  540. decoration: BoxDecoration(
  541. color: Colors.white,
  542. borderRadius: BorderRadius.all(Radius.circular(50)),
  543. border: Border.all(color: index==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6))
  544. ),
  545. margin: EdgeInsets.only(top: hsp(10),bottom: hsp(7)),
  546. ),
  547. if(index<1)Container(
  548. height: hsp(30),
  549. width: hsp(5),
  550. color: Color(0xFFCACAD4),
  551. )
  552. ],
  553. ),
  554. Container(
  555. child: RichText(
  556. text: TextSpan(
  557. text: '${widget.orderDict[index==0?'setoutInfo':'arriveInfo']['display']}',
  558. style: TextStyle(color: Color(0xFF000000),fontSize: zsp(32),fontWeight: FontWeight.bold),
  559. children: [
  560. TextSpan(
  561. text: ' ${widget.orderDict[index==0?'setoutInfo':'arriveInfo']['airplaneName']}',
  562. style: TextStyle(color: Color(0xFF999999),fontSize: zsp(20),fontWeight: FontWeight.normal),
  563. )
  564. ]
  565. ),
  566. ),
  567. margin: EdgeInsets.only(left: wsp(10)),
  568. )
  569. ],
  570. );
  571. },
  572. itemCount: 2,
  573. shrinkWrap: true,
  574. physics: NeverScrollableScrollPhysics(),
  575. ),
  576. ),
  577. Container(
  578. child: Text('¥ ${widget.orderDict['unitPrice']} x ${widget.orderDict['travelersNumber']}人',style: TextStyle(fontSize: zsp(28),color: Color(0xFFA2A2A2)),),
  579. padding: EdgeInsets.only(top: hsp(10)),
  580. )
  581. ],
  582. ),
  583. )
  584. ],
  585. ):widget.type==payType.business?Container(
  586. margin: EdgeInsets.only(top: hsp(10)),
  587. child: Column(
  588. children: [
  589. ListView.separated(
  590. shrinkWrap: true,
  591. itemBuilder: (context,index){
  592. return Container(
  593. color: Colors.white,
  594. child: Column(
  595. children: [
  596. widget.orderDict['charterType']=='1'?Container(
  597. padding: EdgeInsets.only(left: wsp(32),right: wsp(32),top: hsp(20),bottom: hsp(20)),
  598. child: Column(
  599. children: [
  600. Row(
  601. children: [
  602. Container(
  603. child: SingleChildScrollView(
  604. child: Text('${widget.orderDict['itineraries'][index]['setOutInfo']['display']}',
  605. style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),maxLines: 1,),
  606. scrollDirection: Axis.horizontal,
  607. ),
  608. width: (MediaQuery.of(context).size.width-hsp(240))/2,
  609. ),
  610. Image(height: hsp(60),width: hsp(60),image: AssetImage('lib/images/plane.png'),),
  611. Container(
  612. child: SingleChildScrollView(
  613. child: Text('${widget.orderDict['itineraries'][index]['arriveInfo']['display']}',
  614. style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),maxLines: 1,),
  615. scrollDirection: Axis.horizontal,
  616. ),
  617. width: (MediaQuery.of(context).size.width-hsp(240))/2,
  618. alignment: Alignment.centerRight,
  619. ),
  620. ],
  621. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  622. ),
  623. Row(
  624. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  625. children: [
  626. Container(
  627. child: Text('${widget.orderDict['itineraries'][index]['setOutInfo']['airplaneName']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  628. width: (MediaQuery.of(context).size.width-hsp(300))/2,
  629. ),
  630. // Text('${widget.orderDict['itineraries'][index]['time']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  631. Container(
  632. child: Text('${widget.orderDict['itineraries'][index]['arriveInfo']['airplaneName']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  633. width: (MediaQuery.of(context).size.width-hsp(300))/2,
  634. alignment: Alignment.centerRight,
  635. ),
  636. ],
  637. )
  638. ],
  639. ),
  640. ):Container(
  641. width: MediaQuery.of(context).size.width-hsp(60),
  642. child: ListView.builder(
  643. itemBuilder: (context,indexSub){
  644. return Row(
  645. crossAxisAlignment: CrossAxisAlignment.start,
  646. children: [
  647. Column(
  648. children: [
  649. Container(
  650. height: hsp(30),
  651. width: hsp(30),
  652. decoration: BoxDecoration(
  653. color: Colors.white,
  654. borderRadius: BorderRadius.all(Radius.circular(50)),
  655. border: Border.all(color: indexSub%2==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6))
  656. ),
  657. margin: EdgeInsets.only(top: hsp(10),bottom: hsp(7)),
  658. ),
  659. if(indexSub<1)Container(
  660. height: hsp(30),
  661. width: hsp(5),
  662. color: Color(0xFFCACAD4),
  663. )
  664. ],
  665. ),
  666. Container(
  667. child: RichText(
  668. text: TextSpan(
  669. text: '${widget.orderDict['itineraries'][index][indexSub==0?'setout':'arrive']}',
  670. style: TextStyle(color: Color(0xFF000000),fontSize: hsp(30),fontWeight: FontWeight.bold),
  671. children: [
  672. ]
  673. ),
  674. ),
  675. margin: EdgeInsets.only(left: wsp(10),top: hsp(5)),
  676. )
  677. ],
  678. );
  679. },
  680. itemCount: 2,
  681. shrinkWrap: true,
  682. physics: NeverScrollableScrollPhysics(),
  683. padding: EdgeInsets.only(top: hsp(10),bottom: hsp(10)),
  684. ),
  685. ),
  686. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),),
  687. Container(
  688. padding: EdgeInsets.only(left: wsp(32),right: wsp(32),top: hsp(20),bottom: hsp(20)),
  689. child: Row(
  690. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  691. children: [
  692. Column(
  693. children: [
  694. Text('出发',style: TextStyle(fontSize: zsp(24),color: Color(0xFF666666)),),
  695. RichText(
  696. text: TextSpan(
  697. text: _getDateStr('${widget.orderDict['itineraries'][index]['timeSetout']}'),style: TextStyle(fontSize: zsp(28),fontWeight: FontWeight.bold,color: Colors.black),
  698. children: [
  699. // TextSpan(
  700. // text: '今天',
  701. // style: TextStyle(fontSize: zsp(24),fontWeight: FontWeight.normal),
  702. // )
  703. ]
  704. ),
  705. )],
  706. crossAxisAlignment: CrossAxisAlignment.start,
  707. ),
  708. Column(
  709. children: [
  710. Text('到达',style: TextStyle(fontSize: zsp(24),color: Color(0xFF666666)),),
  711. RichText(
  712. text: TextSpan(
  713. text: _getDateStr('${widget.orderDict['itineraries'][index]['timeArrive']}'),style: TextStyle(fontSize: zsp(28),fontWeight: FontWeight.bold,color: Colors.black),
  714. children: [
  715. // TextSpan(
  716. // text: '今天',
  717. // style: TextStyle(fontSize: zsp(24),fontWeight: FontWeight.normal),
  718. // )
  719. ]
  720. ),
  721. )
  722. ],
  723. crossAxisAlignment: CrossAxisAlignment.start,
  724. ),
  725. // Icon(Icons.keyboard_arrow_right,size: hsp(50),color: Color(0xFFC1C1C1),)
  726. ],
  727. ),
  728. ),
  729. ],
  730. ),
  731. );
  732. },
  733. separatorBuilder: (context,index){
  734. return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),);
  735. },
  736. itemCount: (widget.orderDict['itineraries']).length,
  737. padding: EdgeInsets.all(0),
  738. physics: NeverScrollableScrollPhysics(),
  739. ),
  740. ],
  741. ),
  742. ):Column(
  743. children: [
  744. Container(
  745. padding: EdgeInsets.all(hsp(30)),
  746. margin: EdgeInsets.only(top: hsp(12)),
  747. width: MediaQuery.of(context).size.width,
  748. color: Colors.white,
  749. child: Row(
  750. crossAxisAlignment: CrossAxisAlignment.start,
  751. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  752. children: [
  753. Container(
  754. width: (MediaQuery.of(context).size.width-hsp(280)),
  755. padding: EdgeInsets.only(right: wsp(30)),
  756. child: ListView.builder(
  757. itemBuilder: (context,indexSub){
  758. return Stack(
  759. children: [
  760. Container(
  761. width: MediaQuery.of(context).size.width-hsp(280)-wsp(60),
  762. child: Column(
  763. children: [
  764. Text('${widget.orderDict[indexSub==0?'setoutInfo':'arriveInfo']['display']}',style: TextStyle(fontSize: zsp(30),color: Colors.black),),
  765. Text('${widget.orderDict[indexSub==0?'setoutInfo':'arriveInfo']['airplaneName']}',style: TextStyle(fontSize: zsp(22),color: Color(0xFF999999)),),
  766. ],
  767. crossAxisAlignment: CrossAxisAlignment.start,
  768. ),
  769. decoration: BoxDecoration(
  770. border: Border(left: BorderSide(width: 1,color: indexSub==1?Colors.transparent:Color(0xFFEFEFEE))),
  771. ),
  772. padding: EdgeInsets.only(left: 15,bottom: hsp(28)),
  773. margin: EdgeInsets.only(left: hsp(14)),
  774. ),
  775. Positioned(
  776. left: 0,
  777. width: 12,
  778. top: 0,
  779. child: Container(
  780. decoration: BoxDecoration(
  781. color: Colors.white,
  782. borderRadius: BorderRadius.all(Radius.circular(50)),
  783. border: Border.all(color: indexSub==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6))
  784. ),
  785. margin: EdgeInsets.only(top: 5),
  786. ),
  787. height: 17,
  788. ),
  789. Positioned(
  790. left: 4,
  791. width: 5,
  792. top: 0,
  793. child: Container(color: Colors.white),
  794. height: 5,
  795. ),
  796. Positioned(
  797. left: 4,
  798. width: 5,
  799. top: 17,
  800. child: Container(color: Colors.white),
  801. height: 5,
  802. ),
  803. ],
  804. );
  805. },
  806. itemCount: 2,
  807. shrinkWrap: true,
  808. padding: EdgeInsets.all(0),
  809. physics: NeverScrollableScrollPhysics(),
  810. )
  811. ),
  812. Container(
  813. width: (MediaQuery.of(context).size.width-wsp(280))*0.35,
  814. child: Text('¥ ${widget.orderDict['price']}x ${(widget.orderDict['travelersNumber']==null?1:widget.orderDict['travelersNumber'])}人',style: TextStyle(fontSize: zsp(28),color: Color(0xFFA2A2A2)),),
  815. padding: EdgeInsets.only(top: hsp(10)),
  816. )
  817. ],
  818. ),
  819. ),
  820. if(widget.orderDict['travelersNumber']!=null)Container(
  821. padding: EdgeInsets.all(hsp(30)),
  822. margin: EdgeInsets.only(top: hsp(12)),
  823. width: MediaQuery.of(context).size.width,
  824. color: Colors.white,
  825. child: Row(
  826. crossAxisAlignment: CrossAxisAlignment.start,
  827. children: [
  828. Container(
  829. width: wsp(150),
  830. alignment: Alignment.center,
  831. child: Text('乘机人',style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),),
  832. ),
  833. Container(
  834. width: MediaQuery.of(context).size.width-hsp(60)-wsp(150),
  835. child: ListView.separated(
  836. itemBuilder: (context,index){
  837. return Container(
  838. width: MediaQuery.of(context).size.width-hsp(60)-wsp(150),
  839. padding: EdgeInsets.only(bottom: index==1?0:hsp(20),top: index==0?0:hsp(20)),
  840. child: Column(
  841. crossAxisAlignment: CrossAxisAlignment.start,
  842. children: [
  843. Text('${widget.orderDict['personnelInfo'][index]['username']} ${widget.orderDict['personnelInfo'][index]['phone']}',style: TextStyle(fontSize: zsp(32),color: Color(0xFF343434),fontWeight: FontWeight.bold),),
  844. Text('身份证 ${widget.orderDict['personnelInfo'][index]['cardid']}',style: TextStyle(fontSize: zsp(25),color: Color(0xFF666666),))
  845. ],
  846. ),
  847. );
  848. },
  849. separatorBuilder: (context,index){
  850. return Divider(color: Color(0xFFE5E5E5),height: 0.5,thickness: 0.5,);
  851. },
  852. itemCount: widget.orderDict['personnelInfo']!=null?widget.orderDict['personnelInfo'].length:0,
  853. padding: EdgeInsets.all(0),
  854. shrinkWrap: true,
  855. ),
  856. ),
  857. ],
  858. ),
  859. ),
  860. ],
  861. ),
  862. Container(
  863. padding: EdgeInsets.all(hsp(30)),
  864. margin: EdgeInsets.only(top: hsp(12)),
  865. width: MediaQuery.of(context).size.width,
  866. color: Colors.white,
  867. child: RichText(
  868. text: TextSpan(
  869. text: '应付总额:',
  870. style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),
  871. children: [
  872. TextSpan(
  873. text: '¥${widget.orderDict['price']}',
  874. style: TextStyle(color: Color(0xFF007EFF),fontWeight: FontWeight.bold),
  875. )
  876. ]
  877. ),
  878. ),
  879. ),
  880. Container(
  881. padding: EdgeInsets.all(hsp(30)),
  882. margin: EdgeInsets.only(top: hsp(12)),
  883. width: MediaQuery.of(context).size.width,
  884. color: Colors.white,
  885. child: Text('订单编号:${widget.orderDict['orderSn']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF9A9A9A)),),
  886. ),
  887. Container(
  888. padding: EdgeInsets.all(hsp(30)),
  889. margin: EdgeInsets.only(top: hsp(12)),
  890. width: MediaQuery.of(context).size.width,
  891. color: Colors.white,
  892. child: Text('支付方式',style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),),
  893. ),
  894. ListView.separated(
  895. itemBuilder: (context,index){
  896. return GestureDetector(
  897. onTap: (){
  898. setState(() {
  899. _selected = index;
  900. });
  901. },
  902. behavior: HitTestBehavior.opaque,
  903. child: Container(
  904. height: hsp(92),
  905. color: Colors.white,
  906. padding: EdgeInsets.only(left: hsp(30),right: hsp(30)),
  907. child: Row(
  908. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  909. children: [
  910. Row(
  911. children: [
  912. Container(
  913. height: hsp(50),
  914. width: hsp(50),
  915. margin: EdgeInsets.only(right: hsp(25)),
  916. child: Image.asset(index==0?'lib/images/余额.png':index==1?'lib/images/wexinLogo.png':'lib/images/aliLogo.png'),
  917. ),
  918. Text(index==0?'余额':index==1?'微信支付':'支付宝',style: TextStyle(fontSize: zsp(30),color: Color(0xFF343434),)),
  919. ],
  920. ),
  921. Icon(Icons.check,color:index==_selected?Color(0xFF007EFF):Colors.transparent,size: hsp(40),),
  922. ],
  923. ),
  924. ),
  925. );
  926. },
  927. separatorBuilder: (context,index){
  928. return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F3),);
  929. },
  930. itemCount: 3,
  931. padding: EdgeInsets.all(0),
  932. physics: NeverScrollableScrollPhysics(),
  933. shrinkWrap: true,
  934. )
  935. ],
  936. ),
  937. ),
  938. ),
  939. Container(
  940. height: hsp(120),
  941. width: MediaQuery.of(context).size.width,
  942. color: Colors.white,
  943. padding: EdgeInsets.only(left: wsp(60),right: wsp(60)),
  944. child: Row(
  945. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  946. children: [
  947. GestureDetector(
  948. onTap: (){
  949. showDialog(
  950. context: context,
  951. builder: (context) {
  952. return AlertDialog(
  953. actionsPadding: EdgeInsets.all(0),
  954. title: Text('提示',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(36)),),
  955. content: Text('确认取消订单吗?',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(30))),
  956. actions: <Widget>[
  957. FlatButton(child: Text('取消',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(30))),onPressed: (){
  958. Navigator.pop(context);
  959. },),
  960. FlatButton(child: Text('确认',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(30))),onPressed: (){
  961. Navigator.pop(context);
  962. _postCancelOrderData();
  963. },),
  964. ],
  965. );
  966. }
  967. );
  968. },
  969. child: Container(
  970. height: hsp(88),
  971. width: wsp(300),
  972. decoration: BoxDecoration(
  973. borderRadius: BorderRadius.all(Radius.circular(50)),
  974. border: Border.all(color: Color(0xFFD9D9D9),width: 1)
  975. ),
  976. alignment: Alignment.center,
  977. child: Text('取消订单',style: TextStyle(fontSize: zsp(34),color: Color(0xFF343434)),),
  978. ),
  979. ),
  980. GestureDetector(
  981. onTap: () {
  982. _postOrderData();
  983. },
  984. child: Container(
  985. height: hsp(88),
  986. width: wsp(300),
  987. decoration: BoxDecoration(
  988. borderRadius: BorderRadius.all(Radius.circular(50)),
  989. color: Color(0xFF007EFF)
  990. ),
  991. alignment: Alignment.center,
  992. child: Text('去付款',style: TextStyle(fontSize: zsp(34),color: Colors.white),),
  993. ),
  994. )
  995. ],
  996. ),
  997. )
  998. ],
  999. ),
  1000. );
  1001. }
  1002. _postOrderData() async{
  1003. if(_selected==0){
  1004. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/balance/wx/checkBalance',parameter: {},isLoading: true,isToken: true,
  1005. refresh: (){});
  1006. if(dict!=null){
  1007. if(dict['code']==801){
  1008. _showAlertView(1);
  1009. }else{
  1010. showDialog(context: context,builder: (context){
  1011. return AlertDialog(
  1012. contentPadding: EdgeInsets.all(0),
  1013. actionsPadding: EdgeInsets.all(0),
  1014. buttonPadding: EdgeInsets.all(0),
  1015. insetPadding: EdgeInsets.all(0),
  1016. titlePadding: EdgeInsets.all(0),
  1017. backgroundColor: Colors.transparent,
  1018. content: ysPayKeybord(context,(value){
  1019. _postPayData(value);
  1020. },'${widget.orderDict['orderName']}',
  1021. '${widget.orderDict['price']}')
  1022. );
  1023. });
  1024. }
  1025. }
  1026. }else{
  1027. Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/applets/createPayOrder',
  1028. parameter: {'id':widget.orderDict['orderSn'],'way':_selected+1,'type':2},isLoading: true,
  1029. isToken: true,refresh: (){});
  1030. if(dict!=null){
  1031. if(_selected==2){
  1032. var payResult = await FlutterAlipay.pay('${dict['data']}');
  1033. String payResultStatus = payResult.resultStatus;
  1034. if (payResultStatus == "9000") {
  1035. print('=================================订单支付成功');
  1036. setState(() {
  1037. _isSucceed = true;
  1038. });
  1039. } else if (payResultStatus == "6001") {
  1040. print('=================================支付取消');
  1041. } else if (payResultStatus == "4000") {
  1042. print('=================================支付失败');
  1043. } else if (payResultStatus == "8000") {
  1044. print('=================================等待支付');
  1045. } else if (payResultStatus == "6002") {
  1046. print('=================================无网络');
  1047. } else if (payResultStatus == "5000") {
  1048. print('=================================重复支付');
  1049. } else {
  1050. print('=================================支付失败,未知错误');
  1051. }
  1052. }else if(_selected==1){
  1053. Map result = dict['data'];
  1054. fluwx.payWithWeChat(
  1055. appId: result['appId'].toString(),
  1056. partnerId: result['partnerId'].toString(),
  1057. prepayId: result['prepayId'].toString(),
  1058. packageValue: result['package'].toString(),
  1059. nonceStr: result['nonceStr'].toString(),
  1060. timeStamp: int.parse('${result['timeStamp']}'),
  1061. sign: result['paySign'].toString(),
  1062. ).then((data) {});
  1063. }
  1064. }
  1065. }
  1066. }
  1067. _getMin(String hours){
  1068. DateTime day1 = DateTime.parse(hours);
  1069. DateTime day2 = DateTime.now();
  1070. return day1.difference(day2).inMinutes;
  1071. }
  1072. _postCancelOrderData() async{
  1073. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/cancelOrder',
  1074. parameter: {'orderSn':widget.orderDict['orderSn']},isLoading: false,isToken: true);
  1075. if(dict!=null){
  1076. Navigator.pop(context);
  1077. }
  1078. }
  1079. _postPayData(String pass) async{
  1080. var dict = await ysRequestHttpEncrypt(context,type: requestType.post,api: '/app/applets/balance/balancePay',
  1081. parameter: {'orderSn':widget.orderDict['orderSn'],'price':widget.orderDict['price'],'password': pass},isLoading: true,isToken: true);
  1082. if(dict!=null){
  1083. if(dict==''){
  1084. setState(() {
  1085. _isSucceed = true;
  1086. });
  1087. }else if(dict['code']==804){
  1088. _showAlertView(2);
  1089. }else if(dict['code']==801){
  1090. _showAlertView(1);
  1091. }
  1092. }
  1093. }
  1094. _showAlertView (int type) async{
  1095. showCupertinoDialog(
  1096. context: context,
  1097. builder: (context) {
  1098. return CupertinoAlertDialog(
  1099. title: Text('提示\n'),
  1100. content: Text(type==1?'未设置支付密码':'余额不足请充值'),
  1101. actions: <Widget>[
  1102. CupertinoDialogAction(child: Text('取消'),onPressed: (){Navigator.pop(context);},),
  1103. CupertinoDialogAction(child: Text(type==1?'去设置':'去充值'),onPressed: (){
  1104. Navigator.pop(context);
  1105. Navigator.of(context).push(
  1106. CupertinoPageRoute(
  1107. builder: (context){
  1108. return type==1?YSSetPayPass():YSMoney();
  1109. }
  1110. )
  1111. );
  1112. },),
  1113. ],
  1114. );
  1115. }
  1116. );
  1117. }
  1118. _getDateStr(String date){
  1119. return date.substring(0,date.length-3);
  1120. }
  1121. }