YSShortPlane.dart 10 KB

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