YSHome.dart 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. import 'dart:convert';
  2. import 'dart:io';
  3. import 'package:dio/dio.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:install_plugin/install_plugin.dart';
  7. import 'package:jpush_flutter/jpush_flutter.dart';
  8. import 'package:package_info/package_info.dart';
  9. import 'package:path_provider/path_provider.dart';
  10. import 'package:permission_handler/permission_handler.dart';
  11. import 'package:shared_preferences/shared_preferences.dart';
  12. import 'package:ysairplane2/code/YSCity.dart';
  13. import 'package:ysairplane2/code/YSContractPlaneDetail.dart';
  14. import 'package:ysairplane2/code/YSDoctorPlane.dart';
  15. import 'package:ysairplane2/code/YSHelpPlane.dart';
  16. import 'package:ysairplane2/code/YSHomeMsg.dart';
  17. import 'package:ysairplane2/code/YSMarryPlane.dart';
  18. import 'package:ysairplane2/code/YSSearch.dart';
  19. import 'package:ysairplane2/code/YSShortDetail.dart';
  20. import 'package:ysairplane2/code/YSShortGoods.dart';
  21. import 'package:ysairplane2/code/YSShortPlane.dart';
  22. import 'package:ysairplane2/code/YSTravelling.dart';
  23. import 'package:ysairplane2/tools/YSNetWorking.dart';
  24. import 'package:flutter_swiper/flutter_swiper.dart';
  25. import 'package:ysairplane2/code/YSNews.dart';
  26. import 'package:ysairplane2/tools/YSTools.dart';
  27. import 'YSContractPlane.dart';
  28. import 'YSSightseeingPlane.dart';
  29. class YSHome extends StatefulWidget {
  30. @override
  31. _YSHomeState createState() => _YSHomeState();
  32. }
  33. class _YSHomeState extends State<YSHome> with AutomaticKeepAliveClientMixin{
  34. List _banners = [];
  35. List _products = [];
  36. Map _advertising;
  37. String _city = '';
  38. List _dataArray = [];
  39. SwiperController _swiperController = SwiperController();
  40. bool _isLocation = false;
  41. @override
  42. bool get wantKeepAlive => true;
  43. @override
  44. void initState() {
  45. Future.delayed(Duration(seconds: 0)).then((value){
  46. _getFeatureDisplayShowData();
  47. _getPrivacyAgreement();
  48. });
  49. super.initState();
  50. }
  51. _getPrivacyAgreement() async{
  52. if(Platform.isAndroid){
  53. _getPermission();
  54. }else{
  55. setState(() {
  56. _isLocation = true;
  57. });
  58. }
  59. // SharedPreferences prefer = await SharedPreferences.getInstance();
  60. // if(prefer.getBool('isRead')==true){
  61. // _getPermission();
  62. // }else{
  63. // var dict = await ysRequestHttp(context, type: requestType.get, api: '/app/applets/dic/dtDic/getPrivacyAgreement', parameter: {},isLoading: false);
  64. // if(dict!=null){
  65. // showAgreeAlert(context,title: '用户协议与隐私政策',content: dict['data']['value'],agree: (value){
  66. // if(value==false){
  67. // Navigator.pop(context);
  68. // }else{
  69. // Navigator.pop(context);
  70. // if(Platform.isAndroid){
  71. // _getPermission();
  72. // }else{
  73. // setState(() {
  74. // _isLocation = true;
  75. // });
  76. // }
  77. // }
  78. // });
  79. // }
  80. // }
  81. }
  82. @override
  83. void dispose() {
  84. _swiperController.dispose();
  85. super.dispose();
  86. }
  87. @override
  88. Widget build(BuildContext context) {
  89. super.build(context);
  90. return Scaffold(
  91. backgroundColor: Colors.white,
  92. appBar: CupertinoNavigationBar(
  93. leading: GestureDetector(
  94. onTap: (){
  95. Navigator.of(context,rootNavigator: true).push(
  96. CupertinoPageRoute(
  97. builder: (context){
  98. return YSCity(isHome: true);
  99. }
  100. )
  101. ).then((value) async{
  102. if(value!=null){
  103. _city = value['name'];
  104. SharedPreferences preferences = await SharedPreferences.getInstance();
  105. preferences.setString('location', _city);
  106. _getFeatureDisplayListData(_city);
  107. }
  108. });
  109. },
  110. child: Row(
  111. mainAxisSize: MainAxisSize.min,
  112. children: [
  113. Container(
  114. width: hsp(35*(_city.length>5?5:_city.length)),
  115. child: Text(_city,style: TextStyle(fontSize: zsp(28),color: Color(0xFF8E8E93)),overflow: TextOverflow.ellipsis,),
  116. ),
  117. Icon(Icons.keyboard_arrow_down,size: zsp(30),color: Color(0xFF8E8E93),)
  118. ],
  119. ),
  120. ),
  121. middle: GestureDetector(
  122. onTap: (){
  123. Navigator.of(context,rootNavigator: true).push(
  124. CupertinoPageRoute(
  125. builder: (context){
  126. return YSSearch();
  127. }
  128. )
  129. );
  130. },
  131. child: Container(
  132. height: hsp(66),
  133. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  134. decoration: BoxDecoration(
  135. color: Color(0xFFF0F0F1),
  136. borderRadius: BorderRadius.all(Radius.circular(5))
  137. ),
  138. child: Row(
  139. children: [
  140. Icon(Icons.search,size: hsp(40),color: Color(0xFF8E8E93),),
  141. Text(' 目的地·酒店·关键词',style: TextStyle(fontSize: zsp(28),color: Color(0xFF8E8E93),fontWeight: FontWeight.normal),)
  142. ],
  143. ),
  144. ),
  145. ),
  146. trailing: GestureDetector(
  147. onTap: (){
  148. Navigator.of(context,rootNavigator: true).push(
  149. CupertinoPageRoute(
  150. builder: (context){
  151. return YSHomeMsg();
  152. }
  153. )
  154. );
  155. },
  156. child: Container(
  157. height: hsp(40),
  158. width: wsp(40),
  159. child: Image.asset('lib/images/homeMsg.png'),
  160. ),
  161. ),
  162. border: Border.all(width: 0.5,color: Colors.white),
  163. ),
  164. body: Container(
  165. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-94,
  166. child: RefreshIndicator(
  167. onRefresh: _getFeatureDisplayShowData,
  168. child: SingleChildScrollView(
  169. padding: EdgeInsets.all(0),
  170. child: Column(
  171. children: [
  172. if(_isLocation)Container(
  173. height: 1,
  174. width: 1,
  175. child: platformView(
  176. platforms: (value) {
  177. value.setMethodCallHandler((call) {
  178. if(call.method == "city"){
  179. print('==================${call.arguments}');
  180. SharedPreferences.getInstance().then((value2){
  181. // if(value2.getString('cityHistory')!=null){
  182. // String historyStr = value2.getString('cityHistory');
  183. // List historyList = jsonDecode(historyStr);
  184. // _city = '${historyList[0]['name']}';
  185. // }else{
  186. // _city = call.arguments;
  187. // _city = _city.replaceAll('市', '');
  188. // }
  189. _city = call.arguments;
  190. _city = _city.replaceAll('市', '');
  191. value2.setString('location', _city);
  192. _getFeatureDisplayListData(_city);
  193. });
  194. }
  195. return;
  196. });
  197. },
  198. message: {'type':1}
  199. )
  200. ),
  201. if(_banners.length>0)banner(context, _banners),
  202. if(_products.length>0)products(context, _products),
  203. if(_advertising!=null)Container(
  204. margin: EdgeInsets.only(left: hsp(24),right: hsp(24),bottom: hsp(24)),
  205. child: ysImageLoad(
  206. imageUrl: '${_advertising['url']}',
  207. fit: BoxFit.fill,
  208. height: wsp(136),
  209. width: MediaQuery.of(context).size.width-hsp(48)
  210. ),
  211. ),
  212. Divider(height: 10,thickness: 10,color: Color(0xFFF5F6F8),),
  213. ListView.separated(
  214. itemBuilder: (context,index){
  215. return _dataArray[index]['displayType']=='1'?Column(
  216. children: [
  217. Container(
  218. height: hsp(100),
  219. padding: EdgeInsets.only(left: hsp(24),right: hsp(24)),
  220. child: Row(
  221. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  222. children: [
  223. Row(
  224. children: [
  225. Container(
  226. height: hsp(36),
  227. width: wsp(5),
  228. color: Color(0xFF3676EC),
  229. margin: EdgeInsets.only(right: wsp(20),top: hsp(8)),
  230. ),
  231. Text('${_dataArray[index]['labelName']}',style: TextStyle(fontSize: zsp(36),color: Color(0xFF181818),fontWeight: FontWeight.bold),)
  232. ],
  233. ),
  234. GestureDetector(
  235. onTap: (){
  236. Navigator.of(context,rootNavigator: true).push(
  237. CupertinoPageRoute(
  238. builder: (context){
  239. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?YSShortGoods():
  240. _dataArray[index]['target']=='4'?YSSightseeingPlane(type: planeType.marry,):_dataArray[index]['target']=='5'?YSSightseeingPlane(type: planeType.sport,):_dataArray[index]['target']=='6'?YSShortPlane():
  241. _dataArray[index]['target']=='7'?YSTravelling():_dataArray[index]['target']=='8'?YSContractPlane():_dataArray[index]['target']=='9'?YSSightseeingPlane(type: planeType.sightseeing,):YSNews();
  242. }
  243. )
  244. );
  245. },
  246. child: Row(
  247. children: [
  248. Text('更多',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  249. Icon(Icons.keyboard_arrow_right,size: hsp(30),color: Color(0xFF999999),)
  250. ],
  251. ),
  252. )
  253. ],
  254. ),
  255. ),
  256. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F2),),
  257. Container(
  258. height: hsp(387),
  259. margin: EdgeInsets.all(hsp(24)),
  260. child: Row(
  261. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  262. children: [
  263. if(_dataArray[index]['dtAirTours'].length>0)GestureDetector(
  264. child: Stack(
  265. children: [
  266. Container(
  267. height: hsp(387),
  268. width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2,
  269. decoration: BoxDecoration(
  270. borderRadius: BorderRadius.all(Radius.circular(5))
  271. ),
  272. child: ClipRRect(
  273. child: ysImageLoad(
  274. imageUrl: '${_dataArray[index]['dtAirTours'][0]['cover']}',
  275. fit: BoxFit.fill,
  276. height: hsp(387),
  277. width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2,
  278. ),
  279. borderRadius: BorderRadius.all(Radius.circular(5)),
  280. )
  281. ),
  282. Container(
  283. height: hsp(40),
  284. alignment: Alignment.centerLeft,
  285. child: Text('${_dataArray[index]['dtAirTours'][0]['title']}',style: TextStyle(fontSize: zsp(20),color: Colors.white),),
  286. decoration: BoxDecoration(
  287. color: Colors.black26,
  288. borderRadius: BorderRadius.only(bottomRight: Radius.circular(5),topLeft: Radius.circular(5))
  289. ),
  290. padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  291. )
  292. ],
  293. ),
  294. onTap: (){
  295. Navigator.of(context,rootNavigator: true).push(
  296. CupertinoPageRoute(
  297. builder: (context){
  298. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?
  299. YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours']
  300. [0]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][0]['id'],):
  301. _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][0]['id'],):_dataArray[index]['target']=='7'?
  302. YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][0]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'],
  303. marryId: _dataArray[index]['dtAirTours'][0]['id'],):YSNews();
  304. }
  305. )
  306. );
  307. },
  308. ),
  309. Column(
  310. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  311. children: [
  312. if(_dataArray[index]['dtAirTours'].length>1)GestureDetector(
  313. child: Stack(
  314. children: [
  315. Container(
  316. height: hsp(387)/2-wsp(6),
  317. width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2,
  318. decoration: BoxDecoration(
  319. borderRadius: BorderRadius.all(Radius.circular(5))
  320. ),
  321. child: ClipRRect(
  322. child: ysImageLoad(
  323. imageUrl: '${_dataArray[index]['dtAirTours'][1]['cover']}',
  324. fit: BoxFit.fill,
  325. height: hsp(387)/2-wsp(6),
  326. width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2,
  327. ),
  328. borderRadius: BorderRadius.all(Radius.circular(5)),
  329. )
  330. ),
  331. Container(
  332. height: hsp(40),
  333. alignment: Alignment.centerLeft,
  334. child: Text('${_dataArray[index]['dtAirTours'][1]['title']}',style: TextStyle(fontSize: zsp(20),color: Colors.white),),
  335. decoration: BoxDecoration(
  336. color: Color(0xFFEC6163),
  337. borderRadius: BorderRadius.only(bottomRight: Radius.circular(5),topLeft: Radius.circular(5))
  338. ),
  339. padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  340. )
  341. ],
  342. ),
  343. onTap: (){
  344. Navigator.of(context,rootNavigator: true).push(
  345. CupertinoPageRoute(
  346. builder: (context){
  347. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?
  348. YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours']
  349. [1]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][1]['id'],):
  350. _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][1]['id'],):_dataArray[index]['target']=='7'?
  351. YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][1]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'],
  352. marryId: _dataArray[index]['dtAirTours'][1]['id'],):YSNews();
  353. }
  354. )
  355. );
  356. }
  357. ),
  358. if(_dataArray[index]['dtAirTours'].length>2)GestureDetector(
  359. child: Stack(
  360. children: [
  361. Container(
  362. height: hsp(387)/2-wsp(6),
  363. width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2,
  364. decoration: BoxDecoration(
  365. borderRadius: BorderRadius.all(Radius.circular(5))
  366. ),
  367. child: ClipRRect(
  368. child: ysImageLoad(
  369. imageUrl: '${_dataArray[index]['dtAirTours'][2]['cover']}',
  370. fit: BoxFit.fill,
  371. height: hsp(387)/2-wsp(6),
  372. width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2,
  373. ),
  374. borderRadius: BorderRadius.all(Radius.circular(5)),
  375. )
  376. ),
  377. Container(
  378. height: hsp(40),
  379. alignment: Alignment.centerLeft,
  380. child: Text('${_dataArray[index]['dtAirTours'][2]['title']}',style: TextStyle(fontSize: zsp(20),color: Colors.white),),
  381. decoration: BoxDecoration(
  382. color: Color(0xFFFB882E),
  383. borderRadius: BorderRadius.only(bottomRight: Radius.circular(5),topLeft: Radius.circular(5))
  384. ),
  385. padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  386. )
  387. ],
  388. ),
  389. onTap: (){
  390. Navigator.of(context,rootNavigator: true).push(
  391. CupertinoPageRoute(
  392. builder: (context){
  393. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?
  394. YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours']
  395. [2]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type:_dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][2]['id'],):
  396. _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][2]['id'],):_dataArray[index]['target']=='7'?
  397. YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][2]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'],
  398. marryId: _dataArray[index]['dtAirTours'][2]['id'],):YSNews();
  399. }
  400. )
  401. );
  402. }
  403. ),
  404. ],
  405. )
  406. ],
  407. ),
  408. ),
  409. ],
  410. ):_dataArray[index]['displayType']=='2'?Column(
  411. children: [
  412. if((_dataArray[index]['dtAirTours']).length>0)Container(
  413. height: hsp(100),
  414. color: Colors.white,
  415. padding: EdgeInsets.only(left: hsp(24),right: hsp(24)),
  416. child: Row(
  417. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  418. children: [
  419. Row(
  420. children: [
  421. Container(
  422. height: hsp(36),
  423. width: wsp(5),
  424. color: Color(0xFF3676EC),
  425. margin: EdgeInsets.only(right: wsp(20),top: hsp(8)),
  426. ),
  427. Text('${_dataArray[index]['labelName']}',style: TextStyle(fontSize: zsp(36),color: Color(0xFF181818),fontWeight: FontWeight.bold),)
  428. ],
  429. ),
  430. GestureDetector(
  431. onTap: (){
  432. Navigator.of(context,rootNavigator: true).push(
  433. CupertinoPageRoute(
  434. builder: (context){
  435. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?YSShortGoods():
  436. _dataArray[index]['target']=='4'?YSSightseeingPlane(type: planeType.marry,):_dataArray[index]['target']=='5'?YSSightseeingPlane(type: planeType.sport,):_dataArray[index]['target']=='6'?YSShortPlane():
  437. _dataArray[index]['target']=='7'?YSTravelling():_dataArray[index]['target']=='8'?YSContractPlane():_dataArray[index]['target']=='9'?YSSightseeingPlane(type: planeType.sightseeing,):YSNews();
  438. }
  439. )
  440. );
  441. },
  442. child: Row(
  443. children: [
  444. Text('更多',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  445. Icon(Icons.keyboard_arrow_right,size: hsp(30),color: Color(0xFF999999),)
  446. ],
  447. ),
  448. )
  449. ],
  450. ),
  451. ),
  452. if((_dataArray[index]['dtAirTours']).length>0)Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F2),),
  453. if((_dataArray[index]['dtAirTours']).length>0)Container(
  454. height: hsp(420),
  455. margin: EdgeInsets.only(top: hsp(24),bottom: hsp(24),left: wsp(40),right: wsp(24)),
  456. child: Swiper(
  457. itemBuilder: (BuildContext context, int indexSub) {
  458. return GestureDetector(
  459. onTap: (){
  460. Navigator.of(context,rootNavigator: true).push(
  461. CupertinoPageRoute(
  462. builder: (context){
  463. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?
  464. YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours']
  465. [indexSub]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],):
  466. _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='7'?
  467. YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'],
  468. marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],):YSNews();
  469. }
  470. )
  471. );
  472. },
  473. child: Container(
  474. width: wsp(350),
  475. margin: EdgeInsets.only(bottom: hsp(20),top: hsp(10)),
  476. decoration: BoxDecoration(
  477. color: Colors.white,
  478. boxShadow: [
  479. BoxShadow(
  480. color: Color(0x1A000000),
  481. blurRadius: wsp(20),
  482. offset: Offset(1, 1),
  483. )
  484. ]
  485. ),
  486. child: Column(
  487. children: [
  488. Stack(
  489. children: [
  490. Container(
  491. height: hsp(200),
  492. width: wsp(350),
  493. decoration: BoxDecoration(
  494. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)),
  495. ),
  496. child: ClipRRect(
  497. child: ysImageLoad(
  498. imageUrl: '${_dataArray[index]['dtAirTours'][indexSub]['cover']}',
  499. fit: BoxFit.fill,
  500. height: hsp(200),
  501. width: wsp(350),
  502. ),
  503. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)),
  504. )
  505. ),
  506. // Row(
  507. // children: [
  508. // Container(
  509. // height: hsp(32),
  510. // alignment: Alignment.centerLeft,
  511. // child: Text('西安',style: TextStyle(fontSize: zsp(20),color: Colors.white),),
  512. // decoration: BoxDecoration(
  513. // color: Color(0xFFE9C68E),
  514. // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomRight: Radius.circular(5))
  515. // ),
  516. // padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  517. // )
  518. // ],
  519. // )
  520. ],
  521. ),
  522. Container(
  523. decoration: BoxDecoration(
  524. borderRadius: BorderRadius.only(bottomLeft: Radius.circular(5),bottomRight: Radius.circular(5)),
  525. ),
  526. child: Column(
  527. children: [
  528. Container(
  529. width: wsp(350),
  530. child: Text('${_dataArray[index]['dtAirTours'][indexSub]['title']}',
  531. style: TextStyle(fontSize: zsp(28),fontWeight: FontWeight.bold,color: Color(0xFF181818)),
  532. overflow: TextOverflow.ellipsis,maxLines: 2,),
  533. margin: EdgeInsets.only(top: hsp(20),bottom: hsp(15)),
  534. ),
  535. SingleChildScrollView(
  536. scrollDirection: Axis.horizontal,
  537. child: Row(
  538. children: [
  539. Text('¥',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  540. Text('${_dataArray[index]['dtAirTours'][indexSub]['price']}',style: TextStyle(fontSize: zsp(38),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  541. Text(' 元起',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  542. Text(' ${_dataArray[index]['dtAirTours'][indexSub]['dtFlightInformation']['seatNum']}人体验',style: TextStyle(fontSize: zsp(16),color: Color(0xFFA2A2A2),fontWeight: FontWeight.normal),),
  543. ],
  544. ),
  545. )
  546. ],
  547. crossAxisAlignment: CrossAxisAlignment.start,
  548. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  549. ),
  550. padding: EdgeInsets.all(hsp(10)),
  551. )
  552. ],
  553. ),
  554. ),
  555. );
  556. },
  557. itemCount: (_dataArray[index]['dtAirTours']).length,
  558. scrollDirection: Axis.horizontal,
  559. loop: true,
  560. viewportFraction: 0.5,
  561. scale: 0.8,
  562. onTap: (index) {
  563. debugPrint("点击了第:$index个");
  564. },
  565. ),
  566. ),
  567. ],
  568. ):Column(
  569. children: [
  570. if((_dataArray[index]['dtAirTours']).length>0)Container(
  571. height: hsp(100),
  572. color: Colors.white,
  573. padding: EdgeInsets.only(left: hsp(24),right: hsp(24)),
  574. child: Row(
  575. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  576. children: [
  577. Row(
  578. children: [
  579. Container(
  580. height: hsp(36),
  581. width: wsp(5),
  582. color: Color(0xFF3676EC),
  583. margin: EdgeInsets.only(right: wsp(20),top: hsp(8)),
  584. ),
  585. Text('${_dataArray[index]['labelName']}',style: TextStyle(fontSize: zsp(36),color: Color(0xFF181818),fontWeight: FontWeight.bold),)
  586. ],
  587. ),
  588. GestureDetector(
  589. onTap: (){
  590. Navigator.of(context,rootNavigator: true).push(
  591. CupertinoPageRoute(
  592. builder: (context){
  593. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?YSShortGoods():
  594. _dataArray[index]['target']=='4'?YSSightseeingPlane(type: planeType.marry,):_dataArray[index]['target']=='5'?YSSightseeingPlane(type: planeType.sport,):_dataArray[index]['target']=='6'?YSShortPlane():
  595. _dataArray[index]['target']=='7'?YSTravelling():_dataArray[index]['target']=='8'?YSContractPlane():_dataArray[index]['target']=='9'?YSSightseeingPlane(type: planeType.sightseeing,):YSNews();
  596. }
  597. )
  598. );
  599. },
  600. child: Row(
  601. children: [
  602. Text('更多',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  603. Icon(Icons.keyboard_arrow_right,size: hsp(30),color: Color(0xFF999999),)
  604. ],
  605. ),
  606. )
  607. ],
  608. ),
  609. ),
  610. if((_dataArray[index]['dtAirTours']).length>0)Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F2),),
  611. if((_dataArray[index]['dtAirTours']).length>0)Container(
  612. height: hsp(430),
  613. margin: EdgeInsets.all(hsp(24)),
  614. child: ListView.separated(
  615. scrollDirection: Axis.horizontal,
  616. itemBuilder: (context,indexSub){
  617. return GestureDetector(
  618. onTap: (){
  619. Navigator.of(context,rootNavigator: true).push(
  620. CupertinoPageRoute(
  621. builder: (context){
  622. return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?
  623. YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours']
  624. [indexSub]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],):
  625. _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='7'?
  626. YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'],
  627. marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],):YSNews();
  628. }
  629. )
  630. );
  631. },
  632. child: Container(
  633. height: hsp(410),
  634. width: wsp(350),
  635. decoration: BoxDecoration(
  636. color: Colors.white,
  637. boxShadow: [
  638. BoxShadow(
  639. color: Color(0x1A000000),
  640. blurRadius: wsp(20),
  641. offset: Offset(1, 1),
  642. )
  643. ]
  644. ),
  645. child: Column(
  646. children: [
  647. Stack(
  648. children: [
  649. Container(
  650. height: hsp(210),
  651. width: wsp(330),
  652. decoration: BoxDecoration(
  653. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)),
  654. ),
  655. child: ClipRRect(
  656. child: ysImageLoad(
  657. imageUrl: '${_dataArray[index]['dtAirTours'][indexSub]['cover']}',
  658. fit: BoxFit.fill,
  659. height: hsp(210),
  660. width: wsp(330),
  661. ),
  662. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)),
  663. )
  664. ),
  665. Row(
  666. children: [
  667. if(_dataArray[index]['dtAirTours'][indexSub]['isVip']==1)Container(
  668. height: hsp(32),
  669. width: wsp(59),
  670. decoration: BoxDecoration(
  671. color: Color(0xFFE9C68E),
  672. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomRight: Radius.circular(5))
  673. ),
  674. padding: EdgeInsets.only(left: wsp(10),right: wsp(10)),
  675. child: Image.asset('lib/images/vip.png'),
  676. )
  677. ],
  678. )
  679. ],
  680. ),
  681. Container(
  682. height: hsp(200),
  683. decoration: BoxDecoration(
  684. borderRadius: BorderRadius.only(bottomLeft: Radius.circular(5),bottomRight: Radius.circular(5)),
  685. ),
  686. child: Column(
  687. children: [
  688. Container(
  689. width: wsp(330),
  690. child: Text('${_dataArray[index]['dtAirTours'][indexSub]['title']}',style: TextStyle(fontSize: zsp(32),fontWeight: FontWeight.bold,color: Color(0xFF181818)),overflow: TextOverflow.ellipsis,),
  691. ),
  692. Row(
  693. children: [
  694. Container(
  695. height: hsp(30),
  696. child: Row(
  697. children: [
  698. Image(image: AssetImage('lib/images/vip2.png'),height: hsp(15),width: wsp(16),),
  699. Text(' ${_dataArray[index]['dtAirTours'][indexSub]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(18),color: Color(0xFFF9DEAC)),)
  700. ],
  701. ),
  702. color: Color(0xFF000000),
  703. padding: EdgeInsets.only(left: wsp(7),right: wsp(7)),
  704. ),
  705. Container(
  706. height: hsp(30),
  707. decoration: BoxDecoration(
  708. border: Border.all(color: Color(0xFF000000),width: 0.1)
  709. ),
  710. padding: EdgeInsets.only(left: wsp(10),right: wsp(10)),
  711. child: Text('座位${_dataArray[index]['dtAirTours'][indexSub]['dtFlightInformation']['seatNum']}',style: TextStyle(fontSize: zsp(18),color: Color(0xFF565656)),),
  712. alignment: Alignment.center,
  713. )
  714. ],
  715. ),
  716. //Text('${_dataArray[index]['dtAirTours'][indexSub]['flightTime']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFFA2A2A2)),),
  717. SingleChildScrollView(
  718. scrollDirection: Axis.horizontal,
  719. child: Row(
  720. children: [
  721. Text('¥',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  722. Text('${_dataArray[index]['dtAirTours'][indexSub]['discountPrice']}',style: TextStyle(fontSize: zsp(38),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  723. Text(' 元起/座 ',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),),
  724. Text('¥${_dataArray[index]['dtAirTours'][indexSub]['price']}元起/座',
  725. style: TextStyle(fontSize: zsp(16),color: Color(0xFFA2A2A2),fontWeight: FontWeight.normal,decoration: TextDecoration.lineThrough),),
  726. ],
  727. ),
  728. )
  729. ],
  730. crossAxisAlignment: CrossAxisAlignment.start,
  731. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  732. ),
  733. padding: EdgeInsets.all(hsp(20)),
  734. )
  735. ],
  736. ),
  737. ),
  738. );
  739. },
  740. separatorBuilder: (context,index){
  741. return Container(
  742. color: Colors.white,
  743. width: wsp(14),
  744. );
  745. },
  746. itemCount: (_dataArray[index]['dtAirTours']).length,
  747. padding: EdgeInsets.only(bottom: hsp(20)),
  748. ),
  749. ),
  750. ],
  751. );
  752. },
  753. separatorBuilder: (context,index){
  754. return Divider(height: 10,thickness: 10,color: Color(0xFFF5F6F8),);
  755. },
  756. itemCount: _dataArray.length,
  757. padding: EdgeInsets.all(0),
  758. shrinkWrap: true,
  759. physics: NeverScrollableScrollPhysics(),
  760. ),
  761. Container(
  762. height: 30,
  763. color: Color(0xFFF5F6F8),
  764. )
  765. ],
  766. ),
  767. ),
  768. ),
  769. ),
  770. );
  771. }
  772. Future<void> _getFeatureDisplayShowData() async{
  773. SharedPreferences prefer = await SharedPreferences.getInstance();
  774. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/featureDisplay/show',parameter: {},isLoading: false,isToken: false);
  775. if(dict!=null){
  776. final JPush jpush = new JPush();
  777. jpush.setAlias(prefer.getString('phone'));
  778. _banners = dict['data']['banner'];
  779. _products = dict['data']['product'];
  780. _advertising = dict['data']['advertising'];
  781. _getFeatureDisplayListData(_city);
  782. }
  783. }
  784. _getPermission() async{
  785. if (await Permission.locationAlways.request().isGranted || await Permission.locationWhenInUse.request().isGranted) {
  786. _isLocation = true;
  787. }else{
  788. Map<Permission, PermissionStatus> statuses = await [
  789. Permission.location,
  790. Permission.locationAlways,
  791. ].request();
  792. if(statuses[Permission.location].isGranted||statuses[Permission.locationAlways].isGranted){
  793. _isLocation = true;
  794. }
  795. print('==============C ${statuses[Permission.location]}');
  796. }
  797. if(_isLocation){
  798. setState(() {});
  799. }
  800. }
  801. _getFeatureDisplayListData(String city) async {
  802. Map dict = await ysRequestHttp(context, type: requestType.get,api: '/app/applets/featureDisplay/list',parameter: {'city':city},isLoading: false,isToken: false);
  803. if (dict != null) {
  804. setState(() {
  805. _dataArray = dict['data'];
  806. });
  807. _getVersionData();
  808. }
  809. }
  810. _getVersionData() async {
  811. SharedPreferences prefer = await SharedPreferences.getInstance();
  812. if(prefer.getBool('isRead')==false)return;
  813. Map dict = await ysRequestHttp(context, type: requestType.get,api: '/app/applets/version/info',parameter: {},isLoading: false,isToken: false);
  814. if (dict != null) {
  815. if(dict['data']==null)return;
  816. PackageInfo packageInfo = await PackageInfo.fromPlatform();
  817. int version1 = int.parse(packageInfo.version.split('.').join(''));
  818. int version2 = int.parse('${dict['data']['versionNo']}'.split('.').join(''));
  819. if(version1<version2){
  820. var status = await Permission.storage.status;
  821. if (status.isGranted==false) {
  822. Map<Permission, PermissionStatus> statuses = await [Permission.storage].request();
  823. if(statuses[Permission.storage].isGranted==false){
  824. return;
  825. }
  826. }
  827. double progress = -1;
  828. showGeneralDialog(
  829. context: context,
  830. barrierDismissible:false,
  831. barrierLabel: '',
  832. transitionDuration: Duration(milliseconds: 200),
  833. pageBuilder: (BuildContext context, Animation<double> animation,
  834. Animation<double> secondaryAnimation) {
  835. return Center(
  836. child: StatefulBuilder(
  837. builder: (context,updateSet){
  838. return Container(
  839. height: hsp(800),
  840. width: MediaQuery.of(context).size.width-hsp(200),
  841. child: Column(
  842. children: [
  843. Stack(
  844. children: [
  845. Container(
  846. height: hsp(700),
  847. decoration: BoxDecoration(
  848. borderRadius: BorderRadius.all(Radius.circular(5)),
  849. image: DecorationImage(image: AssetImage('lib/images/组796.png'),fit: BoxFit.fill,)
  850. ),
  851. ),
  852. Container(
  853. margin: EdgeInsets.only(top: hsp(80),left: hsp(40)),
  854. child: Text('发现新版本',style: TextStyle(fontSize: zsp(40),color: Color(0xFFFEFDFD),decoration: TextDecoration.none)),
  855. ),
  856. Container(
  857. margin: EdgeInsets.only(top: hsp(145),left: hsp(40)),
  858. child: Text('${dict['data']['versionNo']}',style: TextStyle(fontSize: zsp(27),color: Color(0xFFFEFDFD),decoration: TextDecoration.none)),
  859. ),
  860. progress==-1?Column(
  861. children: [
  862. Container(
  863. margin: EdgeInsets.only(top: hsp(300)),
  864. height: hsp(250),
  865. width: MediaQuery.of(context).size.width,
  866. padding: EdgeInsets.only(left: hsp(50),right: hsp(50),top: hsp(30)),
  867. child: SingleChildScrollView(
  868. padding: EdgeInsets.all(0),
  869. child: Text('${dict['data']['content']}',style: TextStyle(fontSize: zsp(26),
  870. color: Color(0xFF555555),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  871. ),
  872. ),
  873. GestureDetector(
  874. onTap: () async{
  875. PackageInfo app;
  876. PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
  877. app = packageInfo;
  878. });
  879. /// 创建存储文件
  880. Directory storageDir = await getExternalStorageDirectory();
  881. String storagePath = storageDir.path;
  882. File file = new File('$storagePath/${app.appName}v${dict['data']['versionNo']}.apk');
  883. if (!file.existsSync()) {
  884. file.createSync();
  885. }
  886. try {
  887. /// 发起下载请求
  888. Response response = await Dio().get('${dict['data']['address']}',options: Options(responseType: ResponseType.bytes,),
  889. onReceiveProgress: (count,total){
  890. if (total != -1) {
  891. progress = double.parse('${(count / total).toStringAsFixed(2)}');
  892. if(progress==1){
  893. String _apkFilePath = file.path;
  894. if (_apkFilePath.isEmpty) {
  895. print('make sure the apk file is set');
  896. return;
  897. }
  898. InstallPlugin.installApk(_apkFilePath, app.packageName).then((result) {
  899. print('install apk $result');
  900. }).catchError((error) {
  901. print('install apk error: $error');
  902. });
  903. }
  904. updateSet(() {});
  905. }
  906. });
  907. file.writeAsBytesSync(response.data);
  908. } catch (e) {
  909. print(e);
  910. }
  911. // updateSet(() {
  912. // isUpdate = true;
  913. // });
  914. },
  915. child: Container(
  916. margin: EdgeInsets.only(top: hsp(50),left: hsp(20)),
  917. width: MediaQuery.of(context).size.width-hsp(340),
  918. height: hsp(70),
  919. decoration: BoxDecoration(
  920. color: Color(0xFF5792FF),
  921. borderRadius: BorderRadius.all(Radius.circular(50))
  922. ),
  923. alignment: Alignment.center,
  924. child: Text('立即更新',style: TextStyle(fontSize: zsp(33),color: Color(0xFFFEFDFD),decoration: TextDecoration.none),),
  925. ),
  926. )
  927. ],
  928. ):Column(
  929. children: [
  930. Container(
  931. margin: EdgeInsets.only(top: hsp(350),bottom: hsp(20)),
  932. height: hsp(250),
  933. width: MediaQuery.of(context).size.width,
  934. alignment: Alignment.center,
  935. child: Stack(
  936. children: [
  937. Container(
  938. height: hsp(170),
  939. width: hsp(170),
  940. child: CircularProgressIndicator(
  941. value: progress,
  942. backgroundColor: Color(0xFFF5F5F5),
  943. valueColor: AlwaysStoppedAnimation<Color>(Color(0xFF4587FF)),
  944. strokeWidth: hsp(20),
  945. ),
  946. ),
  947. Container(
  948. height: hsp(170),
  949. width: hsp(170),
  950. alignment: Alignment.center,
  951. child: Text('${(progress*100).toStringAsFixed(1)}%',style: TextStyle(fontSize: zsp(30),color: Color(0xFF4587FF),
  952. decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  953. ),
  954. ],
  955. ),
  956. ),
  957. Text('新版本正在努力的更新中,请稍等',style: TextStyle(fontSize: zsp(26),
  958. color: Color(0xFF999999),decoration: TextDecoration.none,fontWeight: FontWeight.normal),)
  959. ],
  960. ),
  961. ],
  962. ),
  963. if(progress==-1)GestureDetector(
  964. onTap: (){Navigator.pop(context);},
  965. child: Container(
  966. height: hsp(50),
  967. width: hsp(50),
  968. child: Image.asset('lib/images/关闭.png'),
  969. margin: EdgeInsets.only(top: hsp(50)),
  970. ),
  971. )
  972. ],
  973. ),
  974. );
  975. },
  976. ),
  977. );
  978. }
  979. );
  980. }
  981. }
  982. }
  983. }
  984. banner(BuildContext context, List array) {
  985. SwiperController _swiperController = SwiperController();
  986. Future<List> _future = Future.value(array);
  987. return ysFutureWidge(
  988. net: _future,
  989. data: (value){
  990. return Container(
  991. height: hsp(292),
  992. margin: EdgeInsets.all(hsp(24)),
  993. child: Swiper(
  994. itemBuilder: (BuildContext context, int index) {
  995. return ysImageLoad(
  996. imageUrl: '${value.data[index]['url']}',
  997. fit: BoxFit.fill,
  998. height: hsp(292),
  999. width: MediaQuery.of(context).size.width-hsp(48)
  1000. );
  1001. },
  1002. itemCount: value.data.length,
  1003. scrollDirection: Axis.horizontal,
  1004. loop: true,
  1005. duration: 300,
  1006. autoplay: true,
  1007. onTap: (index) {
  1008. Navigator.of(context,rootNavigator: true).push(
  1009. CupertinoPageRoute(
  1010. builder: (context){
  1011. return value.data[index]['target']==1?YSDoctorPlane():value.data[index]['target']==2?YSHelpPlane():value.data[index]['target']==3?
  1012. YSShortGoods():value.data[index]['target']==4?YSMarryPlane(type: value.data[index]['target'],marryId: value.data[index]['targerId'],):value.data[index]['target']==5?
  1013. YSMarryPlane(type: value.data[index]['target'],marryId: value.data[index]['targerId'],):
  1014. value.data[index]['target']==6?YSShortDetail(shortId: value.data[index]['targerId'],):value.data[index]['target']==7?
  1015. YSTravelling():value.data[index]['target']==8?YSContractPlaneDetail(contractId: value.data[index]['targerId'],):value.data[index]['target']==9?YSMarryPlane(type: value.data[index]['target'],
  1016. marryId: value.data[index]['targerId'],):YSNews();
  1017. }
  1018. )
  1019. );
  1020. },
  1021. pagination: SwiperPagination(
  1022. alignment: Alignment.bottomCenter,
  1023. builder: DotSwiperPaginationBuilder(
  1024. color: Colors.white,
  1025. activeColor: Colors.white,
  1026. size: 5.0,
  1027. activeSize: 10.0
  1028. ),
  1029. ),
  1030. autoplayDisableOnInteraction : true,
  1031. controller: _swiperController,
  1032. ),
  1033. );
  1034. }
  1035. );
  1036. }
  1037. products(BuildContext context, List array) {
  1038. Future<List> _future = Future.value(array);
  1039. return ysFutureWidge(
  1040. net: _future,
  1041. data: (value){
  1042. return Container(
  1043. margin: EdgeInsets.only(left: hsp(24),right: hsp(24),top: hsp(15),bottom: hsp(30)),
  1044. child: GridView.builder(
  1045. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  1046. crossAxisCount: 5,
  1047. crossAxisSpacing: wsp(51),
  1048. mainAxisSpacing: hsp(36),
  1049. childAspectRatio: 0.75
  1050. ),
  1051. itemBuilder: (context,index){
  1052. return GestureDetector(
  1053. onTap: (){
  1054. Navigator.of(context,rootNavigator: true).push(
  1055. CupertinoPageRoute(
  1056. builder: (context){
  1057. return value.data[index]['target']==1?YSDoctorPlane():value.data[index]['target']==2?YSHelpPlane():value.data[index]['target']==3?YSShortGoods():
  1058. value.data[index]['target']==4?YSSightseeingPlane(type: planeType.marry,):value.data[index]['target']==5?YSSightseeingPlane(type: planeType.sport,):value.data[index]['target']==6?YSShortPlane():
  1059. value.data[index]['target']==7?YSTravelling():value.data[index]['target']==8?YSContractPlane():value.data[index]['target']==9?YSSightseeingPlane(type: planeType.sightseeing,):YSNews();
  1060. }
  1061. )
  1062. );
  1063. },
  1064. child: Container(
  1065. child: Column(
  1066. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1067. children: [
  1068. ysImageLoad(
  1069. width: 40,
  1070. height: 40,
  1071. imageUrl: '${value.data[index]['url']}',
  1072. fit: BoxFit.fill
  1073. ),
  1074. Text('${value.data[index]['name']}',style: TextStyle(fontSize: zsp(23),color: Color(0xFF34373A)),)
  1075. ],
  1076. ),
  1077. ),
  1078. );
  1079. },
  1080. itemCount: value.data.length,
  1081. padding: EdgeInsets.all(0),
  1082. physics: NeverScrollableScrollPhysics(),
  1083. shrinkWrap: true,
  1084. ),
  1085. );
  1086. }
  1087. );
  1088. }