Merge branch 'master' of 192.168.2.201:laiiihz/akuCommunity

* 'master' of 192.168.2.201:laiiihz/akuCommunity:
  调整设置我的房屋逻辑, 调整当前房屋组件, 重写生活缴费费用计算逻辑
hmxc
小赖 4 years ago
commit 706b5e6804

@ -1,4 +1,5 @@
// Flutter imports: // Flutter imports:
import 'package:akuCommunity/widget/others/bee_header_house.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -9,12 +10,10 @@ import 'package:velocity_x/velocity_x.dart';
// Project imports: // Project imports:
import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/manager/life_pay_model.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/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/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/pages/things_page/widget/bee_list_view.dart';
import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/utils/bee_parse.dart'; import 'package:akuCommunity/utils/bee_parse.dart';
@ -29,10 +28,10 @@ class LifePayPage extends StatefulWidget {
_LifePayPageState createState() => _LifePayPageState(); _LifePayPageState createState() => _LifePayPageState();
} }
class SelectList { class SelectPay {
bool value; double payTotal;
List<String> selected; int payCount;
SelectList(); SelectPay();
} }
class _LifePayPageState extends State<LifePayPage> { class _LifePayPageState extends State<LifePayPage> {
@ -40,7 +39,9 @@ class _LifePayPageState extends State<LifePayPage> {
// List<SelectList> selectItems = []; // List<SelectList> selectItems = [];
List<int> _selectYears = []; List<int> _selectYears = [];
List<LifePayModel> _models = []; List<LifePayModel> _models = [];
List<SelectPay> _selectPay = [];
double _totalCost = 0;
int _count = 0;
// int _getLength(LifePayModel model) { // int _getLength(LifePayModel model) {
// int count = 0; // int count = 0;
// model.dailyPaymentTypeVos.forEach((element) { // model.dailyPaymentTypeVos.forEach((element) {
@ -63,56 +64,56 @@ class _LifePayPageState extends State<LifePayPage> {
super.dispose(); super.dispose();
} }
Widget _buildHouseCard( // Widget _buildHouseCard(
String title, // String title,
String detail, // String detail,
) { // ) {
return Material( // return Material(
color: kForeGroundColor, // color: kForeGroundColor,
child: Padding( // child: Padding(
padding: EdgeInsets.all(32.w), // padding: EdgeInsets.all(32.w),
child: Column( // child: Column(
crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
children: [ // children: [
'当前房屋'.text.black.size(28.sp).make(), // '当前房屋'.text.black.size(28.sp).make(),
32.w.heightBox, // 32.w.heightBox,
GestureDetector( // GestureDetector(
onTap: () { // onTap: () {
MyHousePage( // MyHousePage(
needFindPayTag: true, // needFindPayTag: true,
).to(); // ).to();
}, // },
child: Row( // child: Row(
children: [ // children: [
Image.asset( // Image.asset(
R.ASSETS_ICONS_HOUSE_PNG, // R.ASSETS_ICONS_HOUSE_PNG,
width: 60.w, // width: 60.w,
height: 60.w, // height: 60.w,
), // ),
40.w.widthBox, // 40.w.widthBox,
Expanded( // Expanded(
child: Column( // child: Column(
crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
children: [ // children: [
title.text.black.size(32.sp).bold.make(), // title.text.black.size(32.sp).bold.make(),
10.w.heightBox, // 10.w.heightBox,
detail.text.black.size(32.sp).bold.make() // detail.text.black.size(32.sp).bold.make()
], // ],
), // ),
), // ),
Icon( // Icon(
CupertinoIcons.chevron_forward, // CupertinoIcons.chevron_forward,
size: 40.w, // size: 40.w,
), // ),
], // ],
).material(color: Colors.transparent), // ).material(color: Colors.transparent),
), // ),
24.w.heightBox, // 24.w.heightBox,
], // ],
), // ),
), // ),
); // );
} // }
Widget _buildCard(LifePayModel model, int index) { Widget _buildCard(LifePayModel model, int index) {
return Container( return Container(
@ -153,8 +154,12 @@ class _LifePayPageState extends State<LifePayPage> {
// setState(() {}); // setState(() {});
if (_selectYears.contains(index)) { if (_selectYears.contains(index)) {
_selectYears.remove(index); _selectYears.remove(index);
_totalCost -= _selectPay[index].payTotal;
_count -= _selectPay[index].payCount;
} else { } else {
_selectYears.add(index); _selectYears.add(index);
_totalCost += _selectPay[index].payTotal;
_count += _selectPay[index].payCount;
} }
setState(() {}); setState(() {});
}, },
@ -225,10 +230,12 @@ class _LifePayPageState extends State<LifePayPage> {
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
LifePayDetailPage( List payMent = LifePayDetailPage(
model: _models[index], model: _models[index],
// selectItems: selectItems[index].selected, // selectItems: selectItems[index].selected,
).to(); ).to();
_selectPay[index].payCount = payMent[0];
_selectPay[index].payTotal = payMent[1];
}, },
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@ -267,6 +274,9 @@ class _LifePayPageState extends State<LifePayPage> {
body: BeeListView( body: BeeListView(
path: API.manager.dailyPaymentList, path: API.manager.dailyPaymentList,
controller: _controller, controller: _controller,
extraParams: {
'estateId': userProvider.currentHouseId,
},
convert: (model) { convert: (model) {
return model.tableList return model.tableList
.map((e) => LifePayModel.fromJson(e)) .map((e) => LifePayModel.fromJson(e))
@ -276,12 +286,13 @@ class _LifePayPageState extends State<LifePayPage> {
_models = items; _models = items;
return Column( return Column(
children: [ children: [
_buildHouseCard( // _buildHouseCard(
kEstateName, // kEstateName,
userProvider.userDetailModel.estateNames.isEmpty // userProvider.userDetailModel.estateNames.isEmpty
? '' // ? ''
: BeeParse.getEstateName( // : BeeParse.getEstateName(
userProvider.userDetailModel.estateNames[0])), // userProvider.userDetailModel.estateNames[0])),
BeeHeaderHouse(),
16.w.heightBox, 16.w.heightBox,
Container( Container(
padding: EdgeInsets.all(32.w), padding: EdgeInsets.all(32.w),
@ -301,6 +312,7 @@ class _LifePayPageState extends State<LifePayPage> {
); );
}), }),
bottomNavi: Container( bottomNavi: Container(
color: kForeGroundColor,
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(
32.w, 16.w, 32.w, 12.w + MediaQuery.of(context).padding.bottom), 32.w, 16.w, 32.w, 12.w + MediaQuery.of(context).padding.bottom),
child: Row( child: Row(
@ -322,12 +334,20 @@ class _LifePayPageState extends State<LifePayPage> {
onTap: () { onTap: () {
if (_models.length == _selectYears.length) { if (_models.length == _selectYears.length) {
_selectYears.clear(); _selectYears.clear();
_totalCost = 0;
_count = 0;
} else { } else {
for (var i = 0; i < _models.length; i++) { for (var i = 0; i < _models.length; i++) {
if (!_selectYears.contains(i)) { if (!_selectYears.contains(i)) {
_selectYears.add(i); _selectYears.add(i);
} }
} }
_totalCost = 0;
_count = 0;
for (var item in _selectPay) {
_totalCost += item.payTotal;
_count += item.payCount;
}
} }
setState(() {}); setState(() {});
}, },
@ -353,7 +373,7 @@ class _LifePayPageState extends State<LifePayPage> {
color: Colors.white, color: Colors.white,
) )
: SizedBox(), : SizedBox(),
), ).material(color: Colors.transparent),
), ),
Spacer(), Spacer(),
Column( Column(
@ -369,13 +389,13 @@ class _LifePayPageState extends State<LifePayPage> {
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
children: [ children: [
TextSpan( TextSpan(
text: '¥3009.84', text: '$_totalCost',
style: TextStyle( style: TextStyle(
color: kDangerColor, color: kDangerColor,
fontSize: 32.sp, fontSize: 32.sp,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold)),
])), ])),
'已选10项'.text.color(ktextSubColor).size(20.sp).make(), '$_count'.text.color(ktextSubColor).size(20.sp).make(),
], ],
), ),
24.w.widthBox, 24.w.widthBox,

@ -27,7 +27,9 @@ class LifePayDetailPage extends StatefulWidget {
} }
class _LifePayDetailPageState extends State<LifePayDetailPage> { class _LifePayDetailPageState extends State<LifePayDetailPage> {
List<String> _selectItems=[]; List<String> _selectItems = [];
double _payTotal = 0;
int _payNum = 0;
int get listLength { int get listLength {
int count = 0; int count = 0;
widget.model.dailyPaymentTypeVos.forEach((element) { widget.model.dailyPaymentTypeVos.forEach((element) {
@ -50,8 +52,12 @@ class _LifePayDetailPageState extends State<LifePayDetailPage> {
String item = id.toString() + groupId.toString(); String item = id.toString() + groupId.toString();
if (_selectItems.contains(item)) { if (_selectItems.contains(item)) {
_selectItems.remove(item); _selectItems.remove(item);
_payNum -= 1;
_payTotal -= price.toDouble();
} else { } else {
_selectItems.add(item); _selectItems.add(item);
_payNum += 1;
_payTotal += price.toDouble();
} }
setState(() {}); setState(() {});
@ -123,6 +129,8 @@ class _LifePayDetailPageState extends State<LifePayDetailPage> {
onTap: () { onTap: () {
if (isAllSelect) { if (isAllSelect) {
_selectItems.clear(); _selectItems.clear();
_payNum = 0;
_payTotal = 0;
} else { } else {
for (var i = 0; for (var i = 0;
i < widget.model.dailyPaymentTypeVos.length; i < widget.model.dailyPaymentTypeVos.length;
@ -139,6 +147,9 @@ class _LifePayDetailPageState extends State<LifePayDetailPage> {
.toString(); .toString();
if (!_selectItems.contains(id)) { if (!_selectItems.contains(id)) {
_selectItems.add(id); _selectItems.add(id);
_payNum += 1;
_payTotal += widget.model.dailyPaymentTypeVos[i]
.detailedVoList[j].paymentPrice.toDouble();
} }
} }
} }
@ -179,13 +190,13 @@ class _LifePayDetailPageState extends State<LifePayDetailPage> {
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
children: [ children: [
TextSpan( TextSpan(
text: '¥3009.84', text: '$_payTotal',
style: TextStyle( style: TextStyle(
color: kDangerColor, color: kDangerColor,
fontSize: 32.sp, fontSize: 32.sp,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold)),
])), ])),
'已选10项'.text.color(ktextSubColor).size(20.sp).make(), '$_payNum'.text.color(ktextSubColor).size(20.sp).make(),
], ],
), ),
MaterialButton( MaterialButton(
@ -195,7 +206,7 @@ class _LifePayDetailPageState extends State<LifePayDetailPage> {
color: kPrimaryColor, color: kPrimaryColor,
padding: EdgeInsets.symmetric(horizontal: 50.w, vertical: 15.w), padding: EdgeInsets.symmetric(horizontal: 50.w, vertical: 15.w),
onPressed: () { onPressed: () {
Get.back(); Get.back(result: [_payNum, _payTotal]);
}, },
child: '选好了'.text.black.size(32.sp).bold.make(), child: '选好了'.text.black.size(32.sp).bold.make(),
), ),

@ -43,12 +43,11 @@ Widget _unPaidTag() {
borderRadius: BorderRadius.circular(36.w), borderRadius: BorderRadius.circular(36.w),
color: Color(0xFFFFEBE8), color: Color(0xFFFFEBE8),
border: Border.all(width: 2.w, color: Color(0xFFFC361D))), 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<MyHousePage> { class _MyHousePageState extends State<MyHousePage> {
int _select;
List<EstatePaymentModel> _list = []; List<EstatePaymentModel> _list = [];
List<EstatePaymentModel> get _unPaidList => List<EstatePaymentModel> get _unPaidList =>
_list.where((element) => element.status == 1).toList(); _list.where((element) => element.status == 1).toList();
@ -65,18 +64,19 @@ class _MyHousePageState extends State<MyHousePage> {
Widget _buildCard(String currentHouse, String estateName, int index, Widget _buildCard(String currentHouse, String estateName, int index,
{bool paid = false}) { {bool paid = false}) {
UserProvider userProvider = Provider.of<UserProvider>(context);
return Container( return Container(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 32.w), padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 32.w),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
_select = index; userProvider.setCurrentHouse(estateName);
setState(() {}); setState(() {});
}, },
child: Row( child: Row(
children: [ children: [
CommonRadio( CommonRadio(
value: index, value: BeeParse.getEstateNameId(estateName),
groupValue: _select, groupValue: userProvider.currentHouseId,
size: 32.w, size: 32.w,
), ),
24.w.widthBox, 24.w.widthBox,
@ -113,12 +113,15 @@ class _MyHousePageState extends State<MyHousePage> {
title: '我的房屋', title: '我的房屋',
body: ListView( body: ListView(
children: <Widget>[ children: <Widget>[
...userProvider.userDetailModel.estateNames ...userProvider.userDetailModel.estateNames.isEmpty
? [SizedBox()]
: userProvider.userDetailModel.estateNames
.map((e) => _buildCard(userProvider.currentHouse, e, .map((e) => _buildCard(userProvider.currentHouse, e,
userProvider.userDetailModel.estateNames.indexOf(e), userProvider.userDetailModel.estateNames.indexOf(e),
paid: widget.needFindPayTag paid: widget.needFindPayTag
? false ? false
: _unPaidList.one((element) => element.roomName == e))) : _unPaidList
.one((element) => element.roomName == e)))
.toList(), .toList(),
].sepWidget(separate: BeeDivider.horizontal()), ].sepWidget(separate: BeeDivider.horizontal()),
), ),

@ -2,6 +2,7 @@
import 'dart:io'; import 'dart:io';
// Flutter imports: // Flutter imports:
import 'package:akuCommunity/widget/others/bee_header_house.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';

@ -1,4 +1,5 @@
// Flutter imports: // Flutter imports:
import 'package:akuCommunity/utils/bee_parse.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
@ -139,6 +140,7 @@ class UserProvider extends ChangeNotifier {
/// ///
String _currentHouse; String _currentHouse;
int get currentHouseId => BeeParse.getEstateNameId(_currentHouse);
String get currentHouse => _currentHouse; String get currentHouse => _currentHouse;
setCurrentHouse(String house) { setCurrentHouse(String house) {
_currentHouse = house; _currentHouse = house;

@ -1,12 +1,21 @@
class BeeParse { class BeeParse {
static int getEstateNameId(String estateName) { static int getEstateNameId(String estateName) {
if (estateName.isEmpty) {
return -1;
} else {
int a = int.parse(estateName.split('|')[0]); int a = int.parse(estateName.split('|')[0]);
return a; return a;
} }
}
static String getEstateName(String estateNmae) { static String getEstateName(String estateNmae) {
if (estateNmae.isEmpty) {
return '';
} else {
return estateNmae.split('|')[1]; return estateNmae.split('|')[1];
} }
}
static String getCustomYears(int year) { static String getCustomYears(int year) {
int dif = year - DateTime.now().year; int dif = year - DateTime.now().year;

@ -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<BeeHeaderHouse> {
@override
Widget build(BuildContext context) {
UserProvider userProvider = Provider.of<UserProvider>(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()
],
),
),
);
}
}
Loading…
Cancel
Save