调整设置我的房屋逻辑,

调整当前房屋组件,
重写生活缴费费用计算逻辑
hmxc
张萌 4 years ago
parent 6029ef6977
commit c2ccb2fe80

@ -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<String> selected;
SelectList();
class SelectPay {
double payTotal;
int payCount;
SelectPay();
}
class _LifePayPageState extends State<LifePayPage> {
@ -40,7 +39,9 @@ class _LifePayPageState extends State<LifePayPage> {
// List<SelectList> selectItems = [];
List<int> _selectYears = [];
List<LifePayModel> _models = [];
List<SelectPay> _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<LifePayPage> {
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<LifePayPage> {
// 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<LifePayPage> {
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<LifePayPage> {
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<LifePayPage> {
_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<LifePayPage> {
);
}),
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<LifePayPage> {
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<LifePayPage> {
color: Colors.white,
)
: SizedBox(),
),
).material(color: Colors.transparent),
),
Spacer(),
Column(
@ -369,13 +389,13 @@ class _LifePayPageState extends State<LifePayPage> {
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,

@ -27,7 +27,9 @@ class LifePayDetailPage extends StatefulWidget {
}
class _LifePayDetailPageState extends State<LifePayDetailPage> {
List<String> _selectItems=[];
List<String> _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<LifePayDetailPage> {
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<LifePayDetailPage> {
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<LifePayDetailPage> {
.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<LifePayDetailPage> {
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<LifePayDetailPage> {
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(),
),

@ -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<MyHousePage> {
int _select;
List<EstatePaymentModel> _list = [];
List<EstatePaymentModel> get _unPaidList =>
_list.where((element) => element.status == 1).toList();
@ -65,18 +64,19 @@ class _MyHousePageState extends State<MyHousePage> {
Widget _buildCard(String currentHouse, String estateName, int index,
{bool paid = false}) {
UserProvider userProvider = Provider.of<UserProvider>(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<MyHousePage> {
title: '我的房屋',
body: ListView(
children: <Widget>[
...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()),
),
);

@ -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';
@ -219,12 +220,13 @@ class _AddFixedSubmitPageState extends State<AddFixedSubmitPage> {
children: [
ListView(
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(),
_getType(),
_buildReportCard(),
_addImages(),

@ -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;

@ -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) {

@ -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