YSBill.dart 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter_easyrefresh/easy_refresh.dart';
  4. import 'package:ysairplane2/base/YSBase.dart';
  5. import 'package:ysairplane2/tools/YSNetWorking.dart';
  6. import 'package:ysairplane2/tools/YSTools.dart';
  7. class YSBill extends StatefulWidget {
  8. @override
  9. _YSBillState createState() => _YSBillState();
  10. }
  11. class _YSBillState extends State<YSBill> {
  12. List _dataArray = [];
  13. int _page = 1;
  14. String _timeStr = '全部';
  15. String _amountStr = '0.00';
  16. @override
  17. void initState() {
  18. Future.delayed(Duration(seconds: 0)).then((value){
  19. _refresh();
  20. });
  21. super.initState();
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return YSBase(
  26. ystitle: '账单',
  27. yschild: Column(
  28. children: [
  29. Container(
  30. height: hsp(155),
  31. padding: EdgeInsets.only(left: wsp(44),right: wsp(44),top: hsp(25),bottom: hsp(25)),
  32. color: Color(0xFFF5F5F5),
  33. child: Column(
  34. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  35. crossAxisAlignment: CrossAxisAlignment.start,
  36. children: [
  37. GestureDetector(
  38. onTap: (){
  39. showModalBottomSheet(
  40. context: context,
  41. builder: (context){
  42. return YSDatePicker(
  43. isBefore: true,
  44. choose: (value){
  45. _timeStr = value;
  46. _refresh();
  47. },
  48. );
  49. }
  50. );
  51. },
  52. child: Row(
  53. children: [
  54. Text('$_timeStr',style: TextStyle(fontSize: zsp(34),color: Color(0xFF131318),fontWeight: FontWeight.bold),),
  55. Icon(Icons.keyboard_arrow_down,size: 20,color: Color(0xFF131318),)
  56. ],
  57. ),
  58. ),
  59. Text('支出¥$_amountStr',style: TextStyle(fontSize: zsp(30),color: Color(0xFF898989)),),
  60. ],
  61. ),
  62. ),
  63. Container(
  64. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(155),
  65. child: EasyRefresh(
  66. onRefresh: _refresh,
  67. onLoad: _loadMore,
  68. header: TaurusHeader(),
  69. footer: TaurusFooter(),
  70. child: ListView.builder(
  71. itemBuilder: (context,index){
  72. return Container(
  73. height: hsp(159),
  74. padding: EdgeInsets.only(left: wsp(36),right: wsp(36),top: hsp(25)),
  75. child: Column(
  76. children: [
  77. Row(
  78. children: [
  79. Container(
  80. height: hsp(100),
  81. width: hsp(100),
  82. decoration: BoxDecoration(
  83. color: Color(0xFFF5F5F5),
  84. borderRadius: BorderRadius.all(Radius.circular(hsp(50)))
  85. ),
  86. child: Image.asset('lib/images/wallet.png'),
  87. ),
  88. Container(
  89. width: MediaQuery.of(context).size.width/2-20,
  90. margin: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  91. child: Column(
  92. children: [
  93. Container(
  94. width: MediaQuery.of(context).size.width/2-20,
  95. child: SingleChildScrollView(
  96. scrollDirection: Axis.horizontal,
  97. child: Text('${_dataArray[index]['ordersn']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF131318)),maxLines: 1,),
  98. ),
  99. ),
  100. Text('${_dataArray[index]['time']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFFA7A7A7)),)
  101. ],
  102. crossAxisAlignment: CrossAxisAlignment.start,
  103. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  104. ),
  105. ),
  106. Container(
  107. width: MediaQuery.of(context).size.width/2-103,
  108. child: Text('${_dataArray[index]['type']==2?'-':'+'}${_dataArray[index]['amount']}',style: TextStyle(fontSize: zsp(35),color: Color(0xFF000000),fontWeight: FontWeight.bold),maxLines: 1,overflow: TextOverflow.ellipsis,),
  109. alignment: Alignment.centerRight,
  110. )
  111. ],
  112. ),
  113. Container(
  114. margin: EdgeInsets.only(left: wsp(147),top: hsp(24)),
  115. height: hsp(1),
  116. color: Color(0xFFF5F5F5),
  117. )
  118. ],
  119. ),
  120. );
  121. },
  122. itemCount: _dataArray.length
  123. ),
  124. ),
  125. )
  126. ],
  127. ),
  128. );
  129. }
  130. Future<void> _refresh() async{
  131. _page = 1;
  132. Map request = {};
  133. request['pageNum'] = _page;
  134. request['pageSize'] = 10;
  135. if(_timeStr!='全部'){
  136. request['time'] = DateTime.parse('$_timeStr:00');
  137. }
  138. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/balance/getBalanceHistory',parameter: request,isLoading: false,
  139. isToken: true,refresh: (){_refresh();});
  140. if(dict!=null){
  141. _amountStr = '${dict['totalAmount']}';
  142. setState(() {
  143. _dataArray = dict['data']['resultList'];
  144. });
  145. }
  146. }
  147. Future<void> _loadMore() async{
  148. _page++;
  149. Map request = {};
  150. request['pageNum'] = _page;
  151. request['pageSize'] = 10;
  152. if(_timeStr!='全部'){
  153. request['time'] = DateTime.parse('$_timeStr:00');
  154. }
  155. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/balance/getBalanceHistory',parameter: request,isLoading: false,
  156. isToken: true,refresh: (){_loadMore();});
  157. if(dict!=null){
  158. setState(() {
  159. _dataArray.addAll(dict['data']['resultList']);
  160. });
  161. }
  162. }
  163. }
  164. // Dismissible(
  165. // key: Key(UniqueKey().toString()),
  166. // onDismissed: (direction) async{
  167. //
  168. // },
  169. // secondaryBackground: Container(
  170. // color: Color(0xFFDE4242),
  171. // height: hsp(159),
  172. // padding: EdgeInsets.only(right: wsp(36)),
  173. // alignment: Alignment.centerRight,
  174. // child: Text('删除',style: TextStyle(color: Colors.white,fontWeight: FontWeight.bold,fontSize: zsp(37)),),
  175. // )