import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:ysairplane2/base/YSBase.dart'; import 'package:ysairplane2/code/YSIncome.dart'; import 'package:ysairplane2/code/YSMember.dart'; import 'package:ysairplane2/code/YSUnionOrder.dart'; import 'package:ysairplane2/code/YSWithdrawal.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSTools.dart'; import 'package:flutter/services.dart'; import 'YSUnionOrderDetail.dart'; class YSUnionHome extends StatefulWidget { const YSUnionHome({Key key}) : super(key: key); @override _YSUnionHomeState createState() => _YSUnionHomeState(); } class _YSUnionHomeState extends State { Map _msgDict = {'balance':0,'thisMothPrice':0,'servantsUserSize':0,'servantsCode':'', 'lastMothPrice':0,'servantsPartnerSize':0,'latestOrderList':[]}; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _getUnionData(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ystitle: '顺翔联盟', yscolor: Color(0xFFF5F6F8), yschild: Container( width: MediaQuery.of(context).size.width, child: Stack( children: [ Container( height: hsp(400), decoration: BoxDecoration(image: DecorationImage(image: AssetImage('lib/images/图层2257.png'),fit: BoxFit.fill)), padding: EdgeInsets.only(top: hsp(50),left: hsp(20),right: hsp(20)), width: MediaQuery.of(context).size.width, child: Column( children: [ Text('可提现金额(元)',style: TextStyle(fontSize: zsp(28),color: Colors.white),), Container( margin: EdgeInsets.only(top: hsp(20)), child: Text('${_msgDict['balance']}',style: TextStyle(fontSize: zsp(60),color: Colors.white,fontWeight: FontWeight.bold),maxLines: 1,), ), Container( margin: EdgeInsets.only(top: hsp(50)), height: hsp(100), child: ListView.separated( itemBuilder: (context,index){ return Container( width: (MediaQuery.of(context).size.width-hsp(41))/2, child: Text('${index==0?'本月':'上月'}预估收入\n¥${index==0?'${_msgDict['thisMothPrice']}':'${_msgDict['lastMothPrice']}'}', style: TextStyle(fontSize: zsp(22),color: Colors.white),textAlign: TextAlign.center,), alignment: Alignment.center, ); }, separatorBuilder: (context,index){ return Container( margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20)), width: hsp(2), color: Colors.white, ); }, itemCount: 2, scrollDirection: Axis.horizontal, ), ) ], ), ), Container( margin: EdgeInsets.only(top: hsp(370)), width: MediaQuery.of(context).size.width, child: LayoutBuilder( builder: (context,conSize){ return Column( children: [ Container( height: hsp(120), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(5)) ), margin: EdgeInsets.only(left: hsp(20),right: hsp(20),bottom: hsp(20)), child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return index==0?YSIncome():YSWithdrawal(); } ) ); }, child: Container( width: (MediaQuery.of(context).size.width-hsp(41))/2, child: Row( mainAxisSize: MainAxisSize.min, children: [ Image.asset('lib/images/${index==0?'收入明细':'去提现'}.png',height: hsp(30),width: hsp(30),color: Colors.grey,), Text(' ${index==0?'收入明细':'去提现'}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF7C7C7C)),textAlign: TextAlign.center,), ], ), alignment: Alignment.center, padding: EdgeInsets.only(left: hsp(20),right: hsp(20)), ), ); }, separatorBuilder: (context,index){ return Container( margin: EdgeInsets.only(top: hsp(30),bottom: hsp(30)), width: hsp(2), color: Color(0xFFE2E2E2), ); }, itemCount: 2, scrollDirection: Axis.horizontal, ), ), GestureDetector( child: Container( height: hsp(150), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(5)) ), margin: EdgeInsets.only(left: hsp(20),right: hsp(20),bottom: hsp(20)), child: Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ ConstrainedBox( constraints: BoxConstraints( maxWidth: MediaQuery.of(context).size.width-hsp(40)-hsp(200) ), child: Text('推广码:${_msgDict['servantsCode']} ',style: TextStyle(fontSize: zsp(30),color: Colors.black),maxLines: 1,), ), GestureDetector( child: Text('复制',style: TextStyle(fontSize: zsp(30),color: Color(0xFF007AFF)),), onTap: (){ Clipboard.setData(ClipboardData(text: '${_msgDict['servantsCode']}')); ysFlutterToast(context, '推广码已复制'); }, ), ], ), Container( child: RichText( text: TextSpan( text: '推广用户:', style: TextStyle(fontSize: zsp(22),color: Color(0xFF666666)), children: [ TextSpan( text: '${_msgDict['servantsUserSize']}人', style: TextStyle(color: Color(0xFF007AFF)), ), TextSpan( text: ' 推广商家:', ), TextSpan( text: '${_msgDict['servantsPartnerSize']}', style: TextStyle(color: Color(0xFF007AFF)), ) ] ), ), margin: EdgeInsets.only(top: hsp(20)), ) ], mainAxisSize: MainAxisSize.min, ), Icon(Icons.chevron_right,size: hsp(40),color: Color(0xFFCCCCCC),) ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), padding: EdgeInsets.all(hsp(20)), width: MediaQuery.of(context).size.width-hsp(40), alignment: Alignment.centerLeft, ), onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSMember(); } ) ); }, behavior: HitTestBehavior.opaque, ), GestureDetector( child: Container( height: hsp(120), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(5)) ), margin: EdgeInsets.only(left: hsp(20),right: hsp(20),bottom: hsp(20)), child: Row( children: [ Container( width: hsp(200), child: Text('订单明细',style: TextStyle(fontSize: zsp(30),color: Colors.black),), ), Row( children: [ Container( width: MediaQuery.of(context).size.width-hsp(320), child: Text('更多',style: TextStyle(fontSize: zsp(30),color: Color(0xFFCCCCCC)),), alignment: Alignment.centerRight, ), Icon(Icons.chevron_right,size: hsp(40),color: Color(0xFFCCCCCC),) ], ) ], ), padding: EdgeInsets.only(left: hsp(20),right: hsp(20)), ), onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSUnionOrder(); } ) ); }, behavior: HitTestBehavior.opaque, ), ListView.separated( itemBuilder: (context,index){ Map item = _msgDict['latestOrderList'][index]; return GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSUnionOrderDetail(order: item,); } ) ); }, behavior: HitTestBehavior.opaque, child: Container( padding: EdgeInsets.all(hsp(20)), color: Colors.white, child: LayoutBuilder( builder: (context,listSize){ return Column( children: [ Row( children: [ Container( width: listSize.maxWidth-hsp(200), child: RichText( text: TextSpan( text: '订单编号:', style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)), children: [ TextSpan( text: '${item['orderSn']}', style: TextStyle(color: Colors.black) ) ] ), ), ), Container( width: hsp(200), child: Text(item['orderStatus']==0?'已下单':item['orderStatus']==1?'已核验':'已退款',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),), alignment: Alignment.centerRight, ) ], ), Container( margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20)), child: Row( children: [ Container( width: listSize.maxWidth*0.7, child: Text('${item['typeName']}',style: TextStyle(fontSize: zsp(34),color: Color(0xFF5F5F5F)),), ), Container( width: listSize.maxWidth*0.3, alignment: Alignment.centerRight, child: RichText( text: TextSpan( text: '${item['orderPrice']}', style: TextStyle(fontSize: zsp(40),color: Colors.black), children: [ TextSpan( text: '元', style: TextStyle(fontSize: zsp(24)) ) ] ), ), ) ], ), ), Row( children: [ Container( width: listSize.maxWidth*0.2, child: RichText( text: TextSpan( text: '佣金:', style: TextStyle(fontSize: zsp(22),color: Color(0xFF999999)), children: [ TextSpan( text: '${item['servantsPrice']}', style: TextStyle(color: Colors.black) ) ] ), ), ), Container( width: listSize.maxWidth*0.3, child: RichText( text: TextSpan( text: '用户:', style: TextStyle(fontSize: zsp(22),color: Color(0xFF999999)), children: [ TextSpan( text: '${item['nickName']}', style: TextStyle(color: Colors.black) ) ] ), ), alignment: Alignment.center, ), Container( width: listSize.maxWidth*0.5, child: RichText( text: TextSpan( text: '支付时间:', style: TextStyle(fontSize: zsp(22),color: Color(0xFF999999)), children: [ TextSpan( text: '${item['payTime']}', style: TextStyle(color: Colors.black) ) ] ), ), alignment: Alignment.centerRight, ) ], ) ], ); }, ), ), ); }, separatorBuilder: (context,index){ return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),); }, itemCount: _msgDict['latestOrderList'].length, physics: NeverScrollableScrollPhysics(), shrinkWrap: true, ) ], ); }, ), ) ], ), ), ); } _getUnionData() async{ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/servants/getUnionIndex',parameter: {},isLoading: false,isToken: true); if(dict!=null){ setState(() { _msgDict = dict['data']; }); } } }