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/code/YSUnionOrder.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSTools.dart'; class YSMember extends StatefulWidget { const YSMember({Key key}) : super(key: key); @override _YSMemberState createState() => _YSMemberState(); } class _YSMemberState extends State { int _titleIndex = 0; 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(88), color: Colors.white, padding: EdgeInsets.only(left: hsp(30),right: hsp(30)), child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ _titleIndex = index; _refreshData(); }, child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end, children: [ Text(index==0?'个人':'商家',style: TextStyle(fontSize: zsp(36),color: Color(_titleIndex==index?0xFF007AFF:0xFF747474)),), Container( height: hsp(4), width: hsp(50), color: _titleIndex==index?Color(0xFF007AFF):Colors.transparent, margin: EdgeInsets.only(top: hsp(15),bottom: hsp(3)), ) ], ), ); }, separatorBuilder: (context,index){ return Container(width: hsp(30),); }, itemCount: 2, scrollDirection: Axis.horizontal, ), ), Container( margin: EdgeInsets.only(top: hsp(20)), height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(108), child: EasyRefresh( onRefresh: _refreshData, onLoad: _loadMoreData, header: TaurusHeader( ), footer: TaurusFooter( ), child: ListView.separated( itemBuilder: (context,index){ Map item = _dataArray[index]; return GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return _titleIndex==0?YSUnionOrder(userId: item['userId'],):YSUnionOrder(shopId: item['partnerId'],); } ) ); }, behavior: HitTestBehavior.opaque, child: Container( padding: EdgeInsets.all(hsp(30)), color: Colors.white, child: LayoutBuilder( builder: (context,listSize){ return Row( children: [ Container( width: listSize.maxWidth*0.6-hsp(40), child: _titleIndex==1?Text('${item['name']}',style: TextStyle(fontSize: zsp(28),color: Colors.black),): RichText( text: TextSpan( text: '${item['name']}', style: TextStyle(fontSize: zsp(28),color: Colors.black), children: [ TextSpan( text: ' / ${getSecretStr('${item['phoneNumber']}')}', style: TextStyle(color: Color(0xFF999999)) ) ] ), ) ), Container( width: listSize.maxWidth*0.4, alignment: Alignment.centerRight, child: Text('${item['createTime']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),), ), Icon(Icons.chevron_right,size: hsp(40),color: Color(0xFFCCCCCC),) ], ); }, ), ), ); }, separatorBuilder: (context,index){ return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),); }, itemCount: _dataArray.length, ), ), ) ], ), ), ); } Future _refreshData() async{ _page = 1; Map request = {}; request['pageNum'] = _page; String url = '/app/servants/getUserList'; if(_titleIndex==1){ url = '/app/servants/getPartnerList'; } Map dict = await ysRequestHttp(context,type: requestType.get,api: url,parameter: request,isLoading: false,isToken: true); if(dict!=null){ setState(() { _dataArray = dict['data']['resultList']; }); } } Future _loadMoreData() async{ _page++; Map request = {}; request['pageNum'] = _page; String url = '/app/servants/getUserList'; if(_titleIndex==1){ url = '/app/servants/getPartnerList'; } Map dict = await ysRequestHttp(context,type: requestType.get,api: url,parameter: request, isLoading: false,isToken: true); if(dict!=null){ setState(() { _dataArray.addAll(dict['data']['resultList']); }); } } }