| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658 |
- import 'dart:convert';
- import 'dart:math' as math;
- import 'package:bbyyy/beans/flow_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';
- class WalletPage extends StatefulWidget {
- @override
- _WalletPageState createState() => _WalletPageState();
- }
- class _WalletPageState extends State<WalletPage> {
- int sTab = 0;
- List<FlowBeanDataDataRecords> flow = [];
- int page = 1;
- RefreshController controller = RefreshController(initialRefresh: true);
- int total = 0;
- double totalAmount = 0.0;
- @override
- void initState() {
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Column(
- children: [
- Stack(
- children: [
- Container(
- decoration: BoxDecoration(
- gradient: LinearGradient(colors: MyColors.lg),
- ),
- height: 200,
- ),
- 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(
- // decoration: BoxDecoration(
- // border: Border.all(color: Colors.white, width: 1),
- // borderRadius: BorderRadius.all(Radius.circular(20))),
- // height: 40,
- // width: double.infinity,
- // margin: EdgeInsets.symmetric(horizontal: 33, vertical: 7),
- // child: Row(
- // children: [
- // Expanded(
- // child: GestureDetector(
- // onTap: () {
- // setState(() {
- // sTab = 0;
- // controller.requestRefresh();
- // });
- // },
- // behavior: HitTestBehavior.translucent,
- // child: Container(
- // height: 40,
- // decoration: BoxDecoration(
- // borderRadius: BorderRadius.only(
- // topLeft: Radius.circular(20),
- // bottomLeft: Radius.circular(20),
- // ),
- // color: sTab == 0
- // ? Colors.white
- // : Colors.transparent),
- // child: Text(
- // '我的收入',
- // style: TextStyle(
- // color: sTab == 0
- // ? MyColors.cFF4233
- // : Colors.white),
- // ),
- // alignment: Alignment.center,
- // ),
- // ),
- // ),
- // Expanded(
- // child: GestureDetector(
- // onTap: () {
- // setState(() {
- // sTab = 1;
- // controller.requestRefresh();
- // });
- // },
- // behavior: HitTestBehavior.translucent,
- // child: Container(
- // height: 40,
- // decoration: BoxDecoration(
- // borderRadius: BorderRadius.only(
- // topRight: Radius.circular(20),
- // bottomRight: Radius.circular(20),
- // ),
- // color: sTab == 1
- // ? Colors.white
- // : Colors.transparent),
- // child: Text(
- // '我的支出',
- // style: TextStyle(
- // color: sTab == 1
- // ? MyColors.cFF4233
- // : Colors.white),
- // ),
- // alignment: Alignment.center,
- // ),
- // ),
- // )
- // ],
- // ),
- // ),
- Container(
- margin: EdgeInsets.only(top: 10),
- child: Row(
- children: [
- ClipRRect(
- child: MyViews()
- .netImg(imgURL(MyCookie().getPic()), 36, 36),
- borderRadius: BorderRadius.circular(18),
- ),
- Container(
- margin: EdgeInsets.only(left: 10),
- child: Text(
- '${MyCookie().getName()}(${MyCookie().getUID()})',
- style: TextStyle(color: Colors.white, fontSize: 15),
- ),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.center,
- ),
- alignment: Alignment.center,
- ),
- Container(
- margin: EdgeInsets.only(top: 25),
- child: Center(
- child: Text(
- '共$total笔',
- style: TextStyle(color: Colors.white, fontSize: 20),
- ),
- ),
- ),
- // Container(
- // height: 22,
- // child: Row(
- // children: [
- // Text(
- // '$total笔数',
- // style: TextStyle(color: Colors.white, fontSize: 14),
- // ),
- // // Visibility(
- // // visible: sTab == 0,
- // // child: GestureDetector(
- // // onTap: () {
- // // if (MyCookie().userBean.aliPayAccount.isEmpty) {
- // // MyTools().toPage(context, SetAlipayPage(),
- // // (then) {
- // // if (MyCookie()
- // // .userBean
- // // .aliPayAccount
- // // .isNotEmpty) {
- // // MyTools().toPage(context, WithdrawPage(),
- // // (then) {
- // // controller.requestRefresh();
- // // });
- // // }
- // // });
- // // } else {
- // // MyTools().toPage(context, WithdrawPage(),
- // // (then) {
- // // controller.requestRefresh();
- // // });
- // // }
- // // },
- // // behavior: HitTestBehavior.translucent,
- // // child: Container(
- // // decoration: BoxDecoration(
- // // color: MyColors.cFFCD00,
- // // borderRadius:
- // // BorderRadius.all(Radius.circular(15)),
- // // ),
- // // height: 30,
- // // width: 70,
- // // child: Text(
- // // '申请提现',
- // // style: TextStyle(
- // // color: Colors.white, fontSize: 13),
- // // ),
- // // alignment: Alignment.center,
- // // padding: EdgeInsets.only(bottom: 1),
- // // ),
- // // ),
- // // )
- // ],
- // mainAxisAlignment: MainAxisAlignment.spaceBetween,
- // ),
- // alignment: Alignment.centerLeft,
- // margin: EdgeInsets.only(top: 25, left: 15, right: 17),
- // ),
- // Container(
- // child: Text(
- // '¥${NumUtil.multiply(totalAmount, 1)}',
- // style: TextStyle(color: Colors.white, fontSize: 24),
- // ),
- // alignment: Alignment.center,
- // margin: EdgeInsets.only(top: 2),
- // ),
- ],
- )
- ],
- ),
- 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 = ['全部', '今天', '昨天', '本周', '上周', '本月'];
- List<String> 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<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 != -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() {
- getUserWalletBalance((re, hE) {
- if (!hE) {
- UserBalanceEntity balance =
- UserBalanceEntity().fromJson(json.decode(re.data.toString()));
- MyCookie().userBean.balance = balance.data;
- setState(() {});
- }
- }, (e) {}, context);
- var conditions = [
- "user_uid==${MyCookie().getUID()}",
- // "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 ${[
- flowTypeWithdraw
- ]}');
- break;
- case 4:
- conditions.add('type IN ${[
- flowTypePlatformFee
- ]}');
- break;
- }
- // conditions.add("type IN ${typeIndex == 1 ? [
- // flowTypeOrderCommodity,
- // flowTypeOrderAnnualFee,
- // flowTypeOrderVirtualProduct,
- // flowTypeOrderThirdPlatform,
- // flowTypeOrderOfflineTransfer,
- // flowTypeScancodeAilyPay
- // ] : [flowTypeShopCommission]}");
- }
- 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) {});
- }
- }
|