123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- 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<YSBill> {
- 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<void> _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<void> _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)),),
- // )
|