import 'dart:convert'; import 'package:bbyyy/beans/flow_bean_entity.dart'; import 'package:bbyyy/beans/my_shop_bean_entity.dart'; import 'package:bbyyy/beans/store_bean_entity.dart'; import 'package:bbyyy/beans/user_balance_entity.dart'; import 'package:bbyyy/https/MyDio.dart'; import 'package:bbyyy/https/url.dart'; import 'package:bbyyy/my_tools/const.dart'; import 'package:bbyyy/my_tools/dims.dart'; import 'package:bbyyy/my_tools/my_colors.dart'; import 'package:bbyyy/my_tools/my_cookie.dart'; import 'package:bbyyy/my_tools/my_tools.dart'; import 'package:bbyyy/my_tools/my_views.dart'; import 'package:bbyyy/pay/pay_tools.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'dart:math' as math; class ReferrerFlowPage extends StatefulWidget { MyShopBeanDataData data; ReferrerFlowPage(this.data); @override _ReferrerFlowPageState createState() => _ReferrerFlowPageState(); } class _ReferrerFlowPageState extends State { int page = 1; int total = 0; double totalAmount = 0.0; RefreshController controller = RefreshController(initialRefresh: true); List flow = []; @override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ Stack( children: [ Container( decoration: BoxDecoration( gradient: LinearGradient(colors: MyColors.lg), ), height: 220, ), Column( children: [ SafeArea( bottom: false, child: Container( height: 45, width: double.infinity, color: Colors.transparent, child: Stack( children: [ Text( '资金流水', style: TextStyle(color: Colors.white, fontSize: 16), ), Positioned( left: 0, child: GestureDetector( onTap: () { Navigator.pop(context); }, behavior: HitTestBehavior.translucent, child: Transform.rotate( angle: math.pi, child: Padding( padding: EdgeInsets.only( left: 16, right: 16, top: 8, bottom: 8), child: SvgPicture.asset( 'images/svg/箭头.svg', color: Colors.white, height: 14, ), ), ), ), ), Row( children: [ GestureDetector( onTap: () { showSelect(); }, behavior: HitTestBehavior.translucent, child: Container( padding: EdgeInsets.symmetric( vertical: 8, horizontal: 16), child: Text( '筛选', style: TextStyle( color: Colors.white, fontSize: 16), ), ), ), ], mainAxisAlignment: MainAxisAlignment.end, ) ], alignment: Alignment.center, ), ), ), Container( margin: EdgeInsets.only(top: 10), child: Row( children: [ ClipRRect( child: MyViews() .netImg(imgURL(widget.data.recommenderPic), 36, 36), borderRadius: BorderRadius.circular(18), ), Container( margin: EdgeInsets.only(left: 10), child: Text( '${widget.data.recommenderName}(${hideUID(widget.data.recommenderUid.toString())})', style: TextStyle(color: Colors.white, fontSize: 15), ), ), ], mainAxisAlignment: MainAxisAlignment.center, ), alignment: Alignment.center, ), // Container( // margin: EdgeInsets.only(top: 10), // child: Center( // child: Text( // '总额:$totalAmount', // style: TextStyle(color: Colors.white, fontSize: 20), // ), // ), // ), Container( margin: EdgeInsets.only(top: 10), child: Center( child: Text( '共$total笔', style: TextStyle(color: Colors.white, fontSize: 20), ), ), ), ], ) ], ), Expanded( child: SmartRefresher( controller: controller, onRefresh: onRefresh, onLoading: onLoading, enablePullDown: true, enablePullUp: true, child: flow.length == 0 ? SingleChildScrollView(child: noData()) : ListView.builder( itemBuilder: (c, index) { return MyViews().getWalletItem(flow[index], context); }, padding: EdgeInsets.only(top: 13), itemCount: flow.length, ), ), ), ], ), ); } StateSetter ss; List types = ['全部', '订单', '佣金','缴费']; int typeIndex = 0; // List times = ['全部', '今天', '昨天', '本周', '上周', '本月']; List times = ['今天', '昨天', '本周'];//, '上周' int timeIndex = -1; void showSelect() { showModalBottomSheet( backgroundColor: Colors.transparent, context: context, builder: (context) { return StatefulBuilder(builder: (c, s) { ss = s; return Container( color: Colors.transparent, height: 240 + (MediaQuery.of(context).size.width / 3 / 2.5) * ((types.length / 3).ceil()), child: Column( children: [ Container( padding: EdgeInsets.only(left: 10, right: 10, top: 3, bottom: 0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(8), topRight: Radius.circular(8))), child: Row( children: [ GestureDetector( onTap: () { Navigator.pop(context); }, behavior: HitTestBehavior.translucent, child: Padding( padding: const EdgeInsets.all(8.0), child: Text( '取消', style: TextStyle( color: MyColors.cFF4233, fontSize: 14), ), ), ), Text( '类型筛选', style: TextStyle(color: MyColors.c333333, fontSize: 16), ), GestureDetector( child: Padding( padding: const EdgeInsets.all(8.0), child: Text( '确定', style: TextStyle( color: MyColors.cFF4233, fontSize: 14), ), ), behavior: HitTestBehavior.translucent, onTap: () { Navigator.pop(context); controller.requestRefresh(); }, ), ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), height: 39.5, ), Container( height: 0.5, color: MyColors.cF5F5F5, ), Expanded( child: Container( color: Colors.white, child: SingleChildScrollView( child: Column( children: [ Visibility( visible: types.length > 1, child: Container( height: 20 + (MediaQuery.of(context).size.width / 3 / 2.5) * ((types.length / 3).ceil()), color: Colors.white, child: Column( children: [ Container( child: Text( '类型筛选', style: TextStyle( color: MyColors.c333333, fontSize: 15), ), margin: EdgeInsets.only( left: 18, top: 5, bottom: 5), height: 20, ), Expanded( child: GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, childAspectRatio: 3), children: getTypeItems(), physics: NeverScrollableScrollPhysics(), ), ) ], crossAxisAlignment: CrossAxisAlignment.start, ), ), ), Visibility( visible: times.length > 1, child: Container( height: 20 + (MediaQuery.of(context).size.width / 3 / 2.5) * ((times.length / 3).ceil()), color: Colors.white, child: Column( children: [ Container( child: Text( '时间筛选', style: TextStyle( color: MyColors.c333333, fontSize: 15), ), margin: EdgeInsets.only( left: 18, top: 5, bottom: 5), height: 20, ), Expanded( child: GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, childAspectRatio: 3), children: getTimeItems(), physics: NeverScrollableScrollPhysics(), ), ) ], crossAxisAlignment: CrossAxisAlignment.start, ), ), ), ], crossAxisAlignment: CrossAxisAlignment.start, ), ), ), ) ], ), ); }); }); } getTypeItems() { List item = []; for (int i = 0; i < types.length; i++) { item.add(GestureDetector( onTap: () { ss(() { if (typeIndex == i) { typeIndex = -1; } else { typeIndex = i; } }); // getTime(timeIndex); }, behavior: HitTestBehavior.translucent, child: Container( alignment: Alignment.center, child: Container( decoration: BoxDecoration( color: i == typeIndex ? MyColors.cFFECEB : MyColors.cEDEDED, borderRadius: BorderRadius.all(Radius.circular(4))), height: 34, width: 100, child: Text( types[i], style: TextStyle( color: i == typeIndex ? MyColors.cFF4233 : MyColors.c666666, fontSize: 14), ), alignment: Alignment.center, ), ), )); } return item; } getTimeItems() { List item = []; for (int i = 0; i < times.length; i++) { item.add(GestureDetector( onTap: () { ss(() { if (timeIndex == i) { timeIndex = -1; } else { timeIndex = i; } }); if (timeIndex != -1) { getTime(timeIndex); } }, behavior: HitTestBehavior.translucent, child: Container( alignment: Alignment.center, child: Container( decoration: BoxDecoration( color: i == timeIndex ? MyColors.cFFECEB : MyColors.cEDEDED, borderRadius: BorderRadius.all(Radius.circular(4))), height: 34, width: 100, child: Text( times[i], style: TextStyle( color: i == timeIndex ? MyColors.cFF4233 : MyColors.c666666, fontSize: 14), ), alignment: Alignment.center, ), ), )); } return item; } void myFlow() { var conditions = [ // "user_uid==${MyCookie().getUID()}", 'recommender_uid == ${widget.data.recommenderUid}', 'paid_amount > 0 ' // "paid_amount ${sTab == 0 ? '>' : '<'} 0" ]; if (typeIndex != 0 && typeIndex != -1) { switch (typeIndex){ case 1: conditions.add("type IN ${[ flowTypeOrderCommodity, flowTypeOrderAnnualFee, flowTypeOrderVirtualProduct, flowTypeOrderThirdPlatform, flowTypeOrderOfflineTransfer, flowTypeScancodeAilyPay ]}"); break; case 2: conditions.add("type IN ${ [flowTypeShopCommission]}"); break; case 3: conditions.add("type IN ${ [flowTypePlatformFee]}"); break; } } if (timeIndex != -1) { conditions.add("pay_time between ${getTime(timeIndex)}"); }else{ conditions.add("pay_time between ${getTime(6)}"); } MyDio().query({ "key": "flow", "filters": {"conditions": conditions}, "dims": flowDims, "order_by": ["id,DESC"], "paging": [page, 50] }, (response, hasError) { if (!hasError) { FlowBeanEntity entity = FlowBeanEntity.fromJson(json.decode(response.data.toString())); total = entity.data.total; totalAmount = entity.data.data.totalAmount; if (page == 1) { flow.clear(); } try { flow.addAll(entity.data.data.records); } catch (e) {} setState(() {}); } endRe(controller); }, (error) {}); } void onRefresh() { page = 1; checkIfYouAreTheOwner(); myFlow(); } void onLoading() { page++; myFlow(); } void checkIfYouAreTheOwner() { MyDio().query({ "key": "shop", "filters": { "conditions": ["owner_uid == ${MyCookie().getUID()}"] }, "dims": shopDims, "paging": [1, 5000] }, (response, hasError) { if (!hasError) { StoreBeanEntity entity = StoreBeanEntity.fromJson(json.decode(response.data.toString())); if (entity.data.data.length == 0) { types.remove('佣金'); } setState(() {}); } endRe(controller); }, (error) {}); } }