YSIncome.dart 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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/tools/YSNetWorking.dart';
  6. import 'package:ysairplane2/tools/YSTools.dart';
  7. class YSIncome extends StatefulWidget {
  8. const YSIncome({Key key}) : super(key: key);
  9. @override
  10. _YSIncomeState createState() => _YSIncomeState();
  11. }
  12. class _YSIncomeState extends State<YSIncome> {
  13. String _timeSrt = '';
  14. List _dataArray = [];
  15. int _page = 1;
  16. @override
  17. void initState() {
  18. Future.delayed(Duration(seconds: 0)).then((value){
  19. _refreshData();
  20. });
  21. super.initState();
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return YSBase(
  26. ystitle: '收入明细',
  27. yscolor: Color(0xFFF5F6F8),
  28. yschild: Container(
  29. width: MediaQuery.of(context).size.width,
  30. child: Column(
  31. children: [
  32. Container(
  33. height: hsp(80),
  34. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  35. child: GestureDetector(
  36. onTap: (){
  37. showModalBottomSheet(
  38. context: context,
  39. builder: (context){
  40. return YSDatePicker(isDate: true,choose: (value){
  41. print(value);
  42. _timeSrt = value.substring(0,7);
  43. _refreshData();
  44. },);
  45. }
  46. );
  47. },
  48. child: Row(
  49. children: [
  50. Text(_timeSrt.isEmpty?'全部':_timeSrt,style: TextStyle(fontSize: zsp(30),color: Colors.black),),
  51. Icon(Icons.keyboard_arrow_down,size: hsp(40),color: Color(0xFFCCCCCC),)
  52. ],
  53. ),
  54. )
  55. ),
  56. Container(
  57. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(80),
  58. color: Colors.white,
  59. child: EasyRefresh(
  60. onRefresh: _refreshData,
  61. onLoad: _loadMoreData,
  62. header: TaurusHeader(
  63. ),
  64. footer: TaurusFooter(
  65. ),
  66. child: ListView.separated(
  67. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  68. itemBuilder: (context,index){
  69. Map item = _dataArray[index];
  70. return GestureDetector(
  71. onTap: (){
  72. Navigator.of(context).push(
  73. CupertinoPageRoute(
  74. builder: (context){
  75. return YSIncomeDetail(income: item,);
  76. }
  77. )
  78. );
  79. },
  80. child: Container(
  81. padding: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
  82. child: LayoutBuilder(
  83. builder: (context,listSize){
  84. return Row(
  85. children: [
  86. Container(
  87. width: listSize.maxWidth-hsp(150),
  88. child: RichText(
  89. text: TextSpan(
  90. text: '${item['orderName']}',
  91. style: TextStyle(fontSize: zsp(28),color: Colors.black),
  92. children: [
  93. if(item['orderSn']!=null)TextSpan(
  94. text: '[订单编号: ${item['orderSn']}]',
  95. style: TextStyle(color: Color(0xFF999999))
  96. )
  97. ]
  98. ),
  99. ),
  100. ),
  101. Container(
  102. width: hsp(110),
  103. child: Text('${item['status']}',style: TextStyle(fontSize: zsp(28),
  104. color: Color(item['status']=='冻结中'?0xFFFFAE00:0xFF999999)),),
  105. alignment: Alignment.centerRight,
  106. ),
  107. Icon(Icons.chevron_right,size: hsp(40),color: Color(0xFF999999),)
  108. ],
  109. );
  110. },
  111. ),
  112. ),
  113. );
  114. },
  115. separatorBuilder: (context,index){
  116. return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),);
  117. },
  118. itemCount: _dataArray.length,
  119. ),
  120. ),
  121. )
  122. ],
  123. ),
  124. ),
  125. );
  126. }
  127. Future<void> _refreshData() async{
  128. _page = 1;
  129. if(_timeSrt.isEmpty)_timeSrt = '${DateTime.now().year}-'+'${DateTime.now().month}'.padLeft(2,'0');
  130. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/servants/incomeList',parameter: {'pageNum':_page,'date':_timeSrt},isLoading: false,isToken: true);
  131. if(dict!=null){
  132. setState(() {
  133. _dataArray = dict['data']['resultList'];
  134. });
  135. }
  136. }
  137. Future<void> _loadMoreData() async{
  138. _page++;
  139. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/servants/incomeList',parameter: {'pageNum':_page,'date':_timeSrt},isLoading: false,isToken: true);
  140. if(dict!=null){
  141. setState(() {
  142. _dataArray.addAll(dict['data']['resultList']);
  143. });
  144. }
  145. }
  146. }
  147. class YSIncomeDetail extends StatefulWidget {
  148. final Map income;
  149. const YSIncomeDetail({Key key, this.income}) : super(key: key);
  150. @override
  151. _YSIncomeDetailState createState() => _YSIncomeDetailState();
  152. }
  153. class _YSIncomeDetailState extends State<YSIncomeDetail> {
  154. List _titleArray = [];
  155. @override
  156. void initState() {
  157. if(widget.income!=null){
  158. if(widget.income['type']==1){
  159. _titleArray = [{'title':'','content':''},{'title':'订单编号','content':''},{'title':'佣金状态','content':''},{'title':'佣金金额','content':''}
  160. ,{'title':'订单状态','content':''},{'title':'订单金额','content':''}];
  161. _titleArray[0]['title'] = widget.income['orderName'];
  162. _titleArray[1]['content'] = widget.income['orderSn'];
  163. _titleArray[2]['content'] = widget.income['status'];
  164. _titleArray[3]['content'] = '${widget.income['servantsPrice']??'0.00'}';
  165. _titleArray[4]['content'] = widget.income['orderStatus'];
  166. _titleArray[5]['content'] = '${widget.income['orderPrice']??'0.00'}';
  167. }else{
  168. _titleArray = [{'title':'','content':''},{'title':'提现状态','content':''},{'title':'提现方式','content':''}
  169. ,{'title':'提现账号','content':''},{'title':'提现金额','content':''},{'title':'提现时间','content':''}];
  170. _titleArray[0]['title'] = widget.income['orderName'];
  171. _titleArray[1]['content'] = widget.income['status'];
  172. _titleArray[2]['content'] = widget.income['accountName'];
  173. _titleArray[3]['content'] = widget.income['account'];
  174. _titleArray[4]['content'] = '${widget.income['price']??'0.00'}';
  175. _titleArray[5]['content'] = widget.income['createTime'];
  176. }
  177. }
  178. super.initState();
  179. }
  180. @override
  181. Widget build(BuildContext context) {
  182. return YSBase(
  183. ystitle: '收入明细详情',
  184. yscolor: Color(0xFFF5F6F8),
  185. yschild: Container(
  186. color: Colors.white,
  187. width: MediaQuery.of(context).size.width,
  188. child: ListView.separated(
  189. padding: EdgeInsets.only(left: hsp(30),right: hsp(30)),
  190. itemBuilder: (context,index){
  191. Map item = _titleArray[index];
  192. return Container(
  193. padding: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
  194. child: LayoutBuilder(
  195. builder: (context,listSize){
  196. return Row(
  197. children: [
  198. Container(
  199. width: hsp(200),
  200. child: Text(item['title'],style: TextStyle(fontSize: zsp(28),color: Colors.black,fontWeight: index==0?FontWeight.bold:FontWeight.normal),),
  201. ),
  202. Container(
  203. width: listSize.maxWidth-hsp(200),
  204. child: Text(item['content'],style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),),
  205. alignment: Alignment.centerRight,
  206. )
  207. ],
  208. );
  209. },
  210. ),
  211. );
  212. },
  213. separatorBuilder: (context,index){
  214. return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),);
  215. },
  216. itemCount: _titleArray.length,
  217. shrinkWrap: true,
  218. physics: NeverScrollableScrollPhysics(),
  219. ),
  220. ),
  221. );
  222. }
  223. }