YSContractPlane.dart 58 KB

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