YSHome.dart 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. import 'dart:convert';
  2. import 'package:cached_network_image/cached_network_image.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:shared_preferences/shared_preferences.dart';
  6. import 'package:ysairplane/code/YSCity.dart';
  7. import 'package:ysairplane/code/YSContractPlaneDetail.dart';
  8. import 'package:ysairplane/code/YSDoctorPlane.dart';
  9. import 'package:ysairplane/code/YSHelpPlane.dart';
  10. import 'package:ysairplane/code/YSHomeMsg.dart';
  11. import 'package:ysairplane/code/YSMarryPlane.dart';
  12. import 'package:ysairplane/code/YSSearch.dart';
  13. import 'package:ysairplane/code/YSShortDetail.dart';
  14. import 'package:ysairplane/code/YSShortGoods.dart';
  15. import 'package:ysairplane/code/YSShortPlane.dart';
  16. import 'package:ysairplane/code/YSTravelling.dart';
  17. import 'package:ysairplane/tools/YSNetWorking.dart';
  18. import 'package:flutter_swiper/flutter_swiper.dart';
  19. import 'package:ysairplane/code/YSNews.dart';
  20. import 'package:ysairplane/tools/YSTools.dart';
  21. import 'YSContractPlane.dart';
  22. import 'YSSightseeingPlane.dart';
  23. class YSHome extends StatefulWidget {
  24. @override
  25. _YSHomeState createState() => _YSHomeState();
  26. }
  27. class _YSHomeState extends State<YSHome> with AutomaticKeepAliveClientMixin{
  28. List _banners = [];
  29. List _products = [];
  30. Map _advertising;
  31. String _city = '';
  32. List _dataArray = [];
  33. SwiperController _swiperController = SwiperController();
  34. @override
  35. bool get wantKeepAlive => true;
  36. @override
  37. void initState() {
  38. Future.delayed(Duration(seconds: 0)).then((value){
  39. _getFeatureDisplayShowData();
  40. });
  41. super.initState();
  42. }
  43. @override
  44. void dispose() {
  45. _swiperController.dispose();
  46. super.dispose();
  47. }
  48. @override
  49. Widget build(BuildContext context) {
  50. super.build(context);
  51. return Scaffold(
  52. backgroundColor: Colors.white,
  53. appBar: CupertinoNavigationBar(
  54. leading: GestureDetector(
  55. onTap: (){
  56. Navigator.of(context,rootNavigator: true).push(
  57. CupertinoPageRoute(
  58. builder: (context){
  59. return YSCity();
  60. }
  61. )
  62. ).then((value){
  63. if(value!=null){
  64. _city = value['display'];
  65. _getFeatureDisplayListData(_city);
  66. }
  67. });
  68. },
  69. child: Row(
  70. mainAxisSize: MainAxisSize.min,
  71. children: [
  72. Container(
  73. width: hsp(35*(_city.length>5?5:_city.length)),
  74. child: Text(_city,style: TextStyle(fontSize: zsp(28),color: Color(0xFF8E8E93)),overflow: TextOverflow.ellipsis,),
  75. ),
  76. Icon(Icons.keyboard_arrow_down,size: zsp(30),color: Color(0xFF8E8E93),)
  77. ],
  78. ),
  79. ),
  80. middle: GestureDetector(
  81. onTap: (){
  82. Navigator.of(context,rootNavigator: true).push(
  83. CupertinoPageRoute(
  84. builder: (context){
  85. return YSSearch();
  86. }
  87. )
  88. );
  89. },
  90. child: Container(
  91. height: hsp(66),
  92. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  93. decoration: BoxDecoration(
  94. color: Color(0xFFF0F0F1),
  95. borderRadius: BorderRadius.all(Radius.circular(5))
  96. ),
  97. child: Row(
  98. children: [
  99. Icon(Icons.search,size: hsp(40),color: Color(0xFF8E8E93),),
  100. Text(' 目的地·酒店·关键词',style: TextStyle(fontSize: zsp(28),color: Color(0xFF8E8E93),fontWeight: FontWeight.normal),)
  101. ],
  102. ),
  103. ),
  104. ),
  105. trailing: GestureDetector(
  106. onTap: (){
  107. Navigator.of(context,rootNavigator: true).push(
  108. CupertinoPageRoute(
  109. builder: (context){
  110. return YSHomeMsg();
  111. }
  112. )
  113. );
  114. },
  115. child: Container(
  116. height: hsp(30),
  117. width: wsp(30),
  118. child: Image.asset('lib/images/homeMsg.png'),
  119. ),
  120. ),
  121. border: Border.all(width: 0.5,color: Colors.white),
  122. ),
  123. body: Container(
  124. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-94,
  125. child: SingleChildScrollView(
  126. padding: EdgeInsets.all(0),
  127. child: Column(
  128. children: [
  129. if(_banners.length>0)Container(
  130. height: hsp(292),
  131. margin: EdgeInsets.all(hsp(24)),
  132. child: Swiper(
  133. itemBuilder: (BuildContext context, int index) {
  134. return CachedNetworkImage(
  135. imageUrl: '${_banners[index]['url']}',
  136. fit: BoxFit.fill,
  137. );
  138. },
  139. itemCount: _banners.length,
  140. scrollDirection: Axis.horizontal,
  141. loop: true,
  142. duration: 300,
  143. autoplay: true,
  144. onTap: (index) {
  145. Navigator.of(context,rootNavigator: true).push(
  146. CupertinoPageRoute(
  147. builder: (context){
  148. return _banners[index]['target']==1?YSDoctorPlane():_banners[index]['target']==2?YSHelpPlane():_banners[index]['target']==3?
  149. YSShortGoods():_banners[index]['target']==4?YSMarryPlane(type: _banners[index]['target'],marryId: _banners[index]['targerId'],):_banners[index]['target']==5?
  150. YSMarryPlane(type: _banners[index]['target'],marryId: _banners[index]['targerId'],):
  151. _banners[index]['target']==6?YSShortDetail(shortId: _banners[index]['targerId'],):_banners[index]['target']==7?
  152. YSTravelling():_banners[index]['target']==8?YSContractPlaneDetail(contractId: _banners[index]['targerId'],):_banners[index]['target']==9?YSMarryPlane(type: _banners[index]['target'],
  153. marryId: _banners[index]['targerId'],):YSNews();
  154. }
  155. )
  156. );
  157. },
  158. pagination: SwiperPagination(
  159. alignment: Alignment.bottomCenter,
  160. builder: DotSwiperPaginationBuilder(
  161. color: Colors.white,
  162. activeColor: Colors.white,
  163. size: 5.0,
  164. activeSize: 10.0
  165. ),
  166. ),
  167. autoplayDisableOnInteraction : true,
  168. controller: _swiperController,
  169. ),
  170. ),
  171. Container(
  172. margin: EdgeInsets.only(left: hsp(24),right: hsp(24),top: hsp(15),bottom: hsp(30)),
  173. child: GridView.builder(
  174. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  175. crossAxisCount: 5,
  176. crossAxisSpacing: wsp(51),
  177. mainAxisSpacing: hsp(36),
  178. childAspectRatio: 0.75
  179. ),
  180. itemBuilder: (context,index){
  181. return GestureDetector(
  182. onTap: (){
  183. Navigator.of(context,rootNavigator: true).push(
  184. CupertinoPageRoute(
  185. builder: (context){
  186. return _products[index]['target']==1?YSDoctorPlane():_products[index]['target']==2?YSHelpPlane():_products[index]['target']==3?YSShortGoods():
  187. _products[index]['target']==4?YSSightseeingPlane(type: planeType.marry,):_products[index]['target']==5?YSSightseeingPlane(type: planeType.sport,):_products[index]['target']==6?YSShortPlane():
  188. _products[index]['target']==7?YSTravelling():_products[index]['target']==8?YSContractPlane():_products[index]['target']==9?YSSightseeingPlane(type: planeType.sightseeing,):YSNews();
  189. }
  190. )
  191. );
  192. },
  193. child: Container(
  194. child: Column(
  195. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  196. children: [
  197. CachedNetworkImage(
  198. width: 40,
  199. height: 40,
  200. imageUrl: '${_products[index]['url']}',
  201. fit: BoxFit.fill
  202. ),
  203. Text('${_products[index]['name']}',style: TextStyle(fontSize: zsp(23),color: Color(0xFF34373A)),)
  204. ],
  205. ),
  206. ),
  207. );
  208. },
  209. itemCount: _products.length,
  210. padding: EdgeInsets.all(0),
  211. physics: NeverScrollableScrollPhysics(),
  212. shrinkWrap: true,
  213. ),
  214. ),
  215. if(_advertising!=null)Container(
  216. margin: EdgeInsets.only(left: hsp(24),right: hsp(24),bottom: hsp(24)),
  217. height: wsp(136),
  218. decoration: BoxDecoration(
  219. image: DecorationImage(
  220. image: NetworkImage('${_advertising['url']}'),
  221. fit: BoxFit.fill
  222. )
  223. ),
  224. ),
  225. Divider(height: 10,thickness: 10,color: Color(0xFFF5F6F8),),
  226. ListView.separated(
  227. itemBuilder: (context,index){
  228. return _dataArray[index]['displayType']=='1'?Column(
  229. children: [
  230. Container(
  231. height: hsp(100),
  232. padding: EdgeInsets.all(hsp(24)),
  233. child: Row(
  234. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  235. children: [
  236. Row(
  237. children: [
  238. Container(
  239. height: hsp(36),
  240. width: wsp(5),
  241. color: Color(0xFF3676EC),
  242. margin: EdgeInsets.only(right: wsp(20),top: hsp(8)),
  243. ),
  244. Text('${_dataArray[index]['labelName']}',style: TextStyle(fontSize: zsp(36),color: Color(0xFF181818),fontWeight: FontWeight.bold),)
  245. ],
  246. ),
  247. GestureDetector(
  248. onTap: (){
  249. Navigator.of(context,rootNavigator: true).push(
  250. CupertinoPageRoute(
  251. builder: (context){
  252. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?YSShortGoods():
  253. _dataArray[index]['target']=='4'?YSSightseeingPlane(type: planeType.marry,):_dataArray[index]['target']=='5'?YSSightseeingPlane(type: planeType.sport,):_dataArray[index]['target']=='6'?YSShortPlane():
  254. _dataArray[index]['target']=='7'?YSTravelling():_dataArray[index]['target']=='8'?YSContractPlane():_dataArray[index]['target']=='9'?YSSightseeingPlane(type: planeType.sightseeing,):YSNews();
  255. }
  256. )
  257. );
  258. },
  259. child: Row(
  260. children: [
  261. Text('更多',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  262. Icon(Icons.keyboard_arrow_right,size: hsp(30),color: Color(0xFF999999),)
  263. ],
  264. ),
  265. )
  266. ],
  267. ),
  268. ),
  269. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F2),),
  270. Container(
  271. height: hsp(387),
  272. margin: EdgeInsets.all(hsp(24)),
  273. child: Row(
  274. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  275. children: [
  276. GestureDetector(
  277. child: Stack(
  278. children: [
  279. Container(
  280. height: hsp(387),
  281. width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2,
  282. decoration: BoxDecoration(
  283. borderRadius: BorderRadius.all(Radius.circular(5))
  284. ),
  285. child: ClipRRect(
  286. child: CachedNetworkImage(
  287. imageUrl: '${_dataArray[index]['dtAirTours'][0]['cover']}',
  288. fit: BoxFit.fill,
  289. ),
  290. borderRadius: BorderRadius.all(Radius.circular(5)),
  291. )
  292. ),
  293. Container(
  294. height: hsp(40),
  295. alignment: Alignment.centerLeft,
  296. child: Text('${_dataArray[index]['dtAirTours'][0]['title']}',style: TextStyle(fontSize: zsp(20),color: Colors.white),),
  297. decoration: BoxDecoration(
  298. color: Colors.black26,
  299. borderRadius: BorderRadius.only(bottomRight: Radius.circular(5),topLeft: Radius.circular(5))
  300. ),
  301. padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  302. )
  303. ],
  304. ),
  305. onTap: (){
  306. Navigator.of(context,rootNavigator: true).push(
  307. CupertinoPageRoute(
  308. builder: (context){
  309. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?
  310. YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours']
  311. [0]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][0]['id'],):
  312. _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][0]['id'],):_dataArray[index]['target']=='7'?
  313. YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][0]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'],
  314. marryId: _dataArray[index]['dtAirTours'][0]['id'],):YSNews();
  315. }
  316. )
  317. );
  318. },
  319. ),
  320. Column(
  321. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  322. children: [
  323. GestureDetector(
  324. child: Stack(
  325. children: [
  326. Container(
  327. height: hsp(387)/2-wsp(6),
  328. width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2,
  329. decoration: BoxDecoration(
  330. borderRadius: BorderRadius.all(Radius.circular(5))
  331. ),
  332. child: ClipRRect(
  333. child: CachedNetworkImage(
  334. imageUrl: '${_dataArray[index]['dtAirTours'][1]['cover']}',
  335. fit: BoxFit.fill,
  336. ),
  337. borderRadius: BorderRadius.all(Radius.circular(5)),
  338. )
  339. ),
  340. Container(
  341. height: hsp(40),
  342. alignment: Alignment.centerLeft,
  343. child: Text('${_dataArray[index]['dtAirTours'][1]['title']}',style: TextStyle(fontSize: zsp(20),color: Colors.white),),
  344. decoration: BoxDecoration(
  345. color: Color(0xFFEC6163),
  346. borderRadius: BorderRadius.only(bottomRight: Radius.circular(5),topLeft: Radius.circular(5))
  347. ),
  348. padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  349. )
  350. ],
  351. ),
  352. onTap: (){
  353. Navigator.of(context,rootNavigator: true).push(
  354. CupertinoPageRoute(
  355. builder: (context){
  356. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?
  357. YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours']
  358. [1]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][1]['id'],):
  359. _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][1]['id'],):_dataArray[index]['target']=='7'?
  360. YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][1]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'],
  361. marryId: _dataArray[index]['dtAirTours'][1]['id'],):YSNews();
  362. }
  363. )
  364. );
  365. }
  366. ),
  367. GestureDetector(
  368. child: Stack(
  369. children: [
  370. Container(
  371. height: hsp(387)/2-wsp(6),
  372. width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2,
  373. decoration: BoxDecoration(
  374. borderRadius: BorderRadius.all(Radius.circular(5))
  375. ),
  376. child: ClipRRect(
  377. child: CachedNetworkImage(
  378. imageUrl: '${_dataArray[index]['dtAirTours'][2]['cover']}',
  379. fit: BoxFit.fill,
  380. ),
  381. borderRadius: BorderRadius.all(Radius.circular(5)),
  382. )
  383. ),
  384. Container(
  385. height: hsp(40),
  386. alignment: Alignment.centerLeft,
  387. child: Text('${_dataArray[index]['dtAirTours'][2]['title']}',style: TextStyle(fontSize: zsp(20),color: Colors.white),),
  388. decoration: BoxDecoration(
  389. color: Color(0xFFFB882E),
  390. borderRadius: BorderRadius.only(bottomRight: Radius.circular(5),topLeft: Radius.circular(5))
  391. ),
  392. padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  393. )
  394. ],
  395. ),
  396. onTap: (){
  397. Navigator.of(context,rootNavigator: true).push(
  398. CupertinoPageRoute(
  399. builder: (context){
  400. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?
  401. YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours']
  402. [2]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type:_dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][2]['id'],):
  403. _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][2]['id'],):_dataArray[index]['target']=='7'?
  404. YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][2]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'],
  405. marryId: _dataArray[index]['dtAirTours'][2]['id'],):YSNews();
  406. }
  407. )
  408. );
  409. }
  410. ),
  411. ],
  412. )
  413. ],
  414. ),
  415. ),
  416. ],
  417. ):_dataArray[index]['displayType']=='2'?Column(
  418. children: [
  419. Container(
  420. height: hsp(100),
  421. color: Colors.white,
  422. padding: EdgeInsets.all(hsp(24)),
  423. child: Row(
  424. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  425. children: [
  426. Row(
  427. children: [
  428. Container(
  429. height: hsp(36),
  430. width: wsp(5),
  431. color: Color(0xFF3676EC),
  432. margin: EdgeInsets.only(right: wsp(20),top: hsp(8)),
  433. ),
  434. Text('${_dataArray[index]['labelName']}',style: TextStyle(fontSize: zsp(36),color: Color(0xFF181818),fontWeight: FontWeight.bold),)
  435. ],
  436. ),
  437. GestureDetector(
  438. onTap: (){
  439. Navigator.of(context,rootNavigator: true).push(
  440. CupertinoPageRoute(
  441. builder: (context){
  442. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?YSShortGoods():
  443. _dataArray[index]['target']=='4'?YSSightseeingPlane(type: planeType.marry,):_dataArray[index]['target']=='5'?YSSightseeingPlane(type: planeType.sport,):_dataArray[index]['target']=='6'?YSShortPlane():
  444. _dataArray[index]['target']=='7'?YSTravelling():_dataArray[index]['target']=='8'?YSContractPlane():_dataArray[index]['target']=='9'?YSSightseeingPlane(type: planeType.sightseeing,):YSNews();
  445. }
  446. )
  447. );
  448. },
  449. child: Row(
  450. children: [
  451. Text('更多',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  452. Icon(Icons.keyboard_arrow_right,size: hsp(30),color: Color(0xFF999999),)
  453. ],
  454. ),
  455. )
  456. ],
  457. ),
  458. ),
  459. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F2),),
  460. Container(
  461. height: hsp(420),
  462. margin: EdgeInsets.only(top: hsp(24),bottom: hsp(24),left: wsp(40),right: wsp(24)),
  463. child: Swiper(
  464. itemBuilder: (BuildContext context, int indexSub) {
  465. return GestureDetector(
  466. onTap: (){
  467. Navigator.of(context,rootNavigator: true).push(
  468. CupertinoPageRoute(
  469. builder: (context){
  470. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?
  471. YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours']
  472. [indexSub]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],):
  473. _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='7'?
  474. YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'],
  475. marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],):YSNews();
  476. }
  477. )
  478. );
  479. },
  480. child: Container(
  481. width: wsp(350),
  482. margin: EdgeInsets.only(bottom: hsp(20),top: hsp(10)),
  483. decoration: BoxDecoration(
  484. color: Colors.white,
  485. boxShadow: [
  486. BoxShadow(
  487. color: Color(0x1A000000),
  488. blurRadius: wsp(20),
  489. offset: Offset(1, 1),
  490. )
  491. ]
  492. ),
  493. child: Column(
  494. children: [
  495. Stack(
  496. children: [
  497. Container(
  498. height: hsp(200),
  499. width: wsp(350),
  500. decoration: BoxDecoration(
  501. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)),
  502. ),
  503. child: ClipRRect(
  504. child: CachedNetworkImage(
  505. imageUrl: '${_dataArray[index]['dtAirTours'][indexSub]['cover']}',
  506. fit: BoxFit.fill,
  507. ),
  508. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)),
  509. )
  510. ),
  511. Row(
  512. children: [
  513. Container(
  514. height: hsp(32),
  515. alignment: Alignment.centerLeft,
  516. child: Text('西安',style: TextStyle(fontSize: zsp(20),color: Colors.white),),
  517. decoration: BoxDecoration(
  518. color: Color(0xFFE9C68E),
  519. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomRight: Radius.circular(5))
  520. ),
  521. padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  522. )
  523. ],
  524. )
  525. ],
  526. ),
  527. Container(
  528. decoration: BoxDecoration(
  529. borderRadius: BorderRadius.only(bottomLeft: Radius.circular(5),bottomRight: Radius.circular(5)),
  530. ),
  531. child: Column(
  532. children: [
  533. Container(
  534. width: wsp(350),
  535. child: Text('${_dataArray[index]['dtAirTours'][indexSub]['title']}',
  536. style: TextStyle(fontSize: zsp(28),fontWeight: FontWeight.bold,color: Color(0xFF181818)),overflow: TextOverflow.ellipsis,maxLines: 2,),
  537. margin: EdgeInsets.only(top: hsp(20),bottom: hsp(15)),
  538. ),
  539. SingleChildScrollView(
  540. scrollDirection: Axis.horizontal,
  541. child: Row(
  542. children: [
  543. Text('¥',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  544. Text('${_dataArray[index]['dtAirTours'][indexSub]['price']}',style: TextStyle(fontSize: zsp(38),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  545. Text(' 元起',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  546. Text('${_dataArray[index]['dtAirTours'][indexSub]['dtFlightInformation']['seatNum']}人体验',style: TextStyle(fontSize: zsp(16),color: Color(0xFFA2A2A2),fontWeight: FontWeight.normal),),
  547. ],
  548. ),
  549. )
  550. ],
  551. crossAxisAlignment: CrossAxisAlignment.start,
  552. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  553. ),
  554. padding: EdgeInsets.all(hsp(20)),
  555. )
  556. ],
  557. ),
  558. ),
  559. );
  560. },
  561. itemCount: (_dataArray[index]['dtAirTours']).length,
  562. scrollDirection: Axis.horizontal,
  563. loop: true,
  564. viewportFraction: 0.5,
  565. scale: 0.8,
  566. onTap: (index) {
  567. debugPrint("点击了第:$index个");
  568. },
  569. ),
  570. ),
  571. ],
  572. ):Column(
  573. children: [
  574. Container(
  575. height: hsp(100),
  576. color: Colors.white,
  577. padding: EdgeInsets.all(hsp(24)),
  578. child: Row(
  579. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  580. children: [
  581. Row(
  582. children: [
  583. Container(
  584. height: hsp(36),
  585. width: wsp(5),
  586. color: Color(0xFF3676EC),
  587. margin: EdgeInsets.only(right: wsp(20),top: hsp(8)),
  588. ),
  589. Text('${_dataArray[index]['labelName']}',style: TextStyle(fontSize: zsp(36),color: Color(0xFF181818),fontWeight: FontWeight.bold),)
  590. ],
  591. ),
  592. GestureDetector(
  593. onTap: (){
  594. Navigator.of(context,rootNavigator: true).push(
  595. CupertinoPageRoute(
  596. builder: (context){
  597. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?YSShortGoods():
  598. _dataArray[index]['target']=='4'?YSSightseeingPlane(type: planeType.marry,):_dataArray[index]['target']=='5'?YSSightseeingPlane(type: planeType.sport,):_dataArray[index]['target']=='6'?YSShortPlane():
  599. _dataArray[index]['target']=='7'?YSTravelling():_dataArray[index]['target']=='8'?YSContractPlane():_dataArray[index]['target']=='9'?YSSightseeingPlane(type: planeType.sightseeing,):YSNews();
  600. }
  601. )
  602. );
  603. },
  604. child: Row(
  605. children: [
  606. Text('更多',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  607. Icon(Icons.keyboard_arrow_right,size: hsp(30),color: Color(0xFF999999),)
  608. ],
  609. ),
  610. )
  611. ],
  612. ),
  613. ),
  614. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F2),),
  615. Container(
  616. height: hsp(470),
  617. margin: EdgeInsets.all(hsp(24)),
  618. child: ListView.separated(
  619. scrollDirection: Axis.horizontal,
  620. itemBuilder: (context,indexSub){
  621. return GestureDetector(
  622. onTap: (){
  623. Navigator.of(context,rootNavigator: true).push(
  624. CupertinoPageRoute(
  625. builder: (context){
  626. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?
  627. YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours']
  628. [indexSub]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],):
  629. _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='7'?
  630. YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'],
  631. marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],):YSNews();
  632. }
  633. )
  634. );
  635. },
  636. child: Container(
  637. height: hsp(450),
  638. width: wsp(350),
  639. decoration: BoxDecoration(
  640. color: Colors.white,
  641. boxShadow: [
  642. BoxShadow(
  643. color: Color(0x1A000000),
  644. blurRadius: wsp(20),
  645. offset: Offset(1, 1),
  646. )
  647. ]
  648. ),
  649. child: Column(
  650. children: [
  651. Stack(
  652. children: [
  653. Container(
  654. height: hsp(210),
  655. width: wsp(330),
  656. decoration: BoxDecoration(
  657. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)),
  658. ),
  659. child: ClipRRect(
  660. child: CachedNetworkImage(
  661. imageUrl: '${_dataArray[index]['dtAirTours'][indexSub]['cover']}',
  662. fit: BoxFit.fill,
  663. ),
  664. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)),
  665. )
  666. ),
  667. Row(
  668. children: [
  669. if(_dataArray[index]['dtAirTours'][indexSub]['isVip']==1)Container(
  670. height: hsp(32),
  671. width: wsp(59),
  672. decoration: BoxDecoration(
  673. color: Color(0xFFE9C68E),
  674. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomRight: Radius.circular(5))
  675. ),
  676. padding: EdgeInsets.only(left: wsp(10),right: wsp(10)),
  677. child: Image.asset('lib/images/vip.png'),
  678. )
  679. ],
  680. )
  681. ],
  682. ),
  683. Container(
  684. height: hsp(240),
  685. decoration: BoxDecoration(
  686. borderRadius: BorderRadius.only(bottomLeft: Radius.circular(5),bottomRight: Radius.circular(5)),
  687. ),
  688. child: Column(
  689. children: [
  690. Container(
  691. width: wsp(330),
  692. child: Text('${_dataArray[index]['dtAirTours'][indexSub]['title']}',style: TextStyle(fontSize: zsp(32),fontWeight: FontWeight.bold,color: Color(0xFF181818)),overflow: TextOverflow.ellipsis,),
  693. ),
  694. Row(
  695. children: [
  696. Container(
  697. height: hsp(30),
  698. child: Row(
  699. children: [
  700. Image(image: AssetImage('lib/images/vip2.png'),height: hsp(15),width: wsp(16),),
  701. Text(' ${_dataArray[index]['dtAirTours'][indexSub]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(18),color: Color(0xFFF9DEAC)),)
  702. ],
  703. ),
  704. color: Color(0xFF000000),
  705. padding: EdgeInsets.only(left: wsp(7),right: wsp(7)),
  706. ),
  707. Container(
  708. height: hsp(30),
  709. decoration: BoxDecoration(
  710. border: Border.all(color: Color(0xFF000000),width: 0.1)
  711. ),
  712. padding: EdgeInsets.only(left: wsp(10),right: wsp(10)),
  713. child: Text('座位${_dataArray[index]['dtAirTours'][indexSub]['dtFlightInformation']['seatNum']}',style: TextStyle(fontSize: zsp(18),color: Color(0xFF565656)),),
  714. alignment: Alignment.center,
  715. )
  716. ],
  717. ),
  718. Text('${_dataArray[index]['dtAirTours'][indexSub]['flightTime']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFFA2A2A2)),),
  719. SingleChildScrollView(
  720. scrollDirection: Axis.horizontal,
  721. child: Row(
  722. children: [
  723. Text('¥',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  724. Text('${_dataArray[index]['dtAirTours'][indexSub]['discountPrice']}',style: TextStyle(fontSize: zsp(38),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  725. Text(' 元起/座',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  726. Text(' ¥${_dataArray[index]['dtAirTours'][indexSub]['price']}元起/座',style: TextStyle(fontSize: zsp(16),color: Color(0xFFA2A2A2),fontWeight: FontWeight.normal),),
  727. ],
  728. ),
  729. )
  730. ],
  731. crossAxisAlignment: CrossAxisAlignment.start,
  732. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  733. ),
  734. padding: EdgeInsets.all(hsp(20)),
  735. )
  736. ],
  737. ),
  738. ),
  739. );
  740. },
  741. separatorBuilder: (context,index){
  742. return Container(
  743. color: Colors.white,
  744. width: wsp(14),
  745. );
  746. },
  747. itemCount: (_dataArray[index]['dtAirTours']).length,
  748. padding: EdgeInsets.only(bottom: hsp(20)),
  749. ),
  750. ),
  751. ],
  752. );
  753. },
  754. separatorBuilder: (context,index){
  755. return Divider(height: 10,thickness: 10,color: Color(0xFFF5F6F8),);
  756. },
  757. itemCount: _dataArray.length,
  758. padding: EdgeInsets.all(0),
  759. shrinkWrap: true,
  760. physics: NeverScrollableScrollPhysics(),
  761. ),
  762. Container(
  763. height: 30,
  764. color: Color(0xFFF5F6F8),
  765. )
  766. ],
  767. ),
  768. ),
  769. ),
  770. );
  771. }
  772. _getFeatureDisplayShowData() async{
  773. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/featureDisplay/show',parameter: {},isLoading: false,isToken: false);
  774. if(dict!=null){
  775. _banners = dict['data']['banner'];
  776. _products = dict['data']['product'];
  777. _advertising = dict['data']['advertising'];
  778. SharedPreferences prefer = await SharedPreferences.getInstance();
  779. if(prefer.getString('cityHistory')!=null){
  780. String historyStr = prefer.getString('cityHistory');
  781. List historyList = jsonDecode(historyStr);
  782. _city = '${historyList[0]['display']}';
  783. }else{
  784. _city = '';
  785. }
  786. _getFeatureDisplayListData(_city);
  787. }
  788. }
  789. _getFeatureDisplayListData(String city) async {
  790. Map dict = await ysRequestHttp(context, type: requestType.get,api: '/app/applets/featureDisplay/list',parameter: {'city':city},isLoading: true,isToken: false);
  791. if (dict != null) {
  792. setState(() {
  793. _dataArray = dict['data'];
  794. });
  795. }
  796. }
  797. }