diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 59489166..08d46076 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -9,6 +9,7 @@ class API { static String get resource => '$host/static'; static String image(String? path) => '$resource$path'; + static String file(String? path) => '$resource$path'; static const int networkTimeOut = 10000; @@ -36,7 +37,10 @@ class _Login { String get buildingInfo => '/login/findAllBuildingIAN'; ///查询单元ID - String get unitInfo => '/login/findEstateIANByBuilding'; + String get unitInfo => '/login/findUnitByBuildingId'; + + ///查询房间号 + String get room => '/login/findEstateIdByUnitId'; /// app用户注册 String get signUp => '/login/register'; diff --git a/lib/main.dart b/lib/main.dart index afc597ae..7a782fc7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,12 +1,3 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'package:bot_toast/bot_toast.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:provider/provider.dart'; - import 'package:aku_community/constants/app_theme.dart'; import 'package:aku_community/main_initialize.dart'; import 'package:aku_community/pages/splash/splash_page.dart'; @@ -15,6 +6,15 @@ import 'package:aku_community/provider/sign_up_provider.dart'; import 'package:aku_community/provider/user_provider.dart'; import 'package:aku_community/utils/developer_util.dart'; import 'package:aku_community/utils/headers.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:jpush_flutter/jpush_flutter.dart'; +import 'package:power_logger/power_logger.dart'; +import 'package:provider/provider.dart'; void main() async { const buildType = const String.fromEnvironment('BUILD_TYPE'); @@ -27,7 +27,10 @@ void main() async { await MainInitialize.initJPush(); MainInitialize.initWechat(); MainInitialize.initWebSocket(); - + String? rID; + JPush().getRegistrationID().then((value) => rID = value); + print('jpush registrationID is $rID'); + LoggerData.addData(rID, tag: 'RegistrationID'); runApp(MyApp()); } diff --git a/lib/main_initialize.dart b/lib/main_initialize.dart index 878232a2..294e68c6 100644 --- a/lib/main_initialize.dart +++ b/lib/main_initialize.dart @@ -1,25 +1,23 @@ import 'dart:io'; +import 'package:aku_community/constants/app_theme.dart'; +import 'package:aku_community/constants/config.dart'; +import 'package:aku_community/provider/app_provider.dart'; +import 'package:aku_community/utils/message_parser.dart'; +import 'package:aku_community/utils/websocket/fire_dialog.dart'; +import 'package:aku_community/utils/websocket/web_socket_util.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; - -import 'package:firebase_core/firebase_core.dart'; -import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:fluwx/fluwx.dart'; import 'package:get/get.dart'; import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:power_logger/power_logger.dart'; import 'package:provider/provider.dart'; -import 'package:aku_community/constants/app_theme.dart'; -import 'package:aku_community/constants/config.dart'; -import 'package:aku_community/provider/app_provider.dart'; -import 'package:aku_community/utils/message_parser.dart'; -import 'package:aku_community/utils/websocket/fire_dialog.dart'; -import 'package:aku_community/utils/websocket/web_socket_util.dart'; - class MainInitialize { ///初始化firebase static Future initFirebase() async { @@ -73,10 +71,6 @@ class MainInitialize { debug: true, ); // jpush.applyPushAuthority(); - String? rID; - jpush.getRegistrationID().then((value) => rID = value); - print('jpush registrationID is $rID'); - LoggerData.addData(rID, tag: 'RegistrationID'); } static initWechat() { diff --git a/lib/pages/sign/sign_func.dart b/lib/pages/sign/sign_func.dart index ddb2f5ae..095fad93 100644 --- a/lib/pages/sign/sign_func.dart +++ b/lib/pages/sign/sign_func.dart @@ -1,8 +1,3 @@ -import 'package:bot_toast/bot_toast.dart'; -import 'package:dio/dio.dart'; -import 'package:get/get.dart' hide Response; -import 'package:provider/provider.dart'; - import 'package:aku_community/constants/api.dart'; import 'package:aku_community/model/user/pick_building_model.dart'; import 'package:aku_community/model/user/user_detail_model.dart'; @@ -11,6 +6,10 @@ import 'package:aku_community/provider/sign_up_provider.dart'; import 'package:aku_community/provider/user_provider.dart'; import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:dio/dio.dart'; +import 'package:get/get.dart' hide Response; +import 'package:provider/provider.dart'; class SignFunc { static Future sendMessageCode(String phone) async { @@ -39,6 +38,7 @@ class SignFunc { return response; } + ///获取楼栋 static Future> getBuildingInfo() async { BaseModel model = await NetUtil().get(API.login.buildingInfo); return (model.data as List) @@ -46,6 +46,7 @@ class SignFunc { .toList(); } + ///获取单元 static Future> getUnitInfo(int? id) async { BaseModel model = await NetUtil().get( API.login.unitInfo, @@ -56,6 +57,17 @@ class SignFunc { .toList(); } + ///获取房间 + static Future> getRoom(int? id) async { + BaseModel model = await NetUtil().get( + API.login.room, + params: {"unitId": id}, + ); + return (model.data as List) + .map((e) => PickBuildingModel.fromJson(e)) + .toList(); + } + ///注册 static Future signUp() async { final signUpProvider = diff --git a/lib/ui/profile/house/add_house_page.dart b/lib/ui/profile/house/add_house_page.dart index 50dfba35..ed869b25 100644 --- a/lib/ui/profile/house/add_house_page.dart +++ b/lib/ui/profile/house/add_house_page.dart @@ -1,11 +1,3 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'package:bot_toast/bot_toast.dart'; -import 'package:flustars/flustars.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; - import 'package:aku_community/constants/api.dart'; import 'package:aku_community/ui/profile/house/house_item.dart'; import 'package:aku_community/ui/profile/house/pick_building_page.dart'; @@ -14,6 +6,12 @@ import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:flustars/flustars.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; class AddHousePage extends StatefulWidget { AddHousePage({Key? key}) : super(key: key); @@ -37,6 +35,7 @@ class _AddHousePageState extends State { ); TextStyle get _textStyle => _hintStyle.copyWith(color: Color(0xFF333333)); + // 仅在租客身份下检查租期是否填写 bool get _rentCheck => _roleType != 3 ? true : _range != null; @@ -47,6 +46,7 @@ class _AddHousePageState extends State { _item != null && _roleType != null && _rentCheck; + _renderTile({ required String title, Widget? item, @@ -263,7 +263,7 @@ class _AddHousePageState extends State { _identifyHouse() async { Map params = { - 'estateId': _item!.house.value, + 'estateId': _item!.room.value, 'name': _nameController.text, 'type': _roleType, 'idType': 1, diff --git a/lib/ui/profile/house/house_item.dart b/lib/ui/profile/house/house_item.dart index 6c94a23e..aa16b985 100644 --- a/lib/ui/profile/house/house_item.dart +++ b/lib/ui/profile/house/house_item.dart @@ -2,13 +2,16 @@ import 'package:aku_community/model/user/pick_building_model.dart'; class HouseItem { PickBuildingModel building; - PickBuildingModel house; + PickBuildingModel unit; + PickBuildingModel room; + HouseItem({ required this.building, - required this.house, + required this.unit, + required this.room, }); - int? get houseCode => house.value; + int? get houseCode => room.value; - String get houseName => '${building.label}-${house.label}'; + String get houseName => '${building.label}-${unit.label}单元-${room.label}'; } diff --git a/lib/ui/profile/house/house_owners_page.dart b/lib/ui/profile/house/house_owners_page.dart index ac1e6c35..24246461 100644 --- a/lib/ui/profile/house/house_owners_page.dart +++ b/lib/ui/profile/house/house_owners_page.dart @@ -1,13 +1,3 @@ -import 'package:flutter/material.dart'; - -import 'package:bot_toast/bot_toast.dart'; -import 'package:flustars/flustars.dart'; -import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:power_logger/power_logger.dart'; -import 'package:provider/provider.dart'; - import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/const/resource.dart'; import 'package:aku_community/models/house/lease_detail_model.dart'; @@ -25,11 +15,19 @@ import 'package:aku_community/ui/profile/house/lease_relevation/tenant_house_lis import 'package:aku_community/ui/profile/house/my_house_list.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; -import 'package:aku_community/widget/buttons/bottom_button.dart'; import 'package:aku_community/widget/others/user_tool.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:flustars/flustars.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:power_logger/power_logger.dart'; +import 'package:provider/provider.dart'; class HouseOwnersPage extends StatefulWidget { final int identify; + HouseOwnersPage({Key? key, required this.identify}) : super(key: key); @override @@ -129,7 +127,7 @@ class _HouseOwnersPageState extends State { ? Get.to(() => MyHouseList()) : Get.to(() => TenantHouseListPage()); }, - child: Text(isOwner ? '审核记录' : '我的选房'), + child: Text('审核记录'), ), ], body: isTourist @@ -183,9 +181,9 @@ class _HouseOwnersPageState extends State { ], ), ), - bottomNavi: BottomButton( - onPressed: _addHouse, - child: '新增房屋'.text.size(32.sp).color(ktextPrimary).bold.make()), + // bottomNavi: BottomButton( + // onPressed: _addHouse, + // child: '新增房屋'.text.size(32.sp).color(ktextPrimary).bold.make()), ); } @@ -212,8 +210,16 @@ class _HouseOwnersPageState extends State { id: UserTool.appProveider.selectedHouse!.sysLeaseId!, )); }), - _cardBuild(R.ASSETS_ICONS_CHANGE_PNG, '合同变更', '变更合同信息、重新签约', () {}), - _cardBuild(R.ASSETS_ICONS_CONTRACT_PNG, '合同续签', '到期前线上办理续签手续', () {}), + _cardBuild(R.ASSETS_ICONS_CHANGE_PNG, '合同变更', '变更合同信息、重新签约', () { + Get.to(() => TenantHouseListPage( + leaseId: -UserTool.appProveider.selectedHouse!.sysLeaseId!, + )); + }), + _cardBuild(R.ASSETS_ICONS_CONTRACT_PNG, '合同续签', '到期前线上办理续签手续', () { + Get.to(() => TenantHouseListPage( + leaseId: UserTool.appProveider.selectedHouse!.sysLeaseId!, + )); + }), _cardBuild(R.ASSETS_ICONS_FINISH_PNG, '合同终止', '线上申请终止合同', () async { await stopContract(); }) diff --git a/lib/ui/profile/house/lease_relevation/tenant_house_list_page.dart b/lib/ui/profile/house/lease_relevation/tenant_house_list_page.dart index 806fb79b..b59ef178 100644 --- a/lib/ui/profile/house/lease_relevation/tenant_house_list_page.dart +++ b/lib/ui/profile/house/lease_relevation/tenant_house_list_page.dart @@ -1,17 +1,16 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:velocity_x/velocity_x.dart'; - import 'package:aku_community/constants/api.dart'; import 'package:aku_community/models/house/lease_list_model.dart'; import 'package:aku_community/pages/things_page/widget/bee_list_view.dart'; import 'package:aku_community/ui/profile/house/lease_relevation/lease_house_card.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; class TenantHouseListPage extends StatefulWidget { - TenantHouseListPage({Key? key}) : super(key: key); + final int leaseId; + TenantHouseListPage({Key? key, this.leaseId = 0}) : super(key: key); @override _TenantHouseListPageState createState() => _TenantHouseListPageState(); @@ -38,6 +37,7 @@ class _TenantHouseListPageState extends State { body: BeeListView( path: API.house.leaseList, controller: _refreshController, + extraParams: {'leaseParentId': widget.leaseId}, convert: (models) { return models.tableList! .map((e) => LeaseListModel.fromJson(e)) diff --git a/lib/ui/profile/house/pick_building_page.dart b/lib/ui/profile/house/pick_building_page.dart index dc61f171..f8c99def 100644 --- a/lib/ui/profile/house/pick_building_page.dart +++ b/lib/ui/profile/house/pick_building_page.dart @@ -1,14 +1,12 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:get/get.dart'; -import 'package:velocity_x/velocity_x.dart'; - import 'package:aku_community/model/user/pick_building_model.dart'; import 'package:aku_community/pages/sign/sign_func.dart'; import 'package:aku_community/ui/profile/house/house_item.dart'; import 'package:aku_community/ui/profile/house/pick_unit_page.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; class PickBuildingPage extends StatefulWidget { PickBuildingPage({Key? key}) : super(key: key); @@ -23,10 +21,11 @@ class _PickBuildingPageState extends State { return ListTile( title: model.label!.text.make(), onTap: () async { - PickBuildingModel? houseModel = + List houseModels = await Get.to(() => PickUnitPage(buildingId: model.value)); - if (houseModel != null) { - HouseItem item = HouseItem(building: model, house: houseModel); + if (houseModels.isNotEmpty) { + HouseItem item = HouseItem( + building: model, unit: houseModels[0]!, room: houseModels[1]!); Get.back(result: item); } }, diff --git a/lib/ui/profile/house/pick_room_page.dart b/lib/ui/profile/house/pick_room_page.dart new file mode 100644 index 00000000..85e1c84b --- /dev/null +++ b/lib/ui/profile/house/pick_room_page.dart @@ -0,0 +1,48 @@ +import 'package:aku_community/model/user/pick_building_model.dart'; +import 'package:aku_community/pages/sign/sign_func.dart'; +import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class PickRoomPage extends StatefulWidget { + final int unitId; + const PickRoomPage({Key? key, required this.unitId}) : super(key: key); + + @override + _PickRoomPageState createState() => _PickRoomPageState(); +} + +class _PickRoomPageState extends State { + List _buildingModels = []; + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '选择房间', + body: EasyRefresh( + header: MaterialHeader(), + firstRefresh: true, + onRefresh: () async { + _buildingModels = await SignFunc.getRoom(widget.unitId); + setState(() {}); + }, + child: ListView.builder( + itemBuilder: (context, index) { + return _buildItem(_buildingModels[index]); + }, + itemCount: _buildingModels.length, + ), + ), + ); + } + + _buildItem(PickBuildingModel model) { + return ListTile( + title: model.label!.text.make(), + onTap: () async { + Get.back(result: model); + }, + ).material(color: Colors.white); + } +} diff --git a/lib/ui/profile/house/pick_unit_page.dart b/lib/ui/profile/house/pick_unit_page.dart index 22fb7c98..877bb272 100644 --- a/lib/ui/profile/house/pick_unit_page.dart +++ b/lib/ui/profile/house/pick_unit_page.dart @@ -1,15 +1,15 @@ +import 'package:aku_community/model/user/pick_building_model.dart'; +import 'package:aku_community/pages/sign/sign_func.dart'; +import 'package:aku_community/ui/profile/house/pick_room_page.dart'; +import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:flutter/material.dart'; - import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; -import 'package:aku_community/model/user/pick_building_model.dart'; -import 'package:aku_community/pages/sign/sign_func.dart'; -import 'package:aku_community/widget/bee_scaffold.dart'; - class PickUnitPage extends StatefulWidget { final int? buildingId; + PickUnitPage({Key? key, this.buildingId}) : super(key: key); @override @@ -18,11 +18,16 @@ class PickUnitPage extends StatefulWidget { class _PickUnitPageState extends State { List _buildingModels = []; + _buildItem(PickBuildingModel model) { return ListTile( title: model.label!.text.make(), - onTap: () { - Get.back(result: model); + onTap: () async { + PickBuildingModel? houseModel = + await Get.to(() => PickRoomPage(unitId: model.value!)); + if (houseModel != null) { + Get.back(result: [model, houseModel]); + } }, ).material(color: Colors.white); } @@ -30,7 +35,7 @@ class _PickUnitPageState extends State { @override Widget build(BuildContext context) { return BeeScaffold( - title: '选择楼栋', + title: '选择单元', body: EasyRefresh( header: MaterialHeader(), firstRefresh: true,