1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102 |
- 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<YSHome> 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<void> _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<Permission, PermissionStatus> 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<version2){
- var status = await Permission.storage.status;
- if (status.isGranted==false) {
- Map<Permission, PermissionStatus> 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<double> animation,
- Animation<double> 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>(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<List> _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<List> _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,
- ),
- );
- }
- );
- }
|