YSSearchResult.dart 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_easyrefresh/easy_refresh.dart';
  5. import 'package:shared_preferences/shared_preferences.dart';
  6. import 'package:ysairplane/code/YSPay.dart';
  7. import 'package:ysairplane/code/YSShortDetail.dart';
  8. import 'package:ysairplane/tools/YSNetWorking.dart';
  9. import 'package:ysairplane/tools/YSTools.dart';
  10. import 'YSMarryPlane.dart';
  11. class YSSearchResult extends StatefulWidget {
  12. final searchStr;
  13. final type;
  14. final siftValue;
  15. const YSSearchResult({Key key, this.searchStr, this.type, this.siftValue}) : super(key: key);
  16. @override
  17. _YSSearchResultState createState() => _YSSearchResultState();
  18. }
  19. class _YSSearchResultState extends State<YSSearchResult> {
  20. TextEditingController _searchStr = TextEditingController();
  21. List _tabValues = [{'name':'空中浏览','type':9},{'name':'短途客运','type':6},{'name':'短途货运','type':33},{'name':'航空运动','type':5},
  22. {'name':'婚庆典礼','type':4}];
  23. int _page = 1;
  24. List _dataArray = [];
  25. int _index = 0;
  26. int _typeIndex = 0;
  27. List _priceList = [];
  28. List _kinds = [];
  29. bool _isOrder = false;
  30. int _selected = 0;
  31. Map _kind;
  32. String _timeStr;
  33. List<String> _historyList = [];
  34. TextEditingController _name = TextEditingController();
  35. TextEditingController _volume = TextEditingController();
  36. TextEditingController _weight = TextEditingController();
  37. @override
  38. void initState() {
  39. if(widget.type!=null){
  40. for(int i = 0;i<_tabValues.length;i++){
  41. if(_tabValues[i]['type']==int.parse('${widget.type}')){
  42. _typeIndex = i;
  43. }
  44. }
  45. }
  46. if(widget.searchStr!=null){
  47. _searchStr.text = widget.searchStr;
  48. }
  49. _timeStr = DateTime.now().year.toString()+'-'+DateTime.now().month.toString().padLeft(2,'0')+'-'
  50. +DateTime.now().day.toString().padLeft(2,'0')+' '+DateTime.now().hour.toString().padLeft(2,'0')+':'
  51. +DateTime.now().minute.toString().padLeft(2,'0');
  52. SharedPreferences.getInstance().then((value){
  53. setState(() {
  54. _historyList = value.getStringList('history')??[];
  55. });
  56. });
  57. Future.delayed(Duration(seconds: 0)).then((value){
  58. _refreshData();
  59. });
  60. super.initState();
  61. }
  62. @override
  63. Widget build(BuildContext context) {
  64. return Scaffold(
  65. body: SingleChildScrollView(
  66. child: Stack(
  67. children: [
  68. SingleChildScrollView(
  69. child: Column(
  70. children: [
  71. Container(
  72. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(42),left: wsp(32),right: wsp(32)),
  73. child: Row(
  74. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  75. children: [
  76. GestureDetector(child: Icon(Icons.arrow_back_ios,size: hsp(40),color: Color(0xFF000000),),onTap: (){Navigator.pop(context);},),
  77. Container(
  78. width: MediaQuery.of(context).size.width-wsp(140),
  79. margin: EdgeInsets.only(left: wsp(34)),
  80. padding: EdgeInsets.only(left: wsp(26),right: wsp(26)),
  81. height: hsp(66),
  82. decoration: BoxDecoration(
  83. border: Border.all(color: Color(0xFF007AFF),width: 1),
  84. borderRadius: BorderRadius.all(Radius.circular(5))
  85. ),
  86. child: CupertinoTextField(
  87. placeholder: '',
  88. placeholderStyle: TextStyle(fontSize: zsp(25),color: Color(0xFF545454)),
  89. style: TextStyle(fontSize: zsp(25),color: Color(0xFF545454)),
  90. prefix: Icon(Icons.search,size: hsp(40),color: Color(0xFF8E8E93),),
  91. suffix: GestureDetector(child: Icon(Icons.close,size: hsp(40),color: Color(0xFF8E8E93),),onTap: (){_searchStr.text = '';},),
  92. suffixMode: OverlayVisibilityMode.editing,
  93. controller: _searchStr,
  94. padding: EdgeInsets.all(0),
  95. decoration: BoxDecoration(),
  96. onSubmitted: (value){
  97. if(value.isNotEmpty){
  98. if(_historyList.contains(value)){
  99. _historyList.remove(value);
  100. }
  101. _historyList.insert(0, value);
  102. SharedPreferences.getInstance().then((prefer){
  103. prefer.setStringList('history', _historyList);
  104. _refreshData();
  105. });
  106. }else{
  107. _refreshData();
  108. }
  109. },
  110. textInputAction: TextInputAction.search,
  111. ),
  112. ),
  113. ],
  114. ),
  115. ),
  116. Container(
  117. height: hsp(100),
  118. width: MediaQuery.of(context).size.width,
  119. child: ListView.builder(
  120. itemBuilder: (context,index){
  121. return GestureDetector(
  122. onTap: (){
  123. _typeIndex = index;
  124. _refreshData();
  125. },
  126. child: Container(
  127. width: MediaQuery.of(context).size.width/4,
  128. padding: EdgeInsets.only(top: hsp(20)),
  129. child: Column(
  130. children: [
  131. Text('${_tabValues[index]['name']}',style: TextStyle(color: index==_typeIndex?Color(0xFF007AFF):Colors.black,
  132. fontWeight: _typeIndex==index?FontWeight.bold:FontWeight.normal),),
  133. Container(height: 2,color: index==_typeIndex?Color(0xFF007AFF):Colors.transparent,width: MediaQuery.of(context).size.width/8,
  134. margin: EdgeInsets.only(top: hsp(10)),)
  135. ],
  136. ),
  137. ),
  138. );
  139. },
  140. padding: EdgeInsets.all(0),
  141. itemCount: _tabValues.length,
  142. scrollDirection: Axis.horizontal,
  143. ),
  144. ),
  145. Container(
  146. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(208),
  147. color: Color(0xFFF1F2F3),
  148. child: PageView(
  149. children: [
  150. Container(
  151. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(208),
  152. color: Color(0xFFF1F2F3),
  153. child: EasyRefresh(
  154. onRefresh: _refreshData,
  155. onLoad: _loadMoreData,
  156. header: TaurusHeader(
  157. ),
  158. footer: TaurusFooter(
  159. ),
  160. child: ListView.separated(
  161. itemBuilder: (context,index){
  162. return GestureDetector(
  163. behavior: HitTestBehavior.opaque,
  164. onTap: (){
  165. if(_typeIndex==2){
  166. _index = index;
  167. _getPriceData();
  168. }else{
  169. Navigator.of(context).push(
  170. CupertinoPageRoute(
  171. builder: (context){
  172. return _typeIndex==1?YSShortDetail(shortId: _dataArray[index]['id'],):
  173. YSMarryPlane(marryId: _dataArray[index]['id'],type: _typeIndex==0?9:_typeIndex==3?5:4);
  174. }
  175. )
  176. );
  177. }
  178. },
  179. child: Container(
  180. padding: EdgeInsets.all(hsp(30)),
  181. child: _typeIndex==1?Row(
  182. children: [
  183. Container(
  184. height: hsp(200),
  185. width: hsp(250),
  186. margin: EdgeInsets.only(right: hsp(30)),
  187. child: CachedNetworkImage(
  188. imageUrl: '${_dataArray[index]['cover']}',
  189. fit: BoxFit.fill,
  190. ),
  191. ),
  192. Container(
  193. width: MediaQuery.of(context).size.width-hsp(340),
  194. height: hsp(200),
  195. child: Column(
  196. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  197. crossAxisAlignment: CrossAxisAlignment.start,
  198. children: [
  199. Row(
  200. children: [
  201. Text('${_dataArray[index]['setoutInfo']['display']}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),),
  202. Container(
  203. height: 2,
  204. width: wsp(40),
  205. margin: EdgeInsets.only(left: wsp(20),right: wsp(20)),
  206. color: Color(0xFFCCCCCC),
  207. ),
  208. Text('${_dataArray[index]['arriveInfo']['display']}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),)
  209. ],
  210. ),
  211. Text('${_dataArray[index]['dtFlightInformation']['partnerName']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  212. Row(
  213. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  214. children: [
  215. Text('${_dataArray[index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  216. RichText(
  217. text: TextSpan(
  218. text: '¥',
  219. style: TextStyle(fontSize: zsp(24),color: Color(0xFFEB423B)),
  220. children: [
  221. TextSpan(
  222. text: '${_dataArray[index]['discountPrice']}',
  223. style: TextStyle(fontSize: zsp(42),fontWeight: FontWeight.bold),
  224. ),
  225. TextSpan(
  226. text: '元起',
  227. style: TextStyle(fontSize: zsp(20)),
  228. )
  229. ]
  230. ),
  231. )
  232. ],
  233. )
  234. ],
  235. ),
  236. )
  237. ],
  238. ):_typeIndex==2?Column(
  239. children: [
  240. Container(
  241. padding: EdgeInsets.only(bottom: hsp(30)),
  242. child: Column(
  243. children: [
  244. Row(
  245. children: [
  246. Text('${_dataArray[index]['setoutInfo']['display']}',style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),),
  247. Image(height: hsp(60),width: hsp(60),image: AssetImage('lib/images/plane.png'),),
  248. Text('${_dataArray[index]['arriveInfo']['display']}',style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),),
  249. ],
  250. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  251. ),
  252. Row(
  253. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  254. children: [
  255. Text('${_dataArray[index]['setoutInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  256. Text('${_dataArray[index]['hour']}',style: TextStyle(fontSize: zsp(20),color: Color(0xFF343434)),),
  257. Text('${_dataArray[index]['arriveInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  258. ],
  259. )
  260. ],
  261. ),
  262. ),
  263. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEAEAEA),),
  264. Container(
  265. height: hsp(70),
  266. child: Row(
  267. children: [
  268. Text('${_dataArray[index]['flightTime']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF333333)),),
  269. Text('机型: ${_dataArray[index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF333333)),),
  270. ],
  271. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  272. ),
  273. ),
  274. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEAEAEA),),
  275. Container(
  276. height: hsp(70),
  277. child: Row(
  278. children: [
  279. RichText(
  280. text: TextSpan(
  281. style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),
  282. children: [
  283. TextSpan(
  284. text: '类型: '
  285. ),
  286. TextSpan(
  287. text: '${_dataArray[index]['type']==1?'整机':'拼机'}',
  288. style: TextStyle(color: Color(0xFF333333))
  289. ),
  290. TextSpan(
  291. text: '体积: '
  292. ),
  293. TextSpan(
  294. text: '${_dataArray[index]['totalVolume']}立方米',
  295. style: TextStyle(color: Color(0xFF333333))
  296. ),
  297. TextSpan(
  298. text: '重量: '
  299. ),
  300. TextSpan(
  301. text: '${_dataArray[index]['totalWeight']}吨',
  302. style: TextStyle(color: Color(0xFF333333))
  303. )
  304. ]
  305. ),
  306. ),
  307. Text('¥${_dataArray[index]['discountPrice']}',style: TextStyle(fontSize: zsp(40),color: Color(0xFFEA413A),fontWeight: FontWeight.bold),),
  308. ],
  309. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  310. ),
  311. margin: EdgeInsets.only(top: hsp(20)),
  312. ),
  313. ],
  314. ):Row(
  315. children: [
  316. Container(
  317. height: hsp(200),
  318. width: hsp(250),
  319. child: CachedNetworkImage(
  320. imageUrl: '${_dataArray[index]['cover']}',
  321. fit: BoxFit.fill,
  322. ),
  323. margin: EdgeInsets.only(right: hsp(30)),
  324. ),
  325. Container(
  326. width: MediaQuery.of(context).size.width-hsp(340),
  327. height: hsp(200),
  328. child: Column(
  329. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  330. crossAxisAlignment: CrossAxisAlignment.start,
  331. children: [
  332. Text('${_dataArray[index]['title']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF343434)),maxLines: 2,),
  333. Text('${_dataArray[index]['dtFlightInformation']['partnerName']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  334. Row(
  335. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  336. children: [
  337. Text('${_dataArray[index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  338. RichText(
  339. text: TextSpan(
  340. text: '¥',
  341. style: TextStyle(fontSize: zsp(24),color: Color(0xFFEB423B)),
  342. children: [
  343. TextSpan(
  344. text: '${_dataArray[index]['discountPrice']}',
  345. style: TextStyle(fontSize: zsp(42),fontWeight: FontWeight.bold),
  346. ),
  347. TextSpan(
  348. text: '元起',
  349. style: TextStyle(fontSize: zsp(20)),
  350. )
  351. ]
  352. ),
  353. )
  354. ],
  355. )
  356. ],
  357. ),
  358. )
  359. ],
  360. ),
  361. ),
  362. );
  363. },
  364. separatorBuilder: (context,index){
  365. return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEEEEEE),);
  366. },
  367. itemCount: _dataArray.length,
  368. padding: EdgeInsets.all(0),
  369. ),
  370. ),
  371. )
  372. ],
  373. ),
  374. )
  375. ],
  376. ),
  377. ),
  378. if(_isOrder==true)GestureDetector(
  379. onTap: (){
  380. setState(() {
  381. _isOrder = false;
  382. });
  383. },
  384. child: Container(
  385. height: MediaQuery.of(context).size.height,
  386. width: MediaQuery.of(context).size.width,
  387. color: Colors.black54,
  388. child: GestureDetector(
  389. onTap: (){},
  390. child: Column(
  391. children: [
  392. Container(
  393. height: MediaQuery.of(context).size.height*0.8-hsp(120),
  394. width: MediaQuery.of(context).size.width,
  395. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height*0.2),
  396. decoration: BoxDecoration(
  397. color: Color(0xFFF1F2F3),
  398. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))
  399. ),
  400. child: Column(
  401. crossAxisAlignment: CrossAxisAlignment.start,
  402. children: [
  403. Container(
  404. height: hsp(100),
  405. decoration: BoxDecoration(
  406. color: Colors.white,
  407. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))
  408. ),
  409. padding: EdgeInsets.only(left: 15,right: 15),
  410. child: Row(
  411. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  412. children: [
  413. Container(width: wsp(50),),
  414. Text('订单确认',style: TextStyle(fontSize: 15,color: Color(0xFF000000),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  415. GestureDetector(
  416. child: Text('关闭',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  417. onTap: (){
  418. setState(() {
  419. _isOrder = false;
  420. });
  421. },
  422. ),
  423. ],
  424. ),
  425. ),
  426. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE5E5E5),),
  427. Container(
  428. height: MediaQuery.of(context).size.height*0.8-hsp(220)-0.5,
  429. child: SingleChildScrollView(
  430. padding: EdgeInsets.all(0),
  431. child: Column(
  432. children: [
  433. Container(
  434. padding: EdgeInsets.all(hsp(30)),
  435. color: Colors.white,
  436. width: MediaQuery.of(context).size.width,
  437. child: Column(
  438. crossAxisAlignment: CrossAxisAlignment.start,
  439. children: [
  440. Text('使用日期',style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),),
  441. Container(
  442. margin: EdgeInsets.only(top: hsp(20)),
  443. child: Row(
  444. children: [
  445. Container(
  446. height: hsp(120),
  447. width: MediaQuery.of(context).size.width-hsp(200),
  448. child: ListView.separated(
  449. itemBuilder: (context,index){
  450. return GestureDetector(
  451. behavior: HitTestBehavior.opaque,
  452. onTap: (){
  453. setState(() {
  454. _selected = index;
  455. });
  456. },
  457. child: Stack(
  458. children: [
  459. Container(
  460. height: hsp(120),
  461. width: (MediaQuery.of(context).size.width-hsp(230))/3,
  462. decoration: BoxDecoration(
  463. color: index==_selected?Color(0xFF007EFF):Color(0xFFF0EEEE),
  464. borderRadius: BorderRadius.all(Radius.circular(5))
  465. ),
  466. alignment: Alignment.center,
  467. child: Text('${_priceList[index]['time']} \n¥${_priceList[index]['price']}',
  468. style: TextStyle(fontSize: zsp(20),color: index==_selected?Colors.white:Color(0xFF8B8B8B)),textAlign: TextAlign.center,),
  469. ),
  470. if(_selected==index)Container(
  471. child: Text(timeTag('${_priceList[index]['time']}'),style: TextStyle(fontSize: zsp(16),color: Color(0xFF007EFF)),),
  472. height: hsp(30),
  473. padding: EdgeInsets.only(left: wsp(3),right: wsp(3)),
  474. decoration: BoxDecoration(
  475. color: Color(0xFFF7F7F7),
  476. borderRadius: BorderRadius.only(topLeft: Radius.circular(3),bottomRight: Radius.circular(5))
  477. ),
  478. alignment: Alignment.center,
  479. ),
  480. ],
  481. ),
  482. );
  483. },
  484. separatorBuilder: (context,index){
  485. return Container(width: hsp(15),color: Colors.white,);
  486. },
  487. itemCount: _priceList.length,
  488. padding: EdgeInsets.all(0),
  489. scrollDirection: Axis.horizontal,
  490. ),
  491. ),
  492. GestureDetector(
  493. onTap: (){
  494. showModalBottomSheet(
  495. context: context,
  496. builder: (context){
  497. return YSDatePicker(
  498. choose: (value){
  499. Map time = {'time':value.split(' ')[0],'price':_priceList[0]['price']};
  500. int index;
  501. for(int i=0;i<_priceList.length;i++){
  502. if(_priceList[i]['time']==time['time']){
  503. index = i;
  504. }
  505. }
  506. if(index!=null){
  507. _priceList.removeAt(index);
  508. }
  509. setState(() {
  510. _priceList.insert(0, time);
  511. });
  512. },
  513. );
  514. }
  515. );
  516. },
  517. behavior: HitTestBehavior.opaque,
  518. child: Container(
  519. height: hsp(120),
  520. width: hsp(140),
  521. alignment: Alignment.center,
  522. child: Text('更多\n日期',style: TextStyle(fontSize: zsp(26),color: Color(0xFF007EFF)),),
  523. ),
  524. )
  525. ],
  526. ),
  527. ),
  528. ],
  529. ),
  530. ),
  531. if(_dataArray[_index]['type']==2)Container(
  532. padding: EdgeInsets.all(hsp(30)),
  533. margin: EdgeInsets.only(top: hsp(10)),
  534. width: MediaQuery.of(context).size.width,
  535. color: Colors.white,
  536. child: Column(
  537. crossAxisAlignment: CrossAxisAlignment.start,
  538. children: [
  539. Text('本次拼机截止时间:${_dataArray[_index]['deadlineTime']}',style: TextStyle(fontSize: zsp(26),color: Color(0xFF999999)),),
  540. Row(
  541. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  542. children: [
  543. Text('0吨',style: TextStyle(fontSize: zsp(22),color: Color(0xFF656565)),),
  544. Container(
  545. height: hsp(100),
  546. width: MediaQuery.of(context).size.width-hsp(200),
  547. child: Slider(
  548. value: double.parse('${_dataArray[_index]['nowWeight']}'),
  549. onChanged: (value){
  550. },
  551. activeColor: Color(0xFF0079FF),
  552. min: 0,
  553. max: 10,
  554. divisions: 4,
  555. ),
  556. ),
  557. Text('${_dataArray[_index]['totalWeight']}吨',style: TextStyle(fontSize: zsp(22),color: Color(0xFF656565)),),
  558. ],
  559. ),
  560. Container(
  561. width: MediaQuery.of(context).size.width,
  562. child: Text('目标${_dataArray[_index]['nowWeight']}吨',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  563. alignment: Alignment.center,
  564. ),
  565. ],
  566. ),
  567. ),
  568. Container(
  569. padding: EdgeInsets.all(hsp(30)),
  570. margin: EdgeInsets.only(top: hsp(10)),
  571. color: Colors.white,
  572. child: Column(
  573. children: [
  574. Container(
  575. padding: EdgeInsets.only(bottom: hsp(30)),
  576. child: Column(
  577. children: [
  578. Row(
  579. children: [
  580. Text('${_dataArray[_index]['setoutInfo']['display']}',style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),),
  581. Image(height: hsp(60),width: hsp(60),image: AssetImage('lib/images/plane.png'),),
  582. Text('${_dataArray[_index]['arriveInfo']['display']}',style: TextStyle(fontSize: zsp(40),fontWeight: FontWeight.bold,color: Colors.black),),
  583. ],
  584. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  585. ),
  586. Row(
  587. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  588. children: [
  589. Text('${_dataArray[_index]['setoutInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  590. Text('${_dataArray[_index]['hour']}',style: TextStyle(fontSize: zsp(20),color: Color(0xFF343434)),),
  591. Text('${_dataArray[_index]['arriveInfo']['airplanename']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  592. ],
  593. )
  594. ],
  595. ),
  596. ),
  597. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEAEAEA),),
  598. Container(
  599. height: hsp(70),
  600. child: Row(
  601. children: [
  602. Text('${_dataArray[_index]['flightTime']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF333333)),),
  603. Text('机型: ${_dataArray[_index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF333333)),),
  604. ],
  605. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  606. ),
  607. ),
  608. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEAEAEA),),
  609. Container(
  610. height: hsp(90),
  611. alignment: Alignment.centerLeft,
  612. child: Row(
  613. children: [
  614. RichText(
  615. text: TextSpan(
  616. style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),
  617. children: [
  618. TextSpan(
  619. text: '类型: '
  620. ),
  621. TextSpan(
  622. text: '${_dataArray[_index]['type']==1?'整机':'拼机'}',
  623. style: TextStyle(color: Color(0xFF333333))
  624. ),
  625. TextSpan(
  626. text: '体积: '
  627. ),
  628. TextSpan(
  629. text: '${_dataArray[_index]['totalVolume']}立方米',
  630. style: TextStyle(color: Color(0xFF333333))
  631. ),
  632. TextSpan(
  633. text: '重量: '
  634. ),
  635. TextSpan(
  636. text: '${_dataArray[_index]['totalWeight']}吨',
  637. style: TextStyle(color: Color(0xFF333333))
  638. )
  639. ]
  640. ),
  641. ),
  642. Text('¥${_dataArray[_index]['discountPrice']}',style: TextStyle(fontSize: zsp(40),color: Color(0xFFEA413A),fontWeight: FontWeight.bold),),
  643. ],
  644. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  645. ),
  646. ),
  647. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEAEAEA),),
  648. Container(
  649. height: hsp(90),
  650. alignment: Alignment.centerLeft,
  651. child: RichText(
  652. text: TextSpan(
  653. style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),
  654. children: [
  655. TextSpan(
  656. text: '说明: '
  657. ),
  658. TextSpan(
  659. text: '${_dataArray[_index]['explain']}',style: TextStyle(color: Color(0xFF333333))
  660. ),
  661. ]
  662. ),
  663. ),
  664. )
  665. ],
  666. ),
  667. ),
  668. ListView.separated(
  669. itemBuilder: (context,index){
  670. return Container(
  671. height: hsp(90),
  672. color: Colors.white,
  673. width: MediaQuery.of(context).size.width,
  674. padding: EdgeInsets.only(left: hsp(30),right: hsp(30)),
  675. alignment: Alignment.centerLeft,
  676. child: index==0?Text(
  677. '货物信息',style: TextStyle(fontSize: zsp(30),color: Color(0xFF333333),fontWeight: FontWeight.bold),
  678. ):Row(
  679. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  680. children: [
  681. Text(index==1?'名称':index==2?'类型':index==3?'体积':'重量',style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),),
  682. Container(
  683. height: hsp(90),
  684. width: MediaQuery.of(context).size.width*0.7,
  685. alignment: Alignment.centerRight,
  686. child: index==2?GestureDetector(
  687. onTap: (){
  688. FocusScope.of(context).unfocus();
  689. showModalBottomSheet(
  690. context: context,
  691. builder: (context){
  692. return YSPicker(
  693. dataArray: _kinds,
  694. title: 'name',
  695. choose: (value){
  696. setState(() {
  697. _kind = value;
  698. });
  699. },
  700. );
  701. }
  702. );
  703. },
  704. child: Row(
  705. mainAxisSize: MainAxisSize.min,
  706. children: [
  707. Text(_kind==null?'请选择类型':'${_kind['name']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),),
  708. Icon(Icons.keyboard_arrow_down,size: hsp(40),color: Color(0xFF9A9A9A))
  709. ],
  710. ),
  711. ):CupertinoTextField(
  712. placeholder: index==1?'请输入名称':index==3?'请输入体积':'请输入重量',
  713. placeholderStyle: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),
  714. style: TextStyle(fontSize: zsp(30),color: Color(0xFF9A9A9A)),
  715. decoration: BoxDecoration(),
  716. textAlign: TextAlign.right,
  717. suffix: Text(index==1?'':index==3?'立方米':'吨',style: TextStyle(fontSize: zsp(30),color: Colors.black)),
  718. controller: index==1?_name:index==3?_volume:_weight,
  719. keyboardType: index==1?TextInputType.text:TextInputType.numberWithOptions(),
  720. ),
  721. ),
  722. ],
  723. ),
  724. );
  725. },
  726. separatorBuilder: (context,index){
  727. return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEAEAEA),);
  728. },
  729. itemCount: 5,
  730. padding: EdgeInsets.only(top: hsp(10)),
  731. shrinkWrap: true,
  732. physics: NeverScrollableScrollPhysics(),
  733. ),
  734. if(_dataArray[_index]['type']==2)Container(
  735. padding: EdgeInsets.all(hsp(30)),
  736. margin: EdgeInsets.only(top: hsp(10),bottom: hsp(30)),
  737. color: Colors.white,
  738. child: Row(
  739. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  740. children: [
  741. Container(
  742. width: (MediaQuery.of(context).size.width-hsp(60))*0.6,
  743. child: SingleChildScrollView(
  744. child: Stack(
  745. children: [
  746. for(int i = 0;i<(_dataArray[_index]['dtAirplaneGoods']).length;i++)Container(
  747. height: hsp(70),
  748. width: hsp(70),
  749. margin: EdgeInsets.only(left: hsp(60)*i),
  750. decoration: BoxDecoration(
  751. color: Color(0xFFED5D57),
  752. borderRadius: BorderRadius.all(Radius.circular(50)),
  753. border: Border.all(color: Colors.white,width: 1),
  754. image: DecorationImage(
  755. image: NetworkImage('${_dataArray[_index]['dtAirplaneGoods'][i]['dtUsers']['avatar']}'),
  756. fit: BoxFit.fill,
  757. )
  758. ),
  759. )
  760. ],
  761. ),
  762. scrollDirection: Axis.horizontal,
  763. ),
  764. ),
  765. RichText(
  766. text: TextSpan(
  767. text: '已有',
  768. style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),
  769. children: [
  770. TextSpan(
  771. text: '4',
  772. style: TextStyle(color: Color(0xFF007DFF))
  773. ),
  774. TextSpan(
  775. text: '个人在拼该机'
  776. )
  777. ]
  778. ),
  779. )
  780. ],
  781. ),
  782. )
  783. ],
  784. ),
  785. ),
  786. ),
  787. ],
  788. ),
  789. ),
  790. Container(
  791. height: hsp(120),
  792. width: MediaQuery.of(context).size.width,
  793. color: Colors.white,
  794. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  795. child: Row(
  796. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  797. children: [
  798. RichText(
  799. text: TextSpan(
  800. text: '参考价(¥)',
  801. style: TextStyle(fontSize: zsp(22),color: Color(0xFF181818)),
  802. children: [
  803. TextSpan(
  804. text: ' ${_dataArray[_index]['discountPrice']}',
  805. style: TextStyle(fontSize: zsp(40),color: Color(0xFFFF6600)),
  806. ),
  807. TextSpan(
  808. text: ' 元',
  809. )
  810. ]
  811. ),
  812. ),
  813. // GestureDetector(
  814. // child: Row(
  815. // children: [
  816. // Text('明细',style: TextStyle(fontSize: zsp(22),color: Color(0xFF181818)),),
  817. // Icon(Icons.keyboard_arrow_up,size: hsp(30),color: Color(0xFF007EFF),),
  818. // ],
  819. // ),
  820. // onTap: (){
  821. // setState(() {
  822. // _isDetail = !_isDetail;
  823. // });
  824. // },
  825. // ),
  826. GestureDetector(
  827. onTap: (){
  828. FocusScope.of(context).unfocus();
  829. _postOrderData();
  830. },
  831. child: Container(
  832. height: hsp(70),
  833. padding: EdgeInsets.only(left: wsp(50),right: wsp(50)),
  834. decoration: BoxDecoration(
  835. color: Color(0xFF007EFF),
  836. borderRadius: BorderRadius.all(Radius.circular(50))
  837. ),
  838. alignment: Alignment.center,
  839. child: Text('立即预约',style: TextStyle(fontSize: zsp(30),color: Colors.white,fontWeight: FontWeight.bold),),
  840. ),
  841. )
  842. ],
  843. ),
  844. )
  845. ],
  846. ),
  847. ),
  848. ),
  849. )
  850. ],
  851. ),
  852. ),
  853. );
  854. }
  855. Future<void> _refreshData() async{
  856. _page = 1;
  857. Map request = {};
  858. request['category'] = _tabValues[_typeIndex]['type'];
  859. request['pageNo'] = _page;
  860. request['pageSize'] = 10;
  861. String url = '/app/applets/AirTour/list';
  862. if(_searchStr.text.isNotEmpty){
  863. request['name'] = _searchStr.text;
  864. url = '/app/applets/AirTour/search';
  865. }
  866. Map dict = await ysRequestHttp(context,type: requestType.get,api: url,parameter: request,isLoading: false,isToken: false);
  867. if(dict!=null){
  868. setState(() {
  869. _dataArray = dict['data']['resultList'];
  870. });
  871. }
  872. }
  873. Future<void> _loadMoreData() async{
  874. _page++;
  875. Map request = {};
  876. request['category'] = _tabValues[_typeIndex]['type'];
  877. request['pageNo'] = _page;
  878. request['pageSize'] = 10;
  879. String url = '/app/applets/AirTour/list';
  880. if(_searchStr.text.isNotEmpty){
  881. request['name'] = _searchStr.text;
  882. url = '/app/applets/AirTour/search';
  883. }
  884. Map dict = await ysRequestHttp(context,type: requestType.get,api: url,parameter: request,isLoading: false,isToken: false);
  885. if(dict!=null){
  886. setState(() {
  887. _dataArray.addAll(dict['data']['resultList']);
  888. });
  889. }
  890. }
  891. _getPriceData() async{
  892. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/getDateAndTime',
  893. parameter: {'time':_timeStr,'type':3,'id':_dataArray[_index]['id']},isLoading: true,isToken: true);
  894. if(dict!=null){
  895. _isOrder = true;
  896. _priceList = dict['data'];
  897. _getTypeData();
  898. }
  899. }
  900. _getTypeData() async{
  901. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplanegoods/type/get',parameter: {},isLoading: true,isToken: false);
  902. if(dict!=null){
  903. setState(() {
  904. _kinds = dict['data'];
  905. _kind = _kinds[0];
  906. });
  907. }
  908. }
  909. _postOrderData() async{
  910. if(_name.text.isEmpty){
  911. ysFlutterToast(context, '货物名称不能为空');
  912. return;
  913. }
  914. if(_volume.text.isEmpty){
  915. ysFlutterToast(context, '货物体积不能为空');
  916. return;
  917. }
  918. if(_weight.text.isEmpty){
  919. ysFlutterToast(context, '货物重量不能为空');
  920. return;
  921. }
  922. Map request = {};
  923. request['flightTime'] = '2020-10-07 17:59:27';
  924. request['type'] = 3;
  925. request['airplaneid'] = _dataArray[_index]['id'];
  926. request['airportidSetout'] = _dataArray[_index]['airportidSetout'];
  927. request['airportidArrive'] = _dataArray[_index]['airportidArrive'];
  928. request['airportidArrive'] = _dataArray[_index]['airportidArrive'];
  929. Map value = {};
  930. value['goodsName'] = _name.text;
  931. value['goodsNatureId'] = _kind['id'];
  932. value['goodsVolume'] = _volume.text;
  933. value['goodsWeight'] = _weight.text;
  934. value['contactPerson'] = '111';
  935. value['phone'] = '15829646496';
  936. value['goodsPlace'] = '西安小寨A座国际商务酒店';
  937. value['goodsLocation'] = '108.985463,34.30501';
  938. value['goodsUnloadingPlace'] = '上海酒店';
  939. value['goodsUnloadingLocation'] = '108.985463,34.30501';
  940. request['dtAirplaneGoods'] = value;
  941. request['sourceType'] = _dataArray[_index]['type'];
  942. Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/applets/airplaneorder/createOrder',parameter: request,isLoading: true,isToken: true);
  943. if(dict!=null){
  944. Navigator.of(context).push(
  945. CupertinoPageRoute(
  946. builder: (context){
  947. return YSPay(orderDict: dict['data'],type: payType.goods,);
  948. }
  949. )
  950. );
  951. }
  952. }
  953. }