import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:open_file/open_file.dart'; import 'package:package_info/package_info.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:ysairplane2/code/YSCity.dart'; import 'package:ysairplane2/code/YSContractPlaneDetail.dart'; import 'package:ysairplane2/code/YSDoctorPlane.dart'; import 'package:ysairplane2/code/YSHelpPlane.dart'; import 'package:ysairplane2/code/YSHomeMsg.dart'; import 'package:ysairplane2/code/YSMarryPlane.dart'; import 'package:ysairplane2/code/YSSearch.dart'; import 'package:ysairplane2/code/YSShortDetail.dart'; import 'package:ysairplane2/code/YSShortGoods.dart'; import 'package:ysairplane2/code/YSShortPlane.dart'; import 'package:ysairplane2/code/YSTravelling.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:ysairplane2/code/YSNews.dart'; import 'package:ysairplane2/tools/YSTools.dart'; import 'YSContractPlane.dart'; import 'YSSightseeingPlane.dart'; class YSHome extends StatefulWidget { @override _YSHomeState createState() => _YSHomeState(); } class _YSHomeState extends State with AutomaticKeepAliveClientMixin{ List _banners = []; List _products = []; Map _advertising; String _city = ''; List _dataArray = []; SwiperController _swiperController = SwiperController(); bool _isLocation = false; @override bool get wantKeepAlive => true; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _getFeatureDisplayShowData(); _getPrivacyAgreement(); }); super.initState(); } _getPrivacyAgreement() async{ if(Platform.isAndroid==true){ _getPermission(); }else{ Future.delayed(Duration(seconds: 1)).then((value){ setState(() { _isLocation = true; }); }); } // SharedPreferences prefer = await SharedPreferences.getInstance(); // if(prefer.getBool('isRead')==true){ // _getPermission(); // }else{ // var dict = await ysRequestHttp(context, type: requestType.get, api: '/app/applets/dic/dtDic/getPrivacyAgreement', parameter: {},isLoading: false); // if(dict!=null){ // showAgreeAlert(context,title: '用户协议与隐私政策',content: dict['data']['value'],agree: (value){ // if(value==false){ // Navigator.pop(context); // }else{ // Navigator.pop(context); // if(Platform.isAndroid){ // _getPermission(); // }else{ // setState(() { // _isLocation = true; // }); // } // } // }); // } // } } @override void dispose() { _swiperController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { super.build(context); return Scaffold( backgroundColor: Colors.white, appBar: CupertinoNavigationBar( leading: GestureDetector( onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return YSCity(isHome: true); } ) ).then((value) async{ if(value!=null){ _city = value['name']; SharedPreferences preferences = await SharedPreferences.getInstance(); preferences.setString('location', _city); _getFeatureDisplayListData(_city); } }); }, child: Row( mainAxisSize: MainAxisSize.min, children: [ Container( width: hsp(35*(_city.length>5?5:_city.length)), child: Text(_city,style: TextStyle(fontSize: zsp(28),color: Color(0xFF8E8E93)),overflow: TextOverflow.ellipsis,), ), Icon(Icons.keyboard_arrow_down,size: zsp(30),color: Color(0xFF8E8E93),) ], ), ), middle: GestureDetector( onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return YSSearch(); } ) ); }, child: Container( height: hsp(66), padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), decoration: BoxDecoration( color: Color(0xFFF0F0F1), borderRadius: BorderRadius.all(Radius.circular(5)) ), child: Row( children: [ Icon(Icons.search,size: hsp(40),color: Color(0xFF8E8E93),), Text(' 目的地·酒店·关键词',style: TextStyle(fontSize: zsp(28),color: Color(0xFF8E8E93),fontWeight: FontWeight.normal),) ], ), ), ), trailing: GestureDetector( onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return YSHomeMsg(); } ) ); }, child: Container( height: hsp(40), width: wsp(40), child: Image.asset('lib/images/homeMsg.png'), ), ), border: Border.all(width: 0.5,color: Colors.white), ), body: Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-94, child: RefreshIndicator( onRefresh: _getFeatureDisplayShowData, child: SingleChildScrollView( padding: EdgeInsets.all(0), child: Column( children: [ if(_isLocation==true)Container( height: 1, width: 1, child: platformView( platforms: (value) { value.setMethodCallHandler((call) { if(call.method == "city"){ print('==================>>${call.arguments}'); SharedPreferences.getInstance().then((value2){ // if(value2.getString('cityHistory')!=null){ // String historyStr = value2.getString('cityHistory'); // List historyList = jsonDecode(historyStr); // _city = '${historyList[0]['name']}'; // }else{ // _city = call.arguments; // _city = _city.replaceAll('市', ''); // } _city = call.arguments; _city = _city.replaceAll('市', ''); value2.setString('location', _city); _getFeatureDisplayListData(_city); }); } return; }); }, message: {'type':1} ) ), if(_banners.length>0)banner(context, _banners), if(_products.length>0)products(context, _products), if(_advertising!=null)Container( margin: EdgeInsets.only(left: hsp(24),right: hsp(24),bottom: hsp(24)), child: ysImageLoad( imageUrl: '${_advertising['url']}', fit: BoxFit.fill, height: wsp(136), width: MediaQuery.of(context).size.width-hsp(48) ), ), Divider(height: 10,thickness: 10,color: Color(0xFFF5F6F8),), ListView.separated( itemBuilder: (context,index){ return _dataArray[index]['displayType']=='1'?Column( children: [ Container( height: hsp(100), padding: EdgeInsets.only(left: hsp(24),right: hsp(24)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Container( height: hsp(36), width: wsp(5), color: Color(0xFF3676EC), margin: EdgeInsets.only(right: wsp(20),top: hsp(8)), ), Text('${_dataArray[index]['labelName']}',style: TextStyle(fontSize: zsp(36),color: Color(0xFF181818),fontWeight: FontWeight.bold),) ], ), GestureDetector( onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?YSShortGoods(): _dataArray[index]['target']=='4'?YSSightseeingPlane(type: planeType.marry,):_dataArray[index]['target']=='5'?YSSightseeingPlane(type: planeType.sport,):_dataArray[index]['target']=='6'?YSShortPlane(): _dataArray[index]['target']=='7'?YSTravelling():_dataArray[index]['target']=='8'?YSContractPlane():_dataArray[index]['target']=='9'?YSSightseeingPlane(type: planeType.sightseeing,):YSNews(); } ) ); }, child: Row( children: [ Text('更多',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),), Icon(Icons.keyboard_arrow_right,size: hsp(30),color: Color(0xFF999999),) ], ), ) ], ), ), Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F2),), Container( height: hsp(387), margin: EdgeInsets.all(hsp(24)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ if(_dataArray[index]['dtAirTours'].length>0)GestureDetector( child: Stack( children: [ Container( height: hsp(387), width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5)) ), child: ClipRRect( child: ysImageLoad( imageUrl: '${_dataArray[index]['dtAirTours'][0]['cover']}', fit: BoxFit.fill, height: hsp(387), width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2, ), borderRadius: BorderRadius.all(Radius.circular(5)), ) ), Container( height: hsp(40), alignment: Alignment.centerLeft, child: Text('${_dataArray[index]['dtAirTours'][0]['title']}',style: TextStyle(fontSize: zsp(20),color: Colors.white),), decoration: BoxDecoration( color: Colors.black26, borderRadius: BorderRadius.only(bottomRight: Radius.circular(5),topLeft: Radius.circular(5)) ), padding: EdgeInsets.only(left: hsp(10),right: hsp(10)), ) ], ), onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'? YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'] [0]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][0]['id'],): _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][0]['id'],):_dataArray[index]['target']=='7'? YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][0]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'], marryId: _dataArray[index]['dtAirTours'][0]['id'],):YSNews(); } ) ); }, ), Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ if(_dataArray[index]['dtAirTours'].length>1)GestureDetector( child: Stack( children: [ Container( height: hsp(387)/2-wsp(6), width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5)) ), child: ClipRRect( child: ysImageLoad( imageUrl: '${_dataArray[index]['dtAirTours'][1]['cover']}', fit: BoxFit.fill, height: hsp(387)/2-wsp(6), width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2, ), borderRadius: BorderRadius.all(Radius.circular(5)), ) ), Container( height: hsp(40), alignment: Alignment.centerLeft, child: Text('${_dataArray[index]['dtAirTours'][1]['title']}',style: TextStyle(fontSize: zsp(20),color: Colors.white),), decoration: BoxDecoration( color: Color(0xFFEC6163), borderRadius: BorderRadius.only(bottomRight: Radius.circular(5),topLeft: Radius.circular(5)) ), padding: EdgeInsets.only(left: hsp(10),right: hsp(10)), ) ], ), onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'? YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'] [1]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][1]['id'],): _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][1]['id'],):_dataArray[index]['target']=='7'? YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][1]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'], marryId: _dataArray[index]['dtAirTours'][1]['id'],):YSNews(); } ) ); } ), if(_dataArray[index]['dtAirTours'].length>2)GestureDetector( child: Stack( children: [ Container( height: hsp(387)/2-wsp(6), width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5)) ), child: ClipRRect( child: ysImageLoad( imageUrl: '${_dataArray[index]['dtAirTours'][2]['cover']}', fit: BoxFit.fill, height: hsp(387)/2-wsp(6), width: (MediaQuery.of(context).size.width-wsp(24)*2-wsp(6))/2, ), borderRadius: BorderRadius.all(Radius.circular(5)), ) ), Container( height: hsp(40), alignment: Alignment.centerLeft, child: Text('${_dataArray[index]['dtAirTours'][2]['title']}',style: TextStyle(fontSize: zsp(20),color: Colors.white),), decoration: BoxDecoration( color: Color(0xFFFB882E), borderRadius: BorderRadius.only(bottomRight: Radius.circular(5),topLeft: Radius.circular(5)) ), padding: EdgeInsets.only(left: hsp(10),right: hsp(10)), ) ], ), onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'? YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'] [2]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type:_dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][2]['id'],): _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][2]['id'],):_dataArray[index]['target']=='7'? YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][2]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'], marryId: _dataArray[index]['dtAirTours'][2]['id'],):YSNews(); } ) ); } ), ], ) ], ), ), ], ):_dataArray[index]['displayType']=='2'?Column( children: [ if((_dataArray[index]['dtAirTours']).length>0)Container( height: hsp(100), color: Colors.white, padding: EdgeInsets.only(left: hsp(24),right: hsp(24)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Container( height: hsp(36), width: wsp(5), color: Color(0xFF3676EC), margin: EdgeInsets.only(right: wsp(20),top: hsp(8)), ), Text('${_dataArray[index]['labelName']}',style: TextStyle(fontSize: zsp(36),color: Color(0xFF181818),fontWeight: FontWeight.bold),) ], ), GestureDetector( onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?YSShortGoods(): _dataArray[index]['target']=='4'?YSSightseeingPlane(type: planeType.marry,):_dataArray[index]['target']=='5'?YSSightseeingPlane(type: planeType.sport,):_dataArray[index]['target']=='6'?YSShortPlane(): _dataArray[index]['target']=='7'?YSTravelling():_dataArray[index]['target']=='8'?YSContractPlane():_dataArray[index]['target']=='9'?YSSightseeingPlane(type: planeType.sightseeing,):YSNews(); } ) ); }, child: Row( children: [ Text('更多',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),), Icon(Icons.keyboard_arrow_right,size: hsp(30),color: Color(0xFF999999),) ], ), ) ], ), ), if((_dataArray[index]['dtAirTours']).length>0)Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F2),), if((_dataArray[index]['dtAirTours']).length>0)Container( height: hsp(420), margin: EdgeInsets.only(top: hsp(24),bottom: hsp(24),left: wsp(40),right: wsp(24)), child: Swiper( itemBuilder: (BuildContext context, int indexSub) { return GestureDetector( onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'? YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'] [indexSub]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],): _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='7'? YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'], marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],):YSNews(); } ) ); }, child: Container( width: wsp(350), margin: EdgeInsets.only(bottom: hsp(20),top: hsp(10)), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x1A000000), blurRadius: wsp(20), offset: Offset(1, 1), ) ] ), child: Column( children: [ Stack( children: [ Container( height: hsp(200), width: wsp(350), decoration: BoxDecoration( borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)), ), child: ClipRRect( child: ysImageLoad( imageUrl: '${_dataArray[index]['dtAirTours'][indexSub]['cover']}', fit: BoxFit.fill, height: hsp(200), width: wsp(350), ), borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)), ) ), // Row( // children: [ // Container( // height: hsp(32), // alignment: Alignment.centerLeft, // child: Text('西安',style: TextStyle(fontSize: zsp(20),color: Colors.white),), // decoration: BoxDecoration( // color: Color(0xFFE9C68E), // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomRight: Radius.circular(5)) // ), // padding: EdgeInsets.only(left: hsp(10),right: hsp(10)), // ) // ], // ) ], ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.only(bottomLeft: Radius.circular(5),bottomRight: Radius.circular(5)), ), child: Column( children: [ Container( width: wsp(350), child: Text('${_dataArray[index]['dtAirTours'][indexSub]['title']}', style: TextStyle(fontSize: zsp(28),fontWeight: FontWeight.bold,color: Color(0xFF181818)), overflow: TextOverflow.ellipsis,maxLines: 2,), margin: EdgeInsets.only(top: hsp(20),bottom: hsp(15)), ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: [ Text('¥',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),), Text('${_dataArray[index]['dtAirTours'][indexSub]['price']}',style: TextStyle(fontSize: zsp(38),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),), Text(' 元起',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),), Text(' ${_dataArray[index]['dtAirTours'][indexSub]['dtFlightInformation']['seatNum']}人体验',style: TextStyle(fontSize: zsp(16),color: Color(0xFFA2A2A2),fontWeight: FontWeight.normal),), ], ), ) ], crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, ), padding: EdgeInsets.all(hsp(10)), ) ], ), ), ); }, itemCount: (_dataArray[index]['dtAirTours']).length, scrollDirection: Axis.horizontal, loop: true, viewportFraction: 0.5, scale: 0.8, onTap: (index) { debugPrint("点击了第:$index个"); }, ), ), ], ):Column( children: [ if((_dataArray[index]['dtAirTours']).length>0)Container( height: hsp(100), color: Colors.white, padding: EdgeInsets.only(left: hsp(24),right: hsp(24)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Container( height: hsp(36), width: wsp(5), color: Color(0xFF3676EC), margin: EdgeInsets.only(right: wsp(20),top: hsp(8)), ), Text('${_dataArray[index]['labelName']}',style: TextStyle(fontSize: zsp(36),color: Color(0xFF181818),fontWeight: FontWeight.bold),) ], ), GestureDetector( onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'?YSShortGoods(): _dataArray[index]['target']=='4'?YSSightseeingPlane(type: planeType.marry,):_dataArray[index]['target']=='5'?YSSightseeingPlane(type: planeType.sport,):_dataArray[index]['target']=='6'?YSShortPlane(): _dataArray[index]['target']=='7'?YSTravelling():_dataArray[index]['target']=='8'?YSContractPlane():_dataArray[index]['target']=='9'?YSSightseeingPlane(type: planeType.sightseeing,):YSNews(); } ) ); }, child: Row( children: [ Text('更多',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),), Icon(Icons.keyboard_arrow_right,size: hsp(30),color: Color(0xFF999999),) ], ), ) ], ), ), if((_dataArray[index]['dtAirTours']).length>0)Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F2),), if((_dataArray[index]['dtAirTours']).length>0)Container( height: hsp(430), margin: EdgeInsets.all(hsp(24)), child: ListView.separated( scrollDirection: Axis.horizontal, itemBuilder: (context,indexSub){ return GestureDetector( onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return _dataArray[index]['target']=='1'?YSDoctorPlane():_dataArray[index]['target']=='2'?YSHelpPlane():_dataArray[index]['target']=='3'? YSShortGoods():_dataArray[index]['target']=='4'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'] [indexSub]['id'],):_dataArray[index]['target']=='5'?YSMarryPlane(type: _dataArray[index]['target'],marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],): _dataArray[index]['target']=='6'?YSShortDetail(shortId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='7'? YSTravelling():_dataArray[index]['target']=='8'?YSContractPlaneDetail(contractId: _dataArray[index]['dtAirTours'][indexSub]['id'],):_dataArray[index]['target']=='9'?YSMarryPlane(type: _dataArray[index]['target'], marryId: _dataArray[index]['dtAirTours'][indexSub]['id'],):YSNews(); } ) ); }, child: Container( height: hsp(410), width: wsp(350), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x1A000000), blurRadius: wsp(20), offset: Offset(1, 1), ) ] ), child: Column( children: [ Stack( children: [ Container( height: hsp(210), width: wsp(330), decoration: BoxDecoration( borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)), ), child: ClipRRect( child: ysImageLoad( imageUrl: '${_dataArray[index]['dtAirTours'][indexSub]['cover']}', fit: BoxFit.fill, height: hsp(210), width: wsp(330), ), borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)), ) ), Row( children: [ if(_dataArray[index]['dtAirTours'][indexSub]['isVip']==1)Container( height: hsp(32), width: wsp(59), decoration: BoxDecoration( color: Color(0xFFE9C68E), borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomRight: Radius.circular(5)) ), padding: EdgeInsets.only(left: wsp(10),right: wsp(10)), child: Image.asset('lib/images/vip.png'), ) ], ) ], ), Container( height: hsp(200), decoration: BoxDecoration( borderRadius: BorderRadius.only(bottomLeft: Radius.circular(5),bottomRight: Radius.circular(5)), ), child: Column( children: [ Container( width: wsp(330), child: Text('${_dataArray[index]['dtAirTours'][indexSub]['title']}',style: TextStyle(fontSize: zsp(32),fontWeight: FontWeight.bold,color: Color(0xFF181818)),overflow: TextOverflow.ellipsis,), ), Row( children: [ Container( height: hsp(30), child: Row( children: [ Image(image: AssetImage('lib/images/vip2.png'),height: hsp(15),width: wsp(16),), Text(' ${_dataArray[index]['dtAirTours'][indexSub]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(18),color: Color(0xFFF9DEAC)),) ], ), color: Color(0xFF000000), padding: EdgeInsets.only(left: wsp(7),right: wsp(7)), ), Container( height: hsp(30), decoration: BoxDecoration( border: Border.all(color: Color(0xFF000000),width: 0.1) ), padding: EdgeInsets.only(left: wsp(10),right: wsp(10)), child: Text('座位${_dataArray[index]['dtAirTours'][indexSub]['dtFlightInformation']['seatNum']}',style: TextStyle(fontSize: zsp(18),color: Color(0xFF565656)),), alignment: Alignment.center, ) ], ), //Text('${_dataArray[index]['dtAirTours'][indexSub]['flightTime']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFFA2A2A2)),), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: [ Text('¥',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),), Text('${_dataArray[index]['dtAirTours'][indexSub]['discountPrice']}',style: TextStyle(fontSize: zsp(38),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),), Text(' 元起/座 ',style: TextStyle(fontSize: zsp(20),color: Color(0xFFEB423B),fontWeight: FontWeight.bold),), Text('¥${_dataArray[index]['dtAirTours'][indexSub]['price']}元起/座', style: TextStyle(fontSize: zsp(16),color: Color(0xFFA2A2A2),fontWeight: FontWeight.normal,decoration: TextDecoration.lineThrough),), ], ), ) ], crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, ), padding: EdgeInsets.all(hsp(20)), ) ], ), ), ); }, separatorBuilder: (context,index){ return Container( color: Colors.white, width: wsp(14), ); }, itemCount: (_dataArray[index]['dtAirTours']).length, padding: EdgeInsets.only(bottom: hsp(20)), ), ), ], ); }, separatorBuilder: (context,index){ return Divider(height: 10,thickness: 10,color: Color(0xFFF5F6F8),); }, itemCount: _dataArray.length, padding: EdgeInsets.all(0), shrinkWrap: true, physics: NeverScrollableScrollPhysics(), ), Container( height: 30, color: Color(0xFFF5F6F8), ) ], ), ), ), ), ); } Future _getFeatureDisplayShowData() async{ SharedPreferences prefer = await SharedPreferences.getInstance(); Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/featureDisplay/show',parameter: {},isLoading: false,isToken: false); if(dict!=null){ String phoneStr = prefer.getString('phone'); final JPush jpush = new JPush(); if(phoneStr!=null)jpush.setAlias(phoneStr); _banners = dict['data']['banner']; _products = dict['data']['product']; _advertising = dict['data']['advertising']; _getFeatureDisplayListData(_city); } } _getPermission() async{ if (await Permission.locationAlways.request().isGranted || await Permission.locationWhenInUse.request().isGranted) { _isLocation = true; }else{ Map statuses = await [ Permission.location, Permission.locationAlways, ].request(); if(statuses[Permission.location].isGranted||statuses[Permission.locationAlways].isGranted){ _isLocation = true; } print('==============C ${statuses[Permission.location]}'); } if(_isLocation){ setState(() {}); } } _getFeatureDisplayListData(String city) async { Map dict = await ysRequestHttp(context, type: requestType.get,api: '/app/applets/featureDisplay/list',parameter: {'city':city},isLoading: false,isToken: false); if (dict != null) { setState(() { _dataArray = dict['data']; }); _getVersionData(); } } _getVersionData() async { SharedPreferences prefer = await SharedPreferences.getInstance(); if(prefer.getBool('isRead')==false)return; Map dict = await ysRequestHttp(context, type: requestType.get,api: '/app/applets/version/info',parameter: {},isLoading: false,isToken: false); if (dict != null) { if(dict['data']==null)return; PackageInfo packageInfo = await PackageInfo.fromPlatform(); int version1 = int.parse(packageInfo.version.split('.').join('')); int version2 = int.parse('${dict['data']['versionNo']}'.split('.').join('')); if(version1 statuses = await [Permission.storage].request(); if(statuses[Permission.storage].isGranted==false){ return; } } double progress = -1; showGeneralDialog( context: context, barrierDismissible:false, barrierLabel: '', transitionDuration: Duration(milliseconds: 200), pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { return Center( child: StatefulBuilder( builder: (context,updateSet){ return Container( height: hsp(800), width: MediaQuery.of(context).size.width-hsp(200), child: Column( children: [ Stack( children: [ Container( height: hsp(700), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5)), image: DecorationImage(image: AssetImage('lib/images/组796.png'),fit: BoxFit.fill,) ), ), Container( margin: EdgeInsets.only(top: hsp(80),left: hsp(40)), child: Text('发现新版本',style: TextStyle(fontSize: zsp(40),color: Color(0xFFFEFDFD),decoration: TextDecoration.none)), ), Container( margin: EdgeInsets.only(top: hsp(145),left: hsp(40)), child: Text('${dict['data']['versionNo']}',style: TextStyle(fontSize: zsp(27),color: Color(0xFFFEFDFD),decoration: TextDecoration.none)), ), progress==-1?Column( children: [ Container( margin: EdgeInsets.only(top: hsp(300)), height: hsp(250), width: MediaQuery.of(context).size.width, padding: EdgeInsets.only(left: hsp(50),right: hsp(50),top: hsp(30)), child: SingleChildScrollView( padding: EdgeInsets.all(0), child: Text('${dict['data']['content']}',style: TextStyle(fontSize: zsp(26), color: Color(0xFF555555),decoration: TextDecoration.none,fontWeight: FontWeight.normal),), ), ), GestureDetector( onTap: () async{ PackageInfo app; PackageInfo.fromPlatform().then((PackageInfo packageInfo) { app = packageInfo; }); /// 创建存储文件 Directory storageDir = await getExternalStorageDirectory(); String storagePath = storageDir.path; File file = new File('$storagePath/${app.appName}v${dict['data']['versionNo']}.apk'); if (!file.existsSync()) { file.createSync(); } try { /// 发起下载请求 Response response = await Dio().get('${dict['data']['address']}',options: Options(responseType: ResponseType.bytes,), onReceiveProgress: (count,total){ if (total != -1) { progress = double.parse('${(count / total).toStringAsFixed(2)}'); if(progress==1){ String _apkFilePath = file.path; if (_apkFilePath.isEmpty) { print('make sure the apk file is set'); return; } OpenFile.open(_apkFilePath); // InstallPlugin.installApk(_apkFilePath, app.packageName).then((result) { // print('install apk $result'); // }).catchError((error) { // print('install apk error: $error'); // }); } updateSet(() {}); } }); file.writeAsBytesSync(response.data); } catch (e) { print(e); } // updateSet(() { // isUpdate = true; // }); }, child: Container( margin: EdgeInsets.only(top: hsp(50),left: hsp(20)), width: MediaQuery.of(context).size.width-hsp(340), height: hsp(70), decoration: BoxDecoration( color: Color(0xFF5792FF), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text('立即更新',style: TextStyle(fontSize: zsp(33),color: Color(0xFFFEFDFD),decoration: TextDecoration.none),), ), ) ], ):Column( children: [ Container( margin: EdgeInsets.only(top: hsp(350),bottom: hsp(20)), height: hsp(250), width: MediaQuery.of(context).size.width, alignment: Alignment.center, child: Stack( children: [ Container( height: hsp(170), width: hsp(170), child: CircularProgressIndicator( value: progress, backgroundColor: Color(0xFFF5F5F5), valueColor: AlwaysStoppedAnimation(Color(0xFF4587FF)), strokeWidth: hsp(20), ), ), Container( height: hsp(170), width: hsp(170), alignment: Alignment.center, child: Text('${(progress*100).toStringAsFixed(1)}%',style: TextStyle(fontSize: zsp(30),color: Color(0xFF4587FF), decoration: TextDecoration.none,fontWeight: FontWeight.normal),), ), ], ), ), Text('新版本正在努力的更新中,请稍等',style: TextStyle(fontSize: zsp(26), color: Color(0xFF999999),decoration: TextDecoration.none,fontWeight: FontWeight.normal),) ], ), ], ), if(progress==-1)GestureDetector( onTap: (){Navigator.pop(context);}, child: Container( height: hsp(50), width: hsp(50), child: Image.asset('lib/images/关闭.png'), margin: EdgeInsets.only(top: hsp(50)), ), ) ], ), ); }, ), ); } ); } } } } banner(BuildContext context, List array) { SwiperController _swiperController = SwiperController(); Future _future = Future.value(array); return ysFutureWidge( net: _future, data: (value){ return Container( height: hsp(292), margin: EdgeInsets.all(hsp(24)), child: Swiper( itemBuilder: (BuildContext context, int index) { return ysImageLoad( imageUrl: '${value.data[index]['url']}', fit: BoxFit.fill, height: hsp(292), width: MediaQuery.of(context).size.width-hsp(48) ); }, itemCount: value.data.length, scrollDirection: Axis.horizontal, loop: true, duration: 300, autoplay: true, onTap: (index) { Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return value.data[index]['target']==1?YSDoctorPlane():value.data[index]['target']==2?YSHelpPlane():value.data[index]['target']==3? YSShortGoods():value.data[index]['target']==4?YSMarryPlane(type: value.data[index]['target'],marryId: value.data[index]['targerId'],):value.data[index]['target']==5? YSMarryPlane(type: value.data[index]['target'],marryId: value.data[index]['targerId'],): value.data[index]['target']==6?YSShortDetail(shortId: value.data[index]['targerId'],):value.data[index]['target']==7? YSTravelling():value.data[index]['target']==8?YSContractPlaneDetail(contractId: value.data[index]['targerId'],):value.data[index]['target']==9?YSMarryPlane(type: value.data[index]['target'], marryId: value.data[index]['targerId'],):YSNews(); } ) ); }, pagination: SwiperPagination( alignment: Alignment.bottomCenter, builder: DotSwiperPaginationBuilder( color: Colors.white, activeColor: Colors.white, size: 5.0, activeSize: 10.0 ), ), autoplayDisableOnInteraction : true, controller: _swiperController, ), ); } ); } products(BuildContext context, List array) { Future _future = Future.value(array); return ysFutureWidge( net: _future, data: (value){ return Container( margin: EdgeInsets.only(left: hsp(24),right: hsp(24),top: hsp(15),bottom: hsp(30)), child: GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 5, crossAxisSpacing: wsp(51), mainAxisSpacing: hsp(36), childAspectRatio: 0.75 ), itemBuilder: (context,index){ return GestureDetector( onTap: (){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return value.data[index]['target']==1?YSDoctorPlane():value.data[index]['target']==2?YSHelpPlane():value.data[index]['target']==3?YSShortGoods(): value.data[index]['target']==4?YSSightseeingPlane(type: planeType.marry,):value.data[index]['target']==5?YSSightseeingPlane(type: planeType.sport,):value.data[index]['target']==6?YSShortPlane(): value.data[index]['target']==7?YSTravelling():value.data[index]['target']==8?YSContractPlane():value.data[index]['target']==9?YSSightseeingPlane(type: planeType.sightseeing,):YSNews(); } ) ); }, child: Container( child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ ysImageLoad( width: 40, height: 40, imageUrl: '${value.data[index]['url']}', fit: BoxFit.fill ), Text('${value.data[index]['name']}',style: TextStyle(fontSize: zsp(23),color: Color(0xFF34373A)),) ], ), ), ); }, itemCount: value.data.length, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), shrinkWrap: true, ), ); } ); }