import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:ysairplane2/base/YSBase.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSTools.dart'; class YSBill extends StatefulWidget { @override _YSBillState createState() => _YSBillState(); } class _YSBillState extends State { List _dataArray = []; int _page = 1; String _timeStr = '全部'; String _amountStr = '0.00'; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _refresh(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ystitle: '账单', yschild: Column( children: [ Container( height: hsp(155), padding: EdgeInsets.only(left: wsp(44),right: wsp(44),top: hsp(25),bottom: hsp(25)), color: Color(0xFFF5F5F5), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ GestureDetector( onTap: (){ showModalBottomSheet( context: context, builder: (context){ return YSDatePicker( isBefore: true, choose: (value){ _timeStr = value; _refresh(); }, ); } ); }, child: Row( children: [ Text('$_timeStr',style: TextStyle(fontSize: zsp(34),color: Color(0xFF131318),fontWeight: FontWeight.bold),), Icon(Icons.keyboard_arrow_down,size: 20,color: Color(0xFF131318),) ], ), ), Text('支出¥$_amountStr',style: TextStyle(fontSize: zsp(30),color: Color(0xFF898989)),), ], ), ), Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(155), child: EasyRefresh( onRefresh: _refresh, onLoad: _loadMore, header: TaurusHeader(), footer: TaurusFooter(), child: ListView.builder( itemBuilder: (context,index){ return Container( height: hsp(159), padding: EdgeInsets.only(left: wsp(36),right: wsp(36),top: hsp(25)), child: Column( children: [ Row( children: [ Container( height: hsp(100), width: hsp(100), decoration: BoxDecoration( color: Color(0xFFF5F5F5), borderRadius: BorderRadius.all(Radius.circular(hsp(50))) ), child: Image.asset('lib/images/wallet.png'), ), Container( width: MediaQuery.of(context).size.width/2-20, margin: EdgeInsets.only(left: wsp(30),right: wsp(30)), child: Column( children: [ Container( width: MediaQuery.of(context).size.width/2-20, child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Text('${_dataArray[index]['ordersn']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF131318)),maxLines: 1,), ), ), Text('${_dataArray[index]['time']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFFA7A7A7)),) ], crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, ), ), Container( width: MediaQuery.of(context).size.width/2-103, 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,), alignment: Alignment.centerRight, ) ], ), Container( margin: EdgeInsets.only(left: wsp(147),top: hsp(24)), height: hsp(1), color: Color(0xFFF5F5F5), ) ], ), ); }, itemCount: _dataArray.length ), ), ) ], ), ); } Future _refresh() async{ _page = 1; Map request = {}; request['pageNum'] = _page; request['pageSize'] = 10; if(_timeStr!='全部'){ request['time'] = DateTime.parse('$_timeStr:00'); } Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/balance/getBalanceHistory',parameter: request,isLoading: false, isToken: true,refresh: (){_refresh();}); if(dict!=null){ _amountStr = '${dict['totalAmount']}'; setState(() { _dataArray = dict['data']['resultList']; }); } } Future _loadMore() async{ _page++; Map request = {}; request['pageNum'] = _page; request['pageSize'] = 10; if(_timeStr!='全部'){ request['time'] = DateTime.parse('$_timeStr:00'); } Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/balance/getBalanceHistory',parameter: request,isLoading: false, isToken: true,refresh: (){_loadMore();}); if(dict!=null){ setState(() { _dataArray.addAll(dict['data']['resultList']); }); } } } // Dismissible( // key: Key(UniqueKey().toString()), // onDismissed: (direction) async{ // // }, // secondaryBackground: Container( // color: Color(0xFFDE4242), // height: hsp(159), // padding: EdgeInsets.only(right: wsp(36)), // alignment: Alignment.centerRight, // child: Text('删除',style: TextStyle(color: Colors.white,fontWeight: FontWeight.bold,fontSize: zsp(37)),), // )