YSCourse.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_easyrefresh/easy_refresh.dart';
  4. import 'package:ysairplane2/code/YSCommnetAdd.dart';
  5. import 'package:ysairplane2/code/YSCourseDetail.dart';
  6. import 'package:ysairplane2/code/YSRefund.dart';
  7. import 'package:ysairplane2/code/YSTicketChange.dart';
  8. import 'package:ysairplane2/tools/YSNetWorking.dart';
  9. import 'package:ysairplane2/tools/YSTools.dart';
  10. import 'YSTableCalendar.dart';
  11. class YSCourse extends StatefulWidget {
  12. @override
  13. _YSCourseState createState() => _YSCourseState();
  14. }
  15. class _YSCourseState extends State<YSCourse>{
  16. int _selected = 0;
  17. int _page = 1;
  18. List _dataArray = [];
  19. @override
  20. void initState() {
  21. Future.delayed(Duration(seconds: 0)).then((value){
  22. _refreshData();
  23. });
  24. super.initState();
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. return Scaffold(
  29. backgroundColor: Color(0xFFF5F5F5),
  30. appBar: CupertinoNavigationBar(
  31. leading: Text(''),
  32. trailing: Text(''),
  33. transitionBetweenRoutes: false,
  34. backgroundColor: Colors.white,
  35. border: Border(),
  36. middle: Container(
  37. width: MediaQuery.of(context).size.width-wsp(300),
  38. child: ListView.builder(
  39. itemBuilder: (context,index){
  40. return GestureDetector(
  41. onTap: (){
  42. _selected = index;
  43. _refreshData();
  44. },
  45. child: Container(
  46. width: (MediaQuery.of(context).size.width-wsp(300))/3,
  47. alignment: Alignment.center,
  48. child: Text('${index==0?'全部':index==1?'未出行':'已完成'}',
  49. style: TextStyle(color: _selected==index?Color(0xFF2674ED):Color(0xFF999999),fontWeight: _selected==index?FontWeight.bold:FontWeight.normal,fontSize: zsp(34)),),
  50. ),
  51. );
  52. },
  53. itemCount: 3,
  54. padding: EdgeInsets.all(0),
  55. scrollDirection: Axis.horizontal,
  56. ),
  57. ),
  58. ),
  59. body: EasyRefresh(
  60. onRefresh: _refreshData,
  61. onLoad: _loadMoreData,
  62. header: TaurusHeader(
  63. ),
  64. footer: TaurusFooter(
  65. ),
  66. child: ListView.separated(
  67. itemBuilder: (context,index){
  68. return GestureDetector(
  69. onTap: (){
  70. Navigator.of(context).push(
  71. CupertinoPageRoute(
  72. builder: (context){
  73. return YSCourseDetail(orderStr: _dataArray[index]['orderSn'],);
  74. }
  75. )
  76. );
  77. },
  78. child: Container(
  79. decoration: BoxDecoration(
  80. color: Colors.white,
  81. borderRadius: BorderRadius.all(Radius.circular(10))
  82. ),
  83. child: Column(
  84. children: [
  85. Container(
  86. padding: EdgeInsets.all(hsp(20)),
  87. child: Row(
  88. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  89. children: [
  90. Text('${_dataArray[index]['name']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF141416),fontWeight: FontWeight.bold),),
  91. Text(_dataArray[index]['isExpire']==2?'已过期':_dataArray[index]['consumed']==1?'未出行':'已完成',style: TextStyle(fontSize: zsp(30),color: Color(0xFF2B7BF6)),)
  92. ],
  93. ),
  94. ),
  95. Divider(height: 1,thickness: 1,color: Color(0xFFF5F5F5),),
  96. Container(
  97. padding: EdgeInsets.all(hsp(20)),
  98. child: Row(
  99. children: [
  100. Icon(Icons.access_time,color: Color(0xFFBABAC6),size: hsp(28),),
  101. Text(' ${_dataArray[index]['time']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF24242B)),)
  102. ],
  103. ),
  104. ),
  105. _dataArray[index]['setout']!=null?Container(
  106. width: MediaQuery.of(context).size.width-hsp(80),
  107. child: ListView.builder(
  108. itemBuilder: (context,indexSub2){
  109. return Row(
  110. crossAxisAlignment: CrossAxisAlignment.start,
  111. children: [
  112. Column(
  113. children: [
  114. Container(
  115. height: hsp(28),
  116. width: hsp(28),
  117. decoration: BoxDecoration(
  118. color: Colors.white,
  119. borderRadius: BorderRadius.all(Radius.circular(50)),
  120. border: Border.all(color: indexSub2==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6))
  121. ),
  122. margin: EdgeInsets.only(top: hsp(7),bottom: hsp(7)),
  123. ),
  124. if(indexSub2<1)Container(
  125. height: hsp(28),
  126. child: DashedRect(
  127. color: Color(0xFFCACAD4),
  128. strokeWidth: 1,
  129. gap: 1
  130. ),
  131. )
  132. ],
  133. ),
  134. Container(
  135. child: indexSub2==0?Row(
  136. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  137. children: [
  138. Text(_dataArray[index]['setout']!=null?' ${_dataArray[index]['setout']}':' ',
  139. style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))),
  140. // Icon(Icons.keyboard_arrow_right,size: hsp(50),color: Color(0xFF999999),)
  141. ],
  142. ):Text(_dataArray[index]['arrive']!=null?' ${_dataArray[index]['arrive']}':' ',style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))),
  143. width: MediaQuery.of(context).size.width-hsp(120),
  144. ),
  145. ],
  146. );
  147. },
  148. itemCount: 2,
  149. shrinkWrap: true,
  150. physics: NeverScrollableScrollPhysics(),
  151. padding: EdgeInsets.only(bottom: hsp(20)),
  152. ),
  153. ):Container(
  154. child: Text('${_dataArray[index]['title']}',style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))),
  155. width: MediaQuery.of(context).size.width-hsp(80),
  156. alignment: Alignment.centerLeft,
  157. padding: EdgeInsets.only(bottom: hsp(20)),
  158. ),
  159. if(_dataArray[index]['refundStatus']!=-1)Row(
  160. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  161. children: [
  162. _dataArray[index]['endorseStatus']!=null?Container(
  163. height: hsp(50),
  164. width: hsp(180),
  165. decoration: BoxDecoration(
  166. borderRadius: BorderRadius.only(bottomRight: Radius.circular(50),topRight: Radius.circular(50)),
  167. color: Color(
  168. _dataArray[index]['endorseStatus']==0?0xFFF76B1C:
  169. _dataArray[index]['endorseStatus']==1?0xFF43C38E:0xFFD0021B
  170. ).withOpacity(0.2)
  171. ),
  172. alignment: Alignment.center,
  173. child: Text(
  174. _dataArray[index]['endorseStatus']==0?'改签中':
  175. _dataArray[index]['endorseStatus']==1?'改签成功':'改签失败',
  176. style: TextStyle(fontSize: zsp(26),color: Color(
  177. _dataArray[index]['endorseStatus']==0?0xFFF76B1C:
  178. _dataArray[index]['endorseStatus']==1?0xFF43C38E:0xFFD0021B
  179. )),
  180. ),
  181. ):Container(),
  182. if (_dataArray[index]['isExpire']==2) Container() else Row(
  183. children: [
  184. if(_dataArray[index]['endorseDisplay']==true)GestureDetector(
  185. onTap: (){
  186. showModalBottomSheet(
  187. backgroundColor: Colors.transparent,
  188. isScrollControlled: true,
  189. context: context,
  190. builder: (context){
  191. return YSTableCalendar(orderSn: _dataArray[index]['orderSn'],postDate: (value){
  192. Navigator.of(context).push(
  193. CupertinoPageRoute(
  194. builder: (context){
  195. return YSTicketChange(title: _dataArray[index]['name'],dateStr: value,orderSn: _dataArray[index]['orderSn'],);
  196. }
  197. )
  198. ).then((value){
  199. if(value!=null){
  200. _refreshData();
  201. }
  202. });
  203. },);
  204. }
  205. );
  206. },
  207. child: Container(
  208. padding: EdgeInsets.only(left: hsp(30),right: hsp(30),top: hsp(10),bottom: hsp(10)),
  209. child: Text('改签',style: TextStyle(fontSize: zsp(26),color: Color(0xFF5A5A5A)),),
  210. margin: EdgeInsets.only(bottom: hsp(30),right: hsp(20)),
  211. decoration: BoxDecoration(
  212. borderRadius: BorderRadius.all(Radius.circular(50)),
  213. border: Border.all(color: Color(0xFFE6E6E7),width: 1)
  214. ),
  215. ),
  216. ),
  217. GestureDetector(
  218. onTap: (){
  219. if(_dataArray[index]['consumed']==1){
  220. if(_dataArray[index]['refundStatus']==0){
  221. Navigator.of(context).push(
  222. CupertinoPageRoute(builder: (context){
  223. return YSRefund(msgDict: _dataArray[index],);
  224. })
  225. ).then((value){
  226. if(value!=null){
  227. _refreshData();
  228. }
  229. });
  230. }
  231. }else{
  232. if(_dataArray[index]['isScoring']==false){
  233. Navigator.of(context).push(
  234. CupertinoPageRoute(builder: (context){
  235. return YSCommentAdd(orderStr: _dataArray[index]['orderSn'],);
  236. })
  237. ).then((value){
  238. if(value!=null){
  239. _refreshData();
  240. }
  241. });
  242. }
  243. }
  244. },
  245. child: Container(
  246. padding: EdgeInsets.only(left: hsp(30),right: hsp(30),top: hsp(10),bottom: hsp(10)),
  247. child: Text(_dataArray[index]['consumed']==1?(_dataArray[index]['refundStatus']==0?'退款':'已退款'):
  248. (_dataArray[index]['isScoring']==false?'评价服务':'已评价'),style: TextStyle(fontSize: zsp(26),color: Color(0xFF5A5A5A)),),
  249. margin: EdgeInsets.only(bottom: hsp(30),right: hsp(20)),
  250. decoration: BoxDecoration(
  251. borderRadius: BorderRadius.all(Radius.circular(50)),
  252. border: Border.all(color: Color(0xFFE6E6E7),width: 1)
  253. ),
  254. ),
  255. )
  256. ],
  257. )
  258. ],
  259. )
  260. ],
  261. ),
  262. ),
  263. );
  264. },
  265. separatorBuilder: (context,index){
  266. return Divider(height: hsp(16),thickness: hsp(16),color: Color(0xFFF5F5F5),);
  267. },
  268. itemCount: _dataArray.length,
  269. padding: EdgeInsets.all(hsp(20)),
  270. shrinkWrap: true,
  271. ),
  272. ),
  273. );
  274. }
  275. Future<void> _refreshData() async{
  276. _page = 1;
  277. Map request = {};
  278. request['type'] = _selected+1;
  279. request['pageNum'] = _page;
  280. request['pageSize'] = 10;
  281. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/orderList',
  282. parameter: request,isLoading: false,isToken: true,refresh: _refreshData);
  283. if(dict!=null){
  284. setState(() {
  285. _dataArray = dict['data']['resultList'];
  286. });
  287. }
  288. }
  289. Future<void> _loadMoreData() async{
  290. _page++;
  291. Map request = {};
  292. request['type'] = _selected+1;
  293. request['pageNum'] = _page;
  294. request['pageSize'] = 10;
  295. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/orderList',
  296. parameter: request,isLoading: false,isToken: true,refresh: _refreshData);
  297. if(dict!=null){
  298. setState(() {
  299. _dataArray.addAll(dict['data']['resultList']);
  300. });
  301. }
  302. }
  303. }