YSMember.dart 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_easyrefresh/easy_refresh.dart';
  4. import 'package:ysairplane2/base/YSBase.dart';
  5. import 'package:ysairplane2/code/YSUnionOrder.dart';
  6. import 'package:ysairplane2/tools/YSNetWorking.dart';
  7. import 'package:ysairplane2/tools/YSTools.dart';
  8. class YSMember extends StatefulWidget {
  9. const YSMember({Key key}) : super(key: key);
  10. @override
  11. _YSMemberState createState() => _YSMemberState();
  12. }
  13. class _YSMemberState extends State<YSMember> {
  14. int _titleIndex = 0;
  15. List _dataArray = [];
  16. int _page = 1;
  17. @override
  18. void initState() {
  19. Future.delayed(Duration(seconds: 0)).then((value){
  20. _refreshData();
  21. });
  22. super.initState();
  23. }
  24. @override
  25. Widget build(BuildContext context) {
  26. return YSBase(
  27. ystitle: '联盟成员',
  28. yscolor: Color(0xFFF5F6F8),
  29. yschild: Container(
  30. width: MediaQuery.of(context).size.width,
  31. child: Column(
  32. children: [
  33. Container(
  34. height: hsp(88),
  35. color: Colors.white,
  36. padding: EdgeInsets.only(left: hsp(30),right: hsp(30)),
  37. child: ListView.separated(
  38. itemBuilder: (context,index){
  39. return GestureDetector(
  40. onTap: (){
  41. _titleIndex = index;
  42. _refreshData();
  43. },
  44. child: Column(
  45. mainAxisSize: MainAxisSize.min,
  46. mainAxisAlignment: MainAxisAlignment.end,
  47. children: [
  48. Text(index==0?'个人':'商家',style: TextStyle(fontSize: zsp(36),color: Color(_titleIndex==index?0xFF007AFF:0xFF747474)),),
  49. Container(
  50. height: hsp(4),
  51. width: hsp(50),
  52. color: _titleIndex==index?Color(0xFF007AFF):Colors.transparent,
  53. margin: EdgeInsets.only(top: hsp(15),bottom: hsp(3)),
  54. )
  55. ],
  56. ),
  57. );
  58. },
  59. separatorBuilder: (context,index){
  60. return Container(width: hsp(30),);
  61. },
  62. itemCount: 2,
  63. scrollDirection: Axis.horizontal,
  64. ),
  65. ),
  66. Container(
  67. margin: EdgeInsets.only(top: hsp(20)),
  68. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(108),
  69. child: EasyRefresh(
  70. onRefresh: _refreshData,
  71. onLoad: _loadMoreData,
  72. header: TaurusHeader(
  73. ),
  74. footer: TaurusFooter(
  75. ),
  76. child: ListView.separated(
  77. itemBuilder: (context,index){
  78. Map item = _dataArray[index];
  79. return GestureDetector(
  80. onTap: (){
  81. Navigator.of(context).push(
  82. CupertinoPageRoute(
  83. builder: (context){
  84. return _titleIndex==0?YSUnionOrder(userId: item['userId'],):YSUnionOrder(shopId: item['partnerId'],);
  85. }
  86. )
  87. );
  88. },
  89. behavior: HitTestBehavior.opaque,
  90. child: Container(
  91. padding: EdgeInsets.all(hsp(30)),
  92. color: Colors.white,
  93. child: LayoutBuilder(
  94. builder: (context,listSize){
  95. return Row(
  96. children: [
  97. Container(
  98. width: listSize.maxWidth*0.6-hsp(40),
  99. child: _titleIndex==1?Text('${item['name']}',style: TextStyle(fontSize: zsp(28),color: Colors.black),):
  100. RichText(
  101. text: TextSpan(
  102. text: '${item['name']}',
  103. style: TextStyle(fontSize: zsp(28),color: Colors.black),
  104. children: [
  105. TextSpan(
  106. text: ' / ${getSecretStr('${item['phoneNumber']}')}',
  107. style: TextStyle(color: Color(0xFF999999))
  108. )
  109. ]
  110. ),
  111. )
  112. ),
  113. Container(
  114. width: listSize.maxWidth*0.4,
  115. alignment: Alignment.centerRight,
  116. child: Text('${item['createTime']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),),
  117. ),
  118. Icon(Icons.chevron_right,size: hsp(40),color: Color(0xFFCCCCCC),)
  119. ],
  120. );
  121. },
  122. ),
  123. ),
  124. );
  125. },
  126. separatorBuilder: (context,index){
  127. return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),);
  128. },
  129. itemCount: _dataArray.length,
  130. ),
  131. ),
  132. )
  133. ],
  134. ),
  135. ),
  136. );
  137. }
  138. Future<void> _refreshData() async{
  139. _page = 1;
  140. Map request = {};
  141. request['pageNum'] = _page;
  142. String url = '/app/servants/getUserList';
  143. if(_titleIndex==1){
  144. url = '/app/servants/getPartnerList';
  145. }
  146. Map dict = await ysRequestHttp(context,type: requestType.get,api: url,parameter: request,isLoading: false,isToken: true);
  147. if(dict!=null){
  148. setState(() {
  149. _dataArray = dict['data']['resultList'];
  150. });
  151. }
  152. }
  153. Future<void> _loadMoreData() async{
  154. _page++;
  155. Map request = {};
  156. request['pageNum'] = _page;
  157. String url = '/app/servants/getUserList';
  158. if(_titleIndex==1){
  159. url = '/app/servants/getPartnerList';
  160. }
  161. Map dict = await ysRequestHttp(context,type: requestType.get,api: url,parameter: request, isLoading: false,isToken: true);
  162. if(dict!=null){
  163. setState(() {
  164. _dataArray.addAll(dict['data']['resultList']);
  165. });
  166. }
  167. }
  168. }