YSShortPlane.dart 11 KB

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