diff --git a/lib/pages/life_pay/life_pay_page.dart b/lib/pages/life_pay/life_pay_page.dart index f5772db1..353a9501 100644 --- a/lib/pages/life_pay/life_pay_page.dart +++ b/lib/pages/life_pay/life_pay_page.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:akuCommunity/widget/others/bee_header_house.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -9,12 +10,10 @@ import 'package:velocity_x/velocity_x.dart'; // Project imports: import 'package:akuCommunity/base/base_style.dart'; -import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/life_pay_model.dart'; import 'package:akuCommunity/pages/life_pay/life_pay_record_page/life_pay_record_page.dart'; import 'package:akuCommunity/pages/life_pay/widget/life_pay_detail_page.dart'; -import 'package:akuCommunity/pages/life_pay/widget/my_house_page.dart'; import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/bee_parse.dart'; @@ -29,10 +28,10 @@ class LifePayPage extends StatefulWidget { _LifePayPageState createState() => _LifePayPageState(); } -class SelectList { - bool value; - List selected; - SelectList(); +class SelectPay { + double payTotal; + int payCount; + SelectPay(); } class _LifePayPageState extends State { @@ -40,7 +39,9 @@ class _LifePayPageState extends State { // List selectItems = []; List _selectYears = []; List _models = []; - + List _selectPay = []; + double _totalCost = 0; + int _count = 0; // int _getLength(LifePayModel model) { // int count = 0; // model.dailyPaymentTypeVos.forEach((element) { @@ -63,56 +64,56 @@ class _LifePayPageState extends State { super.dispose(); } - Widget _buildHouseCard( - String title, - String detail, - ) { - return Material( - color: kForeGroundColor, - child: Padding( - padding: EdgeInsets.all(32.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - '当前房屋'.text.black.size(28.sp).make(), - 32.w.heightBox, - GestureDetector( - onTap: () { - MyHousePage( - needFindPayTag: true, - ).to(); - }, - child: Row( - children: [ - Image.asset( - R.ASSETS_ICONS_HOUSE_PNG, - width: 60.w, - height: 60.w, - ), - 40.w.widthBox, - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - title.text.black.size(32.sp).bold.make(), - 10.w.heightBox, - detail.text.black.size(32.sp).bold.make() - ], - ), - ), - Icon( - CupertinoIcons.chevron_forward, - size: 40.w, - ), - ], - ).material(color: Colors.transparent), - ), - 24.w.heightBox, - ], - ), - ), - ); - } + // Widget _buildHouseCard( + // String title, + // String detail, + // ) { + // return Material( + // color: kForeGroundColor, + // child: Padding( + // padding: EdgeInsets.all(32.w), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // '当前房屋'.text.black.size(28.sp).make(), + // 32.w.heightBox, + // GestureDetector( + // onTap: () { + // MyHousePage( + // needFindPayTag: true, + // ).to(); + // }, + // child: Row( + // children: [ + // Image.asset( + // R.ASSETS_ICONS_HOUSE_PNG, + // width: 60.w, + // height: 60.w, + // ), + // 40.w.widthBox, + // Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // title.text.black.size(32.sp).bold.make(), + // 10.w.heightBox, + // detail.text.black.size(32.sp).bold.make() + // ], + // ), + // ), + // Icon( + // CupertinoIcons.chevron_forward, + // size: 40.w, + // ), + // ], + // ).material(color: Colors.transparent), + // ), + // 24.w.heightBox, + // ], + // ), + // ), + // ); + // } Widget _buildCard(LifePayModel model, int index) { return Container( @@ -153,8 +154,12 @@ class _LifePayPageState extends State { // setState(() {}); if (_selectYears.contains(index)) { _selectYears.remove(index); + _totalCost -= _selectPay[index].payTotal; + _count -= _selectPay[index].payCount; } else { _selectYears.add(index); + _totalCost += _selectPay[index].payTotal; + _count += _selectPay[index].payCount; } setState(() {}); }, @@ -225,10 +230,12 @@ class _LifePayPageState extends State { children: [ GestureDetector( onTap: () { - LifePayDetailPage( + List payMent = LifePayDetailPage( model: _models[index], // selectItems: selectItems[index].selected, ).to(); + _selectPay[index].payCount = payMent[0]; + _selectPay[index].payTotal = payMent[1]; }, child: Container( decoration: BoxDecoration( @@ -267,6 +274,9 @@ class _LifePayPageState extends State { body: BeeListView( path: API.manager.dailyPaymentList, controller: _controller, + extraParams: { + 'estateId': userProvider.currentHouseId, + }, convert: (model) { return model.tableList .map((e) => LifePayModel.fromJson(e)) @@ -276,12 +286,13 @@ class _LifePayPageState extends State { _models = items; return Column( children: [ - _buildHouseCard( - kEstateName, - userProvider.userDetailModel.estateNames.isEmpty - ? '' - : BeeParse.getEstateName( - userProvider.userDetailModel.estateNames[0])), + // _buildHouseCard( + // kEstateName, + // userProvider.userDetailModel.estateNames.isEmpty + // ? '' + // : BeeParse.getEstateName( + // userProvider.userDetailModel.estateNames[0])), + BeeHeaderHouse(), 16.w.heightBox, Container( padding: EdgeInsets.all(32.w), @@ -301,6 +312,7 @@ class _LifePayPageState extends State { ); }), bottomNavi: Container( + color: kForeGroundColor, padding: EdgeInsets.fromLTRB( 32.w, 16.w, 32.w, 12.w + MediaQuery.of(context).padding.bottom), child: Row( @@ -322,12 +334,20 @@ class _LifePayPageState extends State { onTap: () { if (_models.length == _selectYears.length) { _selectYears.clear(); + _totalCost = 0; + _count = 0; } else { for (var i = 0; i < _models.length; i++) { if (!_selectYears.contains(i)) { _selectYears.add(i); } } + _totalCost = 0; + _count = 0; + for (var item in _selectPay) { + _totalCost += item.payTotal; + _count += item.payCount; + } } setState(() {}); }, @@ -353,7 +373,7 @@ class _LifePayPageState extends State { color: Colors.white, ) : SizedBox(), - ), + ).material(color: Colors.transparent), ), Spacer(), Column( @@ -369,13 +389,13 @@ class _LifePayPageState extends State { fontWeight: FontWeight.bold), children: [ TextSpan( - text: '¥3009.84', + text: '$_totalCost', style: TextStyle( color: kDangerColor, fontSize: 32.sp, fontWeight: FontWeight.bold)), ])), - '已选10项'.text.color(ktextSubColor).size(20.sp).make(), + '$_count'.text.color(ktextSubColor).size(20.sp).make(), ], ), 24.w.widthBox, diff --git a/lib/pages/life_pay/widget/life_pay_detail_page.dart b/lib/pages/life_pay/widget/life_pay_detail_page.dart index a860ce5f..d2be2566 100644 --- a/lib/pages/life_pay/widget/life_pay_detail_page.dart +++ b/lib/pages/life_pay/widget/life_pay_detail_page.dart @@ -27,7 +27,9 @@ class LifePayDetailPage extends StatefulWidget { } class _LifePayDetailPageState extends State { - List _selectItems=[]; + List _selectItems = []; + double _payTotal = 0; + int _payNum = 0; int get listLength { int count = 0; widget.model.dailyPaymentTypeVos.forEach((element) { @@ -50,8 +52,12 @@ class _LifePayDetailPageState extends State { String item = id.toString() + groupId.toString(); if (_selectItems.contains(item)) { _selectItems.remove(item); + _payNum -= 1; + _payTotal -= price.toDouble(); } else { _selectItems.add(item); + _payNum += 1; + _payTotal += price.toDouble(); } setState(() {}); @@ -123,6 +129,8 @@ class _LifePayDetailPageState extends State { onTap: () { if (isAllSelect) { _selectItems.clear(); + _payNum = 0; + _payTotal = 0; } else { for (var i = 0; i < widget.model.dailyPaymentTypeVos.length; @@ -139,6 +147,9 @@ class _LifePayDetailPageState extends State { .toString(); if (!_selectItems.contains(id)) { _selectItems.add(id); + _payNum += 1; + _payTotal += widget.model.dailyPaymentTypeVos[i] + .detailedVoList[j].paymentPrice.toDouble(); } } } @@ -179,13 +190,13 @@ class _LifePayDetailPageState extends State { fontWeight: FontWeight.bold), children: [ TextSpan( - text: '¥3009.84', + text: '$_payTotal', style: TextStyle( color: kDangerColor, fontSize: 32.sp, fontWeight: FontWeight.bold)), ])), - '已选10项'.text.color(ktextSubColor).size(20.sp).make(), + '$_payNum'.text.color(ktextSubColor).size(20.sp).make(), ], ), MaterialButton( @@ -195,7 +206,7 @@ class _LifePayDetailPageState extends State { color: kPrimaryColor, padding: EdgeInsets.symmetric(horizontal: 50.w, vertical: 15.w), onPressed: () { - Get.back(); + Get.back(result: [_payNum, _payTotal]); }, child: '选好了'.text.black.size(32.sp).bold.make(), ), diff --git a/lib/pages/life_pay/widget/my_house_page.dart b/lib/pages/life_pay/widget/my_house_page.dart index 1f4b040a..03c19878 100644 --- a/lib/pages/life_pay/widget/my_house_page.dart +++ b/lib/pages/life_pay/widget/my_house_page.dart @@ -43,12 +43,11 @@ Widget _unPaidTag() { borderRadius: BorderRadius.circular(36.w), color: Color(0xFFFFEBE8), border: Border.all(width: 2.w, color: Color(0xFFFC361D))), - child: '当前房屋'.text.color(Color(0xFFFC361D)).size(20.sp).make(), + child: '未缴费'.text.color(Color(0xFFFC361D)).size(20.sp).make(), ); } class _MyHousePageState extends State { - int _select; List _list = []; List get _unPaidList => _list.where((element) => element.status == 1).toList(); @@ -65,18 +64,19 @@ class _MyHousePageState extends State { Widget _buildCard(String currentHouse, String estateName, int index, {bool paid = false}) { + UserProvider userProvider = Provider.of(context); return Container( padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 32.w), child: GestureDetector( onTap: () { - _select = index; + userProvider.setCurrentHouse(estateName); setState(() {}); }, child: Row( children: [ CommonRadio( - value: index, - groupValue: _select, + value: BeeParse.getEstateNameId(estateName), + groupValue: userProvider.currentHouseId, size: 32.w, ), 24.w.widthBox, @@ -113,13 +113,16 @@ class _MyHousePageState extends State { title: '我的房屋', body: ListView( children: [ - ...userProvider.userDetailModel.estateNames - .map((e) => _buildCard(userProvider.currentHouse, e, - userProvider.userDetailModel.estateNames.indexOf(e), - paid: widget.needFindPayTag - ? false - : _unPaidList.one((element) => element.roomName == e))) - .toList(), + ...userProvider.userDetailModel.estateNames.isEmpty + ? [SizedBox()] + : userProvider.userDetailModel.estateNames + .map((e) => _buildCard(userProvider.currentHouse, e, + userProvider.userDetailModel.estateNames.indexOf(e), + paid: widget.needFindPayTag + ? false + : _unPaidList + .one((element) => element.roomName == e))) + .toList(), ].sepWidget(separate: BeeDivider.horizontal()), ), ); diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index 8c62292d..30d8b4c7 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -2,6 +2,7 @@ import 'dart:io'; // Flutter imports: +import 'package:akuCommunity/widget/others/bee_header_house.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index a255ba2a..94710100 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:akuCommunity/utils/bee_parse.dart'; import 'package:flutter/material.dart'; // Package imports: @@ -139,6 +140,7 @@ class UserProvider extends ChangeNotifier { ///设置默认房屋 String _currentHouse; + int get currentHouseId => BeeParse.getEstateNameId(_currentHouse); String get currentHouse => _currentHouse; setCurrentHouse(String house) { _currentHouse = house; diff --git a/lib/utils/bee_parse.dart b/lib/utils/bee_parse.dart index 46c0bac4..d0f11592 100644 --- a/lib/utils/bee_parse.dart +++ b/lib/utils/bee_parse.dart @@ -1,11 +1,20 @@ class BeeParse { static int getEstateNameId(String estateName) { - int a = int.parse(estateName.split('|')[0]); - return a; + if (estateName.isEmpty) { + return -1; + } else { + int a = int.parse(estateName.split('|')[0]); + + return a; + } } static String getEstateName(String estateNmae) { - return estateNmae.split('|')[1]; + if (estateNmae.isEmpty) { + return ''; + } else { + return estateNmae.split('|')[1]; + } } static String getCustomYears(int year) { diff --git a/lib/widget/others/bee_header_house.dart b/lib/widget/others/bee_header_house.dart new file mode 100644 index 00000000..3351b7ed --- /dev/null +++ b/lib/widget/others/bee_header_house.dart @@ -0,0 +1,75 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/pages/life_pay/widget/my_house_page.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; +import 'package:akuCommunity/utils/bee_parse.dart'; +import 'package:akuCommunity/widget/bee_divider.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:velocity_x/velocity_x.dart'; +import 'package:akuCommunity/utils/headers.dart'; + +class BeeHeaderHouse extends StatefulWidget { + BeeHeaderHouse({Key key}) : super(key: key); + + @override + _BeeHeaderHouseState createState() => _BeeHeaderHouseState(); +} + +class _BeeHeaderHouseState extends State { + @override + Widget build(BuildContext context) { + UserProvider userProvider = Provider.of(context); + return Material( + color: Colors.transparent, + child: Padding( + padding: EdgeInsets.all(32.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '当前房屋'.text.black.size(28.sp).make(), + 32.w.heightBox, + GestureDetector( + onTap: () { + MyHousePage( + needFindPayTag: true, + ).to(); + }, + child: Row( + children: [ + Image.asset( + R.ASSETS_ICONS_HOUSE_PNG, + width: 60.w, + height: 60.w, + ), + 40.w.widthBox, + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + kEstateName.text.black.size(32.sp).bold.make(), + 10.w.heightBox, + BeeParse.getEstateName(userProvider.currentHouse) + .text + .black + .size(32.sp) + .bold + .make() + ], + ), + ), + Icon( + CupertinoIcons.chevron_forward, + size: 40.w, + ), + ], + ).material(color: Colors.transparent), + ), + 24.w.heightBox, + BeeDivider.horizontal() + ], + ), + ), + ); + } +}