YSContractPlane.dart 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_easyrefresh/easy_refresh.dart';
  4. import 'package:ysairplane/code/YSCity.dart';
  5. import 'package:ysairplane/code/YSContractPlaneDetail.dart';
  6. import 'package:ysairplane/tools/YSNetWorking.dart';
  7. import 'package:ysairplane/tools/YSTools.dart';
  8. class YSContractPlane extends StatefulWidget {
  9. @override
  10. _YSContractPlaneState createState() => _YSContractPlaneState();
  11. }
  12. class _YSContractPlaneState extends State<YSContractPlane> {
  13. int _type = 0;
  14. int _selected = 0;
  15. int _plansIndex = 0;
  16. int _page = 1;
  17. List _dataArray = [];
  18. Map _siftDict,_siftDict2;
  19. Map _startCity,_endCity,_startCity2,_endCity2;
  20. int _priceIndex = 0;
  21. int _dateIndex = 0;
  22. int _dateIndex2 = 0;
  23. int _distanceIndex = 0;
  24. @override
  25. void initState() {
  26. Future.delayed(Duration(seconds: 0)).then((value){
  27. _refreshData();
  28. _getSiftData();
  29. });
  30. super.initState();
  31. }
  32. @override
  33. Widget build(BuildContext context) {
  34. return Scaffold(
  35. endDrawer: Container(
  36. height: MediaQuery.of(context).size.height,
  37. width: MediaQuery.of(context).size.width*0.85,
  38. decoration: BoxDecoration(
  39. color: Colors.white,
  40. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),bottomLeft: Radius.circular(10))
  41. ),
  42. child: Column(
  43. children: [
  44. Container(
  45. height: MediaQuery.of(context).size.height-hsp(100),
  46. width: MediaQuery.of(context).size.width*0.85,
  47. child: SingleChildScrollView(
  48. padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(30),bottom: hsp(30)),
  49. child: _type==2?Column(
  50. children: [
  51. Container(
  52. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  53. child: Column(
  54. crossAxisAlignment: CrossAxisAlignment.start,
  55. children: [
  56. Text('航线',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),),
  57. ListView.separated(
  58. shrinkWrap: true,
  59. itemBuilder: (context,index){
  60. return Container(
  61. child: Row(
  62. children: [
  63. Text('出发地',style: TextStyle(fontSize: zsp(24),color: Color(0xFF2C7CF6)),),
  64. Container(
  65. margin: EdgeInsets.only(left: wsp(40)),
  66. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  67. height: hsp(60),
  68. decoration: BoxDecoration(
  69. color: Color(0xFFF4F4F4),
  70. borderRadius: BorderRadius.all(Radius.circular(50))
  71. ),
  72. alignment: Alignment.center,
  73. child: Row(
  74. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  75. children: [
  76. Text('西安',style: TextStyle(fontSize: zsp(24),color: Colors.black),),
  77. Icon(Icons.keyboard_arrow_right,size: hsp(40),color: Color(0xFF2C7CF6),)
  78. ],
  79. )
  80. )
  81. ],
  82. ),
  83. );
  84. },
  85. itemCount: 2,
  86. padding: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
  87. separatorBuilder: (BuildContext context, int index) {
  88. return Divider(height: hsp(30),thickness: hsp(30),color: Colors.white,);
  89. },
  90. ),
  91. ],
  92. ),
  93. ),
  94. Divider(height: hsp(10),thickness: hsp(10),color: Color(0xFFF4F4F4),),
  95. Container(
  96. width: MediaQuery.of(context).size.width*0.85,
  97. padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: wsp(20),bottom: wsp(30)),
  98. child: Column(
  99. crossAxisAlignment: CrossAxisAlignment.start,
  100. children: [
  101. Text('行程距离',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),),
  102. Container(
  103. margin: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
  104. child: Row(
  105. children: [
  106. Container(
  107. height: hsp(60),
  108. width: wsp(180),
  109. decoration: BoxDecoration(
  110. color: Color(0xFFF4F4F4),
  111. borderRadius: BorderRadius.all(Radius.circular(50))
  112. ),
  113. alignment: Alignment.center,
  114. child: Text('最小距离',style: TextStyle(fontSize: zsp(24),color: Colors.black),),
  115. ),
  116. Container(
  117. height: hsp(3),
  118. width: wsp(30),
  119. color: Color(0xFFF4F4F4),
  120. margin: EdgeInsets.only(left: wsp(33),right: wsp(33)),
  121. ),
  122. Container(
  123. height: hsp(60),
  124. width: wsp(180),
  125. decoration: BoxDecoration(
  126. color: Color(0xFFF4F4F4),
  127. borderRadius: BorderRadius.all(Radius.circular(50))
  128. ),
  129. alignment: Alignment.center,
  130. child: Text('最大距离',style: TextStyle(fontSize: zsp(24),color: Colors.black),),
  131. )
  132. ],
  133. ),
  134. ),
  135. ListView.separated(
  136. itemBuilder: (context,index){
  137. return Container(
  138. height: hsp(60),
  139. width: MediaQuery.of(context).size.width,
  140. decoration: BoxDecoration(
  141. color: Color(0xFFF4F4F4),
  142. borderRadius: BorderRadius.all(Radius.circular(50))
  143. ),
  144. alignment: Alignment.center,
  145. child: Text('100公里 -300公里 30%的选择',style: TextStyle(fontSize: zsp(24),color: Colors.black),),
  146. );
  147. },
  148. separatorBuilder: (context,index){
  149. return Divider(color: Colors.white,height: hsp(30),thickness: hsp(30),);
  150. },
  151. itemCount: 3,
  152. shrinkWrap: true,
  153. padding: EdgeInsets.all(0),
  154. physics: NeverScrollableScrollPhysics(),
  155. )
  156. ],
  157. ),
  158. ),
  159. Divider(height: hsp(10),thickness: hsp(10),color: Color(0xFFF4F4F4),),
  160. Container(
  161. width: MediaQuery.of(context).size.width*0.85,
  162. padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: wsp(20),bottom: wsp(30)),
  163. child: Column(
  164. crossAxisAlignment: CrossAxisAlignment.start,
  165. children: [
  166. Row(
  167. children: [
  168. Text('出发时间',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),),
  169. Icon(Icons.keyboard_arrow_right,size: hsp(40),color: Color(0xFF2C7CF6),)
  170. ],
  171. ),
  172. Container(
  173. width: MediaQuery.of(context).size.width*0.85,
  174. padding: EdgeInsets.only(top: hsp(30)),
  175. height: hsp(90),
  176. child: ListView.separated(
  177. itemBuilder: (context,index){
  178. return Container(
  179. height: hsp(60),
  180. width: wsp(200),
  181. decoration: BoxDecoration(
  182. color: Color(0xFFF4F4F4),
  183. borderRadius: BorderRadius.all(Radius.circular(50))
  184. ),
  185. alignment: Alignment.center,
  186. child: Text('2020.09.18',style: TextStyle(fontSize: zsp(24),color: Colors.black),),
  187. );
  188. },
  189. separatorBuilder: (context,index){
  190. return Container(color: Colors.white,width: wsp(24),);
  191. },
  192. itemCount: 3,
  193. // shrinkWrap: true,
  194. scrollDirection: Axis.horizontal,
  195. padding: EdgeInsets.all(0),
  196. ),
  197. )
  198. ],
  199. ),
  200. )
  201. ],
  202. ):Column(
  203. children: [
  204. Container(
  205. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  206. child: Column(
  207. crossAxisAlignment: CrossAxisAlignment.start,
  208. children: [
  209. // Text('预订方式',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),),
  210. // Container(
  211. // margin: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
  212. // child: Row(
  213. // children: [
  214. // GestureDetector(
  215. // child: Container(
  216. // height: hsp(60),
  217. // width: wsp(180),
  218. // decoration: BoxDecoration(
  219. // color: _way==0?Color(0xFFECF4FF):Color(0xFFF4F4F4),
  220. // border: Border.all(color: _way==0?Color(0xFF2C7CF6):Colors.transparent,width: 1),
  221. // borderRadius: BorderRadius.all(Radius.circular(50))
  222. // ),
  223. // alignment: Alignment.center,
  224. // child: Text('拼座',style: TextStyle(fontSize: zsp(24),color: _way==0?Color(0xFF2C7CF6):Colors.black),),
  225. // ),
  226. // onTap: (){
  227. // setState(() {
  228. // _way = 0;
  229. // });
  230. // },
  231. // ),
  232. // GestureDetector(
  233. // onTap: (){
  234. // setState(() {
  235. // _way = 1;
  236. // });
  237. // },
  238. // child: Container(
  239. // margin: EdgeInsets.only(left: wsp(25)),
  240. // height: hsp(60),
  241. // width: wsp(180),
  242. // decoration: BoxDecoration(
  243. // color: _way==1?Color(0xFFECF4FF):Color(0xFFF4F4F4),
  244. // border: Border.all(color: _way==1?Color(0xFF2C7CF6):Colors.transparent,width: 1),
  245. // borderRadius: BorderRadius.all(Radius.circular(50))
  246. // ),
  247. // alignment: Alignment.center,
  248. // child: Text('整机',style: TextStyle(fontSize: zsp(24),color: _way==1?Color(0xFF2C7CF6):Colors.black),),
  249. // ),
  250. // )
  251. // ],
  252. // ),
  253. // ),
  254. Text('航线',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),),
  255. ListView.separated(
  256. shrinkWrap: true,
  257. itemBuilder: (context,index){
  258. return GestureDetector(
  259. onTap: (){
  260. Navigator.of(context).push(
  261. CupertinoPageRoute(
  262. builder: (context){
  263. return YSCity();
  264. }
  265. )
  266. ).then((value){
  267. if(value!=null){
  268. if(index==0){
  269. _startCity = value;
  270. }else{
  271. _endCity = value;
  272. }
  273. setState(() {
  274. });
  275. }
  276. });
  277. },
  278. child: Container(
  279. child: Row(
  280. children: [
  281. Text('出发地',style: TextStyle(fontSize: zsp(24),color: Color(0xFF2C7CF6)),),
  282. Container(
  283. margin: EdgeInsets.only(left: wsp(40)),
  284. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  285. height: hsp(60),
  286. decoration: BoxDecoration(
  287. color: Color(0xFFF4F4F4),
  288. borderRadius: BorderRadius.all(Radius.circular(50))
  289. ),
  290. alignment: Alignment.center,
  291. child: Row(
  292. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  293. children: [
  294. Text(index==0?'${_startCity!=null?_startCity['display']:'请选择'}':'${_endCity!=null?_endCity['display']:'请选择'}',style: TextStyle(fontSize: zsp(24),color: Colors.black),),
  295. Icon(Icons.keyboard_arrow_right,size: hsp(40),color: Color(0xFF2C7CF6),)
  296. ],
  297. )
  298. )
  299. ],
  300. ),
  301. ),
  302. );
  303. },
  304. itemCount: 2,
  305. padding: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
  306. separatorBuilder: (BuildContext context, int index) {
  307. return Divider(height: hsp(30),thickness: hsp(30),color: Colors.white,);
  308. },
  309. ),
  310. ],
  311. ),
  312. ),
  313. Divider(height: hsp(10),thickness: hsp(10),color: Color(0xFFF4F4F4),),
  314. Container(
  315. width: MediaQuery.of(context).size.width*0.85,
  316. padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: wsp(20),bottom: wsp(30)),
  317. child: Column(
  318. crossAxisAlignment: CrossAxisAlignment.start,
  319. children: [
  320. Text('价格区间',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),),
  321. Container(
  322. margin: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
  323. child: Row(
  324. children: [
  325. Container(
  326. height: hsp(60),
  327. width: wsp(180),
  328. decoration: BoxDecoration(
  329. color: Color(0xFFF4F4F4),
  330. borderRadius: BorderRadius.all(Radius.circular(50))
  331. ),
  332. alignment: Alignment.center,
  333. child: Text(_siftDict==null?'':'${_siftDict['price'][_priceIndex]['min']}元',style: TextStyle(fontSize: zsp(24),color: Colors.black),),
  334. ),
  335. Container(
  336. height: hsp(3),
  337. width: wsp(30),
  338. color: Color(0xFFF4F4F4),
  339. margin: EdgeInsets.only(left: wsp(33),right: wsp(33)),
  340. ),
  341. Container(
  342. height: hsp(60),
  343. width: wsp(180),
  344. decoration: BoxDecoration(
  345. color: Color(0xFFF4F4F4),
  346. borderRadius: BorderRadius.all(Radius.circular(50))
  347. ),
  348. alignment: Alignment.center,
  349. child: Text(_siftDict==null?'':'${_siftDict['price'][_priceIndex]['max']}元',style: TextStyle(fontSize: zsp(24),color: Colors.black),),
  350. )
  351. ],
  352. ),
  353. ),
  354. ListView.separated(
  355. itemBuilder: (context,index){
  356. return GestureDetector(
  357. onTap: (){
  358. setState(() {
  359. _priceIndex = index;
  360. });
  361. },
  362. child: Container(
  363. height: hsp(60),
  364. width: MediaQuery.of(context).size.width,
  365. decoration: BoxDecoration(
  366. color: _priceIndex==index?Color(0xFFECF4FF):Color(0xFFF4F4F4),
  367. border: Border.all(color: _priceIndex==index?Color(0xFF2C7CF6):Colors.transparent,width: 1),
  368. borderRadius: BorderRadius.all(Radius.circular(50))
  369. ),
  370. alignment: Alignment.center,
  371. child: Text('${_siftDict['price'][index]['min']}元 - ${_siftDict['price'][index]['max']}元 ${_siftDict['price'][index]['rate']}的选择',
  372. style: TextStyle(fontSize: zsp(24),color: _priceIndex==index?Color(0xFF2C7CF6):Colors.black),),
  373. ),
  374. );
  375. },
  376. separatorBuilder: (context,index){
  377. return Divider(color: Colors.white,height: hsp(30),thickness: hsp(30),);
  378. },
  379. itemCount: _siftDict!=null?_siftDict['price'].length:0,
  380. shrinkWrap: true,
  381. padding: EdgeInsets.all(0),
  382. physics: NeverScrollableScrollPhysics(),
  383. )
  384. ],
  385. ),
  386. ),
  387. Divider(height: hsp(10),thickness: hsp(10),color: Color(0xFFF4F4F4),),
  388. Container(
  389. width: MediaQuery.of(context).size.width*0.85,
  390. padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: wsp(20),bottom: wsp(30)),
  391. child: Column(
  392. crossAxisAlignment: CrossAxisAlignment.start,
  393. children: [
  394. GestureDetector(
  395. onTap: (){
  396. showModalBottomSheet(
  397. context: context,
  398. builder: (context){
  399. return YSDatePicker(
  400. choose: (value){
  401. DateTime date = DateTime.parse(value);
  402. String timeStr = '${date.year}.${date.month}.${date.day}';
  403. if(_siftDict['date'].contains(timeStr)==true){
  404. _siftDict['date'].remove(timeStr);
  405. }
  406. _siftDict['date'].insert(0, timeStr);
  407. _dateIndex = 0;
  408. setState(() {
  409. });
  410. },
  411. );
  412. }
  413. );
  414. },
  415. child: Row(
  416. children: [
  417. Text('出发时间',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),),
  418. Icon(Icons.keyboard_arrow_right,size: hsp(40),color: Color(0xFF2C7CF6),)
  419. ],
  420. ),
  421. ),
  422. Container(
  423. width: MediaQuery.of(context).size.width*0.85,
  424. padding: EdgeInsets.only(top: hsp(30)),
  425. height: hsp(90),
  426. child: ListView.separated(
  427. itemBuilder: (context,index){
  428. return GestureDetector(
  429. onTap: (){
  430. setState(() {
  431. _dateIndex = index;
  432. });
  433. },
  434. child: Container(
  435. height: hsp(60),
  436. width: wsp(200),
  437. decoration: BoxDecoration(
  438. color: _dateIndex==index?Color(0xFFECF4FF):Color(0xFFF4F4F4),
  439. border: Border.all(color: _dateIndex==index?Color(0xFF2C7CF6):Colors.transparent,width: 1),
  440. borderRadius: BorderRadius.all(Radius.circular(50))
  441. ),
  442. alignment: Alignment.center,
  443. child: Text('${_siftDict['date'][index]}',style: TextStyle(fontSize: zsp(24),color: _dateIndex==index?Color(0xFF2C7CF6):Colors.black),),
  444. ),
  445. );
  446. },
  447. separatorBuilder: (context,index){
  448. return Container(color: Colors.white,width: wsp(24),);
  449. },
  450. itemCount: _siftDict!=null?_siftDict['date'].length:0,
  451. // shrinkWrap: true,
  452. scrollDirection: Axis.horizontal,
  453. padding: EdgeInsets.all(0),
  454. ),
  455. )
  456. ],
  457. ),
  458. ),
  459. Divider(height: hsp(10),thickness: hsp(10),color: Color(0xFFF4F4F4),),
  460. Container(
  461. width: MediaQuery.of(context).size.width*0.85,
  462. padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: wsp(20),bottom: wsp(30)),
  463. child: Column(
  464. crossAxisAlignment: CrossAxisAlignment.start,
  465. children: [
  466. Row(
  467. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  468. children: [
  469. Text('航空公司',style: TextStyle(fontSize: zsp(26),color: Colors.black,fontWeight: FontWeight.bold),),
  470. Icon(Icons.keyboard_arrow_down,size: hsp(40),color: Color(0xFF2C7CF6),)
  471. ],
  472. ),
  473. if(_siftDict!=null)Container(
  474. width: MediaQuery.of(context).size.width*0.85,
  475. padding: EdgeInsets.only(top: hsp(20)),
  476. child: Wrap(
  477. alignment: WrapAlignment.start,
  478. children: <Widget>[
  479. for (int i =0;i<(_siftDict['partner']).length;i++ ) GestureDetector(
  480. behavior: HitTestBehavior.opaque,
  481. onTap: (){
  482. setState(() {
  483. _plansIndex = i;
  484. });
  485. },
  486. child: Container(
  487. margin: EdgeInsets.symmetric(vertical: hsp(16), horizontal: hsp(16)),
  488. decoration: BoxDecoration(
  489. color: _plansIndex==i?Color(0xFFECF4FF):Color(0xFFF4F4F4),
  490. border: Border.all(color: _plansIndex==i?Color(0xFF2C7CF6):Colors.transparent,width: 1),
  491. borderRadius: BorderRadius.all(Radius.circular(50))
  492. ),
  493. padding: EdgeInsets.only(left: wsp(30), right: wsp(30),top: hsp(10),bottom: hsp(10)),
  494. child: Text('${_siftDict['partner'][i]['partnerName']}', style: TextStyle(fontSize: zsp(26),color: _plansIndex==i?Color(0xFF2C7CF6):Colors.black), textAlign: TextAlign.center,),
  495. ),
  496. )
  497. ]
  498. ),
  499. )
  500. ],
  501. ),
  502. )
  503. ],
  504. ),
  505. ),
  506. ),
  507. Container(
  508. height: hsp(100),
  509. padding: EdgeInsets.only(left: wsp(40),right: wsp(40)),
  510. child: Row(
  511. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  512. children: [
  513. GestureDetector(
  514. onTap: (){
  515. _plansIndex = 0;
  516. _priceIndex = 0;
  517. _dateIndex = 0;
  518. _startCity = null;
  519. _endCity = null;
  520. _siftDict2 = _siftDict;
  521. _siftDict = null;
  522. _refreshData();
  523. Navigator.pop(context);
  524. },
  525. child: Container(
  526. child: Text('重置',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(26),color: Colors.black),),
  527. width: (MediaQuery.of(context).size.width*0.85-wsp(100))/2,
  528. height: hsp(70),
  529. alignment: Alignment.center,
  530. decoration: BoxDecoration(
  531. borderRadius: BorderRadius.all(Radius.circular(50)),
  532. border: Border.all(color: Color(0xFFB2B2B2),width: 1)
  533. ),
  534. ),
  535. ),
  536. GestureDetector(
  537. onTap: (){
  538. _refreshData();
  539. Navigator.pop(context);
  540. },
  541. child: Container(
  542. child: Text('确定',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(26),color: Colors.white),),
  543. width: (MediaQuery.of(context).size.width*0.85-wsp(100))/2,
  544. height: hsp(70),
  545. alignment: Alignment.center,
  546. decoration: BoxDecoration(
  547. borderRadius: BorderRadius.all(Radius.circular(50)),
  548. color: Color(0xFF2C7CF6)
  549. ),
  550. ),
  551. )
  552. ],
  553. ),
  554. )
  555. ],
  556. ),
  557. ),
  558. backgroundColor: Color(0xFFF1F2F3),
  559. body: SingleChildScrollView(
  560. child: Container(
  561. width: MediaQuery.of(context).size.width,
  562. child: Column(
  563. children: [
  564. Container(
  565. height: MediaQuery.of(context).padding.top+hsp(20)+hsp(100),
  566. color: Colors.white,
  567. padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: MediaQuery.of(context).padding.top+hsp(20),bottom: hsp(20)),
  568. child: Row(
  569. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  570. children: [
  571. GestureDetector(child: Icon(Icons.arrow_back_ios,size: wsp(40),color: Color(0xFF000000),),onTap: (){Navigator.pop(context);},),
  572. Container(
  573. width: MediaQuery.of(context).size.width-wsp(200),
  574. height: hsp(60),
  575. decoration: BoxDecoration(
  576. color: Color(0xFFF7F7F7),
  577. border: Border.all(color: Color(0xFF2C7CF6),width: hsp(2)),
  578. borderRadius: BorderRadius.all(Radius.circular(5)),
  579. ),
  580. child: ListView.separated(
  581. padding: EdgeInsets.all(0),
  582. itemBuilder: (context,index){
  583. return GestureDetector(
  584. onTap: (){
  585. _type = index;
  586. _refreshData();
  587. },
  588. child: Container(
  589. width: (MediaQuery.of(context).size.width-wsp(200))/3,
  590. height: hsp(60),
  591. alignment: Alignment.center,
  592. child: Text(index==0?'拼座':index==1?'整机':'任意飞',style: TextStyle(color: _type==index?Colors.white:Color(0xFF2C7CF6),fontSize: zsp(26)),),
  593. decoration: BoxDecoration(
  594. color: _type==index?Color(0xFF2C7DF7):Colors.transparent,
  595. borderRadius: index==0?BorderRadius.only(bottomLeft: Radius.circular(2),topLeft: Radius.circular(2)):
  596. index==2?BorderRadius.only(topRight: Radius.circular(5),bottomRight: Radius.circular(5)):BorderRadius.all(Radius.circular(0))
  597. ),
  598. ),
  599. );
  600. },
  601. separatorBuilder: (context,index){
  602. return Container(
  603. height: hsp(60),
  604. width: hsp(2),
  605. color: Color(0xFF2C7CF6),
  606. );
  607. },
  608. itemCount: 3,
  609. scrollDirection: Axis.horizontal,
  610. ),
  611. ),
  612. Icon(Icons.search,size: wsp(40),color: Color(0xFF000000),)
  613. ],
  614. ),
  615. ),
  616. Container(
  617. width: MediaQuery.of(context).size.width,
  618. height: hsp(80),
  619. color: Colors.white,
  620. child: ListView.builder(
  621. itemBuilder: (context,index){
  622. return GestureDetector(
  623. behavior: HitTestBehavior.opaque,
  624. onTap: (){
  625. if(index==2){
  626. if(_siftDict==null&&_siftDict2!=null){
  627. setState(() {
  628. _siftDict = _siftDict2;
  629. });
  630. }
  631. Scaffold.of(context).openEndDrawer();
  632. }else{
  633. _selected = index;
  634. _refreshData();
  635. }
  636. },
  637. child: Container(
  638. alignment: Alignment.center,
  639. width: MediaQuery.of(context).size.width/3,
  640. height: hsp(80),
  641. child: Text(index==0?'综合':index==1?'销量':'筛选',style: TextStyle(fontSize: zsp(26),color: _selected==index?Color(0xFF007EFF):Color(0xFF222222),fontWeight: _selected==index?FontWeight.bold:FontWeight.normal),),
  642. ),
  643. );
  644. },
  645. itemCount: 3,
  646. scrollDirection: Axis.horizontal,
  647. ),
  648. ),
  649. Stack(
  650. children: [
  651. Container(
  652. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(200),
  653. child: EasyRefresh(
  654. onRefresh: _refreshData,
  655. onLoad: _loadMoreData,
  656. header: TaurusHeader(
  657. ),
  658. footer: TaurusFooter(
  659. ),
  660. child: ListView.separated(
  661. itemBuilder: (context,index){
  662. return GestureDetector(
  663. onTap: (){
  664. Navigator.of(context).push(
  665. CupertinoPageRoute(
  666. builder: (context){
  667. return YSContractPlaneDetail(contractId: _dataArray[index]['id'],isWhole: _type,);
  668. }
  669. )
  670. );
  671. },
  672. behavior: HitTestBehavior.opaque,
  673. child: _type!=5?Container(
  674. padding: EdgeInsets.only(bottom: hsp(30)),
  675. margin: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)),
  676. decoration: BoxDecoration(
  677. color: Colors.white,
  678. borderRadius: BorderRadius.all(Radius.circular(5))
  679. ),
  680. child: Column(
  681. crossAxisAlignment: CrossAxisAlignment.start,
  682. children: [
  683. Container(
  684. height: hsp(50),
  685. width: wsp(200),
  686. alignment: Alignment.center,
  687. child: Text(_getDateStr('${_dataArray[index]['flightTime']}'),style: TextStyle(color: Color(0xFF007AFF),fontSize: zsp(24)),),
  688. decoration: BoxDecoration(
  689. color: Color(0xFFF3F9FF),
  690. borderRadius: BorderRadius.only(topLeft: Radius.circular(5))
  691. ),
  692. ),
  693. Row(
  694. children: [
  695. Container(
  696. width: (MediaQuery.of(context).size.width-wsp(56))*0.6,
  697. padding: EdgeInsets.only(top: hsp(30),left: wsp(40),right: wsp(40)),
  698. child: Column(
  699. children: [
  700. Row(
  701. children: [
  702. Text('${_dataArray[index]['setoutInfo']['display']} ',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),),
  703. Container(
  704. height: 2,
  705. width: wsp(50),
  706. color: Color(0xFFCCCCCC),
  707. ),
  708. Text(' ${_dataArray[index]['arriveInfo']['display']}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),)
  709. ],
  710. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  711. ),
  712. Container(
  713. child: Row(
  714. children: [
  715. Text('${_dataArray[index]['setoutInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  716. Text('${_dataArray[index]['arriveInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  717. ],
  718. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  719. ),
  720. margin: EdgeInsets.only(top: hsp(10),bottom: hsp(20)),
  721. ),
  722. Row(
  723. children: [
  724. Container(
  725. color: Color(0xFF000000),
  726. height: hsp(35),
  727. child: Row(
  728. children: [
  729. Image(image: AssetImage('lib/images/vip2.png'),height: hsp(15),width: wsp(16),),
  730. Text(' ${_dataArray[index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(18),color: Color(0xFFF9DEAC)),)
  731. ],
  732. ),
  733. padding: EdgeInsets.only(left: wsp(5),right: wsp(5)),
  734. ),
  735. Container(
  736. padding: EdgeInsets.only(left: wsp(5),right: wsp(5)),
  737. height: hsp(35),
  738. child: Text('座位${_dataArray[index]['dtFlightInformation']['seatNum']}',style: TextStyle(fontSize: zsp(20),color: Color(0xFF565656)),),
  739. decoration: BoxDecoration(
  740. border: Border.all(color: Color(0xFF565656),width: 0.5)
  741. ),
  742. alignment: Alignment.center,
  743. ),
  744. ],
  745. )
  746. ],
  747. ),
  748. ),
  749. Container(
  750. width: (MediaQuery.of(context).size.width-wsp(56))*0.4,
  751. child: Column(
  752. children: [
  753. RichText(
  754. text: TextSpan(
  755. text: '¥ ',
  756. style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.normal),
  757. children: [
  758. TextSpan(
  759. text: '${_dataArray[index]['discountPrice']}',
  760. style: TextStyle(fontSize: zsp(42),fontWeight: FontWeight.bold),
  761. ),
  762. TextSpan(
  763. text: ' 元起',
  764. )
  765. ]
  766. ),
  767. ),
  768. Container(
  769. child: Text('原价: ${_dataArray[index]['price']}元起/座',style: TextStyle(fontSize: zsp(24),color: Color(0xFFA2A2A2),decoration: TextDecoration.lineThrough),),
  770. margin: EdgeInsets.only(top: hsp(10)),
  771. )
  772. ],
  773. ),
  774. ),
  775. ],
  776. )
  777. ],
  778. ),
  779. ):Container(
  780. padding: EdgeInsets.all(hsp(30)),
  781. color: Colors.white,
  782. child: Row(
  783. children: [
  784. Container(
  785. height: hsp(240),
  786. width: hsp(240),
  787. decoration: BoxDecoration(
  788. color: Colors.lightGreen,
  789. borderRadius: BorderRadius.all(Radius.circular(5))
  790. ),
  791. ),
  792. Container(
  793. width: (MediaQuery.of(context).size.width-hsp(280))*0.55,
  794. padding: EdgeInsets.only(top: hsp(30),left: wsp(30),right: wsp(30)),
  795. child: Column(
  796. crossAxisAlignment: CrossAxisAlignment.start,
  797. children: [
  798. Row(
  799. children: [
  800. Text('${_dataArray[index]['setoutInfo']['display']}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),),
  801. Container(
  802. height: 2,
  803. width: wsp(40),
  804. color: Color(0xFFCCCCCC),
  805. ),
  806. Text('${_dataArray[index]['arriveInfo']['display']}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),)
  807. ],
  808. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  809. ),
  810. Container(
  811. child: Row(
  812. children: [
  813. Text('${_dataArray[index]['setoutInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  814. Text('${_dataArray[index]['arriveInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  815. ],
  816. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  817. ),
  818. margin: EdgeInsets.only(top: hsp(10),bottom: hsp(20)),
  819. ),
  820. Row(
  821. children: [
  822. Container(
  823. color: Color(0xFF000000),
  824. height: hsp(35),
  825. child: Row(
  826. children: [
  827. Image(image: AssetImage('lib/images/vip2.png'),height: hsp(15),width: wsp(16),),
  828. Text(' ${_dataArray[index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(18),color: Color(0xFFF9DEAC)),)
  829. ],
  830. ),
  831. padding: EdgeInsets.only(left: wsp(5),right: wsp(5)),
  832. ),
  833. Container(
  834. padding: EdgeInsets.only(left: wsp(5),right: wsp(5)),
  835. height: hsp(35),
  836. child: Text('座位${_dataArray[index]['dtFlightInformation']['seatNum']}',style: TextStyle(fontSize: zsp(20),color: Color(0xFF565656)),),
  837. decoration: BoxDecoration(
  838. border: Border.all(color: Color(0xFF565656),width: 0.5)
  839. ),
  840. alignment: Alignment.center,
  841. ),
  842. ],
  843. ),
  844. Container(
  845. child: Text('8月12日 18:00',style: TextStyle(fontSize: zsp(28),color: Colors.black,fontWeight: FontWeight.bold),),
  846. margin: EdgeInsets.only(top: hsp(20)),
  847. )
  848. ],
  849. ),
  850. ),
  851. Container(
  852. width: (MediaQuery.of(context).size.width-wsp(280))*0.42,
  853. child: Column(
  854. children: [
  855. RichText(
  856. text: TextSpan(
  857. text: '¥ ',
  858. style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.normal),
  859. children: [
  860. TextSpan(
  861. text: '${_dataArray[index]['discountPrice']}',
  862. style: TextStyle(fontSize: zsp(42),fontWeight: FontWeight.bold),
  863. ),
  864. TextSpan(
  865. text: ' 元起',
  866. )
  867. ]
  868. ),
  869. ),
  870. Container(
  871. child: Text('原价: ${_dataArray[index]['price']}元起/座',style: TextStyle(fontSize: zsp(24),color: Color(0xFFA2A2A2),decoration: TextDecoration.lineThrough),),
  872. margin: EdgeInsets.only(top: hsp(10)),
  873. )
  874. ],
  875. ),
  876. )
  877. ],
  878. ),
  879. ),
  880. );
  881. },
  882. separatorBuilder: (context,index){
  883. return Divider(height: hsp(20),thickness: hsp(20),color: Color(0xFFF1F2F3),);
  884. },
  885. itemCount: _dataArray.length,
  886. padding: EdgeInsets.all(0),
  887. ),
  888. )
  889. ),
  890. ],
  891. )
  892. ],
  893. ),
  894. ),
  895. ),
  896. );
  897. }
  898. Future<void> _refreshData() async{
  899. _page = 1;
  900. Map request = {};
  901. request['category'] = 8;
  902. request['type'] = _type+1;
  903. request['pageNo'] = _page;
  904. request['pageSize'] = 10;
  905. if(_siftDict!=null&&_siftDict2!=null){
  906. if(_type==2){
  907. if(_startCity2!=null)request['setout'] = _startCity2['display'];
  908. if(_endCity2!=null)request['arrive'] = _endCity2['display'];
  909. request['maxDistance'] = _siftDict['distance'][_priceIndex]['max'];
  910. request['minDistance'] = _siftDict['distance'][_priceIndex]['min'];
  911. request['time'] = _siftDict['date'][_dateIndex2].replaceAll('.', '-');
  912. }else{
  913. request['time'] = _siftDict['date'][_dateIndex].replaceAll('.', '-');
  914. request['maxPrice'] = _siftDict['price'][_priceIndex]['max'];
  915. request['minPrice'] = _siftDict['price'][_priceIndex]['min'];
  916. if(_startCity!=null)request['setout'] = _startCity['display'];
  917. if(_endCity!=null)request['arrive'] = _endCity['display'];
  918. request['partnerId'] = _siftDict['partner'][_plansIndex]['id'];
  919. }
  920. }
  921. if(_selected==1){
  922. request['sales'] = 1;
  923. }
  924. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: request,isLoading: false,isToken: false);
  925. if(dict!=null){
  926. setState(() {
  927. _dataArray = dict['data']['resultList'];
  928. });
  929. }
  930. }
  931. Future<void> _loadMoreData() async{
  932. _page++;
  933. Map request = {};
  934. request['category'] = 8;
  935. request['type'] = _type+1;
  936. request['pageNo'] = _page;
  937. request['pageSize'] = 10;
  938. if(_siftDict!=null&&_siftDict2!=null){
  939. if(_type==2){
  940. if(_startCity2!=null)request['setout'] = _startCity2['display'];
  941. if(_endCity2!=null)request['arrive'] = _endCity2['display'];
  942. request['maxDistance'] = _siftDict['distance'][_priceIndex]['max'];
  943. request['minDistance'] = _siftDict['distance'][_priceIndex]['min'];
  944. request['time'] = _siftDict['date'][_dateIndex2].replaceAll('.', '-');
  945. }else{
  946. request['time'] = _siftDict['date'][_dateIndex].replaceAll('.', '-');
  947. request['maxPrice'] = _siftDict['price'][_priceIndex]['max'];
  948. request['minPrice'] = _siftDict['price'][_priceIndex]['min'];
  949. if(_startCity!=null)request['setout'] = _startCity['display'];
  950. if(_endCity!=null)request['arrive'] = _endCity['display'];
  951. request['partnerId'] = _siftDict['partner'][_plansIndex]['id'];
  952. }
  953. }
  954. if(_selected==1){
  955. request['sales'] = 1;
  956. }
  957. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: request,isLoading: false,isToken: false);
  958. if(dict!=null){
  959. setState(() {
  960. _dataArray.addAll(dict['data']['resultList']);
  961. });
  962. }
  963. }
  964. _getDateStr(String date) {
  965. DateTime time = DateTime.parse(date);
  966. String timeStr = '${time.month}月${time.day}日 '+time.hour.toString().padLeft(2,'0')+':'+time.minute.toString().padLeft(2,'0');
  967. return timeStr;
  968. }
  969. _getSiftData() async{
  970. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/preferential/filter',parameter: {},isLoading: false,isToken: false);
  971. if(dict!=null){
  972. _siftDict = dict['data'];
  973. List array = [];
  974. DateTime date = DateTime.now();
  975. for(int i = 0;i<7;i++){
  976. String timeStr = '${date.year}.${date.month}.${date.day}';
  977. array.add(timeStr);
  978. date = date.add(Duration(days: 1));
  979. }
  980. _siftDict['date'] = array;
  981. setState(() {
  982. });
  983. }
  984. }
  985. }