From 5de81e360ae155b2d35010f06488fbd79bec2067 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 1 Apr 2021 14:14:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E4=BA=A7=E7=9B=B8=E5=85=B3=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/model/user/house_model.dart | 4 ++++ lib/pages/life_pay/life_pay_page.dart | 6 +++--- .../life_pay/widget/life_pay_detail_page.dart | 4 +++- lib/pages/life_pay/widget/my_house_page.dart | 8 +++----- .../widget/add_fixed_submit_page.dart | 2 +- .../visitor_access_page.dart | 2 +- lib/provider/app_provider.dart | 4 ++++ lib/provider/user_provider.dart | 17 +++-------------- lib/ui/profile/house/pick_my_house_page.dart | 17 ++++++++++++++--- 9 files changed, 36 insertions(+), 28 deletions(-) diff --git a/lib/model/user/house_model.dart b/lib/model/user/house_model.dart index 3494de59..199b6d07 100644 --- a/lib/model/user/house_model.dart +++ b/lib/model/user/house_model.dart @@ -5,6 +5,8 @@ class HouseModel { int id; String roomName; + int estateId; + ///1.未审核,3.审核失败,4.审核成功 int status; @@ -87,6 +89,7 @@ class HouseModel { this.type, this.effectiveTimeStart, this.effectiveTimeEnd, + this.estateId, }); HouseModel.fromJson(Map json) { @@ -96,6 +99,7 @@ class HouseModel { type = json['type']; effectiveTimeStart = json['effectiveTimeStart']; effectiveTimeEnd = json['effectiveTimeEnd']; + estateId = json['estateId']; } Map toJson() { diff --git a/lib/pages/life_pay/life_pay_page.dart b/lib/pages/life_pay/life_pay_page.dart index 1653faf4..d32ebac1 100644 --- a/lib/pages/life_pay/life_pay_page.dart +++ b/lib/pages/life_pay/life_pay_page.dart @@ -69,6 +69,7 @@ class _LifePayPageState extends State { GestureDetector( onTap: () { Get.to(() => PickMyHousePage()); + _controller.callRefresh(); }, child: Row( children: [ @@ -216,6 +217,7 @@ class _LifePayPageState extends State { @override Widget build(BuildContext context) { UserProvider userProvider = Provider.of(context); + final appProvider = Provider.of(context); return BeeScaffold( title: '生活缴费', actions: [ @@ -234,9 +236,7 @@ class _LifePayPageState extends State { body: BeeListView( path: API.manager.dailyPaymentList, controller: _controller, - extraParams: { - 'estateId': userProvider.currentHouseId, - }, + extraParams: {'estateId': appProvider.selectedHouse.estateId}, convert: (model) { _selectPay = List.generate(model.tableList.length, (index) => SelectPay(payCount: 0, payTotal: 0.0)); 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 c60bc2fa..3899fce4 100644 --- a/lib/pages/life_pay/widget/life_pay_detail_page.dart +++ b/lib/pages/life_pay/widget/life_pay_detail_page.dart @@ -1,4 +1,5 @@ import 'package:akuCommunity/constants/app_values.dart'; +import 'package:akuCommunity/provider/app_provider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -86,6 +87,7 @@ class _LifePayDetailPageState extends State { Widget _buildCard(DailyPaymentTypeVos model) { UserProvider userProvider = Provider.of(context); + final appProvider = Provider.of(context); return Container( padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w), child: Column( @@ -94,7 +96,7 @@ class _LifePayDetailPageState extends State { children: [ model.name.text.black.size(30.sp).bold.make(), Spacer(), - '${S.of(context).tempPlotName} ${userProvider.currentHouse}' + '${S.of(context).tempPlotName} ${appProvider.selectedHouse.estateId}' .text .color(ktextSubColor) .size(24.sp) diff --git a/lib/pages/life_pay/widget/my_house_page.dart b/lib/pages/life_pay/widget/my_house_page.dart index 4d30a41c..273b3836 100644 --- a/lib/pages/life_pay/widget/my_house_page.dart +++ b/lib/pages/life_pay/widget/my_house_page.dart @@ -1,4 +1,3 @@ -import 'package:akuCommunity/constants/app_values.dart'; import 'package:akuCommunity/provider/app_provider.dart'; import 'package:flutter/material.dart'; @@ -72,14 +71,13 @@ class _MyHousePageState extends State { padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 32.w), child: GestureDetector( onTap: () { - userProvider.setCurrentHouse(estateName); setState(() {}); }, child: Row( children: [ CommonRadio( value: BeeParse.getEstateNameId(estateName), - groupValue: userProvider.currentHouseId, + groupValue: 0, size: 32.w, ), 24.w.widthBox, @@ -125,8 +123,8 @@ class _MyHousePageState extends State { ...userProvider.userDetailModel.estateNames.isEmpty ? [SizedBox()] : userProvider.userDetailModel.estateNames - .map((e) => _buildCard(userProvider.currentHouseId, e, - userProvider.userDetailModel.estateNames.indexOf(e), + .map((e) => _buildCard( + 0, e, userProvider.userDetailModel.estateNames.indexOf(e), paid: widget.needFindPayTag ? false : _unPaidList diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index a015f98a..038484b2 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -237,7 +237,7 @@ class _AddFixedSubmitPageState extends State { List urls = await NetUtil() .uploadFiles(_files, API.upload.uploadRepair); BaseModel baseModel = await ManagerFunc.reportRepairInsert( - appProvider.selectedHouse.id, + appProvider.selectedHouse.estateId, _selectType + 1, _textEditingController.text, urls); diff --git a/lib/pages/visitor_access_page/visitor_access_page.dart b/lib/pages/visitor_access_page/visitor_access_page.dart index 8b7d3bbd..77d019dd 100644 --- a/lib/pages/visitor_access_page/visitor_access_page.dart +++ b/lib/pages/visitor_access_page/visitor_access_page.dart @@ -315,7 +315,7 @@ class _VisitorAccessPageState extends State { _selectTime(), SizedBox(height: 64.w), _create( - appProvider.selectedHouse.id, + appProvider.selectedHouse.estateId, userProvider.userDetailModel.type, userProvider.userDetailModel.tel, ), diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart index 29860aa4..031fd2b5 100644 --- a/lib/provider/app_provider.dart +++ b/lib/provider/app_provider.dart @@ -186,6 +186,10 @@ class AppProvider extends ChangeNotifier { updateHouses(List items) { if (items == null) return; if (items.isEmpty) return; + _selectedHouse = items.firstWhere( + (element) => element.id == (_selectedHouse?.id ?? -1), + orElse: () => null, + ); _houses = items; notifyListeners(); } diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 4baee0a5..5e37f756 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -8,7 +8,6 @@ import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/user/user_detail_model.dart'; import 'package:akuCommunity/model/user/user_info_model.dart'; import 'package:akuCommunity/pages/sign/sign_func.dart'; -import 'package:akuCommunity/utils/bee_parse.dart'; import 'package:akuCommunity/utils/hive_store.dart'; import 'package:akuCommunity/utils/network/base_model.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; @@ -20,21 +19,20 @@ class UserProvider extends ChangeNotifier { bool get isLogin => _isLogin; bool get isNotLogin => !_isLogin; Future setLogin(int token) async { - final appProvider = Provider.of(Get.context,listen: false); + final appProvider = Provider.of(Get.context, listen: false); _isLogin = true; NetUtil().dio.options.headers.putIfAbsent('App-Admin-Token', () => token); HiveStore.appBox.put('token', token); HiveStore.appBox.put('login', true); await updateProfile(); await updateUserDetail(); - await setCurrentHouse((_userDetailModel?.estateNames?.isEmpty ?? true) - ? '' - : _userDetailModel?.estateNames?.first); await appProvider.updateHouses(await HouseFunc.houses); notifyListeners(); } logout() { + final appProvider = Provider.of(Get.context, listen: false); + appProvider.setCurrentHouse(null); _isLogin = false; _token = null; _userInfoModel = null; @@ -133,13 +131,4 @@ class UserProvider extends ChangeNotifier { await updateProfile(); } } - - ///设置默认房屋 - String _currentHouse; - int get currentHouseId => BeeParse.getEstateNameId(_currentHouse); - String get currentHouse => BeeParse.getEstateName(_currentHouse); - setCurrentHouse(String house) { - _currentHouse = house; - notifyListeners(); - } } diff --git a/lib/ui/profile/house/pick_my_house_page.dart b/lib/ui/profile/house/pick_my_house_page.dart index 994aa6ba..89c570e9 100644 --- a/lib/ui/profile/house/pick_my_house_page.dart +++ b/lib/ui/profile/house/pick_my_house_page.dart @@ -49,7 +49,10 @@ class _PickMyHousePageState extends State { return SliverList( delegate: SliverChildListDelegate( housesWithoutSelected - .map((e) => _HouseCard(model: e)) + .map((e) => _HouseCard( + model: e, + controller: _refreshController, + )) .toList() .sepWidget( separate: Divider( @@ -82,6 +85,7 @@ class _PickMyHousePageState extends State { child: _HouseCard( model: appProvider.selectedHouse, highlight: true, + controller: _refreshController, ), ), _renderSep, @@ -108,8 +112,13 @@ class _PickMyHousePageState extends State { class _HouseCard extends StatelessWidget { final HouseModel model; final bool highlight; - const _HouseCard({Key key, @required this.model, this.highlight = false}) - : super(key: key); + final EasyRefreshController controller; + const _HouseCard({ + Key key, + @required this.model, + this.highlight = false, + @required this.controller, + }) : super(key: key); bool get canTapSlide { if (model == null) return false; return model.status == 4 || model.status == 3 && !highlight; @@ -147,6 +156,8 @@ class _HouseCard extends StatelessWidget { 'ids': [model.id] }, ); + // if(controller.) + controller.callRefresh(); cancel(); } }