import 'package:flutter/cupertino.dart'; import 'package:flutter/material.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 YSIncome extends StatefulWidget { const YSIncome({Key key}) : super(key: key); @override _YSIncomeState createState() => _YSIncomeState(); } class _YSIncomeState extends State { String _timeSrt = ''; List _dataArray = []; int _page = 1; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _refreshData(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ystitle: '收入明细', yscolor: Color(0xFFF5F6F8), yschild: Container( width: MediaQuery.of(context).size.width, child: Column( children: [ Container( height: hsp(80), padding: EdgeInsets.only(left: hsp(20),right: hsp(20)), child: GestureDetector( onTap: (){ showModalBottomSheet( context: context, builder: (context){ return YSDatePicker(isDate: true,choose: (value){ print(value); _timeSrt = value.substring(0,7); _refreshData(); },); } ); }, child: Row( children: [ Text(_timeSrt.isEmpty?'全部':_timeSrt,style: TextStyle(fontSize: zsp(30),color: Colors.black),), Icon(Icons.keyboard_arrow_down,size: hsp(40),color: Color(0xFFCCCCCC),) ], ), ) ), Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(80), color: Colors.white, child: EasyRefresh( onRefresh: _refreshData, onLoad: _loadMoreData, header: TaurusHeader( ), footer: TaurusFooter( ), child: ListView.separated( padding: EdgeInsets.only(left: hsp(20),right: hsp(20)), itemBuilder: (context,index){ Map item = _dataArray[index]; return GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSIncomeDetail(income: item,); } ) ); }, child: Container( padding: EdgeInsets.only(top: hsp(30),bottom: hsp(30)), child: LayoutBuilder( builder: (context,listSize){ return Row( children: [ Container( width: listSize.maxWidth-hsp(150), child: RichText( text: TextSpan( text: '${item['orderName']}', style: TextStyle(fontSize: zsp(28),color: Colors.black), children: [ if(item['orderSn']!=null)TextSpan( text: '[订单编号: ${item['orderSn']}]', style: TextStyle(color: Color(0xFF999999)) ) ] ), ), ), Container( width: hsp(110), child: Text('${item['status']}',style: TextStyle(fontSize: zsp(28), color: Color(item['status']=='冻结中'?0xFFFFAE00:0xFF999999)),), alignment: Alignment.centerRight, ), Icon(Icons.chevron_right,size: hsp(40),color: Color(0xFF999999),) ], ); }, ), ), ); }, separatorBuilder: (context,index){ return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),); }, itemCount: _dataArray.length, ), ), ) ], ), ), ); } Future _refreshData() async{ _page = 1; if(_timeSrt.isEmpty)_timeSrt = '${DateTime.now().year}-'+'${DateTime.now().month}'.padLeft(2,'0'); Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/servants/incomeList',parameter: {'pageNum':_page,'date':_timeSrt},isLoading: false,isToken: true); if(dict!=null){ setState(() { _dataArray = dict['data']['resultList']; }); } } Future _loadMoreData() async{ _page++; Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/servants/incomeList',parameter: {'pageNum':_page,'date':_timeSrt},isLoading: false,isToken: true); if(dict!=null){ setState(() { _dataArray.addAll(dict['data']['resultList']); }); } } } class YSIncomeDetail extends StatefulWidget { final Map income; const YSIncomeDetail({Key key, this.income}) : super(key: key); @override _YSIncomeDetailState createState() => _YSIncomeDetailState(); } class _YSIncomeDetailState extends State { List _titleArray = []; @override void initState() { if(widget.income!=null){ if(widget.income['type']==1){ _titleArray = [{'title':'','content':''},{'title':'订单编号','content':''},{'title':'佣金状态','content':''},{'title':'佣金金额','content':''} ,{'title':'订单状态','content':''},{'title':'订单金额','content':''}]; _titleArray[0]['title'] = widget.income['orderName']; _titleArray[1]['content'] = widget.income['orderSn']; _titleArray[2]['content'] = widget.income['status']; _titleArray[3]['content'] = '${widget.income['servantsPrice']??'0.00'}'; _titleArray[4]['content'] = widget.income['orderStatus']; _titleArray[5]['content'] = '${widget.income['orderPrice']??'0.00'}'; }else{ _titleArray = [{'title':'','content':''},{'title':'提现状态','content':''},{'title':'提现方式','content':''} ,{'title':'提现账号','content':''},{'title':'提现金额','content':''},{'title':'提现时间','content':''}]; _titleArray[0]['title'] = widget.income['orderName']; _titleArray[1]['content'] = widget.income['status']; _titleArray[2]['content'] = widget.income['accountName']; _titleArray[3]['content'] = widget.income['account']; _titleArray[4]['content'] = '${widget.income['price']??'0.00'}'; _titleArray[5]['content'] = widget.income['createTime']; } } super.initState(); } @override Widget build(BuildContext context) { return YSBase( ystitle: '收入明细详情', yscolor: Color(0xFFF5F6F8), yschild: Container( color: Colors.white, width: MediaQuery.of(context).size.width, child: ListView.separated( padding: EdgeInsets.only(left: hsp(30),right: hsp(30)), itemBuilder: (context,index){ Map item = _titleArray[index]; return Container( padding: EdgeInsets.only(top: hsp(30),bottom: hsp(30)), child: LayoutBuilder( builder: (context,listSize){ return Row( children: [ Container( width: hsp(200), child: Text(item['title'],style: TextStyle(fontSize: zsp(28),color: Colors.black,fontWeight: index==0?FontWeight.bold:FontWeight.normal),), ), Container( width: listSize.maxWidth-hsp(200), child: Text(item['content'],style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),), alignment: Alignment.centerRight, ) ], ); }, ), ); }, separatorBuilder: (context,index){ return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),); }, itemCount: _titleArray.length, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), ), ), ); } }