123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- 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<YSMember> {
- 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<void> _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<void> _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']);
- });
- }
- }
- }
|