YSCourse.dart 9.9 KB

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