YSSightseeingPlane.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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/YSSightseeingPlaneDetail.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. Container(
  65. margin: EdgeInsets.only(left: hsp(110),top: MediaQuery.of(context).padding.top+hsp(45)),
  66. width: MediaQuery.of(context).size.width-hsp(140),
  67. height: hsp(60),
  68. decoration: BoxDecoration(
  69. color: Colors.black.withOpacity(0.35),
  70. borderRadius: BorderRadius.all(Radius.circular(50))
  71. ),
  72. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  73. child: Row(
  74. children: [
  75. Row(
  76. children: [
  77. Text('西安',style: TextStyle(fontSize: zsp(26),color: Colors.white),),
  78. Icon(Icons.keyboard_arrow_down,color: Colors.white.withOpacity(0.5),size: hsp(40),)
  79. ],
  80. ),
  81. Container(
  82. height: hsp(30),
  83. width: 0.5,
  84. margin: EdgeInsets.only(left: wsp(10),right: wsp(10)),
  85. color: Colors.white.withOpacity(0.2),
  86. ),
  87. Row(
  88. children: [
  89. Icon(Icons.search,color: Colors.white.withOpacity(0.5),size: hsp(50),),
  90. Text(' 搜索',style: TextStyle(fontSize: zsp(26),color: Colors.white.withOpacity(0.5)),),
  91. ],
  92. )
  93. ],
  94. ),
  95. ),
  96. if(_msgDict!=null)Container(
  97. margin: EdgeInsets.only(left: wsp(50),top: MediaQuery.of(context).padding.top+hsp(250)),
  98. child: RichText(
  99. text: TextSpan(
  100. text: '${_msgDict['name']} ',
  101. style: TextStyle(fontSize: zsp(50),color: Colors.white,fontWeight: FontWeight.bold),
  102. children: [
  103. TextSpan(
  104. text: '${_msgDict['subtitle']}',
  105. style: TextStyle(fontWeight: FontWeight.normal,fontSize: zsp(28),color: Colors.white.withOpacity(0.5))
  106. )
  107. ]
  108. ),
  109. ),
  110. ),
  111. Container(
  112. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(350)),
  113. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(350),
  114. width: MediaQuery.of(context).size.width,
  115. decoration: BoxDecoration(
  116. color: Color(0xFFF1F2F3),
  117. borderRadius: BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
  118. ),
  119. child: Column(
  120. children: [
  121. Container(
  122. width: MediaQuery.of(context).size.width,
  123. height: hsp(80),
  124. child: ListView.builder(
  125. itemBuilder: (context,index){
  126. return GestureDetector(
  127. onTap: (){
  128. _titleIndex = index;
  129. _refreshData();
  130. },
  131. child: Container(
  132. height: hsp(80),
  133. width: MediaQuery.of(context).size.width/4,
  134. alignment: Alignment.center,
  135. child: Text('${_titles[index]}',style: TextStyle(fontSize: zsp(26),color: _titleIndex==index?Color(0xFF007AFF):Color(0xFF222222),fontWeight: _titleIndex==index?FontWeight.bold:FontWeight.normal),),
  136. ),
  137. );
  138. },
  139. itemCount: _titles.length,
  140. padding: EdgeInsets.all(0),
  141. scrollDirection: Axis.horizontal,
  142. ),
  143. ),
  144. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEEEEEE),),
  145. Container(
  146. width: MediaQuery.of(context).size.width,
  147. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(430)-0.5,
  148. child: EasyRefresh(
  149. onRefresh: _refreshData,
  150. onLoad: _loadMoreData,
  151. header: TaurusHeader(
  152. ),
  153. footer: TaurusFooter(
  154. ),
  155. child: ListView.separated(
  156. itemBuilder: (context,index){
  157. return GestureDetector(
  158. behavior: HitTestBehavior.opaque,
  159. onTap: (){
  160. Navigator.of(context).push(
  161. CupertinoPageRoute(
  162. builder: (context){
  163. return YSMarryPlane(marryId: _dataArray[index]['id'],type: _type);
  164. }
  165. )
  166. );
  167. },
  168. child: Container(
  169. padding: EdgeInsets.all(hsp(30)),
  170. child: Row(
  171. children: [
  172. Container(
  173. height: hsp(200),
  174. width: hsp(250),
  175. child: CachedNetworkImage(
  176. imageUrl: '${_dataArray[index]['cover']}',
  177. fit: BoxFit.fill,
  178. ),
  179. margin: EdgeInsets.only(right: hsp(30)),
  180. ),
  181. Container(
  182. width: MediaQuery.of(context).size.width-hsp(340),
  183. height: hsp(200),
  184. child: Column(
  185. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  186. crossAxisAlignment: CrossAxisAlignment.start,
  187. children: [
  188. Text('${_dataArray[index]['title']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF343434)),maxLines: 2,),
  189. Text('${_dataArray[index]['dtFlightInformation']['partnerName']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  190. Row(
  191. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  192. children: [
  193. Text('${_dataArray[index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  194. RichText(
  195. text: TextSpan(
  196. text: '¥',
  197. style: TextStyle(fontSize: zsp(24),color: Color(0xFFEB423B)),
  198. children: [
  199. TextSpan(
  200. text: '${_dataArray[index]['discountPrice']}',
  201. style: TextStyle(fontSize: zsp(42),fontWeight: FontWeight.bold),
  202. ),
  203. TextSpan(
  204. text: '元起',
  205. style: TextStyle(fontSize: zsp(20)),
  206. )
  207. ]
  208. ),
  209. )
  210. ],
  211. )
  212. ],
  213. ),
  214. )
  215. ],
  216. ),
  217. ),
  218. );
  219. },
  220. separatorBuilder: (context,index){
  221. return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEEEEEE),);
  222. },
  223. itemCount: _dataArray.length,
  224. padding: EdgeInsets.all(0),
  225. ),
  226. ),
  227. ),
  228. ],
  229. ),
  230. ),
  231. ],
  232. ),
  233. ),
  234. );
  235. }
  236. _getBackImageData() async{
  237. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/wallconfigure/get',parameter: {'type':_type},isLoading: false,isToken: false);
  238. if(dict!=null){
  239. setState(() {
  240. _msgDict = dict['data'];
  241. });
  242. }
  243. }
  244. Future<void> _refreshData() async{
  245. _page = 1;
  246. Map request = {};
  247. request['category'] = _type;
  248. request['pageNo'] = _page;
  249. request['pageSize'] = 10;
  250. if(_titles[_titleIndex]=='距离'){
  251. request['type'] = 1;
  252. request['location'] = '108.985463,34.30501';
  253. }else if(_titles[_titleIndex]=='价格'){
  254. request['type'] = 2;
  255. }else if(_titles[_titleIndex]=='评分'){
  256. request['type'] = 3;
  257. }else{
  258. request['type'] = 4;
  259. }
  260. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: request,isLoading: false,isToken: false);
  261. if(dict!=null){
  262. setState(() {
  263. _dataArray = dict['data']['resultList'];
  264. });
  265. }
  266. }
  267. Future<void> _loadMoreData() async{
  268. _page++;
  269. Map request = {};
  270. request['category'] = _type;
  271. request['pageNo'] = _page;
  272. request['pageSize'] = 10;
  273. if(_titles[_titleIndex]=='距离'){
  274. request['type'] = 1;
  275. request['location'] = '108.985463,34.30501';
  276. }else if(_titles[_titleIndex]=='价格'){
  277. request['type'] = 2;
  278. }else if(_titles[_titleIndex]=='评分'){
  279. request['type'] = 3;
  280. }else{
  281. request['type'] = 4;
  282. }
  283. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: request,isLoading: false,isToken: false);
  284. if(dict!=null){
  285. setState(() {
  286. _dataArray.add(dict['data']['resultList']);
  287. });
  288. }
  289. }
  290. }