From 74b267541c628fc639beed5421cdef1b0a636b4a Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Wed, 15 Sep 2021 09:34:11 +0800 Subject: [PATCH] fix some issues --- lib/model/user/house_model.dart | 230 +++++++++--------- lib/models/user/passed_house_list_model.dart | 7 +- lib/models/user/user_info_model.dart | 10 +- lib/models/user/user_info_model.g.dart | 4 +- lib/pages/personal/personal_page.dart | 2 +- lib/ui/market/goods/goods_detail_page.dart | 24 +- lib/ui/profile/house/add_house_page.dart | 3 +- lib/ui/profile/house/house_card.dart | 20 +- lib/ui/profile/house/house_func.dart | 10 +- lib/ui/profile/house/house_owners_page.dart | 2 +- .../lease_relevation/user_identify_page.dart | 1 - lib/ui/profile/house/my_house_list.dart | 22 +- pubspec.yaml | 2 +- 13 files changed, 168 insertions(+), 169 deletions(-) diff --git a/lib/model/user/house_model.dart b/lib/model/user/house_model.dart index ae74a0f9..2b51c0ea 100644 --- a/lib/model/user/house_model.dart +++ b/lib/model/user/house_model.dart @@ -1,114 +1,116 @@ -import 'package:flutter/material.dart'; - -import 'package:flustars/flustars.dart'; - -class HouseModel { - int? id; - String? roomName; - - int? estateId; - - ///1.未审核,3.审核失败,4.审核成功 - int? status; - - ///1 审核业主,2审核亲属,3审核租客 - int? type; - String? effectiveTimeStart; - String? effectiveTimeEnd; - - DateTime? get effectiveStartDate => DateUtil.getDateTime(effectiveTimeStart!); - DateTime? get effectiveEndDate => DateUtil.getDateTime(effectiveTimeEnd!); - - // - bool get reviewed => status == 4; - String get typeValue { - switch (type) { - case 1: - return '业主'; - case 2: - return '租客'; - case 3: - return '亲属'; - } - return ''; - } - - String get houseStatus { - if (status == 1) return '审核中'; - if (status == 3) return '未通过'; - if (type == 1) return '业主'; - if (type == 2) return '亲属'; - if (type == 3) return '租客'; - return ''; - } - - Color get houseStatusColor { - if (status != 4) return Color(0xFF666666); - if (type == 1) return Color(0xFF333333); - return Colors.white; - } - - ///我的房屋页面背景颜色 - /// - List get backgroundColor { - if (status != 4) - return [ - Color(0xFFF5F5F5), - Color(0xFFEFEEEE), - Color(0xFFE8E8E8), - ]; - if (type == 1) - return [ - Color(0xFFFFDF7D), - Color(0xFFFFD654), - Color(0xFFFFC40C), - ]; - if (type == 2) - return [ - Color(0xFFFFA446), - Color(0xFFFFA547), - Color(0xFFFF8200), - ]; - if (type == 3) - return [ - Color(0xFF9ADE79), - Color(0xFF91DE6B), - Color(0xFF6ECB41), - ]; - return [ - Color(0xFFF5F5F5), - Color(0xFFEFEEEE), - Color(0xFFE8E8E8), - ]; - } - - HouseModel({ - this.id, - this.roomName, - this.status, - this.type, - this.effectiveTimeStart, - this.effectiveTimeEnd, - this.estateId, - }); - - HouseModel.fromJson(Map json) { - id = json['id']; - roomName = json['roomName']; - status = json['status']; - type = json['type']; - effectiveTimeStart = json['effectiveTimeStart']; - effectiveTimeEnd = json['effectiveTimeEnd']; - estateId = json['estateId']; - } - - Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['roomName'] = this.roomName; - data['status'] = this.status; - data['effectiveTimeStart'] = this.effectiveTimeStart; - data['effectiveTimeEnd'] = this.effectiveTimeEnd; - return data; - } -} +// import 'package:flustars/flustars.dart'; +// import 'package:flutter/material.dart'; +// +// class HouseModel { +// int? id; +// String? roomName; +// +// int? estateId; +// +// ///1.未审核,3.审核失败,4.审核成功 +// int? status; +// +// ///1 审核业主,2审核亲属,3审核租客 +// int? type; +// String? effectiveTimeStart; +// String? effectiveTimeEnd; +// int? sysLeaseId; +// +// DateTime? get effectiveStartDate => DateUtil.getDateTime(effectiveTimeStart!); +// DateTime? get effectiveEndDate => DateUtil.getDateTime(effectiveTimeEnd!); +// +// // +// bool get reviewed => status == 4; +// String get typeValue { +// switch (type) { +// case 1: +// return '业主'; +// case 2: +// return '租客'; +// case 3: +// return '亲属'; +// } +// return ''; +// } +// +// String get houseStatus { +// if (status == 1) return '审核中'; +// if (status == 3) return '未通过'; +// if (type == 1) return '业主'; +// if (type == 2) return '亲属'; +// if (type == 3) return '租客'; +// return ''; +// } +// +// Color get houseStatusColor { +// if (status != 4) return Color(0xFF666666); +// if (type == 1) return Color(0xFF333333); +// return Colors.white; +// } +// +// ///我的房屋页面背景颜色 +// /// +// List get backgroundColor { +// if (status != 4) +// return [ +// Color(0xFFF5F5F5), +// Color(0xFFEFEEEE), +// Color(0xFFE8E8E8), +// ]; +// if (type == 1) +// return [ +// Color(0xFFFFDF7D), +// Color(0xFFFFD654), +// Color(0xFFFFC40C), +// ]; +// if (type == 2) +// return [ +// Color(0xFFFFA446), +// Color(0xFFFFA547), +// Color(0xFFFF8200), +// ]; +// if (type == 3) +// return [ +// Color(0xFF9ADE79), +// Color(0xFF91DE6B), +// Color(0xFF6ECB41), +// ]; +// return [ +// Color(0xFFF5F5F5), +// Color(0xFFEFEEEE), +// Color(0xFFE8E8E8), +// ]; +// } +// +// HouseModel( +// {this.id, +// this.roomName, +// this.status, +// this.type, +// this.effectiveTimeStart, +// this.effectiveTimeEnd, +// this.estateId, +// this.sysLeaseId}); +// +// HouseModel.fromJson(Map json) { +// id = json['id']; +// roomName = json['roomName']; +// status = json['status']; +// type = json['type']; +// effectiveTimeStart = json['effectiveTimeStart']; +// effectiveTimeEnd = json['effectiveTimeEnd']; +// estateId = json['estateId']; +// sysLeaseId = json['sysLeaseId']; +// } +// +// Map toJson() { +// final Map data = new Map(); +// data['id'] = this.id; +// data['roomName'] = this.roomName; +// data['status'] = this.status; +// data['effectiveTimeStart'] = this.effectiveTimeStart; +// data['effectiveTimeEnd'] = this.effectiveTimeEnd; +// data['sysLeaseId'] = this.sysLeaseId; +// return data; +// } +// } diff --git a/lib/models/user/passed_house_list_model.dart b/lib/models/user/passed_house_list_model.dart index 2a5e8df4..1d97d29c 100644 --- a/lib/models/user/passed_house_list_model.dart +++ b/lib/models/user/passed_house_list_model.dart @@ -1,6 +1,6 @@ -import 'package:flutter/material.dart'; - import 'package:equatable/equatable.dart'; +import 'package:flustars/flustars.dart'; +import 'package:flutter/material.dart'; import 'package:json_annotation/json_annotation.dart'; part 'passed_house_list_model.g.dart'; @@ -39,6 +39,9 @@ class PassedHouseListModel extends Equatable { factory PassedHouseListModel.fromJson(Map json) => _$PassedHouseListModelFromJson(json); + DateTime? get effectiveStartDate => DateUtil.getDateTime(effectiveTimeStart!); + DateTime? get effectiveEndDate => DateUtil.getDateTime(effectiveTimeEnd!); + String get houseStatus { if (type == 1) return '业主'; if (type == 2) return '亲属'; diff --git a/lib/models/user/user_info_model.dart b/lib/models/user/user_info_model.dart index 32116c82..710724d3 100644 --- a/lib/models/user/user_info_model.dart +++ b/lib/models/user/user_info_model.dart @@ -8,13 +8,13 @@ part 'user_info_model.g.dart'; class UserInfoModel { int id; List imgUrls; - String name; + String? name; String nickName; String tel; /// 性别 1.男 2.女 int? sex; - String birthday; + String? birthday; String get sexValue { if (sex == null) return '未设置'; @@ -23,7 +23,7 @@ class UserInfoModel { return '未设置'; } - DateTime? get birthdayDate => DateUtil.getDateTime(birthday); + DateTime? get birthdayDate => DateUtil.getDateTime(birthday ?? ''); String get birthdayValue { if (TextUtil.isEmpty(birthday)) @@ -38,10 +38,10 @@ class UserInfoModel { UserInfoModel({ required this.id, required this.imgUrls, - required this.name, + this.name, required this.nickName, required this.tel, this.sex, - required this.birthday, + this.birthday, }); } diff --git a/lib/models/user/user_info_model.g.dart b/lib/models/user/user_info_model.g.dart index c6e06bbb..e2caeb9c 100644 --- a/lib/models/user/user_info_model.g.dart +++ b/lib/models/user/user_info_model.g.dart @@ -12,10 +12,10 @@ UserInfoModel _$UserInfoModelFromJson(Map json) { imgUrls: (json['imgUrls'] as List) .map((e) => ImgModel.fromJson(e as Map)) .toList(), - name: json['name'] as String, + name: json['name'] as String?, nickName: json['nickName'] as String, tel: json['tel'] as String, sex: json['sex'] as int?, - birthday: json['birthday'] as String, + birthday: json['birthday'] as String?, ); } diff --git a/lib/pages/personal/personal_page.dart b/lib/pages/personal/personal_page.dart index c3cdc416..126f953f 100644 --- a/lib/pages/personal/personal_page.dart +++ b/lib/pages/personal/personal_page.dart @@ -74,7 +74,7 @@ class _PersonalIndexState extends State image: API.image(userProvider .userInfoModel!.imgUrls.isNotEmpty ? userProvider - .userInfoModel?.imgUrls.first.url + .userInfoModel!.imgUrls.first.url : ''), height: 106.w, width: 106.w, diff --git a/lib/ui/market/goods/goods_detail_page.dart b/lib/ui/market/goods/goods_detail_page.dart index 04ec5ee1..05090014 100644 --- a/lib/ui/market/goods/goods_detail_page.dart +++ b/lib/ui/market/goods/goods_detail_page.dart @@ -1,14 +1,3 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'package:bot_toast/bot_toast.dart'; -import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:provider/provider.dart'; -import 'package:velocity_x/velocity_x.dart'; -import 'package:waterfall_flow/waterfall_flow.dart'; - import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/const/resource.dart'; import 'package:aku_community/constants/api.dart'; @@ -27,6 +16,15 @@ import 'package:aku_community/widget/bee_back_button.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:flutter/cupertino.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:provider/provider.dart'; +import 'package:velocity_x/velocity_x.dart'; +import 'package:waterfall_flow/waterfall_flow.dart'; ///商品详情页面 class GoodsDetailPage extends StatefulWidget { @@ -55,7 +53,9 @@ class _GoodsDetailPageState extends State { final userProvider = Provider.of(context, listen: false); _refreshController = EasyRefreshController(); _pageController = PageController(); - _nameController.text = userProvider.userInfoModel?.name ?? ''; + _nameController.text = userProvider.userInfoModel?.name ?? + userProvider.userInfoModel?.nickName ?? + ''; _phoneController.text = userProvider.userInfoModel?.tel ?? ''; } diff --git a/lib/ui/profile/house/add_house_page.dart b/lib/ui/profile/house/add_house_page.dart index 5133697e..401bab4b 100644 --- a/lib/ui/profile/house/add_house_page.dart +++ b/lib/ui/profile/house/add_house_page.dart @@ -25,7 +25,7 @@ class _AddHousePageState extends State { TextEditingController _idController = TextEditingController(); GlobalKey _formKey = GlobalKey(); HouseItem? _item; - int? _roleType; + int _roleType = 1; DateTimeRange? _range; TextStyle get _hintStyle => TextStyle( @@ -44,7 +44,6 @@ class _AddHousePageState extends State { _nameController.text.isNotEmpty && _idController.text.isNotEmpty && _item != null && - _roleType != null && _rentCheck; _renderTile({ diff --git a/lib/ui/profile/house/house_card.dart b/lib/ui/profile/house/house_card.dart index b7be3bd5..a4835724 100644 --- a/lib/ui/profile/house/house_card.dart +++ b/lib/ui/profile/house/house_card.dart @@ -1,12 +1,10 @@ -import 'package:flutter/material.dart'; - -import 'package:flustars/flustars.dart'; -import 'package:get/get.dart'; - import 'package:aku_community/const/resource.dart'; import 'package:aku_community/models/user/passed_house_list_model.dart'; import 'package:aku_community/ui/profile/house/pick_my_house_page.dart'; import 'package:aku_community/utils/headers.dart'; +import 'package:flustars/flustars.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; enum CardAuthType { FAIL, @@ -28,13 +26,13 @@ class HouseCard extends StatelessWidget { Key? key, required this.model, required this.isOwner, - }) : type = CardAuthType.FAIL, + }) : type = CardAuthType.FAIL, super(key: key); const HouseCard.success({ Key? key, required this.model, required this.isOwner, - }) : type = CardAuthType.SUCCESS, + }) : type = CardAuthType.SUCCESS, super(key: key); String get _assetPath { @@ -48,7 +46,7 @@ class HouseCard extends StatelessWidget { } String get _roleName { - switch (model!.type) { + switch (model?.type ?? 2) { case 1: return '业主'; case 2: @@ -130,7 +128,7 @@ class HouseCard extends StatelessWidget { ), 10.hb, Text( - model!.roomName, + model?.roomName ?? '', style: Theme.of(context).textTheme.subtitle1, ), Spacer(), @@ -158,7 +156,7 @@ class HouseCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - '到期时间:${_isOverDate(DateUtil.getDateTime(model!.effectiveTimeEnd ?? ''))}', + '到期时间:${_isOverDate(DateUtil.getDateTime(model?.effectiveTimeEnd ?? ''))}', style: Theme.of(context).textTheme.subtitle2!.copyWith( color: Color(0xFF666666), @@ -166,7 +164,7 @@ class HouseCard extends StatelessWidget { ), Text( DateUtil.formatDateStr( - model!.effectiveTimeEnd ?? '', + model?.effectiveTimeEnd ?? '', format: 'yyyy-MM-dd'), style: Theme.of(context).textTheme.subtitle1, ), diff --git a/lib/ui/profile/house/house_func.dart b/lib/ui/profile/house/house_func.dart index 056be86f..ed9d6b0d 100644 --- a/lib/ui/profile/house/house_func.dart +++ b/lib/ui/profile/house/house_func.dart @@ -1,10 +1,7 @@ import 'dart:io'; import 'dart:typed_data'; -import 'package:bot_toast/bot_toast.dart'; - import 'package:aku_community/constants/api.dart'; -import 'package:aku_community/model/user/house_model.dart'; import 'package:aku_community/models/house/lease_detail_model.dart'; import 'package:aku_community/models/house/lease_echo_model.dart'; import 'package:aku_community/models/house/submit_model.dart'; @@ -12,13 +9,16 @@ import 'package:aku_community/models/user/passed_house_list_model.dart'; import 'package:aku_community/utils/network/base_file_model.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'; class HouseFunc { ///查询所有的房屋审核信息 - static Future> get examineHouses async { + static Future> get examineHouses async { BaseModel model = await NetUtil().get(API.user.examineHouseList); if (!model.status!) return []; - return (model.data as List).map((e) => HouseModel.fromJson(e)).toList(); + return (model.data as List) + .map((e) => PassedHouseListModel.fromJson(e)) + .toList(); } ///查询用户所拥有的房屋信息 diff --git a/lib/ui/profile/house/house_owners_page.dart b/lib/ui/profile/house/house_owners_page.dart index 71a2d711..8db03f81 100644 --- a/lib/ui/profile/house/house_owners_page.dart +++ b/lib/ui/profile/house/house_owners_page.dart @@ -149,7 +149,7 @@ class _HouseOwnersPageState extends State { }, child: ListView( children: [ - _emptyHouse + UserTool.appProveider.selectedHouse == null ? 280.hb : Padding( padding: EdgeInsets.all(32.w), diff --git a/lib/ui/profile/house/lease_relevation/user_identify_page.dart b/lib/ui/profile/house/lease_relevation/user_identify_page.dart index c1985ef3..e29bac33 100644 --- a/lib/ui/profile/house/lease_relevation/user_identify_page.dart +++ b/lib/ui/profile/house/lease_relevation/user_identify_page.dart @@ -26,7 +26,6 @@ class _UserIdentifyPageState extends State { TextEditingController _nameController = TextEditingController(); TextEditingController _indentifyCodeController = TextEditingController(); String _sex = '请选择性别'; - String _identify = '请选择身份'; String _tel = ''; @override void initState() { diff --git a/lib/ui/profile/house/my_house_list.dart b/lib/ui/profile/house/my_house_list.dart index 1e901121..962a3c20 100644 --- a/lib/ui/profile/house/my_house_list.dart +++ b/lib/ui/profile/house/my_house_list.dart @@ -1,19 +1,17 @@ -import 'package:flutter/material.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:velocity_x/velocity_x.dart'; - import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/const/resource.dart'; -import 'package:aku_community/model/user/house_model.dart'; +import 'package:aku_community/models/user/passed_house_list_model.dart'; import 'package:aku_community/ui/profile/house/add_house_page.dart'; import 'package:aku_community/ui/profile/house/house_func.dart'; import 'package:aku_community/widget/bee_divider.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/others/bee_row_tile.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:velocity_x/velocity_x.dart'; class MyHouseList extends StatefulWidget { MyHouseList({Key? key}) : super(key: key); @@ -25,7 +23,7 @@ class MyHouseList extends StatefulWidget { class _MyHouseListState extends State { late EasyRefreshController _refreshController; - List models = []; + List models = []; @override void initState() { super.initState(); @@ -74,7 +72,7 @@ class _MyHouseListState extends State { ); } - Widget _buildCard(HouseModel model) { + Widget _buildCard(PassedHouseListModel model) { return Container( padding: EdgeInsets.all(24.w), width: double.infinity, @@ -90,7 +88,7 @@ class _MyHouseListState extends State { children: [ Row( children: [ - model.roomName!.text.size(32.sp).color(ktextPrimary).bold.make(), + model.roomName.text.size(32.sp).color(ktextPrimary).bold.make(), Spacer(), // model.houseStatus.text // .size(30.sp) diff --git a/pubspec.yaml b/pubspec.yaml index b6407a02..30dc4a27 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: aku_community description: A new Flutter project. publish_to: "none" -version: 1.6.0-dev+42 +version: 1.7.0-dev+43 environment: sdk: ">=2.12.0 <3.0.0"