YSOrderOne.dart 29 KB

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