From 46148c57ccf3712f18147470eae5e07b6e43af2e Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Tue, 9 Feb 2021 11:19:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=94=9F=E6=B4=BB=E7=BC=B4?= =?UTF-8?q?=E8=B4=B9=E7=95=8C=E9=9D=A2=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=94=9F?= =?UTF-8?q?=E6=B4=BB=E7=BC=B4=E8=B4=B9=E9=80=89=E6=8B=A9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/model/manager/life_pay_model.dart | 8 +- .../deto_create_page/deto_create_page.dart | 2 +- lib/pages/life_pay/life_pay_page.dart | 227 ++++++------------ .../life_pay/widget/life_pay_detail_page.dart | 96 ++++---- lib/pages/life_pay/widget/my_house_page.dart | 6 +- lib/provider/user_provider.dart | 2 +- lib/widget/buttons/bee_check_radio.dart | 7 +- lib/widget/others/bee_header_house.dart | 2 +- 8 files changed, 145 insertions(+), 205 deletions(-) diff --git a/lib/model/manager/life_pay_model.dart b/lib/model/manager/life_pay_model.dart index b502df97..1704bc8f 100644 --- a/lib/model/manager/life_pay_model.dart +++ b/lib/model/manager/life_pay_model.dart @@ -60,7 +60,7 @@ class DailyPaymentTypeVos { class DetailedVoList { int groupId; - int paymentPrice; + double paymentPrice; List detailsVoList; DetailedVoList({this.groupId, this.paymentPrice, this.detailsVoList}); @@ -91,9 +91,9 @@ class DetailedVoList { class DetailsVoList { int id; String month; - int costPrice; - int paidPrice; - int totalPrice; + double costPrice; + double paidPrice; + double totalPrice; String beginDate; String endDate; String unitPriceType; diff --git a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart index bd49cd57..ac5d0107 100644 --- a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart +++ b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart @@ -119,7 +119,7 @@ class _DetoCreatePageState extends State { ), SizedBox(height: 10.w), Text( - BeeParse.getEstateName(subtitle), + subtitle, style: TextStyle( fontWeight: FontWeight.w600, fontSize: 32.sp, diff --git a/lib/pages/life_pay/life_pay_page.dart b/lib/pages/life_pay/life_pay_page.dart index 353a9501..6841aeee 100644 --- a/lib/pages/life_pay/life_pay_page.dart +++ b/lib/pages/life_pay/life_pay_page.dart @@ -1,4 +1,6 @@ // Flutter imports: +import 'package:akuCommunity/pages/life_pay/widget/my_house_page.dart'; +import 'package:akuCommunity/widget/bee_divider.dart'; import 'package:akuCommunity/widget/others/bee_header_house.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -31,27 +33,16 @@ class LifePayPage extends StatefulWidget { class SelectPay { double payTotal; int payCount; - SelectPay(); + SelectPay({this.payCount, this.payTotal}); } class _LifePayPageState extends State { EasyRefreshController _controller; - // 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) { - // element.detailedVoList.forEach((element) { - // count++; - // }); - // }); - // return count; - // } - @override void initState() { super.initState(); @@ -64,59 +55,61 @@ 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() { + UserProvider userProvider = Provider.of(context); + 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: [ + kEstateName.text.black.size(32.sp).bold.make(), + 10.w.heightBox, + userProvider.currentHouse.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( + padding: EdgeInsets.symmetric(vertical: 20.w), decoration: BoxDecoration( borderRadius: BorderRadius.circular(8.w), color: kForeGroundColor), child: Row( @@ -127,70 +120,26 @@ class _LifePayPageState extends State { children: [ GestureDetector( onTap: () { - // if (selectItems[index].selected.length == - // _getLength(model)) { - // selectItems[index].value = false; - // selectItems[index].selected.clear(); - // _selectYears.remove(index); - // } else { - // selectItems[index].value = true; - // _selectYears.add(index); - // for (var i = 0; i < model.dailyPaymentTypeVos.length; i++) { - // for (var j = 0; - // i < - // model - // .dailyPaymentTypeVos[i].detailedVoList.length; - // i++) { - // String id = model.dailyPaymentTypeVos[i].id.toString() + - // model.dailyPaymentTypeVos[i].detailedVoList[j] - // .groupId - // .toString(); - // if (!selectItems[index].selected.contains(id)) { - // selectItems[index].selected.add(id); - // } - // } - // } - // } - // 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(() {}); + setState(() { + if (_selectYears.contains(index)) { + _selectYears.remove(index); + _totalCost -= (_selectPay[index].payTotal ?? 0.0); + _count -= (_selectPay[index].payCount ?? 0); + } else { + _selectYears.add(index); + _totalCost += (_selectPay[index].payTotal ?? 0.0); + _count += (_selectPay[index].payCount ?? 0); + } + }); }, child: BeeCheckRadio( value: index, groupValue: _selectYears, - // onChange: (value) { - // if (value) { - // selectItems[index].value=false; - // selectItems[index].selected.clear(); - // } else { - // selectItems[index].value=true; - // for (var i = 0; i < model.dailyPaymentTypeVos.length; i++) { - // for (var j = 0; - // i < - // model - // .dailyPaymentTypeVos[i].detailedVoList.length; - // i++) { - // selectItems[index].selected.add( - // model.dailyPaymentTypeVos[i].id.toString() + - // model.dailyPaymentTypeVos[i].detailedVoList[j] - // .groupId - // .toString()); - // } - // } - // } - // }, ), ), ], ), + 24.w.widthBox, Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -201,7 +150,7 @@ class _LifePayPageState extends State { .size(28.sp) .make(), 24.w.heightBox, - '待缴:${model.paymentNum}项' + '待缴:${model.paymentNum}项 已选${_selectPay[index].payCount}项' .text .color(ktextPrimary) .size(28.sp) @@ -216,26 +165,26 @@ class _LifePayPageState extends State { fontWeight: FontWeight.bold), children: [ TextSpan( - text: '¥', + text: '¥ ${_selectPay[index].payTotal}', style: TextStyle( color: kDangerColor, fontSize: 28.sp, fontWeight: FontWeight.bold)), ])) ], - ), + ).expand(), Column( - mainAxisSize: MainAxisSize.min, + mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, children: [ GestureDetector( - onTap: () { - List payMent = LifePayDetailPage( + onTap: () async { + List payMent = await LifePayDetailPage( model: _models[index], - // selectItems: selectItems[index].selected, ).to(); _selectPay[index].payCount = payMent[0]; _selectPay[index].payTotal = payMent[1]; + setState(() {}); }, child: Container( decoration: BoxDecoration( @@ -278,6 +227,8 @@ class _LifePayPageState extends State { 'estateId': userProvider.currentHouseId, }, convert: (model) { + _selectPay = List.generate(model.tableList.length, + (index) => SelectPay(payCount: 0, payTotal: 0.0)); return model.tableList .map((e) => LifePayModel.fromJson(e)) .toList(); @@ -286,13 +237,7 @@ class _LifePayPageState extends State { _models = items; return Column( children: [ - // _buildHouseCard( - // kEstateName, - // userProvider.userDetailModel.estateNames.isEmpty - // ? '' - // : BeeParse.getEstateName( - // userProvider.userDetailModel.estateNames[0])), - BeeHeaderHouse(), + _buildHouseCard(), 16.w.heightBox, Container( padding: EdgeInsets.all(32.w), @@ -304,7 +249,8 @@ class _LifePayPageState extends State { children: [ '缴费账单'.text.color(ktextPrimary).size(28.sp).make(), ...List.generate(items.length, - (index) => _buildCard(items[index], index)), + (index) => _buildCard(items[index], index)) + .sepWidget(separate: BeeDivider.horizontal()), ], ), ), @@ -317,19 +263,6 @@ class _LifePayPageState extends State { 32.w, 16.w, 32.w, 12.w + MediaQuery.of(context).padding.bottom), child: Row( children: [ - // BeeCheckBox.round( - // onChange: (value) { - // if (value) { - // _selectYears.clear(); - // } else { - // for (var i = 0; i < _models.length; i++) { - // _selectYears.add(i); - // } - // } - // setState(() {}); - // }, - // size: 40.w, - // ), GestureDetector( onTap: () { if (_models.length == _selectYears.length) { @@ -395,7 +328,7 @@ class _LifePayPageState extends State { fontSize: 32.sp, fontWeight: FontWeight.bold)), ])), - '$_count'.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 d2be2566..1321005c 100644 --- a/lib/pages/life_pay/widget/life_pay_detail_page.dart +++ b/lib/pages/life_pay/widget/life_pay_detail_page.dart @@ -44,11 +44,9 @@ class _LifePayDetailPageState extends State { return listLength == _selectItems.length; } - Widget _buildTile(int groupId, int id, int years, int price) { - return Row( - children: [ - GestureDetector( - onTap: () { + Widget _buildTile(int groupId, int id, int years, double price) { + return GestureDetector( + onTap: () { String item = id.toString() + groupId.toString(); if (_selectItems.contains(item)) { _selectItems.remove(item); @@ -62,21 +60,25 @@ class _LifePayDetailPageState extends State { setState(() {}); }, - child: BeeCheckRadio( - value: id.toString() + groupId.toString(), - groupValue: _selectItems)), - 24.w.widthBox, - groupId == 1 - ? '$years上半年'.text.black.size(28.sp).make() - : '$years下半年'.text.black.size(28.sp).make(), - Spacer(), - '¥${price.toString()}'.text.color(kDangerColor).size(28.sp).bold.make(), - 24.w.widthBox, - Icon( - CupertinoIcons.chevron_forward, - size: 40.w, - ), - ], + child: Row( + children: [ + + BeeCheckRadio( + value: id.toString() + groupId.toString(), + groupValue: _selectItems), + 24.w.widthBox, + groupId == 1 + ? '$years上半年'.text.black.size(28.sp).make() + : '$years下半年'.text.black.size(28.sp).make(), + Spacer(), + '¥${price.toString()}'.text.color(kDangerColor).size(28.sp).bold.make(), + 24.w.widthBox, + Icon( + CupertinoIcons.chevron_forward, + size: 40.w, + ), + ], + ).material(color: Colors.transparent), ); } @@ -90,7 +92,7 @@ class _LifePayDetailPageState extends State { children: [ model.name.text.black.size(30.sp).bold.make(), Spacer(), - '$kEstateName ${BeeParse.getEstateName(userProvider.currentHouse)}' + '$kEstateName ${userProvider.currentHouse}' .text .color(ktextSubColor) .size(24.sp) @@ -127,34 +129,36 @@ class _LifePayDetailPageState extends State { children: [ GestureDetector( onTap: () { - if (isAllSelect) { - _selectItems.clear(); - _payNum = 0; - _payTotal = 0; - } else { - for (var i = 0; - i < widget.model.dailyPaymentTypeVos.length; - i++) { - for (var j = 0; - i < - widget.model.dailyPaymentTypeVos[i].detailedVoList - .length; + setState(() { + if (isAllSelect) { + _selectItems.clear(); + _payNum = 0; + _payTotal = 0; + } else { + for (var i = 0; + i < widget.model.dailyPaymentTypeVos.length; i++) { - String id = - widget.model.dailyPaymentTypeVos[i].id.toString() + - widget.model.dailyPaymentTypeVos[i] - .detailedVoList[j].groupId - .toString(); - if (!_selectItems.contains(id)) { - _selectItems.add(id); - _payNum += 1; - _payTotal += widget.model.dailyPaymentTypeVos[i] - .detailedVoList[j].paymentPrice.toDouble(); + for (var j = 0; + i < + widget.model.dailyPaymentTypeVos[i].detailedVoList + .length; + i++) { + String id = + widget.model.dailyPaymentTypeVos[i].id.toString() + + widget.model.dailyPaymentTypeVos[i] + .detailedVoList[j].groupId + .toString(); + if (!_selectItems.contains(id)) { + _selectItems.add(id); + _payNum += 1; + _payTotal += widget.model.dailyPaymentTypeVos[i] + .detailedVoList[j].paymentPrice + .toDouble(); + } } } } - } - setState(() {}); + }); }, child: AnimatedContainer( duration: Duration(milliseconds: 300), @@ -196,7 +200,7 @@ class _LifePayDetailPageState extends State { fontSize: 32.sp, fontWeight: FontWeight.bold)), ])), - '$_payNum'.text.color(ktextSubColor).size(20.sp).make(), + '已选$_payNum项'.text.color(ktextSubColor).size(20.sp).make(), ], ), MaterialButton( diff --git a/lib/pages/life_pay/widget/my_house_page.dart b/lib/pages/life_pay/widget/my_house_page.dart index 03c19878..00308863 100644 --- a/lib/pages/life_pay/widget/my_house_page.dart +++ b/lib/pages/life_pay/widget/my_house_page.dart @@ -62,7 +62,7 @@ class _MyHousePageState extends State { } } - Widget _buildCard(String currentHouse, String estateName, int index, + Widget _buildCard(int currentHouseId, String estateName, int index, {bool paid = false}) { UserProvider userProvider = Provider.of(context); return Container( @@ -95,7 +95,7 @@ class _MyHousePageState extends State { ], ), Spacer(), - currentHouse == estateName + currentHouseId == BeeParse.getEstateNameId(estateName) ? _currentHouseTag() : paid ? _unPaidTag() @@ -116,7 +116,7 @@ class _MyHousePageState extends State { ...userProvider.userDetailModel.estateNames.isEmpty ? [SizedBox()] : userProvider.userDetailModel.estateNames - .map((e) => _buildCard(userProvider.currentHouse, e, + .map((e) => _buildCard(userProvider.currentHouseId, e, userProvider.userDetailModel.estateNames.indexOf(e), paid: widget.needFindPayTag ? false diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 94710100..a7aa3f79 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -141,7 +141,7 @@ class UserProvider extends ChangeNotifier { ///设置默认房屋 String _currentHouse; int get currentHouseId => BeeParse.getEstateNameId(_currentHouse); - String get currentHouse => _currentHouse; + String get currentHouse => BeeParse.getEstateName(_currentHouse); setCurrentHouse(String house) { _currentHouse = house; notifyListeners(); diff --git a/lib/widget/buttons/bee_check_radio.dart b/lib/widget/buttons/bee_check_radio.dart index 2400c283..4a04d322 100644 --- a/lib/widget/buttons/bee_check_radio.dart +++ b/lib/widget/buttons/bee_check_radio.dart @@ -17,8 +17,11 @@ class BeeCheckRadio extends StatefulWidget { class _BeeCheckRadioState extends State { bool get _selected { - if (widget.groupValue.contains(widget.value)) return true; - return false; + if (widget.groupValue.contains(widget.value)) { + return true; + } else { + return false; + } } @override diff --git a/lib/widget/others/bee_header_house.dart b/lib/widget/others/bee_header_house.dart index 3351b7ed..87510915 100644 --- a/lib/widget/others/bee_header_house.dart +++ b/lib/widget/others/bee_header_house.dart @@ -49,7 +49,7 @@ class _BeeHeaderHouseState extends State { children: [ kEstateName.text.black.size(32.sp).bold.make(), 10.w.heightBox, - BeeParse.getEstateName(userProvider.currentHouse) + userProvider.currentHouse .text .black .size(32.sp)