| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- 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<ReferrerFlowPage> {
- int page = 1;
- int total = 0;
- double totalAmount = 0.0;
- RefreshController controller = RefreshController(initialRefresh: true);
- List<FlowBeanDataDataRecords> 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}(${widget.data.recommenderUid})',
- 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<String> types = ['全部', '订单', '佣金'];
- int typeIndex = 0;
- List<String> times = ['全部', '今天', '昨天', '本周', '上周', '本月'];
- int timeIndex = 0;
- 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<Widget> 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<Widget> item = [];
- for (int i = 0; i < times.length; i++) {
- item.add(GestureDetector(
- onTap: () {
- ss(() {
- if (timeIndex == i) {
- timeIndex = -1;
- } else {
- timeIndex = i;
- }
- });
- if (timeIndex != 0) {
- getTime(timeIndex - 1);
- }
- },
- 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) {
- conditions.add("type IN ${typeIndex == 1 ? [
- flowTypeOrderCommodity,
- flowTypeOrderAnnualFee,
- flowTypeOrderVirtualProduct,
- flowTypeOrderThirdPlatform,
- flowTypeOrderOfflineTransfer,
- flowTypeScancodeAilyPay
- ] : [flowTypeShopCommission]}");
- }
- if (timeIndex != 0 && timeIndex != -1) {
- conditions.add("pay_time between ${getTime(timeIndex - 1)}");
- }
- 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) {});
- }
- }
|