YSShortPlane.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_easyrefresh/easy_refresh.dart';
  4. import 'package:shared_preferences/shared_preferences.dart';
  5. import 'package:ysairplane2/code/YSShortDetail.dart';
  6. import 'package:ysairplane2/tools/YSNetWorking.dart';
  7. import 'package:ysairplane2/tools/YSTools.dart';
  8. import 'YSSearchResult.dart';
  9. class YSShortPlane extends StatefulWidget {
  10. @override
  11. _YSShortPlaneState createState() => _YSShortPlaneState();
  12. }
  13. class _YSShortPlaneState extends State<YSShortPlane> {
  14. int _page = 1;
  15. List _dataArray = [];
  16. Map _msgDict;
  17. String _cityStr = '';
  18. @override
  19. void initState() {
  20. Future.delayed(Duration(seconds: 0)).then((value){
  21. _getBackImageData();
  22. _refreshData();
  23. });
  24. super.initState();
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. return Scaffold(
  29. backgroundColor: Color(0xFFF1F2F3),
  30. body: SingleChildScrollView(
  31. padding: EdgeInsets.all(0),
  32. child: Stack(
  33. children: [
  34. Container(
  35. height: MediaQuery.of(context).padding.top+hsp(370),
  36. width: MediaQuery.of(context).size.width,
  37. child: _msgDict==null?Image(
  38. image: AssetImage('lib/images/home3.png'),
  39. fit: BoxFit.fill,
  40. ):ysImageLoad(
  41. imageUrl: '${_msgDict['background']}',
  42. fit: BoxFit.fill,
  43. height: MediaQuery.of(context).padding.top+hsp(370),
  44. width: MediaQuery.of(context).size.width,
  45. ),
  46. ),
  47. GestureDetector(
  48. onTap: (){
  49. Navigator.pop(context);
  50. },
  51. child: Container(
  52. margin: EdgeInsets.only(left: hsp(30),right: wsp(30),top: MediaQuery.of(context).padding.top+hsp(50)),
  53. child: Icon(Icons.arrow_back_ios,color: Colors.white,size: hsp(50),),
  54. ),
  55. ),
  56. GestureDetector(
  57. onTap: (){
  58. Navigator.of(context).push(
  59. CupertinoPageRoute(builder: (context){
  60. return YSSearchResult(type: 6,);
  61. })
  62. );
  63. },
  64. child: 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(_cityStr,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. ),
  97. if(_msgDict!=null)Container(
  98. margin: EdgeInsets.only(left: wsp(50),top: MediaQuery.of(context).padding.top+hsp(250)),
  99. child: RichText(
  100. text: TextSpan(
  101. text: '${_msgDict['name']} ',
  102. style: TextStyle(fontSize: zsp(50),color: Colors.white,fontWeight: FontWeight.bold),
  103. children: [
  104. TextSpan(
  105. text: '${_msgDict['subtitle']}',
  106. style: TextStyle(fontWeight: FontWeight.normal,fontSize: zsp(28),color: Colors.white.withOpacity(0.5))
  107. )
  108. ]
  109. ),
  110. ),
  111. ),
  112. Container(
  113. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(350)),
  114. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(350),
  115. width: MediaQuery.of(context).size.width,
  116. decoration: BoxDecoration(
  117. color: Color(0xFFF1F2F3),
  118. borderRadius: BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
  119. ),
  120. child: Container(
  121. width: MediaQuery.of(context).size.width,
  122. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(430)-0.5,
  123. child: EasyRefresh(
  124. onRefresh: _refreshData,
  125. onLoad: _loadMoreData,
  126. header: TaurusHeader(
  127. ),
  128. footer: TaurusFooter(
  129. ),
  130. child: ListView.separated(
  131. itemBuilder: (context,index){
  132. return GestureDetector(
  133. behavior: HitTestBehavior.opaque,
  134. onTap: (){
  135. Navigator.of(context).push(
  136. CupertinoPageRoute(
  137. builder: (context){
  138. return YSShortDetail(shortId: _dataArray[index]['id'],);
  139. }
  140. )
  141. );
  142. },
  143. child: Container(
  144. padding: EdgeInsets.all(hsp(30)),
  145. child: Row(
  146. children: [
  147. Container(
  148. height: hsp(200),
  149. width: hsp(250),
  150. margin: EdgeInsets.only(right: hsp(30)),
  151. child: ysImageLoad(
  152. imageUrl: '${_dataArray[index]['cover']}',
  153. fit: BoxFit.fill,
  154. height: hsp(200),
  155. width: hsp(250),
  156. ),
  157. ),
  158. Container(
  159. width: MediaQuery.of(context).size.width-hsp(340),
  160. height: hsp(200),
  161. child: Column(
  162. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  163. crossAxisAlignment: CrossAxisAlignment.start,
  164. children: [
  165. Container(
  166. width: MediaQuery.of(context).size.width-hsp(340),
  167. child: SingleChildScrollView(
  168. scrollDirection: Axis.horizontal,
  169. child: Row(
  170. children: [
  171. Text('${_dataArray[index]['setoutInfo']['display']}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),),
  172. Container(
  173. height: 2,
  174. width: wsp(40),
  175. margin: EdgeInsets.only(left: wsp(10),right: wsp(10)),
  176. color: Color(0xFFCCCCCC),
  177. ),
  178. Text('${_dataArray[index]['arriveInfo']['display']}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),)
  179. ],
  180. ),
  181. ),
  182. ),
  183. Text('${_dataArray[index]['dtFlightInformation']['partnerName']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  184. Row(
  185. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  186. children: [
  187. Text('${_dataArray[index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),),
  188. RichText(
  189. text: TextSpan(
  190. text: '¥',
  191. style: TextStyle(fontSize: zsp(24),color: Color(0xFFEB423B)),
  192. children: [
  193. TextSpan(
  194. text: '${_dataArray[index]['discountPrice']}',
  195. style: TextStyle(fontSize: zsp(42),fontWeight: FontWeight.bold),
  196. ),
  197. TextSpan(
  198. text: '元起',
  199. style: TextStyle(fontSize: zsp(20)),
  200. )
  201. ]
  202. ),
  203. )
  204. ],
  205. )
  206. ],
  207. ),
  208. )
  209. ],
  210. ),
  211. ),
  212. );
  213. },
  214. separatorBuilder: (context,index){
  215. return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEEEEEE),);
  216. },
  217. itemCount: _dataArray.length,
  218. padding: EdgeInsets.all(0),
  219. ),
  220. ),
  221. )
  222. ),
  223. ],
  224. ),
  225. ),
  226. );
  227. }
  228. _getBackImageData() async{
  229. SharedPreferences preferences = await SharedPreferences.getInstance();
  230. _cityStr = preferences.getString('location');
  231. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/wallconfigure/get',parameter: {'type':6},isLoading: false,isToken: false);
  232. if(dict!=null){
  233. setState(() {
  234. _msgDict = dict['data'];
  235. });
  236. }
  237. }
  238. Future<void> _refreshData() async{
  239. _page = 1;
  240. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: {'category':6,'pageNo':_page,'pageSize':10},isLoading: false,isToken: false);
  241. if(dict!=null){
  242. setState(() {
  243. _dataArray = dict['data']['resultList'];
  244. });
  245. }
  246. }
  247. Future<void> _loadMoreData() async{
  248. _page++;
  249. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: {'category':6,'pageNo':_page,'pageSize':10},isLoading: false,isToken: false);
  250. if(dict!=null){
  251. setState(() {
  252. _dataArray.addAll(dict['data']['resultList']);
  253. });
  254. }
  255. }
  256. }