YSSightseeingPlane.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_easyrefresh/easy_refresh.dart';
  5. import 'package:ysairplane/code/YSMarryPlane.dart';
  6. import 'package:ysairplane/code/YSSearchResult.dart';
  7. import 'package:ysairplane/tools/YSNetWorking.dart';
  8. import 'package:ysairplane/tools/YSTools.dart';
  9. enum planeType{
  10. sightseeing,
  11. sport,
  12. marry,
  13. }
  14. class YSSightseeingPlane extends StatefulWidget {
  15. final planeType type;
  16. const YSSightseeingPlane({Key key, this.type}) : super(key: key);
  17. @override
  18. _YSSightseeingPlaneState createState() => _YSSightseeingPlaneState();
  19. }
  20. class _YSSightseeingPlaneState extends State<YSSightseeingPlane> {
  21. Map _msgDict;
  22. List _titles = ['综合','距离','价格','评分'];
  23. int _titleIndex = 0;
  24. int _page = 1;
  25. List _dataArray = [];
  26. int _type;
  27. @override
  28. void initState() {
  29. Future.delayed(Duration(seconds: 0)).then((value){
  30. _type = widget.type==planeType.marry?4:widget.type==planeType.sport?5:9;
  31. _getBackImageData();
  32. _refreshData();
  33. });
  34. super.initState();
  35. }
  36. @override
  37. Widget build(BuildContext context) {
  38. return Scaffold(
  39. backgroundColor: Color(0xFFF1F2F3),
  40. body: SingleChildScrollView(
  41. padding: EdgeInsets.all(0),
  42. child: Stack(
  43. children: [
  44. Container(
  45. height: MediaQuery.of(context).padding.top+hsp(370),
  46. width: MediaQuery.of(context).size.width,
  47. child: _msgDict==null?Image(
  48. image: AssetImage('lib/images/home3.png'),
  49. fit: BoxFit.fill,
  50. ):CachedNetworkImage(
  51. imageUrl: '${_msgDict['background']}',
  52. fit: BoxFit.fill,
  53. ),
  54. ),
  55. GestureDetector(
  56. onTap: (){
  57. Navigator.pop(context);
  58. },
  59. child: Container(
  60. margin: EdgeInsets.only(left: hsp(30),right: wsp(30),top: MediaQuery.of(context).padding.top+hsp(50)),
  61. child: Icon(Icons.arrow_back_ios,color: Colors.white,size: hsp(50),),
  62. ),
  63. ),
  64. GestureDetector(
  65. onTap: (){
  66. Navigator.of(context).push(
  67. CupertinoPageRoute(builder: (context){
  68. return YSSearchResult(type: _type,);
  69. })
  70. );
  71. },
  72. child : Container(
  73. margin: EdgeInsets.only(left: hsp(110),top: MediaQuery.of(context).padding.top+hsp(45)),
  74. width: MediaQuery.of(context).size.width-hsp(140),
  75. height: hsp(60),
  76. decoration: BoxDecoration(
  77. color: Colors.black.withOpacity(0.35),
  78. borderRadius: BorderRadius.all(Radius.circular(50))
  79. ),
  80. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  81. child: Row(
  82. children: [
  83. Row(
  84. children: [
  85. Text('西安',style: TextStyle(fontSize: zsp(26),color: Colors.white),),
  86. Icon(Icons.keyboard_arrow_down,color: Colors.white.withOpacity(0.5),size: hsp(40),)
  87. ],
  88. ),
  89. Container(
  90. height: hsp(30),
  91. width: 0.5,
  92. margin: EdgeInsets.only(left: wsp(10),right: wsp(10)),
  93. color: Colors.white.withOpacity(0.2),
  94. ),
  95. Row(
  96. children: [
  97. Icon(Icons.search,color: Colors.white.withOpacity(0.5),size: hsp(50),),
  98. Text(' 搜索',style: TextStyle(fontSize: zsp(26),color: Colors.white.withOpacity(0.5)),),
  99. ],
  100. )
  101. ],
  102. ),
  103. ),
  104. ),
  105. if(_msgDict!=null)Container(
  106. margin: EdgeInsets.only(left: wsp(50),top: MediaQuery.of(context).padding.top+hsp(250)),
  107. child: RichText(
  108. text: TextSpan(
  109. text: '${_msgDict['name']} ',
  110. style: TextStyle(fontSize: zsp(50),color: Colors.white,fontWeight: FontWeight.bold),
  111. children: [
  112. TextSpan(
  113. text: '${_msgDict['subtitle']}',
  114. style: TextStyle(fontWeight: FontWeight.normal,fontSize: zsp(28),color: Colors.white.withOpacity(0.5))
  115. )
  116. ]
  117. ),
  118. ),
  119. ),
  120. Container(
  121. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(350)),
  122. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(350),
  123. width: MediaQuery.of(context).size.width,
  124. decoration: BoxDecoration(
  125. color: Color(0xFFF1F2F3),
  126. borderRadius: BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
  127. ),
  128. child: Column(
  129. children: [
  130. Container(
  131. width: MediaQuery.of(context).size.width,
  132. height: hsp(80),
  133. child: ListView.builder(
  134. itemBuilder: (context,index){
  135. return GestureDetector(
  136. onTap: (){
  137. _titleIndex = index;
  138. _refreshData();
  139. },
  140. child: Container(
  141. height: hsp(80),
  142. width: MediaQuery.of(context).size.width/4,
  143. alignment: Alignment.center,
  144. child: Text('${_titles[index]}',style: TextStyle(fontSize: zsp(26),color: _titleIndex==index?Color(0xFF007AFF):Color(0xFF222222),fontWeight: _titleIndex==index?FontWeight.bold:FontWeight.normal),),
  145. ),
  146. );
  147. },
  148. itemCount: _titles.length,
  149. padding: EdgeInsets.all(0),
  150. scrollDirection: Axis.horizontal,
  151. ),
  152. ),
  153. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEEEEEE),),
  154. Container(
  155. width: MediaQuery.of(context).size.width,
  156. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(430)-0.5,
  157. child: EasyRefresh(
  158. onRefresh: _refreshData,
  159. onLoad: _loadMoreData,
  160. header: TaurusHeader(
  161. ),
  162. footer: TaurusFooter(
  163. ),
  164. child: ListView.separated(
  165. itemBuilder: (context,index){
  166. return GestureDetector(
  167. behavior: HitTestBehavior.opaque,
  168. onTap: (){
  169. Navigator.of(context).push(
  170. CupertinoPageRoute(
  171. builder: (context){
  172. return YSMarryPlane(marryId: _dataArray[index]['id'],type: _type);
  173. }
  174. )
  175. );
  176. },
  177. child: Container(
  178. padding: EdgeInsets.all(hsp(30)),
  179. child: Row(
  180. children: [
  181. Container(
  182. height: hsp(200),
  183. width: hsp(250),
  184. child: CachedNetworkImage(
  185. imageUrl: '${_dataArray[index]['cover']}',
  186. fit: BoxFit.fill,
  187. ),
  188. margin: EdgeInsets.only(right: hsp(30)),
  189. ),
  190. Container(
  191. width: MediaQuery.of(context).size.width-hsp(340),
  192. height: hsp(200),
  193. child: Column(
  194. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  195. crossAxisAlignment: CrossAxisAlignment.start,
  196. children: [
  197. Text('${_dataArray[index]['title']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF343434)),maxLines: 2,),
  198. Text('${_dataArray[index]['dtFlightInformation']['partnerName']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  199. Row(
  200. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  201. children: [
  202. Text('${_dataArray[index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  203. RichText(
  204. text: TextSpan(
  205. text: '¥',
  206. style: TextStyle(fontSize: zsp(24),color: Color(0xFFEB423B)),
  207. children: [
  208. TextSpan(
  209. text: '${_dataArray[index]['discountPrice']}',
  210. style: TextStyle(fontSize: zsp(42),fontWeight: FontWeight.bold),
  211. ),
  212. TextSpan(
  213. text: '元起',
  214. style: TextStyle(fontSize: zsp(20)),
  215. )
  216. ]
  217. ),
  218. )
  219. ],
  220. )
  221. ],
  222. ),
  223. )
  224. ],
  225. ),
  226. ),
  227. );
  228. },
  229. separatorBuilder: (context,index){
  230. return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEEEEEE),);
  231. },
  232. itemCount: _dataArray.length,
  233. padding: EdgeInsets.all(0),
  234. ),
  235. ),
  236. ),
  237. ],
  238. ),
  239. ),
  240. ],
  241. ),
  242. ),
  243. );
  244. }
  245. _getBackImageData() async{
  246. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/wallconfigure/get',parameter: {'type':_type},isLoading: false,isToken: false);
  247. if(dict!=null){
  248. setState(() {
  249. _msgDict = dict['data'];
  250. });
  251. }
  252. }
  253. Future<void> _refreshData() async{
  254. _page = 1;
  255. Map request = {};
  256. request['category'] = _type;
  257. request['pageNo'] = _page;
  258. request['pageSize'] = 10;
  259. if(_titles[_titleIndex]=='距离'){
  260. request['type'] = 1;
  261. request['location'] = '108.985463,34.30501';
  262. }else if(_titles[_titleIndex]=='价格'){
  263. request['type'] = 2;
  264. }else if(_titles[_titleIndex]=='评分'){
  265. request['type'] = 3;
  266. }else{
  267. request['type'] = 4;
  268. }
  269. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: request,isLoading: false,isToken: false);
  270. if(dict!=null){
  271. setState(() {
  272. _dataArray = dict['data']['resultList'];
  273. });
  274. }
  275. }
  276. Future<void> _loadMoreData() async{
  277. _page++;
  278. Map request = {};
  279. request['category'] = _type;
  280. request['pageNo'] = _page;
  281. request['pageSize'] = 10;
  282. if(_titles[_titleIndex]=='距离'){
  283. request['type'] = 1;
  284. request['location'] = '108.985463,34.30501';
  285. }else if(_titles[_titleIndex]=='价格'){
  286. request['type'] = 2;
  287. }else if(_titles[_titleIndex]=='评分'){
  288. request['type'] = 3;
  289. }else{
  290. request['type'] = 4;
  291. }
  292. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: request,isLoading: false,isToken: false);
  293. if(dict!=null){
  294. setState(() {
  295. _dataArray.addAll(dict['data']['resultList']);
  296. });
  297. }
  298. }
  299. }