123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_easyrefresh/easy_refresh.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- import 'package:ysairplane2/code/YSMarryPlane.dart';
- import 'package:ysairplane2/code/YSSearchResult.dart';
- import 'package:ysairplane2/tools/YSNetWorking.dart';
- import 'package:ysairplane2/tools/YSTools.dart';
- enum planeType{
- sightseeing,
- sport,
- marry,
- }
- class YSSightseeingPlane extends StatefulWidget {
- final planeType type;
- const YSSightseeingPlane({Key key, this.type}) : super(key: key);
- @override
- _YSSightseeingPlaneState createState() => _YSSightseeingPlaneState();
- }
- class _YSSightseeingPlaneState extends State<YSSightseeingPlane> {
- Map _msgDict;
- List _titles = ['综合','距离','价格','评分'];
- int _titleIndex = 0;
- int _page = 1;
- List _dataArray = [];
- int _type;
- String _cityStr = '';
- @override
- void initState() {
- Future.delayed(Duration(seconds: 0)).then((value){
- _type = widget.type==planeType.marry?4:widget.type==planeType.sport?5:9;
- _getBackImageData();
- _refreshData();
- });
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Color(0xFFF1F2F3),
- body: SingleChildScrollView(
- padding: EdgeInsets.all(0),
- child: Stack(
- children: [
- Container(
- height: MediaQuery.of(context).padding.top+hsp(370),
- width: MediaQuery.of(context).size.width,
- child: _msgDict==null?Image(
- image: AssetImage('lib/images/home3.png'),
- fit: BoxFit.fill,
- ):ysImageLoad(
- imageUrl: '${_msgDict['background']}',
- fit: BoxFit.fill,
- height: MediaQuery.of(context).padding.top+hsp(370),
- width: MediaQuery.of(context).size.width,
- ),
- ),
- GestureDetector(
- onTap: (){
- Navigator.pop(context);
- },
- child: Container(
- margin: EdgeInsets.only(left: hsp(30),right: wsp(30),top: MediaQuery.of(context).padding.top+hsp(50)),
- child: Icon(Icons.arrow_back_ios,color: Colors.white,size: hsp(50),),
- ),
- ),
- GestureDetector(
- onTap: (){
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return YSSearchResult(type: _type,);
- })
- );
- },
- child : Container(
- margin: EdgeInsets.only(left: hsp(110),top: MediaQuery.of(context).padding.top+hsp(45)),
- width: MediaQuery.of(context).size.width-hsp(140),
- height: hsp(60),
- decoration: BoxDecoration(
- color: Colors.black.withOpacity(0.35),
- borderRadius: BorderRadius.all(Radius.circular(50))
- ),
- padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
- child: Row(
- children: [
- Row(
- children: [
- Text(_cityStr,style: TextStyle(fontSize: zsp(26),color: Colors.white),),
- Icon(Icons.keyboard_arrow_down,color: Colors.white.withOpacity(0.5),size: hsp(40),)
- ],
- ),
- Container(
- height: hsp(30),
- width: 0.5,
- margin: EdgeInsets.only(left: wsp(10),right: wsp(10)),
- color: Colors.white.withOpacity(0.2),
- ),
- Row(
- children: [
- Icon(Icons.search,color: Colors.white.withOpacity(0.5),size: hsp(50),),
- Text(' 搜索',style: TextStyle(fontSize: zsp(26),color: Colors.white.withOpacity(0.5)),),
- ],
- )
- ],
- ),
- ),
- ),
- if(_msgDict!=null)Container(
- margin: EdgeInsets.only(left: wsp(50),top: MediaQuery.of(context).padding.top+hsp(250)),
- child: RichText(
- text: TextSpan(
- text: '${_msgDict['name']} ',
- style: TextStyle(fontSize: zsp(50),color: Colors.white,fontWeight: FontWeight.bold),
- children: [
- TextSpan(
- text: '${_msgDict['subtitle']}',
- style: TextStyle(fontWeight: FontWeight.normal,fontSize: zsp(28),color: Colors.white.withOpacity(0.5))
- )
- ]
- ),
- ),
- ),
- Container(
- margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(350)),
- height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(350),
- width: MediaQuery.of(context).size.width,
- decoration: BoxDecoration(
- color: Color(0xFFF1F2F3),
- borderRadius: BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
- ),
- child: Column(
- children: [
- Container(
- width: MediaQuery.of(context).size.width,
- height: hsp(80),
- child: ListView.builder(
- itemBuilder: (context,index){
- return GestureDetector(
- onTap: (){
- _titleIndex = index;
- _refreshData();
- },
- child: Container(
- height: hsp(80),
- width: MediaQuery.of(context).size.width/4,
- alignment: Alignment.center,
- child: Text('${_titles[index]}',style: TextStyle(fontSize: zsp(26),color: _titleIndex==index?Color(0xFF007AFF):Color(0xFF222222),fontWeight: _titleIndex==index?FontWeight.bold:FontWeight.normal),),
- ),
- );
- },
- itemCount: _titles.length,
- padding: EdgeInsets.all(0),
- scrollDirection: Axis.horizontal,
- ),
- ),
- Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEEEEEE),),
- Container(
- width: MediaQuery.of(context).size.width,
- height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(430)-0.5,
- child: EasyRefresh(
- onRefresh: _refreshData,
- onLoad: _loadMoreData,
- header: TaurusHeader(
- ),
- footer: TaurusFooter(
- ),
- child: ListView.separated(
- itemBuilder: (context,index){
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: (){
- Navigator.of(context).push(
- CupertinoPageRoute(
- builder: (context){
- return YSMarryPlane(marryId: _dataArray[index]['id'],type: _type);
- }
- )
- );
- },
- child: Container(
- padding: EdgeInsets.all(hsp(30)),
- child: Row(
- children: [
- Container(
- height: hsp(200),
- width: hsp(250),
- child: ysImageLoad(
- imageUrl: '${_dataArray[index]['cover']}',
- fit: BoxFit.fill,
- height: hsp(200),
- width: hsp(250),
- ),
- margin: EdgeInsets.only(right: hsp(30)),
- ),
- Container(
- width: MediaQuery.of(context).size.width-hsp(340),
- height: hsp(200),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('${_dataArray[index]['title']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF343434)),maxLines: 2,overflow: TextOverflow.ellipsis,),
- Text('${_dataArray[index]['dtFlightInformation']['partnerName']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text('${_dataArray[index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
- RichText(
- text: TextSpan(
- text: '¥',
- style: TextStyle(fontSize: zsp(24),color: Color(0xFFEB423B)),
- children: [
- TextSpan(
- text: '${_dataArray[index]['discountPrice']}',
- style: TextStyle(fontSize: zsp(42),fontWeight: FontWeight.bold),
- ),
- TextSpan(
- text: '元起',
- style: TextStyle(fontSize: zsp(20)),
- )
- ]
- ),
- )
- ],
- )
- ],
- ),
- )
- ],
- ),
- ),
- );
- },
- separatorBuilder: (context,index){
- return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEEEEEE),);
- },
- itemCount: _dataArray.length,
- padding: EdgeInsets.all(0),
- ),
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- );
- }
- _getBackImageData() async{
- SharedPreferences preferences = await SharedPreferences.getInstance();
- _cityStr = preferences.getString('location');
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/wallconfigure/get',parameter: {'type':_type},isLoading: false,isToken: false);
- if(dict!=null){
- setState(() {
- _msgDict = dict['data'];
- });
- }
- }
- Future<void> _refreshData() async{
- _page = 1;
- Map request = {};
- request['category'] = _type;
- request['pageNo'] = _page;
- request['pageSize'] = 10;
- if(_titles[_titleIndex]=='距离'){
- request['type'] = 1;
- request['location'] = '108.985463,34.30501';
- }else if(_titles[_titleIndex]=='价格'){
- request['type'] = 2;
- }else if(_titles[_titleIndex]=='评分'){
- request['type'] = 3;
- }else{
- request['type'] = 4;
- }
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: request,isLoading: false,isToken: false);
- if(dict!=null){
- setState(() {
- _dataArray = dict['data']['resultList'];
- });
- }
- }
- Future<void> _loadMoreData() async{
- _page++;
- Map request = {};
- request['category'] = _type;
- request['pageNo'] = _page;
- request['pageSize'] = 10;
- if(_titles[_titleIndex]=='距离'){
- request['type'] = 1;
- request['location'] = '108.985463,34.30501';
- }else if(_titles[_titleIndex]=='价格'){
- request['type'] = 2;
- }else if(_titles[_titleIndex]=='评分'){
- request['type'] = 3;
- }else{
- request['type'] = 4;
- }
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: request,isLoading: false,isToken: false);
- if(dict!=null){
- setState(() {
- _dataArray.addAll(dict['data']['resultList']);
- });
- }
- }
- }
|