YSOrderOne.dart 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:ysairplane/tools/YSNetWorking.dart';
  4. import 'package:ysairplane/tools/YSTools.dart';
  5. import 'YSPay.dart';
  6. class YSOrderOne extends StatefulWidget {
  7. final msgDict,confirmDict,orderDict;
  8. const YSOrderOne({Key key, this.msgDict, this.confirmDict, this.orderDict}) : super(key: key);
  9. @override
  10. _YSOrderOneState createState() => _YSOrderOneState();
  11. }
  12. class _YSOrderOneState extends State<YSOrderOne> {
  13. bool _isShow = false;
  14. bool _isDetail = false;
  15. List _packList = [];
  16. List _chooses = [];
  17. @override
  18. void initState() {
  19. Future.delayed(Duration(seconds: 0)).then((value){
  20. _getPackData();
  21. });
  22. super.initState();
  23. }
  24. @override
  25. Widget build(BuildContext context) {
  26. return Scaffold(
  27. body: SingleChildScrollView(
  28. child: Column(
  29. children: [
  30. Stack(
  31. children: [
  32. Container(
  33. height: MediaQuery.of(context).size.height-hsp(120),
  34. width: MediaQuery.of(context).size.width,
  35. color: Color(0xFFF1F2F4),
  36. child: SingleChildScrollView(
  37. child: Stack(
  38. children: [
  39. Container(
  40. height: MediaQuery.of(context).padding.top+hsp(380),
  41. width: MediaQuery.of(context).size.width,
  42. child: Image(
  43. image: widget.msgDict==null?AssetImage('lib/images/home3.png'):NetworkImage('${widget.msgDict['background']}'),
  44. fit: BoxFit.fill,
  45. ),
  46. ),
  47. GestureDetector(
  48. onTap: (){Navigator.pop(context);},
  49. child: Container(
  50. margin: EdgeInsets.only(left: wsp(32),top: MediaQuery.of(context).padding.top+hsp(30)),
  51. child: Icon(Icons.arrow_back_ios,size: hsp(40),color: Colors.white,),
  52. ),
  53. ),
  54. if(widget.msgDict!=null)Container(
  55. margin: EdgeInsets.only(left: wsp(32),top: MediaQuery.of(context).padding.top+hsp(130),right: wsp(32)),
  56. width: MediaQuery.of(context).size.width-wsp(64),
  57. alignment: Alignment.center,
  58. child: Text('${widget.msgDict['name']}',style: TextStyle(fontSize: zsp(40),color: Colors.white,fontWeight: FontWeight.bold),)
  59. ),
  60. if(widget.msgDict!=null)Container(
  61. margin: EdgeInsets.only(left: wsp(32),top: MediaQuery.of(context).padding.top+hsp(200),right: wsp(32)),
  62. width: MediaQuery.of(context).size.width-wsp(64),
  63. alignment: Alignment.center,
  64. child: Text('${widget.msgDict['subtitle']}',style: TextStyle(fontSize: zsp(28),color: Colors.white.withOpacity(0.6)),)
  65. ),
  66. Container(
  67. width: MediaQuery.of(context).size.width-wsp(60),
  68. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(300),left: wsp(30),bottom: hsp(40)),
  69. decoration: BoxDecoration(
  70. borderRadius: BorderRadius.all(Radius.circular(10)),
  71. color: Colors.white,
  72. ),
  73. child: Column(
  74. children: [
  75. ListView.separated(
  76. shrinkWrap: true,
  77. itemBuilder: (context,index){
  78. return Container(
  79. child: Column(
  80. children: [
  81. widget.orderDict['charterType']==1?Container(
  82. padding: EdgeInsets.only(left: wsp(32),right: wsp(32),top: hsp(20),bottom: hsp(20)),
  83. child: Column(
  84. children: [
  85. Row(
  86. children: [
  87. Container(
  88. child: Text('${widget.confirmDict['itineraries'][index]['setOutInfo']['display']}',
  89. style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),),
  90. width: (MediaQuery.of(context).size.width-hsp(210))/2,
  91. ),
  92. Image(height: hsp(60),width: hsp(60),image: AssetImage('lib/images/plane.png'),),
  93. Container(
  94. child: Text('${widget.confirmDict['itineraries'][index]['arriveInfo']['display']}',
  95. style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),),
  96. width: (MediaQuery.of(context).size.width-hsp(210))/2,
  97. alignment: Alignment.centerRight,
  98. ),
  99. ],
  100. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  101. ),
  102. Row(
  103. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  104. children: [
  105. Container(
  106. child: Text('${widget.confirmDict['itineraries'][index]['setOutInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  107. width: (MediaQuery.of(context).size.width-hsp(300))/2,
  108. ),
  109. Text('${widget.confirmDict['itineraries'][index]['time']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  110. Container(
  111. child: Text('${widget.confirmDict['itineraries'][index]['arriveInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  112. width: (MediaQuery.of(context).size.width-hsp(300))/2,
  113. alignment: Alignment.centerRight,
  114. ),
  115. ],
  116. )
  117. ],
  118. ),
  119. ):Container(
  120. width: MediaQuery.of(context).size.width-hsp(100),
  121. child: ListView.builder(
  122. itemBuilder: (context,indexSub){
  123. return Row(
  124. crossAxisAlignment: CrossAxisAlignment.start,
  125. children: [
  126. Column(
  127. children: [
  128. Container(
  129. height: hsp(30),
  130. width: hsp(30),
  131. decoration: BoxDecoration(
  132. color: Colors.white,
  133. borderRadius: BorderRadius.all(Radius.circular(50)),
  134. border: Border.all(color: indexSub%2==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6))
  135. ),
  136. margin: EdgeInsets.only(top: hsp(10),bottom: hsp(7)),
  137. ),
  138. if(indexSub<1)Container(
  139. height: hsp(30),
  140. width: hsp(5),
  141. color: Color(0xFFCACAD4),
  142. )
  143. ],
  144. ),
  145. Container(
  146. child: RichText(
  147. text: TextSpan(
  148. text: '${widget.confirmDict['itineraries'][index][indexSub==0?'setout':'arrive']}',
  149. style: TextStyle(color: Color(0xFF000000),fontSize: hsp(30),fontWeight: FontWeight.bold),
  150. children: [
  151. ]
  152. ),
  153. ),
  154. margin: EdgeInsets.only(left: wsp(10),top: hsp(5)),
  155. )
  156. ],
  157. );
  158. },
  159. itemCount: 2,
  160. shrinkWrap: true,
  161. physics: NeverScrollableScrollPhysics(),
  162. padding: EdgeInsets.all(hsp(30)),
  163. ),
  164. ),
  165. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),),
  166. Container(
  167. padding: EdgeInsets.only(left: wsp(32),right: wsp(32),top: hsp(20),bottom: hsp(20)),
  168. child: Row(
  169. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  170. children: [
  171. Column(
  172. children: [
  173. Text('出发',style: TextStyle(fontSize: zsp(24),color: Color(0xFF666666)),),
  174. RichText(
  175. text: TextSpan(
  176. text: _getDateStr('${widget.confirmDict['itineraries'][index]['timeSetout']}'),style: TextStyle(fontSize: zsp(28),fontWeight: FontWeight.bold,color: Colors.black),
  177. children: [
  178. // TextSpan(
  179. // text: '今天',
  180. // style: TextStyle(fontSize: zsp(24),fontWeight: FontWeight.normal),
  181. // )
  182. ]
  183. ),
  184. )],
  185. crossAxisAlignment: CrossAxisAlignment.start,
  186. ),
  187. Column(
  188. children: [
  189. Text('到达',style: TextStyle(fontSize: zsp(24),color: Color(0xFF666666)),),
  190. RichText(
  191. text: TextSpan(
  192. text: _getDateStr('${widget.confirmDict['itineraries'][index]['timeArrive']}'),style: TextStyle(fontSize: zsp(28),fontWeight: FontWeight.bold,color: Colors.black),
  193. children: [
  194. // TextSpan(
  195. // text: '今天',
  196. // style: TextStyle(fontSize: zsp(24),fontWeight: FontWeight.normal),
  197. // )
  198. ]
  199. ),
  200. )
  201. ],
  202. crossAxisAlignment: CrossAxisAlignment.start,
  203. ),
  204. // Icon(Icons.keyboard_arrow_right,size: hsp(50),color: Color(0xFFC1C1C1),)
  205. ],
  206. ),
  207. ),
  208. ],
  209. ),
  210. );
  211. },
  212. separatorBuilder: (context,index){
  213. return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),);
  214. },
  215. itemCount: (widget.confirmDict['itineraries']).length,
  216. padding: EdgeInsets.all(0),
  217. physics: NeverScrollableScrollPhysics(),
  218. ),
  219. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),),
  220. Container(
  221. width: MediaQuery.of(context).size.width-wsp(60),
  222. padding: EdgeInsets.all(wsp(32)),
  223. child: Text('出行人数 ${widget.confirmDict['travelersNumber']}人',style: TextStyle(fontSize: zsp(36),color: Colors.black),),
  224. ),
  225. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),),
  226. Container(
  227. padding: EdgeInsets.all(wsp(32)),
  228. child: Row(
  229. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  230. children: [
  231. Text('${widget.confirmDict['dtFlightInformation']['partnerName']}',style: TextStyle(fontSize: zsp(36),color: Colors.black),),
  232. // Icon(Icons.keyboard_arrow_right,size: hsp(50),color: Color(0xFFC1C1C1),)
  233. ],
  234. ),
  235. ),
  236. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE9E9E9),indent: wsp(32),endIndent: wsp(32),),
  237. GestureDetector(
  238. onTap: (){
  239. setState(() {
  240. _isShow = !_isShow;
  241. });
  242. },
  243. behavior: HitTestBehavior.opaque,
  244. child: Container(
  245. padding: EdgeInsets.all(wsp(32)),
  246. child: Row(
  247. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  248. children: [
  249. Text('更多服务',style: TextStyle(fontSize: zsp(36),color: Colors.black),),
  250. Icon(Icons.keyboard_arrow_down,size: hsp(50),color: Color(0xFFC1C1C1),)
  251. ],
  252. )
  253. ),
  254. ),
  255. if(_isShow==true)Container(
  256. decoration: BoxDecoration(
  257. color: Colors.white,
  258. borderRadius: BorderRadius.only(bottomRight: Radius.circular(10),bottomLeft: Radius.circular(10))
  259. ),
  260. child: ListView.builder(
  261. shrinkWrap: true,
  262. itemBuilder: (context,index){
  263. return Container(
  264. padding: EdgeInsets.only(bottom: wsp(20),left: hsp(30),right: hsp(30)),
  265. child: Row(
  266. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  267. children: [
  268. Row(
  269. children: [
  270. Text('${_packList[index]['name']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),),
  271. Container(
  272. width: wsp(50),
  273. child: GestureDetector(
  274. child: Icon(Icons.error_outline,size: hsp(40),color: Color(0xFF999999)),
  275. ),
  276. ),
  277. Text('${_packList[index]['price']}元',style: TextStyle(fontSize: zsp(28),color: Colors.black),),
  278. ],
  279. ),
  280. GestureDetector(
  281. child: Container(
  282. height: hsp(60),
  283. width: hsp(100),
  284. child: Image.asset(_chooses.contains(_packList[index])==true?'lib/images/kaiguankai.png':'lib/images/kaiguanguan.png'),
  285. ),
  286. onTap: (){
  287. setState(() {
  288. if(_chooses.contains(_packList[index])==true){
  289. _chooses.remove(_packList[index]);
  290. }else{
  291. _chooses.add(_packList[index]);
  292. }
  293. });
  294. },
  295. )
  296. ],
  297. ),
  298. );
  299. },
  300. itemCount: _packList.length,
  301. padding: EdgeInsets.all(0),
  302. physics: NeverScrollableScrollPhysics(),
  303. ),
  304. )
  305. ],
  306. ),
  307. )
  308. ],
  309. ),
  310. ),
  311. ),
  312. if(_isDetail==true)GestureDetector(
  313. onTap: (){
  314. setState(() {
  315. _isDetail = false;
  316. });
  317. },
  318. child: Container(
  319. height: MediaQuery.of(context).size.height-hsp(120),
  320. color: Colors.black45,
  321. child: Container(
  322. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-hsp(120)-hsp(370)),
  323. height: hsp(370),
  324. decoration: BoxDecoration(
  325. color: Colors.white,
  326. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))
  327. ),
  328. child: GestureDetector(
  329. onTap: (){},
  330. behavior: HitTestBehavior.opaque,
  331. child: Column(
  332. children: [
  333. Container(
  334. height: hsp(100),
  335. padding: EdgeInsets.only(left: 15,right: 15),
  336. child: Row(
  337. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  338. children: [
  339. GestureDetector(
  340. child: Text('关闭',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none),),
  341. onTap: (){
  342. setState(() {
  343. _isDetail = false;
  344. });
  345. },
  346. ),
  347. Text('明细',style: TextStyle(fontSize: 15,color: Color(0xFF000000),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  348. Container(width: wsp(50),),
  349. ],
  350. ),
  351. ),
  352. Container(
  353. height: hsp(100),
  354. color: Color(0xFFF7F8F9),
  355. padding: EdgeInsets.only(left: wsp(40),right: wsp(40),bottom: hsp(20),top: hsp(20)),
  356. child: Row(
  357. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  358. children: [
  359. Text('座位',style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000),decoration: TextDecoration.none),),
  360. Text('¥ ${widget.confirmDict['price']}x ${widget.confirmDict['travelersNumber']}人',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none),),
  361. ],
  362. ),
  363. ),
  364. Container(
  365. color: Color(0xFFF7F8F9),
  366. height: hsp(170),
  367. child: ListView.builder(
  368. padding: EdgeInsets.all(0),
  369. itemBuilder: (context,index){
  370. return Container(
  371. padding: EdgeInsets.only(left: wsp(40),right: wsp(40),bottom: hsp(10)),
  372. child: Row(
  373. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  374. children: [
  375. Text('${_chooses[index]['name']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF9A9A9A)),),
  376. Text('¥ ${_chooses[index]['price']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF9A9A9A)),),
  377. ],
  378. ),
  379. );
  380. },
  381. itemCount: _chooses.length,
  382. ),
  383. )
  384. ],
  385. ),
  386. ),
  387. ),
  388. ),
  389. )
  390. ],
  391. ),
  392. Container(
  393. height: hsp(120),
  394. width: MediaQuery.of(context).size.width,
  395. color: Colors.white,
  396. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  397. child: Row(
  398. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  399. children: [
  400. RichText(
  401. text: TextSpan(
  402. text: '参考价(¥)',
  403. style: TextStyle(fontSize: zsp(22),color: Color(0xFF181818)),
  404. children: [
  405. TextSpan(
  406. text: ' ${_getPrice()}',
  407. style: TextStyle(fontSize: zsp(40),color: Color(0xFFFF6600)),
  408. )
  409. ]
  410. ),
  411. ),
  412. GestureDetector(
  413. child: Row(
  414. children: [
  415. Text('明细',style: TextStyle(fontSize: zsp(22),color: Color(0xFF181818)),),
  416. Icon(Icons.keyboard_arrow_up,size: hsp(30),color: Color(0xFF007EFF),),
  417. ],
  418. ),
  419. onTap: (){
  420. setState(() {
  421. _isDetail = !_isDetail;
  422. });
  423. },
  424. ),
  425. GestureDetector(
  426. onTap: (){
  427. _postPlaneOrderData();
  428. },
  429. child: Container(
  430. height: hsp(70),
  431. padding: EdgeInsets.only(left: wsp(50),right: wsp(50)),
  432. decoration: BoxDecoration(
  433. color: Color(0xFF007EFF),
  434. borderRadius: BorderRadius.all(Radius.circular(50))
  435. ),
  436. alignment: Alignment.center,
  437. child: Text('立即预约',style: TextStyle(fontSize: zsp(30),color: Colors.white,fontWeight: FontWeight.bold),),
  438. ),
  439. )
  440. ],
  441. ),
  442. )
  443. ],
  444. ),
  445. ),
  446. );
  447. }
  448. _postPlaneOrderData() async{
  449. widget.orderDict['price'] = '${_getPrice()}';
  450. List array = [];
  451. _chooses.forEach((element) {
  452. array.add(element['id']);
  453. });
  454. widget.orderDict['serviceIds'] = array.join(',');
  455. Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/applets/airplaneorder/createOrder',parameter: widget.orderDict,isLoading: true,isToken: true);
  456. if(dict!=null){
  457. Navigator.of(context).push(
  458. CupertinoPageRoute(
  459. builder: (context){
  460. return YSPay(orderDict: dict['data'],type: payType.business,);
  461. }
  462. )
  463. );
  464. }
  465. }
  466. _getPackData() async{
  467. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneservice/get',parameter: {'type':7},isLoading: true,isToken: false);
  468. if(dict!=null){
  469. _packList = dict['data'];
  470. }
  471. }
  472. _getDateStr(String date){
  473. return date.substring(0,date.length-3);
  474. }
  475. _getPrice(){
  476. double price = double.parse('${widget.confirmDict['price']}')*int.parse('${widget.confirmDict['travelersNumber']}');
  477. _chooses.forEach((element) {
  478. price+=double.parse('${element['price']}');
  479. });
  480. return price;
  481. }
  482. }