123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- import 'package:flutter/material.dart';
- import 'package:flutter_picker/flutter_picker.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
- import 'package:liftmanager/internal/wode/model/wallet_model.dart';
- import 'package:liftmanager/internal/wode/presenter/wallet_list_presenter.dart';
- import 'package:liftmanager/mvp/base_page_state.dart';
- import 'package:liftmanager/res/resources.dart';
- import 'package:liftmanager/utils/time_format.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/widgets/my_refresh_list.dart';
- import 'package:liftmanager/widgets/state_layout.dart';
- import 'package:provider/provider.dart';
- class SmallMoney extends StatefulWidget {
- // QuestionList(this.index);
- // final String index;
- @override
- SmallMoneyState createState() => SmallMoneyState();
- }
- class SmallMoneyState
- extends BasePageState<SmallMoney, WalletListPresenterSeconds>
- with AutomaticKeepAliveClientMixin {
- BaseListProvider<Records> provider = BaseListProvider<Records>();
- ScrollController _scrollController = new ScrollController();
- @override
- void initState() {
- provider.setStateTypeNotNotify(StateType.loading);
- super.initState();
- _onRefresh();
- print(66666);
- }
- @override
- void dispose() {
- _scrollController.dispose();
- super.dispose();
- }
- int currentYear;
- int currentMonth;
- String incomeStr = '0';
- String outcomeStr = '0';
- String currentDate = '全部';
- List<int> selecteds = [];
- getBusinessType(int type) {
- String str;
- if (type == 1) {
- str = "充值会员";
- } else if (type == 2) {
- str = "打赏";
- } else if (type == 3) {
- str = "充值";
- } else if (type == 4) {
- str = "诊单业务";
- } else if (type == 5) {
- str = "提现";
- } else if (type == 6) {
- str = "提现失败退款";
- } else if (type == 7) {
- str = "余额消费";
- } else if (type == 8) {
- str = "拒绝接单退款";
- }else if (type == 9) {
- str = "专家惩罚";
- }else if (type == 10) {
- str = "申诉退款";
- }else if (type == 11) {
- str = "粉丝充值返利";
- }else if (type == 12) {
- str = "现金支付";
- }else if (type == 13) {
- str = "差旅费";
- }
- return str;
- }
- void selectTimePeriod() {
- List pickerdata = [];
- int minYear = 2016;
- DateTime now = new DateTime.now();
- int maxYear = now.year;
- int lastMonth = now.month;
- print(lastMonth);
- for (int i = minYear; i <= maxYear; i++) {
- List<int> month = [];
- int monthLength = (i == maxYear) ? lastMonth : 12;
- for (int j = 1; j <= monthLength; j++) {
- month.add(j);
- }
- pickerdata.add({i.toString(): month});
- }
- new Picker(
- adapter: PickerDataAdapter<String>(
- pickerdata: pickerdata,
- ),
- selecteds: selecteds,
- changeToFirst: true,
- hideHeader: false,
- cancelText:"取消",
- confirmText:"确认",
- onConfirm: (Picker picker, List value) {
- print(picker.getSelectedValues());
- selecteds = value;
- currentYear = int.parse(picker.getSelectedValues()[0]);
- currentMonth = int.parse(picker.getSelectedValues()[1]);
- currentDate = picker.getSelectedValues()[0] +
- '年' +
- picker.getSelectedValues()[1] +
- '月';
- _onRefresh();
- setState(() {});
- },
- ).showModal(this.context);
- }
- int _page = 1;
- @override
- Widget build(BuildContext context) {
- double width = MediaQuery.of(context).size.width;
- return ChangeNotifierProvider<BaseListProvider<Records>>(
- create: (_) => provider,
- child: Scaffold(
- resizeToAvoidBottomPadding: true,
- appBar: MyAppBar(centerTitle: "零钱明细"),
- body: Container(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Container(
- width: width,
- height: 60,
- padding: EdgeInsets.only(
- left: ScreenUtil().setWidth(15),
- right: ScreenUtil().setWidth(15),
- ),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(width: 0.5, color: Colours.line),
- ),
- color: Color(0xffEFEFEF),
- ),
- // padding: EdgeInsets.only(left:15,right:15),
- // color: Color(0xFFF1F4FC),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- GestureDetector(
- onTap: () {
- selectTimePeriod();
- },
- child: ClipRRect(
- borderRadius: BorderRadius.circular(20),
- child: Container(
- // height: ,
- padding: EdgeInsets.only(
- left: 10, right: 3, top: 2, bottom: 2),
- color: Colors.white,
- child: Row(
- children: <Widget>[
- Text(
- currentDate,
- style: TextStyle(
- color: Color(0xff333333),
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.center,
- ),
- Container(
- padding: EdgeInsets.only(top: 3),
- child: Icon(
- Icons.keyboard_arrow_down,
- size: 20.0,
- ),
- )
- ],
- ),
- ),
- ),
- ),
- Container(
- padding: EdgeInsets.only(top: 10),
- child: Column(
- children: <Widget>[
- Row(children: <Widget>[
- Text(
- "支出:",
- style: TextStyle(
- color: Color(0xff333333),
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- Text(
- "¥" + outcomeStr,
- style: TextStyle(
- color: Color(0xff333333),
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- ]),
- Row(children: <Widget>[
- Text(
- "收入:",
- style: TextStyle(
- color: Color(0xff333333),
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- Text(
- "¥" + incomeStr,
- style: TextStyle(
- color: Color(0xff333333),
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- ]),
- ],
- ),
- ),
- ],
- ),
- ),
- Expanded(
- flex: 1,
- child: Consumer<BaseListProvider<Records>>(
- builder: (_, provider, __) {
- return MyListView(
- key: Key('wallet_list'),
- itemCount: provider.list.length,
- stateType: provider.stateType,
- onRefresh: _onRefresh,
- loadMore: _loadMore,
- pageSize: 8,
- hasMore: provider.hasMore,
- itemBuilder: (_, index) {
- return InkWell(
- child: Container(
- padding: EdgeInsets.only(
- left: ScreenUtil().setWidth(15),
- right: ScreenUtil().setWidth(15),
- top: ScreenUtil().setWidth(15),
- bottom: ScreenUtil().setWidth(15)),
- decoration: BoxDecoration(
- border: Border(
- bottom:
- BorderSide(width: 0.5, color: Colours.line),
- ),
- color: Colors.white,
- ),
- child: Column(
- // crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Container(
- padding: EdgeInsets.only(bottom: 5),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- getBusinessType(provider.list[index].businessType),
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(16),
- color: Color(0xff333333),
- ),
- ),
- Text(
- (provider.list[index].type == 1
- ? "-"
- : "+") +
- provider.list[index].amount
- .toString(),
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(16),
- color: Colors.red,
- ),
- ),
- ],
- ),
- ),
- Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- provider.list[index].descr ?? "",
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(13),
- color: Color(0xff999999),
- ),
- ),
- Text(
- DateUtils.instance.getFormartData(
- timeSamp:
- provider.list[index].createTime,
- format: "yyyy-MM-dd"),
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(13),
- color: Color(0xff999999),
- ),
- ),
- ],
- ),
- ],
- ),
- ),
- onTap: () {
- // print(i);
- // NavigatorUtils.push(context, BbsRouter.positionDetail);
- },
- );
- },
- );
- },
- ),
- )
- ],
- ),
- ),
- ),
- );
- }
- Future _onRefresh() async {
- _page = 1;
- await presenter.getWalletList(_page,
- currentYear: currentYear,
- currentMonth: currentMonth, complete: (income, outcome) {
- setState(() {
- incomeStr = income.toString();
- outcomeStr = outcome.toString();
- });
- });
- }
- Future _loadMore() async {
- _page++;
- await presenter.getWalletList(_page,
- currentYear: currentYear,
- currentMonth: currentMonth, complete: (income, outcome) {
- setState(() {
- incomeStr = income.toString();
- outcomeStr = outcome.toString();
- });
- });
- }
- @override
- WalletListPresenterSeconds createPresenter() {
- return WalletListPresenterSeconds();
- }
- bool get wantKeepAlive => true;
- }
|