添加房屋

pull/1/head
张萌 3 years ago
parent 1acc472d69
commit 251be03960

@ -7,4 +7,7 @@ class _ProfileApi {
class _MyHouse {
///
String get userHouse => '/app/user/myEstate/findAllMyEstate';
///
String get addHouse => '/app/user/myEstate/insertEstateApply';
}

@ -18,6 +18,7 @@ class SARSAPI {
static _ProfileApi profile = _ProfileApi();
static _Login login = _Login();
static _User user = _User();
static _House house = _House();
}
class _City {
@ -61,3 +62,8 @@ class _Login {
///app
String get loginTelCode => '/app/login/loginTelCode';
}
class _House {
///()
String get allHouses => '/app/estate/findEstateCascade';
}

@ -0,0 +1,30 @@
extension intExt on int {
String get toChinese {
String nubStr = this.toString();
if (nubStr.length > 2) {
return '';
} else if (nubStr.length > 1) {
var p1 = _getNum(nubStr, 1);
var p2 = _getNum(nubStr, 2);
if (p2 == '') {
p2 = '';
}
if (p1 == '') {
p1 = '';
}
return p1 + '' + p2;
} else {
return _getNum(nubStr, 1);
}
}
//
String _getNum(String dig, int index) {
List<String> _chinese = ['', '', '', '', '', '', '', '', '', ''];
if (index > dig.length) {
return '';
} else {
return _chinese[int.parse(dig[index - 1])];
}
}
}

@ -0,0 +1,91 @@
import 'package:json_annotation/json_annotation.dart';
part 'estate_cascade_model.g.dart';
@JsonSerializable()
class EstateCascadeModel {
final int id;
final String name;
final List<Unit> childList;
factory EstateCascadeModel.fromJson(Map<String, dynamic> json) =>
_$EstateCascadeModelFromJson(json);
const EstateCascadeModel({
required this.id,
required this.name,
required this.childList,
});
}
@JsonSerializable()
class Unit {
final int id;
final String name;
final int floor;
final List<House> childList;
factory Unit.fromJson(Map<String, dynamic> json) => _$UnitFromJson(json);
List<Floor> get floors {
var list = List.generate(
floor,
(index) =>
Floor(name: '${index + 1}', houses: _screenHouseByIndex(index)));
return list;
}
List<House> _screenHouseByIndex(int index) {
var list = <House>[];
childList.forEach((element) {
if (element.name.startsWith((index + 1).toString())) {
list.add(element.copyWith());
}
});
return list;
}
const Unit({
required this.id,
required this.name,
required this.floor,
required this.childList,
});
}
@JsonSerializable()
class House {
final int id;
final String name;
final String manageEstateTypeName;
factory House.fromJson(Map<String, dynamic> json) => _$HouseFromJson(json);
const House({
required this.id,
required this.name,
required this.manageEstateTypeName,
});
House copyWith({
int? id,
String? name,
String? manageEstateTypeName,
}) {
return House(
id: id ?? this.id,
name: name ?? this.name,
manageEstateTypeName: manageEstateTypeName ?? this.manageEstateTypeName,
);
}
}
class Floor {
final String name;
final List<House> houses;
const Floor({
required this.name,
required this.houses,
});
}

@ -0,0 +1,31 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'estate_cascade_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
EstateCascadeModel _$EstateCascadeModelFromJson(Map<String, dynamic> json) =>
EstateCascadeModel(
id: json['id'] as int,
name: json['name'] as String,
childList: (json['childList'] as List<dynamic>)
.map((e) => Unit.fromJson(e as Map<String, dynamic>))
.toList(),
);
Unit _$UnitFromJson(Map<String, dynamic> json) => Unit(
id: json['id'] as int,
name: json['name'] as String,
floor: json['floor'] as int,
childList: (json['childList'] as List<dynamic>)
.map((e) => House.fromJson(e as Map<String, dynamic>))
.toList(),
);
House _$HouseFromJson(Map<String, dynamic> json) => House(
id: json['id'] as int,
name: json['name'] as String,
manageEstateTypeName: json['manageEstateTypeName'] as String,
);

@ -0,0 +1,15 @@
import 'package:aku_new_community/models/sars_model/my_house/estate_cascade_model.dart';
class PickedHouseModel {
final EstateCascadeModel? building;
final Unit? unit;
final Floor? floor;
final House? house;
const PickedHouseModel({
this.building,
this.unit,
this.floor,
this.house,
});
}

@ -9,12 +9,12 @@ class UserInfoModel {
final String? name;
final String? idCard;
final String tel;
// final List<ImgModel> imgUrls;
/// 1. 2. 3.
// 1. 2. 3.
final int? sex;
final String? nickName;
final bool isExistPassword;
final bool isPointsSignSetting;
String get sexValue {
if (sex == 1) return '';
@ -41,6 +41,7 @@ class UserInfoModel {
this.name,
this.idCard,
required this.tel,
required this.isPointsSignSetting,
this.sex,
this.nickName,
required this.isExistPassword,

@ -11,7 +11,9 @@ UserInfoModel _$UserInfoModelFromJson(Map<String, dynamic> json) =>
id: json['id'] as int,
communityId: json['communityId'] as int,
name: json['name'] as String?,
idCard: json['idCard'] as String?,
tel: json['tel'] as String,
isPointsSignSetting: json['isPointsSignSetting'] as bool,
sex: json['sex'] as int?,
nickName: json['nickName'] as String?,
isExistPassword: json['isExistPassword'] as bool,

@ -82,7 +82,9 @@ class _CodeMessagePageState extends State<CodeMessagePage> {
UserTool.appProveider.pickedCityAndCommunity!
.communityModel!.id);
if (re.data['success']) {
UserTool.userProvider.setLogin(re.data['data'] as int);
await UserTool.userProvider
.setLogin(re.data['data'] as int);
await UserTool.dataProvider.addHistories();
} else {
_errorMessage = re.data['msg'];
BotToast.showText(text: re.data['msg']);

@ -104,7 +104,8 @@ class _OtherLoginPageState extends State<OtherLoginPage> {
UserTool
.appProveider.pickedCityAndCommunity!.communityModel!.id);
if (response.data['success']) {
UserTool.userProvider.setLogin(response.data['data']);
await UserTool.userProvider.setLogin(response.data['data']);
await UserTool.dataProvider.addHistories();
} else {
BotToast.showText(text: response.data['message']);
}

@ -3,6 +3,7 @@ import 'package:aku_new_community/models/login/china_region_model.dart';
import 'package:aku_new_community/models/login/history_login_model.dart';
import 'package:aku_new_community/utils/hive_store.dart';
import 'package:aku_new_community/utils/network/net_util.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import 'package:flutter/material.dart';
class DataProvider extends ChangeNotifier {
@ -41,8 +42,8 @@ class DataProvider extends ChangeNotifier {
List<HistoryLoginModel> get loginHistories => _loginHistories;
Future addHistories(HistoryLoginModel model) async {
_loginHistories.insert(0, model);
Future addHistories() async {
_loginHistories.insert(0, UserTool.appProveider.pickedCityAndCommunity!);
if (_loginHistories.length > 4) {
_loginHistories.removeAt(_loginHistories.length - 1);
}

@ -1,10 +1,22 @@
import 'package:aku_new_community/constants/sars_api.dart';
import 'package:aku_new_community/extensions/int_ext.dart';
import 'package:aku_new_community/extensions/widget_list_ext.dart';
import 'package:aku_new_community/models/sars_model/my_house/estate_cascade_model.dart';
import 'package:aku_new_community/models/sars_model/my_house/picked_house.dart';
import 'package:aku_new_community/ui/profile/new_house/widgets/add_house_button.dart';
import 'package:aku_new_community/utils/bee_map.dart';
import 'package:aku_new_community/utils/enum/identify.dart';
import 'package:aku_new_community/utils/network/net_util.dart';
import 'package:aku_new_community/widget/bee_divider.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import 'package:aku_new_community/widget/picker/bee_house_cascade_picker.dart';
import 'package:aku_new_community/widget/picker/bee_identify_picker.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
class AddHousePage extends StatefulWidget {
@ -15,6 +27,19 @@ class AddHousePage extends StatefulWidget {
}
class _AddHousePageState extends State<AddHousePage> {
Identify _identify = Identify.OWNER;
List<PickedHouseModel> _pickedHouses = [PickedHouseModel()];
PickedHouseModel? _otherPickHouse;
TextEditingController _nameController = TextEditingController();
TextEditingController _telController = TextEditingController();
@override
void dispose() {
_nameController.dispose();
_telController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
var identify = Padding(
@ -31,14 +56,15 @@ class _AddHousePageState extends State<AddHousePage> {
),
Expanded(
child: GestureDetector(
onTap: () {
BotToast.showText(text: 'text');
onTap: () async {
_identify = await BeeIdentifyPicker.pick(context);
setState(() {});
},
child: Material(
color: Colors.transparent,
child: Row(
children: [
'业主'
'${BeeMap.getIdentify(_identify)}'
.text
.size(28.sp)
.color(Colors.black.withOpacity(0.65))
@ -170,25 +196,307 @@ class _AddHousePageState extends State<AddHousePage> {
tel
],
),
)
),
],
),
),
24.w.heightBox,
_getProperty(),
],
)),
bottomNavi: Padding(
padding: EdgeInsets.all(32.w),
child: AddHouseButton(
text: '提交',
onTap: () async {
var cancel = BotToast.showLoading();
var base = await NetUtil().post(SARSAPI.profile.house.addHouse,
params: {
'identity': _identify.index + 1,
'manageEstateIds': _identify.index == 0
? _pickedHouses
: [_otherPickHouse],
'ownerName': _nameController.text,
'ownerTel': _telController.text,
'tenantName': _nameController.text,
'tenantTel': _telController.text,
},
showMessage: true);
cancel();
if (base.success) {
Get.back();
}
}),
),
);
}
Widget _propertyRight() {
Widget _getProperty() {
switch (_identify) {
case Identify.OWNER:
return _propertyRightOwner();
case Identify.OWNER_RELATIVES:
return _propertyRightOther();
case Identify.TENANT:
return _propertyRightOther();
case Identify.TENANT_RELATIVES:
return _propertyRightOther();
}
}
Widget _propertyRightOwner() {
return Container(
width: 686.w,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16.w),
color: Colors.white, borderRadius: BorderRadius.circular(16.w)),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
child: Row(
children: [
'产权信息'.text.size(32.sp).black.bold.make(),
Spacer(),
IconButton(
padding: EdgeInsets.zero,
constraints: BoxConstraints(minWidth: 20.w, minHeight: 20.w),
onPressed: () {
_pickedHouses.add(PickedHouseModel());
setState(() {});
},
icon: Icon(
CupertinoIcons.plus,
size: 30.w,
),
),
],
),
),
BeeDivider.horizontal(),
Padding(
padding: EdgeInsets.symmetric(
horizontal: 32.w,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: _pickedHouses
.mapIndexed((currentValue, index) =>
_propertyOwnerTile(currentValue, index))
.toList()
.sepWidget(separate: BeeDivider.horizontal()),
),
)
],
),
);
}
Widget _propertyRightOther() {
var house = GestureDetector(
onTap: () async {
var cancel = BotToast.showLoading();
var base = await NetUtil().get(SARSAPI.house.allHouses);
cancel();
if (base.success) {
var _buildings = (base.data as List)
.map((e) => EstateCascadeModel.fromJson(e))
.toList();
_otherPickHouse =
await BeeHouseCascadePicker.pick(context, _buildings);
} else {
BotToast.showText(text: base.msg);
}
},
child: Material(
color: Colors.transparent,
child: Container(
width: double.infinity,
height: 105.w,
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 32.w),
child: Row(
children: [
'选择房屋'
.text
.size(28.sp)
.color(Colors.black.withOpacity(0.65))
.make(),
56.w.widthBox,
'${_otherPickHouse == null ? '请选择楼层房号' : '${_otherPickHouse!.building!.name}-${_otherPickHouse!.unit!.name}-${_otherPickHouse!.floor!.name}层-${_otherPickHouse!.house!.name}'}'
.text
.size(28.sp)
.color(Colors.black.withOpacity(0.25))
.make(),
Spacer(),
Icon(
CupertinoIcons.chevron_right,
size: 25.w,
color: Colors.black.withOpacity(0.25),
)
],
),
),
),
);
var name = Container(
width: double.infinity,
height: 105.w,
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 32.w),
child: Row(
children: [
'${_identify.index == 3 ? '房屋租户' : '房屋业主'}'
.text
.size(28.sp)
.color(Colors.black.withOpacity(0.65))
.make(),
56.w.widthBox,
Expanded(
child: TextField(
controller: _nameController,
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
hintText: '${_identify.index == 3 ? '请输入租户姓名' : '请输入业主姓名'}',
hintStyle: TextStyle(
fontSize: 28.sp,
color: Colors.black.withOpacity(0.25),
)),
)),
],
),
);
var tel = Container(
width: double.infinity,
height: 105.w,
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 32.w),
child: Row(
children: [
'${_identify.index == 3 ? '租户手机' : '业主手机'}'
.text
.size(28.sp)
.color(Colors.black.withOpacity(0.65))
.make(),
56.w.widthBox,
Expanded(
child: TextField(
controller: _telController,
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
hintText: '${_identify.index == 3 ? '请输入租户手机号' : '请输入业主手机号'}',
hintStyle: TextStyle(
fontSize: 28.sp,
color: Colors.black.withOpacity(0.25),
)),
)),
],
),
);
return Container(
width: 686.w,
decoration: BoxDecoration(
color: Colors.white, borderRadius: BorderRadius.circular(16.w)),
child: Column(
children: [],
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
child: Row(
children: [
'产权信息'.text.size(32.sp).black.bold.make(),
Spacer(),
],
),
),
BeeDivider.horizontal(),
Padding(
padding: EdgeInsets.symmetric(
horizontal: 32.w,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
house,
BeeDivider.horizontal(),
name,
BeeDivider.horizontal(),
tel
],
),
)
],
),
);
}
Widget _propertyOwnerTile(PickedHouseModel model, int index) {
return Column(
children: [
32.w.heightBox,
Container(
width: double.infinity,
height: 60.w,
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 32.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
color: Colors.black.withOpacity(0.06)),
child: '产权信息${(index + 1).toChinese}'
.text
.size(26.sp)
.color(Colors.black.withOpacity(0.45))
.make(),
),
GestureDetector(
onTap: () async {
var cancel = BotToast.showLoading();
var base = await NetUtil().get(SARSAPI.house.allHouses);
cancel();
if (base.success) {
var _buildings = (base.data as List)
.map((e) => EstateCascadeModel.fromJson(e))
.toList();
_pickedHouses[index] =
await BeeHouseCascadePicker.pick(context, _buildings);
} else {
BotToast.showText(text: base.msg);
}
},
child: Material(
color: Colors.transparent,
child: Container(
width: double.infinity,
height: 105.w,
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 32.w),
child: Row(
children: [
'选择房屋'
.text
.size(28.sp)
.color(Colors.black.withOpacity(0.65))
.make(),
56.w.widthBox,
'${model.house == null ? '请选择楼层房号' : '${model.building!.name}-${model.unit!.name}-${model.floor!.name}层-${model.house!.name}'}'
.text
.size(28.sp)
.color(Colors.black.withOpacity(0.25))
.make(),
Spacer(),
Icon(
CupertinoIcons.chevron_right,
size: 25.w,
color: Colors.black.withOpacity(0.25),
)
],
),
),
),
),
],
);
}
}

@ -1,5 +1,7 @@
import 'dart:ui';
import 'package:aku_new_community/utils/enum/identify.dart';
class BeeMap {
static Map<int, String> fixTag = {
1: '公区报修',
@ -75,4 +77,17 @@ class BeeMap {
1: false,
3: true,
};
static String getIdentify(Identify identify) {
switch (identify) {
case Identify.OWNER:
return '业主';
case Identify.OWNER_RELATIVES:
return '业主家属';
case Identify.TENANT:
return '租户';
case Identify.TENANT_RELATIVES:
return '租户家属';
}
}
}

@ -0,0 +1,6 @@
enum Identify {
OWNER,
OWNER_RELATIVES,
TENANT,
TENANT_RELATIVES,
}

@ -0,0 +1,152 @@
import 'package:aku_new_community/models/sars_model/my_house/estate_cascade_model.dart';
import 'package:aku_new_community/models/sars_model/my_house/picked_house.dart';
import 'package:aku_new_community/widget/picker/bee_picker_box.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
class BeeHouseCascadePicker extends StatefulWidget {
final List<EstateCascadeModel> buildings;
static Future<PickedHouseModel> pick(
BuildContext context, List<EstateCascadeModel> buildings) async {
var result = await showModalBottomSheet(
context: context,
builder: (context) {
return BeeHouseCascadePicker(buildings: buildings);
});
return result;
}
const BeeHouseCascadePicker({Key? key, required this.buildings})
: super(key: key);
@override
_BeeHouseCascadePickerState createState() => _BeeHouseCascadePickerState();
}
class _BeeHouseCascadePickerState extends State<BeeHouseCascadePicker> {
List<EstateCascadeModel> _buildings = [];
int _pickBuildingIndex = 0;
EstateCascadeModel get _pickedBuilding => _buildings[_pickBuildingIndex];
int _pickUnitIndex = 0;
Unit get _pickedUnit => _pickedBuilding.childList[_pickUnitIndex];
Floor get _pickedFloor => _pickedUnit.floors[_pickFloorIndex];
int _pickFloorIndex = 0;
House get _pickedHouse => _pickedFloor.houses[_pickHouseIndex];
int _pickHouseIndex = 0;
PickedHouseModel get pickedHouseModel => PickedHouseModel(
building: _pickedBuilding,
unit: _pickedUnit,
floor: _pickedFloor,
house: _pickedHouse,
);
FixedExtentScrollController _unitController = FixedExtentScrollController();
FixedExtentScrollController _floorController = FixedExtentScrollController();
FixedExtentScrollController _houseController = FixedExtentScrollController();
@override
void initState() {
_buildings = widget.buildings;
super.initState();
}
@override
void dispose() {
_unitController.dispose();
_floorController.dispose();
_houseController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BeePickerBox(
onPressed: () {
Get.back(result: pickedHouseModel);
},
child: Row(
children: [
Flexible(
child: CupertinoPicker(
onSelectedItemChanged: (int value) {
_pickBuildingIndex = value;
_unitController.jumpToItem(0);
_floorController.jumpToItem(0);
_houseController.jumpToItem(0);
setState(() {});
},
itemExtent: 80.w,
children: _buildings
.map((e) => Center(
child: Padding(
padding: EdgeInsets.only(left: 20.w, right: 20.w),
child: Text(e.name, textAlign: TextAlign.center),
),
))
.toList(),
),
),
Flexible(
child: CupertinoPicker(
onSelectedItemChanged: (int value) {
_pickUnitIndex = value;
_floorController.jumpToItem(0);
_houseController.jumpToItem(0);
setState(() {});
},
itemExtent: 80.w,
children: _pickedBuilding.childList
.map((e) => Center(
child: Padding(
padding: EdgeInsets.only(left: 20.w, right: 20.w),
child: Text(e.name, textAlign: TextAlign.center),
),
))
.toList(),
),
),
Flexible(
child: CupertinoPicker(
onSelectedItemChanged: (int value) {
_pickFloorIndex = value;
_houseController.jumpToItem(0);
setState(() {});
},
itemExtent: 80.w,
children: _pickedUnit.floors
.map((e) => Center(
child: Padding(
padding: EdgeInsets.only(left: 20.w, right: 20.w),
child: Text(e.name, textAlign: TextAlign.center),
),
))
.toList(),
),
),
Flexible(
child: CupertinoPicker(
onSelectedItemChanged: (int value) {
_pickHouseIndex = value;
setState(() {});
},
itemExtent: 80.w,
children: _pickedFloor.houses
.map((e) => Center(
child: Padding(
padding: EdgeInsets.only(left: 20.w, right: 20.w),
child: Text(e.name, textAlign: TextAlign.center),
),
))
.toList(),
),
)
],
));
}
}

@ -0,0 +1,53 @@
import 'package:aku_new_community/utils/bee_map.dart';
import 'package:aku_new_community/utils/enum/identify.dart';
import 'package:aku_new_community/widget/picker/bee_picker_box.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
class BeeIdentifyPicker extends StatefulWidget {
static Future<Identify> pick(BuildContext context) async {
var result = await showModalBottomSheet(
context: context,
builder: (context) {
return BeeIdentifyPicker();
});
return result;
}
const BeeIdentifyPicker({
Key? key,
}) : super(key: key);
@override
_BeeIdentifyPickerState createState() => _BeeIdentifyPickerState();
}
class _BeeIdentifyPickerState extends State<BeeIdentifyPicker> {
Identify _identify = Identify.OWNER;
@override
Widget build(BuildContext context) {
return BeePickerBox(
onPressed: () {
Get.back(result: _identify);
},
title: '选择身份',
child: CupertinoPicker(
onSelectedItemChanged: (int value) {
_identify = Identify.values[value];
},
itemExtent: 80.w,
children: Identify.values
.map((e) => Center(
child: Padding(
padding: EdgeInsets.only(left: 8.w, right: 40.w),
child: Text(BeeMap.getIdentify(e),
textAlign: TextAlign.center),
),
))
.toList(),
));
}
}
Loading…
Cancel
Save