diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 335e5ba4..86296af3 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -1,5 +1,3 @@ -part 'sars_api.dart'; - class API { ///HOST static const String host = 'http://121.41.26.225:8006'; @@ -26,12 +24,17 @@ class API { static _Search search = _Search(); static _Pay pay = _Pay(); static _House house = _House(); - static _SarsApi sarsApi = _SarsApi(); } class _Login { - /// 获取手机验证码 - String get sendSMSCode => '/login/sendMMSLogin'; + //查询所有小区信息 + String get allCommunity => '/app/login/findAllCommunity'; + + //账号密码登录 + String get login => '/app/login/loginTelPwd'; + + // 获取手机验证码 + String get sendSMSCode => '/app/login/sendTelCode'; /// 通过验证码短信登陆 String get loginBySMS => '/login/loginSMSUser'; @@ -54,10 +57,7 @@ class _Login { class _User { ///用户资料 - String get userProfile => '/user/personalData/findPersonalData'; - - ///用户详细资料 - String get userDetail => '/user/personalData/getUserDetail'; + String get userProfile => '/app/user/findDetail'; ///设置用户性别 String get setSex => '/user/personalData/updateSex'; diff --git a/lib/constants/application_objects.dart b/lib/constants/application_objects.dart index 530aa4cf..3858f769 100644 --- a/lib/constants/application_objects.dart +++ b/lib/constants/application_objects.dart @@ -30,7 +30,6 @@ import 'package:aku_new_community/ui/manager/questionnaire/questionnaire_page.da import 'package:aku_new_community/ui/profile/car/car_manage_page.dart'; import 'package:aku_new_community/ui/profile/car_parking/car_parking_page.dart'; import 'package:aku_new_community/ui/profile/house/house_owners_page.dart'; -import 'package:aku_new_community/widget/others/user_tool.dart'; import 'package:flutter/material.dart'; ///应用对象 @@ -138,7 +137,7 @@ List userAppObjects = [ '我的房屋', R.ASSETS_ICONS_USER_ICON_WDFW_PNG, () => HouseOwnersPage( - identify: UserTool.userProvider.userDetailModel!.type ?? 4, + identify: 4, )), AO('我的车位', R.ASSETS_ICONS_USER_ICON_WDCW_PNG, () => CarParkingPage()), AO('我的车', R.ASSETS_ICONS_USER_ICON_WDC_PNG, () => CarManagePage()), diff --git a/lib/constants/profile_api.dart b/lib/constants/profile_api.dart new file mode 100644 index 00000000..b25e9d02 --- /dev/null +++ b/lib/constants/profile_api.dart @@ -0,0 +1,10 @@ +part of 'sars_api.dart'; + +class _ProfileApi { + _MyHouse house = _MyHouse(); +} + +class _MyHouse { + ///查询所有我的房屋 + String get userHouse => '/app/user/myEstate/findAllMyEstate'; +} diff --git a/lib/constants/sars_api.dart b/lib/constants/sars_api.dart index b4f5c1fe..e6d74846 100644 --- a/lib/constants/sars_api.dart +++ b/lib/constants/sars_api.dart @@ -1,8 +1,23 @@ -part of 'api.dart'; +part 'profile_api.dart'; -class _SarsApi { - _City city = _City(); - _LoginAndSignup login = _LoginAndSignup(); +class SARSAPI { + ///HOST + static const String host = 'http://121.41.26.225:8006'; + + ///接口基础地址 + static const String baseURL = '$host'; + + ///静态资源路径 + 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; + static _City city = _City(); + static _ProfileApi profile = _ProfileApi(); + static _Login login = _Login(); + static _User user = _User(); } class _City { @@ -10,7 +25,21 @@ class _City { String get allCity => '/app/city/allCity'; } -class _LoginAndSignup { +class _User { + ///用户资料 + String get userProfile => '/app/user/findDetail'; +} + +class _Login { ///查询所有小区信息 String get allCommunity => '/app/login/findAllCommunity'; + + ///账号密码登录 + String get login => '/app/login/loginTelPwd'; + + /// 获取手机验证码 + String get sendSMSCode => '/app/login/sendTelCode'; + + ///app用户(手机号验证码)登录 + String get loginTelCode => '/app/login/loginTelCode'; } diff --git a/lib/models/login/history_login_model.dart b/lib/models/login/history_login_model.dart index dc6b1df8..aa522e70 100644 --- a/lib/models/login/history_login_model.dart +++ b/lib/models/login/history_login_model.dart @@ -9,14 +9,14 @@ part 'history_login_model.g.dart'; @HiveType(typeId: 4) class HistoryLoginModel { @HiveField(0) - final PickedCityModel cityModel; + PickedCityModel cityModel; @HiveField(1) - final CommunityModel communityModel; + CommunityModel? communityModel; factory HistoryLoginModel.fromJson(Map json) => _$HistoryLoginModelFromJson(json); - const HistoryLoginModel({ + HistoryLoginModel({ required this.cityModel, - required this.communityModel, + this.communityModel, }); } diff --git a/lib/models/login/history_login_model.g.dart b/lib/models/login/history_login_model.g.dart index 37327909..2783cf33 100644 --- a/lib/models/login/history_login_model.g.dart +++ b/lib/models/login/history_login_model.g.dart @@ -18,7 +18,7 @@ class HistoryLoginModelAdapter extends TypeAdapter { }; return HistoryLoginModel( cityModel: fields[0] as PickedCityModel, - communityModel: fields[1] as CommunityModel, + communityModel: fields[1] as CommunityModel?, ); } @@ -51,6 +51,8 @@ HistoryLoginModel _$HistoryLoginModelFromJson(Map json) => HistoryLoginModel( cityModel: PickedCityModel.fromJson(json['cityModel'] as Map), - communityModel: CommunityModel.fromJson( - json['communityModel'] as Map), + communityModel: json['communityModel'] == null + ? null + : CommunityModel.fromJson( + json['communityModel'] as Map), ); diff --git a/lib/models/user/my_house_model.dart b/lib/models/user/my_house_model.dart new file mode 100644 index 00000000..d060f8ba --- /dev/null +++ b/lib/models/user/my_house_model.dart @@ -0,0 +1,34 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'my_house_model.g.dart'; + +@JsonSerializable() +class MyHouseModel { + final int id; + final String addressName; + final String communityName; + final String buildingName; + final String estateName; + final String unitName; + final String manageEstateTypeName; + final int identity; + final String name; + final String tel; + final String isDefault; + factory MyHouseModel.fromJson(Map json) => + _$MyHouseModelFromJson(json); + + const MyHouseModel({ + required this.id, + required this.addressName, + required this.communityName, + required this.buildingName, + required this.estateName, + required this.unitName, + required this.manageEstateTypeName, + required this.identity, + required this.name, + required this.tel, + required this.isDefault, + }); +} diff --git a/lib/models/user/my_house_model.g.dart b/lib/models/user/my_house_model.g.dart new file mode 100644 index 00000000..0e3ccb28 --- /dev/null +++ b/lib/models/user/my_house_model.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'my_house_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +MyHouseModel _$MyHouseModelFromJson(Map json) => MyHouseModel( + id: json['id'] as int, + addressName: json['addressName'] as String, + communityName: json['communityName'] as String, + buildingName: json['buildingName'] as String, + estateName: json['estateName'] as String, + unitName: json['unitName'] as String, + manageEstateTypeName: json['manageEstateTypeName'] as String, + identity: json['identity'] as int, + name: json['name'] as String, + tel: json['tel'] as String, + isDefault: json['isDefault'] as String, + ); diff --git a/lib/models/user/user_info_model.dart b/lib/models/user/user_info_model.dart index d5638103..8d04bc0a 100644 --- a/lib/models/user/user_info_model.dart +++ b/lib/models/user/user_info_model.dart @@ -1,47 +1,48 @@ import 'package:aku_new_community/model/common/img_model.dart'; -import 'package:flustars/flustars.dart'; import 'package:json_annotation/json_annotation.dart'; part 'user_info_model.g.dart'; @JsonSerializable() class UserInfoModel { - int id; - List imgUrls; - String? name; - String nickName; - String tel; + final int id; + final int communityId; + final String? name; + final String tel; + final List imgUrls; - /// 性别 1.男 2.女 - int? sex; - String? birthday; + /// 性别 1.男 2.女 3.保密 + final int? sex; + final String? nickName; + final bool isExistPassword; String get sexValue { - if (sex == null) return '未设置'; if (sex == 1) return '男'; if (sex == 2) return '女'; + if (sex == 3) return '保密'; return '未设置'; } - DateTime? get birthdayDate => DateUtil.getDateTime(birthday ?? ''); + // DateTime? get birthdayDate => DateUtil.getDateTime(birthday ?? ''); - String get birthdayValue { - if (TextUtil.isEmpty(birthday)) - return '未设置'; - else - return DateUtil.formatDate(birthdayDate, format: 'yyyy-MM-dd'); - } + // String get birthdayValue { + // if (TextUtil.isEmpty(birthday)) + // return '未设置'; + // else + // return DateUtil.formatDate(birthdayDate, format: 'yyyy-MM-dd'); + // } factory UserInfoModel.fromJson(Map json) => _$UserInfoModelFromJson(json); - UserInfoModel({ + const UserInfoModel({ required this.id, - required this.imgUrls, + required this.communityId, this.name, - required this.nickName, required this.tel, + required this.imgUrls, this.sex, - this.birthday, + this.nickName, + required this.isExistPassword, }); } diff --git a/lib/models/user/user_info_model.g.dart b/lib/models/user/user_info_model.g.dart index 3c61206c..a680aa3f 100644 --- a/lib/models/user/user_info_model.g.dart +++ b/lib/models/user/user_info_model.g.dart @@ -9,12 +9,13 @@ part of 'user_info_model.dart'; UserInfoModel _$UserInfoModelFromJson(Map json) => UserInfoModel( id: json['id'] as int, + communityId: json['communityId'] as int, + name: json['name'] as String?, + tel: json['tel'] as String, imgUrls: (json['imgUrls'] as List) .map((e) => ImgModel.fromJson(e as Map)) .toList(), - 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?, + nickName: json['nickName'] as String?, + isExistPassword: json['isExistPassword'] as bool, ); diff --git a/lib/pages/community_introduce/community_introduce_page.dart b/lib/pages/community_introduce/community_introduce_page.dart index ebe05314..76200488 100644 --- a/lib/pages/community_introduce/community_introduce_page.dart +++ b/lib/pages/community_introduce/community_introduce_page.dart @@ -33,7 +33,7 @@ class _CommunityIntroducePageState extends State { onRefresh: () async { BaseModel baseModel = await NetUtil().get(API.manager.communityIntroduceInfo); - if (baseModel.status! && baseModel.data != null) { + if (baseModel.success && baseModel.data != null) { _model = CommunityIontroduceModel.fromJson(baseModel.data); } _onload = false; diff --git a/lib/pages/electronic_commerc/electronic_commerc_detail_page.dart b/lib/pages/electronic_commerc/electronic_commerc_detail_page.dart index 462d183c..43638eba 100644 --- a/lib/pages/electronic_commerc/electronic_commerc_detail_page.dart +++ b/lib/pages/electronic_commerc/electronic_commerc_detail_page.dart @@ -52,7 +52,7 @@ class _ElectronicCommercDetailPageState await NetUtil().get(API.manager.electronicCommercDetail, params: { "electronicCommerceId": widget.id, }); - if (baseModel.status! && baseModel.data != null) { + if (baseModel.success && baseModel.data != null) { _detailModel = ElectronicCommercDetailModel.fromJson(baseModel.data); } else { diff --git a/lib/pages/electronic_commerc/electronic_commerc_page.dart b/lib/pages/electronic_commerc/electronic_commerc_page.dart index 76071494..5312fe3d 100644 --- a/lib/pages/electronic_commerc/electronic_commerc_page.dart +++ b/lib/pages/electronic_commerc/electronic_commerc_page.dart @@ -47,7 +47,7 @@ class _ElectronicCommercPageState extends State final cancel = BotToast.showLoading(); BaseModel baseModel = await NetUtil().get(API.manager.electronicCommercCategory); - if (baseModel.status == true && baseModel.data != null) { + if (baseModel.success == true && baseModel.data != null) { _models = (baseModel.data as List) .map((e) => ElectronicCommercCategoryModel.fromJson(e)) .toList(); diff --git a/lib/pages/event_activity/voting_detail_page.dart b/lib/pages/event_activity/voting_detail_page.dart index d9d5aa26..4b7ad43a 100644 --- a/lib/pages/event_activity/voting_detail_page.dart +++ b/lib/pages/event_activity/voting_detail_page.dart @@ -275,7 +275,7 @@ class _VotingDetailPageState extends State { } else { BaseModel baseModel = await ManagerFunc.vote(widget.id, _selectId); - if (baseModel.status!) { + if (baseModel.success) { await Get.dialog(_shouwVoteDialog()); _hasVoted = true; setState(() {}); diff --git a/lib/pages/express_packages/express_package_card.dart b/lib/pages/express_packages/express_package_card.dart index 7fe17d62..77f20a25 100644 --- a/lib/pages/express_packages/express_package_card.dart +++ b/lib/pages/express_packages/express_package_card.dart @@ -134,10 +134,10 @@ class _ExpressPackageCardState extends State { "packageCollectionId": id, }, ); - if (baseModel.status ?? false) { - BotToast.showText(text: baseModel.message ?? '未知错误'); + if (baseModel.success) { + BotToast.showText(text: baseModel.message); } - return baseModel.status; + return baseModel.success; } Widget _rowTile(String assetPath, String titile, Widget content) { diff --git a/lib/pages/geographic_information/geograhic_information.dart b/lib/pages/geographic_information/geograhic_information.dart index faf6b5c3..d5198bf3 100644 --- a/lib/pages/geographic_information/geograhic_information.dart +++ b/lib/pages/geographic_information/geograhic_information.dart @@ -36,7 +36,7 @@ class _GeographicInformationPageState extends State { onRefresh: () async { BaseModel baseModel = await NetUtil().get(API.manager.geographyInformation); - if (baseModel.status! && baseModel.data != null) { + if (baseModel.success && baseModel.data != null) { _model = GeographicInformationModel.fromJson(baseModel.data); } _onload = false; diff --git a/lib/pages/geographic_information/geographic_information_page.dart b/lib/pages/geographic_information/geographic_information_page.dart index b614547d..b4ddfefb 100644 --- a/lib/pages/geographic_information/geographic_information_page.dart +++ b/lib/pages/geographic_information/geographic_information_page.dart @@ -36,7 +36,7 @@ class _GeographicInformationPageState extends State { onRefresh: () async { BaseModel baseModel = await NetUtil().get(API.manager.geographyInformation); - if (baseModel.status! && baseModel.data != null) { + if (baseModel.success && baseModel.data != null) { _model = GeographicInformationModel.fromJson(baseModel.data); } _onload = false; diff --git a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart index c3f316a6..4f176506 100644 --- a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart +++ b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart @@ -444,7 +444,7 @@ class _DetoCreatePageState extends State { .uploadFiles(_files, API.upload.uploadRepair); BaseModel baseModel = await ManagerFunc.articleOutSubmit( id: BeeParse.getEstateNameId( - userProvider.userDetailModel!.estateNames![0]), + userProvider.myHouseInfo!.communityName), name: _itemName, weight: _selectWeight! + 1, approach: _selectApproach + 1, @@ -452,10 +452,10 @@ class _DetoCreatePageState extends State { time: datetime, urls: urls, ); - if (baseModel.status!) { + if (baseModel.success) { Get.back(); } else - BotToast.showText(text: baseModel.message!); + BotToast.showText(text: baseModel.message); cancel(); } : () { diff --git a/lib/pages/goods_deto_page/widget/goods_info_card_button.dart b/lib/pages/goods_deto_page/widget/goods_info_card_button.dart index 61da065b..28ecd3c8 100644 --- a/lib/pages/goods_deto_page/widget/goods_info_card_button.dart +++ b/lib/pages/goods_deto_page/widget/goods_info_card_button.dart @@ -96,7 +96,7 @@ class GoodsInfoCardButton extends StatelessWidget { case '查看二维码': ArticleQRModel _model = await ManagerFunc.getQRcode(id); - if (_model.status!) { + if (_model.status ?? false) { Get.to(() => DetoCodePage(id: id, model: _model)); } else { BotToast.showText(text: _model.message!); diff --git a/lib/pages/goods_manage_page/retrun/return_goods_detail_page.dart b/lib/pages/goods_manage_page/retrun/return_goods_detail_page.dart index b6152aa3..cf6e3366 100644 --- a/lib/pages/goods_manage_page/retrun/return_goods_detail_page.dart +++ b/lib/pages/goods_manage_page/retrun/return_goods_detail_page.dart @@ -165,7 +165,7 @@ class _ReturnGoodsDetailPageState extends State { Future getModels() async { BaseModel baseModel = await NetUtil().get(API.manager.articleReturnList); - if (baseModel.status! && baseModel.data != null) { + if (baseModel.success && baseModel.data != null) { return (baseModel.data as List) .map((e) => ArticleReturnListModel.fromJson(e)) .toList(); diff --git a/lib/pages/life_pay/life_pay_page.dart b/lib/pages/life_pay/life_pay_page.dart index e951f4d5..1c1ce5f3 100644 --- a/lib/pages/life_pay/life_pay_page.dart +++ b/lib/pages/life_pay/life_pay_page.dart @@ -207,9 +207,9 @@ class _LifePayPageState extends State { "payType": 1, //暂时写死 等待后续补充 "payPrice": total.payTotal.toDoubleStringAsFixed() }); - if (baseModel.status ?? false) { + if (baseModel.success) { bool result = await PayUtil() - .callAliPay(baseModel.message!, API.pay.dailPayMentCheck); + .callAliPay(baseModel.message, API.pay.dailPayMentCheck); if (result) { Get.off(() => PayFinishPage()); } @@ -263,7 +263,7 @@ class _LifePayPageState extends State { await NetUtil().get(API.manager.dailyPaymentPrePay, params: { "estateId": UserTool.appProveider.selectedHouse!.estateId, }); - if (baseModel.status ?? false) { + if (baseModel.success) { return (baseModel.data as num).toDouble(); } else { return 0; diff --git a/lib/pages/life_pay/life_pre_pay_page.dart b/lib/pages/life_pay/life_pre_pay_page.dart index 6c1ff765..0a044ff9 100644 --- a/lib/pages/life_pay/life_pre_pay_page.dart +++ b/lib/pages/life_pay/life_pre_pay_page.dart @@ -161,14 +161,14 @@ class _LifePrePayPageState extends State { "payType": 1, "payPrice": _editingController.text }); - if (baseModel.status ?? false) { + if (baseModel.success) { bool result = await PayUtil().callAliPay( - baseModel.message!, API.pay.dailPaymentPrePayCheck); + baseModel.message, API.pay.dailPaymentPrePayCheck); if (result) { Get.off(() => PayFinishPage()); } } else { - BotToast.showText(text: baseModel.message ?? ""); + BotToast.showText(text: baseModel.message); } } catch (e) { LoggerData.addData(e); diff --git a/lib/pages/message_center_page/system_message/system_message_page.dart b/lib/pages/message_center_page/system_message/system_message_page.dart index 3390f876..799c058b 100644 --- a/lib/pages/message_center_page/system_message/system_message_page.dart +++ b/lib/pages/message_center_page/system_message/system_message_page.dart @@ -57,8 +57,8 @@ class _SystemMessagePageState extends State { children: [ '系统通知'.text.black.bold.size(32.sp).make(), Spacer(), - BeeMap.messageRead[model.status!]!.text - .color(BeeMap.messageIsRead[model.status!]! + BeeMap.messageRead[model.status]!.text + .color(BeeMap.messageIsRead[model.status]! ? Color(0xFF999999) : Colors.red) .size(32.sp) diff --git a/lib/pages/opening_code_page/opening_code_page.dart b/lib/pages/opening_code_page/opening_code_page.dart index e023de4a..2a7cc5f6 100644 --- a/lib/pages/opening_code_page/opening_code_page.dart +++ b/lib/pages/opening_code_page/opening_code_page.dart @@ -50,7 +50,7 @@ class _OpeningCodePageState extends State { _currentTime.add(Duration(seconds: seconds)), format: 'yyyy/MM/dd HH:mm:ss'), }); - if ((baseModel.status ?? false) && baseModel.data != null) { + if ((baseModel.success) && baseModel.data != null) { _qrCode = baseModel.data; _onload = false; _overDate = false; diff --git a/lib/pages/personal/clock_in/clock_in_page.dart b/lib/pages/personal/clock_in/clock_in_page.dart index 76be7345..41ad7bfe 100644 --- a/lib/pages/personal/clock_in/clock_in_page.dart +++ b/lib/pages/personal/clock_in/clock_in_page.dart @@ -67,11 +67,12 @@ class _ClockInPageState extends State { child: ClipOval( child: FadeInImage.assetNetwork( placeholder: Assets.images.placeholder.path, - image: API.image(UserTool - .userProvider.userInfoModel!.imgUrls.isNotEmpty - ? UserTool - .userProvider.userInfoModel!.imgUrls.first.url - : ''), + image: API.image( + (UserTool.userProvider.userInfoModel?.imgUrls ?? []) + .isNotEmpty + ? UserTool + .userProvider.userInfoModel!.imgUrls.first.url + : ''), height: 106.w, width: 106.w, fit: BoxFit.cover, diff --git a/lib/pages/personal/personal_page.dart b/lib/pages/personal/personal_page.dart index 22f4e9e7..b15cfd5f 100644 --- a/lib/pages/personal/personal_page.dart +++ b/lib/pages/personal/personal_page.dart @@ -220,8 +220,8 @@ class _PersonalIndexState extends State body: EasyRefresh( header: MaterialHeader(), onRefresh: () async { - await userProvider.updateProfile(); - await userProvider.updateUserDetail(); + await userProvider.updateUserInfo(); + await userProvider.updateMyHouseInfo(); }, child: Stack( children: [ @@ -513,19 +513,12 @@ class _PersonalIndexState extends State mainAxisAlignment: MainAxisAlignment.center, children: [ _function( - '我的房屋', - R.ASSETS_ICONS_ICON_MY_HOUSE_PNG, - () => HouseOwnersPage( - identify: - UserTool.userProvider.userDetailModel?.type ?? - 4, - ), - userProvider.userDetailModel!.estateNames!.isEmpty - ? '' - : userProvider - .userDetailModel!.estateNames?[0] ?? - '', - ), + '我的房屋', + R.ASSETS_ICONS_ICON_MY_HOUSE_PNG, + () => HouseOwnersPage( + identify: 4, + ), + userProvider.myHouseInfo?.communityName ?? ''), 36.hb, _function('我的车位', R.ASSETS_ICONS_ICON_MY_CARSEAT_PNG, () => CarParkingPage(), ''), diff --git a/lib/pages/personal/user_func.dart b/lib/pages/personal/user_func.dart index 4d0612d0..ec58be11 100644 --- a/lib/pages/personal/user_func.dart +++ b/lib/pages/personal/user_func.dart @@ -29,7 +29,7 @@ class Userfunc { 'isDefault': isDefault }, showMessage: false); - if (model.status ?? false) { + if (model.success) { BotToast.showText(text: '添加成功'); return true; } else { @@ -51,7 +51,7 @@ class Userfunc { 'isDefault': isDefault }, showMessage: false); - if (model.status ?? false) { + if (model.success) { BotToast.showText(text: '修改成功'); return true; } else { @@ -64,7 +64,7 @@ class Userfunc { static Future deleteAddress(int addressId) async { BaseModel model = await NetUtil().post(API.user.deleteAddress, params: {'addressId': addressId}, showMessage: false); - if (model.status ?? false) { + if (model.success) { BotToast.showText(text: '删除成功'); return true; } else { @@ -77,7 +77,7 @@ class Userfunc { static Future setIsDefaultAddress(int addressId) async { BaseModel model = await NetUtil().post(API.user.settingDefaultAddress, params: {'addressId': addressId}, showMessage: false); - if (model.status ?? false) { + if (model.success) { BotToast.showText(text: '设置成功'); return true; } else { diff --git a/lib/pages/personal/user_profile_page.dart b/lib/pages/personal/user_profile_page.dart index a010a495..d48c86a4 100644 --- a/lib/pages/personal/user_profile_page.dart +++ b/lib/pages/personal/user_profile_page.dart @@ -72,7 +72,7 @@ class _UserProfilePageState extends State { Function cancel = BotToast.showLoading(); BaseFileModel model = await NetUtil().upload(API.upload.uploadAvatar, file); - if (model.status!) + if (model.status ?? false) userProvider.updateAvatar(model.url); else BotToast.showText(text: model.message!); @@ -109,7 +109,7 @@ class _UserProfilePageState extends State { FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, image: API.image( - userProvider.userInfoModel!.imgUrls.isNotEmpty + (userProvider.userInfoModel?.imgUrls ?? []).isNotEmpty ? userProvider.userInfoModel?.imgUrls.first.url : ''), height: 56.w, @@ -166,7 +166,7 @@ class _UserProfilePageState extends State { ), _buildTile( '出生日期', - userProvider.userInfoModel!.birthdayValue.text.make(), + 'userProvider.userInfoModel!.birthdayValue'.text.make(), onPressed: () async { DateTime? date = await BeeDatePicker.pick(DateTime.now()); if (date != null) userProvider.setBirthday(date); diff --git a/lib/pages/property/property_func.dart b/lib/pages/property/property_func.dart index 3ee13a63..3a88eb57 100644 --- a/lib/pages/property/property_func.dart +++ b/lib/pages/property/property_func.dart @@ -10,7 +10,7 @@ class PropertyFunc { await NetUtil().get(API.manager.dailyPaymentPrePay, params: { "estateId": UserTool.appProveider.selectedHouse!.estateId, }); - if (baseModel.status ?? false) { + if (baseModel.success) { return (baseModel.data as num).toDouble(); } else { return 0; @@ -23,7 +23,7 @@ class PropertyFunc { await NetUtil().get(API.manager.findUnpaidAmount, params: { "estateId": UserTool.appProveider.selectedHouse!.estateId, }); - if (baseModel.status ?? false) { + if (baseModel.success) { return (baseModel.data as num).toDouble(); } else { return 0; diff --git a/lib/pages/property/property_page.dart b/lib/pages/property/property_page.dart index 55d733d0..4dcd6092 100644 --- a/lib/pages/property/property_page.dart +++ b/lib/pages/property/property_page.dart @@ -8,7 +8,6 @@ import 'package:aku_new_community/provider/user_provider.dart'; import 'package:aku_new_community/ui/profile/house/add_house_page.dart'; import 'package:aku_new_community/ui/profile/house/house_owners_page.dart'; import 'package:aku_new_community/utils/headers.dart'; -import 'package:aku_new_community/widget/others/user_tool.dart'; import 'package:aku_new_community/widget/views/application_view.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; @@ -169,10 +168,7 @@ class _PropertyPageState extends State ), Spacer(), Text( - userProvider.userDetailModel!.estateNames!.isEmpty - ? '暂未绑定' - : userProvider.userDetailModel!.estateNames?[0] ?? - '暂未绑定', + userProvider.myHouseInfo!.communityName, style: TextStyle( fontSize: 28.sp, color: Colors.white.withOpacity(0.85), @@ -183,8 +179,7 @@ class _PropertyPageState extends State GestureDetector( onTap: () { Get.to(HouseOwnersPage( - identify: - UserTool.userProvider.userDetailModel!.type ?? 4, + identify: 4, )); }, child: Container( @@ -419,8 +414,8 @@ class _PropertyPageState extends State body: EasyRefresh( header: MaterialHeader(), onRefresh: () async { - await userProvider.updateProfile(); - await userProvider.updateUserDetail(); + await userProvider.updateUserInfo(); + await userProvider.updateMyHouseInfo(); }, child: CustomScrollView( slivers: [ diff --git a/lib/pages/renovation_manage/new_renovation/new_renovation_add_page.dart b/lib/pages/renovation_manage/new_renovation/new_renovation_add_page.dart index f7c4dc90..37fb1409 100644 --- a/lib/pages/renovation_manage/new_renovation/new_renovation_add_page.dart +++ b/lib/pages/renovation_manage/new_renovation/new_renovation_add_page.dart @@ -73,7 +73,7 @@ class _NewRenovationAddPageState extends State { }, showMessage: true); - if (baseModel.status ?? false) { + if (baseModel.success) { Get.back(); } } else { diff --git a/lib/pages/renovation_manage/new_renovation/new_renovation_card.dart b/lib/pages/renovation_manage/new_renovation/new_renovation_card.dart index e5327594..9cf454cc 100644 --- a/lib/pages/renovation_manage/new_renovation/new_renovation_card.dart +++ b/lib/pages/renovation_manage/new_renovation/new_renovation_card.dart @@ -139,7 +139,7 @@ class _NewRenovationCardState extends State { "userDecorationNewId": widget.model.id, }, showMessage: true); - if (baseModel.status ?? false) { + if (baseModel.success) { widget.callRefresh(); } }) diff --git a/lib/pages/share_pay_page/share_pay_page.dart b/lib/pages/share_pay_page/share_pay_page.dart index 1ca5431e..77fc1d7d 100644 --- a/lib/pages/share_pay_page/share_pay_page.dart +++ b/lib/pages/share_pay_page/share_pay_page.dart @@ -196,9 +196,9 @@ class _SharePayPageState extends State { "payType": 1, //暂时写死 等待后续补充 "payPrice": total.payTotal.toDoubleStringAsFixed() }); - if (baseModel.status ?? false) { + if (baseModel.success) { bool result = await PayUtil() - .callAliPay(baseModel.message!, API.pay.sharePayOrderCodeCheck); + .callAliPay(baseModel.message, API.pay.sharePayOrderCodeCheck); if (result) { Get.off(() => PayFinishPage()); } @@ -252,7 +252,7 @@ class _SharePayPageState extends State { // await NetUtil().get(API.manager.dailyPaymentPrePay, params: { // "estateId": UserTool.appProveider.selectedHouse!.estateId, // }); - // if (baseModel.status ?? false) { + // if (baseModel.success) { // return (baseModel.data as num).toDouble(); // } else { // return 0; diff --git a/lib/pages/sign/login/code_message_page.dart b/lib/pages/sign/login/code_message_page.dart new file mode 100644 index 00000000..967d8e09 --- /dev/null +++ b/lib/pages/sign/login/code_message_page.dart @@ -0,0 +1,137 @@ +import 'package:aku_new_community/pages/sign/sign_func.dart'; +import 'package:aku_new_community/widget/bee_scaffold.dart'; +import 'package:aku_new_community/widget/others/user_tool.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:sms_autofill/sms_autofill.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class CodeMessagePage extends StatefulWidget { + final String tel; + + const CodeMessagePage({Key? key, required this.tel}) : super(key: key); + + @override + _CodeMessagePageState createState() => _CodeMessagePageState(); +} + +class _CodeMessagePageState extends State { + String? _errorMessage; + TextEditingController _controller = TextEditingController(); + + @override + void initState() { + Future.delayed(Duration(milliseconds: 0), () async { + await SmsAutoFill().listenForCode(); + }); + super.initState(); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '', + body: SafeArea( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 48.w, vertical: 24.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 46.w.heightBox, + '请输入验证码' + .text + .size(36.sp) + .color(Colors.black.withOpacity(0.65)) + .bold + .make(), + 16.w.heightBox, + _errorMessage == null + ? '${_errorMessage}'.text.color(Colors.red).size(28.sp).make() + : '验证码已发送至' + .richText + .withTextSpanChildren([ + '${widget.tel}' + .textSpan + .size(28.sp) + .color(Color(0xFFCF1322).withOpacity(0.8)) + .make(), + ]) + .size(28.sp) + .color(Colors.black.withOpacity(0.45)) + .make(), + 80.w.heightBox, + PinFieldAutoFill( + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + codeLength: 6, + onCodeChanged: (code) async { + if (code!.length >= 6) { + var re = await SignFunc.loginBySms( + widget.tel, + code, + UserTool.appProveider.pickedCityAndCommunity! + .communityModel!.id); + if (re.data['success']) { + UserTool.userProvider.setLogin(re.data['data']); + var success = + await UserTool.userProvider.updateUserInfo(); + if (!success) { + return; + } + } else { + _errorMessage = re.data['message']; + BotToast.showText(text: re.data['message']); + _controller.clear(); + } + } + }, + decoration: UnderlineDecoration( + colorBuilder: FixedColorListBuilder([ + Colors.black.withOpacity(0.3), + Colors.black.withOpacity(0.3), + Colors.black.withOpacity(0.3), + Colors.black.withOpacity(0.3), + Colors.black.withOpacity(0.3), + Colors.black.withOpacity(0.3), + ])), + ), + 24.w.heightBox, + Row( + children: [ + Spacer(), + TextButton( + onPressed: () async { + var base = await SignFunc.sendMessageCode( + widget.tel, + UserTool.appProveider.pickedCityAndCommunity! + .communityModel!.id); + if (base.success) { + _errorMessage = null; + UserTool.appProveider.startTimer(); + } else { + BotToast.showText(text: base.message); + } + }, + child: (UserTool.appProveider.second >= 60 + ? '重新发送验证码' + : '${UserTool.appProveider.second}秒后可重新发送') + .text + .size(28.sp) + .color(Color(0xFF5096F1)) + .make()), + ], + ) + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/sign/login/login_page.dart b/lib/pages/sign/login/login_page.dart index b6075407..2f7cbd1f 100644 --- a/lib/pages/sign/login/login_page.dart +++ b/lib/pages/sign/login/login_page.dart @@ -1,9 +1,12 @@ import 'package:aku_new_community/base/base_style.dart'; +import 'package:aku_new_community/pages/sign/login/other_login_page.dart'; import 'package:aku_new_community/pages/sign/login/select_community.dart'; +import 'package:aku_new_community/provider/app_provider.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:flutter/material.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'; class LoginPage extends StatefulWidget { @@ -30,17 +33,7 @@ class _LoginPageState extends State { Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - GestureDetector( - onTap: () { - Get.to(() => SelectCommunity()); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - '请先选择小区'.text.size(32.sp).color(Color(0xFF5096F1)).make() - ], - ), - ), + CommunityWidget(), 80.w.heightBox, '${'1547***93018'}' .text @@ -61,7 +54,9 @@ class _LoginPageState extends State { ), 24.w.heightBox, InkWell( - onTap: () {}, + onTap: () { + Get.to(() => OtherLoginPage()); + }, child: Text( '其他登录方式', style: TextStyle( @@ -73,29 +68,79 @@ class _LoginPageState extends State { ], ), Spacer(), - RichText( - text: TextSpan( - style: TextStyle( - fontSize: 24.sp, - color: ktextSubColor, - ), - text: '注册/登记即代表同意', - children: [ - WidgetSpan( - child: InkWell( - onTap: () { - //TODO:跳转隐私政策 - }, - child: '《小蜜蜂隐私政策及用户协议》' - .text - .size(24.sp) - .color(Color(0xFF5096F1)) - .make(), - )), - ])), + BottomTip(), ], ), ), ); } } + +class BottomTip extends StatelessWidget { + const BottomTip({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.only(bottom: 100.w), + child: RichText( + text: TextSpan( + style: TextStyle( + fontSize: 24.sp, + color: ktextSubColor, + ), + text: '注册/登记即代表同意', + children: [ + WidgetSpan( + child: InkWell( + onTap: () { + //TODO:跳转隐私政策 + }, + child: '《小蜜蜂隐私政策及用户协议》' + .text + .size(24.sp) + .color(Color(0xFF5096F1)) + .make(), + )), + ])), + ); + } +} + +class CommunityWidget extends StatelessWidget { + final MainAxisAlignment? align; + + const CommunityWidget({ + Key? key, + this.align, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + AppProvider appProveider = Provider.of(context, listen: true); + return GestureDetector( + onTap: () async { + await Get.to(() => SelectCommunity()); + // setState(); + }, + child: Row( + mainAxisAlignment: align ?? MainAxisAlignment.center, + children: [ + (appProveider.pickedCityAndCommunity != null + ? '${appProveider.pickedCityAndCommunity?.cityModel.district.name ?? ''} ${appProveider.pickedCityAndCommunity!.communityModel!.name}' + : '') + .text + .color(Colors.black) + .make(), + '${appProveider.pickedCityAndCommunity == null ? '请先选择小区' : ' 切换'}' + .text + .size(32.sp) + .color(Color(0xFF5096F1)) + .make(), + ], + ), + ); + } +} diff --git a/lib/pages/sign/login/other_login_page.dart b/lib/pages/sign/login/other_login_page.dart new file mode 100644 index 00000000..e29cf3e1 --- /dev/null +++ b/lib/pages/sign/login/other_login_page.dart @@ -0,0 +1,196 @@ +import 'package:aku_new_community/pages/sign/login/code_message_page.dart'; +import 'package:aku_new_community/pages/sign/login/login_page.dart'; +import 'package:aku_new_community/pages/sign/sign_func.dart'; +import 'package:aku_new_community/pages/sign/widget/login_button_widget.dart'; +import 'package:aku_new_community/pages/sign/widget/psd_text_field.dart'; +import 'package:aku_new_community/pages/sign/widget/tel_text_field.dart'; +import 'package:aku_new_community/provider/app_provider.dart'; +import 'package:aku_new_community/widget/bee_scaffold.dart'; +import 'package:aku_new_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_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class OtherLoginPage extends StatefulWidget { + const OtherLoginPage({Key? key}) : super(key: key); + + @override + _OtherLoginPageState createState() => _OtherLoginPageState(); +} + +class _OtherLoginPageState extends State { + PageController _controller = PageController(); + List _tabs = ['账号登录', '验证码登录']; + int _currentIndex = 0; + TextEditingController _tel = TextEditingController(); + TextEditingController _psd = TextEditingController(); + + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + _controller.dispose(); + _tel.dispose(); + _psd.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '', + bodyColor: Colors.white, + body: Column( + children: [ + Row( + children: [ + 24.w.widthBox, + ..._tabs + .mapIndexed((e, index) => _tab(e, index, onTap: (value) { + _currentIndex = value; + _controller.jumpToPage(_currentIndex); + setState(() {}); + })) + .toList(), + ], + ), + Flexible( + child: PageView( + controller: _controller, + children: [_accountView(), _verificationView()], + ), + ), + BottomTip(), + ], + ), + ); + } + + Widget _accountView() { + return ListView( + padding: EdgeInsets.symmetric(horizontal: 32.w), + children: [ + 140.w.heightBox, + CommunityWidget( + align: MainAxisAlignment.start, + ), + 40.w.heightBox, + TelTextField( + controller: _tel, + ), + 40.w.heightBox, + PsdTextField( + controller: _psd, + ), + 100.w.heightBox, + LoginButtonWidget( + onTap: () async { + var check = checkInput(); + if (!check) { + return; + } + var cancel = BotToast.showLoading(); + var response = await SignFunc.login( + _tel.text, + _psd.text, + UserTool + .appProveider.pickedCityAndCommunity!.communityModel!.id); + if (response.data['success']) { + UserTool.userProvider.setLogin(response.data['data']); + var success = await UserTool.userProvider.updateUserInfo(); + if (!success) { + return; + } + } else { + BotToast.showText(text: response.data['message']); + } + cancel(); + }, + text: '登录'), + ], + ); + } + + bool checkInput() { + if (!RegexUtil.isTel(_tel.text)) { + BotToast.showText(text: '请输入正确的手机号!'); + return false; + } + if (UserTool.appProveider.pickedCityAndCommunity == null) { + BotToast.showText(text: '请先选择小区!'); + return false; + } + return true; + } + + Widget _verificationView() { + AppProvider appProvider = Provider.of(context); + return ListView( + padding: EdgeInsets.symmetric(horizontal: 32.w), + children: [ + 140.w.heightBox, + CommunityWidget( + align: MainAxisAlignment.start, + ), + 40.w.heightBox, + TelTextField(controller: _tel), + 100.w.heightBox, + LoginButtonWidget( + onTap: () async { + var check = checkInput(); + if (!check) { + return; + } + var base = await SignFunc.sendMessageCode( + _tel.text, + UserTool + .appProveider.pickedCityAndCommunity!.communityModel!.id); + if (base.success) { + Get.to(() => CodeMessagePage(tel: _tel.text)); + appProvider.startTimer(); + } else { + BotToast.showText(text: base.message); + } + }, + text: appProvider.timerStart + ? '${appProvider.second}秒后重新获取' + : '获取验证码'), + 24.w.heightBox, + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + '未注册的手机验证后会自动创建账号' + .text + .size(28.sp) + .color(Colors.black.withOpacity(0.25)) + .make(), + ], + ), + ], + ); + } + + Widget _tab(String text, int index, {required Function(int) onTap}) { + return GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () => onTap(index), + child: Container( + padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), + alignment: Alignment.center, + child: text.text + .size(_currentIndex == index ? 36.sp : 32.sp) + .lineHeight(_currentIndex == index ? 1.2 : 1.2) + .color( + Colors.black.withOpacity(_currentIndex == index ? 0.65 : 0.45)) + .make(), + ), + ); + } +} diff --git a/lib/pages/sign/login/psd_verify.dart b/lib/pages/sign/login/psd_verify.dart new file mode 100644 index 00000000..98751447 --- /dev/null +++ b/lib/pages/sign/login/psd_verify.dart @@ -0,0 +1,36 @@ +import 'package:flustars/flustars.dart'; + +enum PSDVERIFY { shorLength, Insufficient, different, correct, empty } + +class PsdVerify { + //检测含有字母、数字、符号中两种的正则表达式 + static String reg = r'^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).*'; + static PSDVERIFY check(String psd, String confirmPsd) { + if (psd.isEmpty || confirmPsd.isEmpty) { + return PSDVERIFY.empty; + } else if (psd != confirmPsd) { + return PSDVERIFY.different; + } else if (psd.length < 6) { + return PSDVERIFY.shorLength; + } else if (!RegexUtil.matches(reg, psd)) { + return PSDVERIFY.Insufficient; + } else { + return PSDVERIFY.correct; + } + } + + static String checkString(PSDVERIFY enu) { + switch (enu) { + case PSDVERIFY.shorLength: + return '密码不能小于6位'; + case PSDVERIFY.Insufficient: + return '密码至少由两种类型组成'; + case PSDVERIFY.different: + return '您输入的确认密码和新密码不一致,请检查后重新输入'; + case PSDVERIFY.correct: + return ''; + case PSDVERIFY.empty: + return ''; + } + } +} diff --git a/lib/pages/sign/login/select_community.dart b/lib/pages/sign/login/select_community.dart index 75af528e..e75fac50 100644 --- a/lib/pages/sign/login/select_community.dart +++ b/lib/pages/sign/login/select_community.dart @@ -1,8 +1,9 @@ import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/models/login/community_model.dart'; -import 'package:aku_new_community/models/login/picked_city_model.dart'; +import 'package:aku_new_community/models/login/history_login_model.dart'; import 'package:aku_new_community/utils/network/net_util.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_city_picker.dart'; import 'package:aku_new_community/widget/picker/bee_community_picker.dart'; import 'package:bot_toast/bot_toast.dart'; @@ -21,22 +22,24 @@ class SelectCommunity extends StatefulWidget { } class _SelectCommunityState extends State { - PickedCityModel? _model; - CommunityModel? _community; - String get cityName { + var _model = UserTool.appProveider.pickedCityAndCommunity; if (_model == null) { return '请选择省、市、县/区'; } else { - return _model!.province.name + _model!.city.name + _model!.district.name; + return _model.cityModel.province.name + + _model.cityModel.city.name + + _model.cityModel.district.name; } } String get communityName { + var _community = + UserTool.appProveider.pickedCityAndCommunity?.communityModel; if (_community == null) { return '请选择小区'; } else { - return _community!.name; + return _community.name; } } @@ -45,77 +48,143 @@ class _SelectCommunityState extends State { super.initState(); } + @override + void deactivate() { + Future.delayed(Duration(milliseconds: 0), () async { + if (UserTool.appProveider.pickedCityAndCommunity != null && + UserTool.appProveider.pickedCityAndCommunity?.communityModel == + null) { + UserTool.appProveider.resetPickedCity(); + } + }); + super.deactivate(); + } + @override Widget build(BuildContext context) { - return BeeScaffold( - title: '选择登录小区', - body: ListView( + var selectCity = GestureDetector( + onTap: () async { + var _city = await BeeCityPicker.pick(context); + if (_city != null) { + UserTool.appProveider.setPickedCity(city: _city); + } + setState(() {}); + }, + child: Container( + color: Colors.white, + width: double.infinity, + height: 88.w, + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), + child: Row( + children: [ + '选择城市'.text.size(28.sp).black.make(), + Spacer(), + '${cityName}'.text.black.make(), + 32.w.widthBox, + Icon( + CupertinoIcons.right_chevron, + size: 20.w, + ) + ], + ), + ), + ); + var selectCommunity = GestureDetector( + onTap: () async { + var cancel = BotToast.showLoading(); + List _communities = []; + var base = await NetUtil().get(API.login.allCommunity); + if (base.success) { + _communities = (base.data as List) + .map((e) => CommunityModel.fromJson(e)) + .toList(); + } + cancel(); + var _community = await BeeCommunityPicker.pick(context, _communities); + if (_community != null) { + UserTool.appProveider.setPickedCity(community: _community); + } + setState(() {}); + }, + child: Container( + color: Colors.white, + width: double.infinity, + height: 88.w, + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), + child: Row( + children: [ + '选择小区'.text.size(28.sp).black.make(), + Spacer(), + '${communityName}'.text.black.make(), + 32.w.widthBox, + Icon( + CupertinoIcons.right_chevron, + size: 20.w, + ) + ], + ), + ), + ); + var history = Offstage( + offstage: UserTool.dataProvider.loginHistories.length == 0, + child: Container( + width: double.infinity, + color: Colors.white, + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '历史登录'.text.size(28.sp).color(Colors.black.withOpacity(0.2)).make(), + 24.w.widthBox, + ...UserTool.dataProvider.loginHistories + .map((e) => _historyTile(e)) + .toList(), + ], + ), + ), + ); + return WillPopScope( + onWillPop: () async { + var bool = UserTool.appProveider.pickedCityAndCommunity != null && + UserTool.appProveider.pickedCityAndCommunity?.communityModel == + null; + if (bool) { + BotToast.showText(text: '请选择小区'); + return false; + } else { + return true; + } + }, + child: BeeScaffold( + title: '选择登录小区', + body: ListView( + children: [ + selectCity, + selectCommunity, + 10.w.heightBox, + history, + ], + ), + ), + ); + } + + Widget _historyTile(HistoryLoginModel model) { + return Container( + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), + child: Row( children: [ - GestureDetector( - onTap: () async { - _model = await BeeCityPicker.pick(context); - setState(() {}); - }, - child: Container( - color: Colors.white, - width: double.infinity, - height: 88.w, - padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), - child: Row( - children: [ - '选择城市'.text.size(28.sp).black.make(), - Spacer(), - '${cityName}'.text.black.make(), - 32.w.widthBox, - Icon( - CupertinoIcons.right_chevron, - size: 20.w, - ) - ], - ), - ), - ), - GestureDetector( - onTap: () async { - var cancel = BotToast.showLoading(); - List _communities = []; - var base = await NetUtil().get(API.sarsApi.login.allCommunity); - if (base.status ?? false) { - _communities = (base.data as List) - .map((e) => CommunityModel.fromJson(e)) - .toList(); - } - cancel(); - _community = await BeeCommunityPicker.pick(context, _communities); - setState(() {}); - }, - child: Container( - color: Colors.white, - width: double.infinity, - height: 88.w, - padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), - child: Row( - children: [ - '选择小区'.text.size(28.sp).black.make(), - Spacer(), - '${communityName}'.text.black.make(), - 32.w.widthBox, - Icon( - CupertinoIcons.right_chevron, - size: 20.w, - ) - ], - ), - ), - ), - Container( - width: double.infinity, - color: Colors.white, - padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), - child: Column( - children: [], - ), + Icon( + CupertinoIcons.search, + size: 30.w, + color: Colors.black.withOpacity(0.2), ), + 24.w.widthBox, + '${model.communityModel!.name}(${model.cityModel.province.name}·${model.cityModel.city.name}·${model.cityModel.district.name})' + .text + .size(28.sp) + .color(Colors.black.withOpacity(0.2)) + .make(), ], ), ); diff --git a/lib/pages/sign/login/set_psd_page.dart b/lib/pages/sign/login/set_psd_page.dart new file mode 100644 index 00000000..454d7b45 --- /dev/null +++ b/lib/pages/sign/login/set_psd_page.dart @@ -0,0 +1,83 @@ +import 'package:aku_new_community/pages/sign/login/psd_verify.dart'; +import 'package:aku_new_community/pages/sign/widget/login_button_widget.dart'; +import 'package:aku_new_community/pages/sign/widget/psd_text_field.dart'; +import 'package:aku_new_community/widget/bee_scaffold.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class SetPsdPage extends StatefulWidget { + const SetPsdPage({Key? key}) : super(key: key); + + @override + _SetPsdPageState createState() => _SetPsdPageState(); +} + +class _SetPsdPageState extends State { + TextEditingController _psdController = TextEditingController(); + TextEditingController _confirmPsdController = TextEditingController(); + + PSDVERIFY get psdCheck => + PsdVerify.check(_psdController.text, _confirmPsdController.text); + bool _psdVisible = false; + bool _confirmVisible = false; + + @override + void dispose() { + _psdController.dispose(); + _confirmPsdController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '', + bodyColor: Colors.white, + body: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + 24.w.heightBox, + Row( + children: [ + 48.w.widthBox, + '首次登陆,请设置账号密码' + .text + .size(36.sp) + .bold + .color(Colors.black.withOpacity(0.65)) + .make(), + Spacer(), + ], + ), + 16.w.heightBox, + Row( + children: [ + 48.w.widthBox, + '密码需由6-20位数字、字母、或符号组成,至少两种' + .text + .size(28.sp) + .color(Colors.black.withOpacity(0.45)) + .make(), + Spacer(), + ], + ), + 144.w.heightBox, + PsdTextField(controller: _psdController, hintText: '请输入密码'), + 24.w.heightBox, + PsdTextField(controller: _confirmPsdController, hintText: '请再次输入密码'), + 16.w.heightBox, + PsdVerify.checkString(psdCheck) + .text + .size(28.sp) + .color(Color(0xFFCF1322).withOpacity(0.8)) + .make(), + 37.w.heightBox, + LoginButtonWidget( + onTap: psdCheck == PSDVERIFY.correct ? () {} : null, text: '确认'), + ], + ), + ); + } +} diff --git a/lib/pages/sign/sign_func.dart b/lib/pages/sign/sign_func.dart index 60769134..f12e3da3 100644 --- a/lib/pages/sign/sign_func.dart +++ b/lib/pages/sign/sign_func.dart @@ -1,21 +1,29 @@ import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/model/user/pick_building_model.dart'; -import 'package:aku_new_community/model/user/user_detail_model.dart'; +import 'package:aku_new_community/models/user/my_house_model.dart'; import 'package:aku_new_community/models/user/user_info_model.dart'; +import 'package:aku_new_community/pages/sign/login/set_psd_page.dart'; +import 'package:aku_new_community/pages/sign/sign_up/sign_up_set_nickname_page.dart'; import 'package:aku_new_community/provider/sign_up_provider.dart'; import 'package:aku_new_community/provider/user_provider.dart'; import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/utils/network/net_util.dart'; +import 'package:aku_new_community/widget/others/user_tool.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'; +import '../tab_navigator.dart'; + class SignFunc { - static Future sendMessageCode(String phone) async { + //发送手机号验证码 + static Future sendMessageCode( + String phone, int communityId) async { BaseModel baseModel = await NetUtil().post( - API.login.sendSMSCode, - params: {'tel': phone}, + SARSAPI.login.sendSMSCode, + params: {'tel': phone, 'communityId': communityId}, showMessage: true, ); return baseModel; @@ -30,10 +38,30 @@ class SignFunc { return baseModel; } - static Future login(String phone, String code) async { + //登录 + static Future login( + String phone, String code, int communityId) async { Response response = await NetUtil().dio!.post( - API.login.loginBySMS, - data: {'tel': phone, 'code': code}, + API.login.login, + data: { + 'tel': phone, + 'password': code, + 'communityId': communityId, + }, + ); + return response; + } + + //验证码登录 + static Future loginBySms( + String phone, String code, int communityId) async { + Response response = await NetUtil().dio!.post( + API.login.login, + data: { + 'tel': phone, + 'code': code, + 'communityId': communityId, + }, ); return response; } @@ -87,15 +115,25 @@ class SignFunc { static Future getUserInfo() async { BaseModel baseModel = await NetUtil().get(API.user.userProfile); - if (baseModel.data == null) return null; + if (baseModel.data == null || !baseModel.success) return null; return UserInfoModel.fromJson(baseModel.data); } - static Future getUserDetail() async { + static Future getMyHouseInfo() async { BaseModel baseModel = await NetUtil().get( - API.user.userDetail, + SARSAPI.profile.house.userHouse, ); if (baseModel.data == null) return null; - return UserDetailModel.fromJson(baseModel.data); + return MyHouseModel.fromJson(baseModel.data); + } + + static Future checkNameAndAccount() async { + if (!UserTool.userProvider.userInfoModel!.isExistPassword) { + await Get.to(() => SetPsdPage()); + } else if (UserTool.userProvider.userInfoModel!.nickName == null) { + await Get.to(() => SignUpSetNicknamePage()); + } else { + Get.offAll(() => TabNavigator()); + } } } diff --git a/lib/pages/sign/sign_in_page.dart b/lib/pages/sign/sign_in_page.dart index 0390f89b..31e5be7d 100644 --- a/lib/pages/sign/sign_in_page.dart +++ b/lib/pages/sign/sign_in_page.dart @@ -1,21 +1,16 @@ import 'dart:async'; import 'package:aku_new_community/base/base_style.dart'; -import 'package:aku_new_community/pages/sign/sign_func.dart'; -import 'package:aku_new_community/pages/sign/sign_up/sign_up_set_nickname_page.dart'; -import 'package:aku_new_community/pages/tab_navigator.dart'; import 'package:aku_new_community/provider/sign_up_provider.dart'; import 'package:aku_new_community/provider/user_provider.dart'; import 'package:aku_new_community/utils/headers.dart'; import 'package:aku_new_community/widget/bee_back_button.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:bot_toast/bot_toast.dart'; -import 'package:dio/dio.dart'; import 'package:flustars/flustars.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart' hide Response; -import 'package:power_logger/power_logger.dart'; import 'package:provider/provider.dart'; class SignInPage extends StatefulWidget { @@ -55,24 +50,24 @@ class _SignInPageState extends State { Provider.of(Get.context!, listen: false); if (!result) return; CancelFunc cancel = BotToast.showLoading(); - Response response = await SignFunc.login(_phone.text, _code.text); - LoggerData.addData(response); - - if (response.data['status']) { - if (response.data['choose'] == 1) { - userProvider.setLogin(response.data['token']); - cancel(); - Get.offAll(() => TabNavigator()); - } else { - cancel(); - signUpProvider.setTel(_phone.text); - await Get.to(() => SignUpSetNicknamePage()); - signUpProvider.clearAll(); - } - } else { - BotToast.showText(text: response.data['message']); - cancel(); - } + // Response response = await SignFunc.login(_phone.text, _code.text); + // LoggerData.addData(response); + // + // if (response.data['status']) { + // if (response.data['choose'] == 1) { + // userProvider.setLogin(response.data['token']); + // cancel(); + // Get.offAll(() => TabNavigator()); + // } else { + // cancel(); + // signUpProvider.setTel(_phone.text); + // await Get.to(() => SignUpSetNicknamePage()); + // signUpProvider.clearAll(); + // } + // } else { + // BotToast.showText(text: response.data['message']); + // cancel(); + // } } Widget _inkWellLogin() { @@ -235,7 +230,7 @@ class _SignInPageState extends State { ), onPressed: _canGetCode ? () { - SignFunc.sendMessageCode(_phone.text); + // SignFunc.sendMessageCode(_phone.text); startTick(); } : null, diff --git a/lib/pages/sign/widget/login_button_widget.dart b/lib/pages/sign/widget/login_button_widget.dart new file mode 100644 index 00000000..27a471e7 --- /dev/null +++ b/lib/pages/sign/widget/login_button_widget.dart @@ -0,0 +1,30 @@ +import 'package:aku_new_community/base/base_style.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class LoginButtonWidget extends StatelessWidget { + final VoidCallback? onTap; + final String text; + const LoginButtonWidget({Key? key, required this.onTap, required this.text}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialButton( + minWidth: 686.w, + height: 97.w, + onPressed: onTap, + elevation: 0, + child: Text( + text, + style: TextStyle( + fontSize: 32.sp, + ), + ), + disabledTextColor: Colors.black.withOpacity(0.45), + disabledColor: Colors.black.withOpacity(0.06), + color: kPrimaryColor, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(60.w)), + ); + } +} diff --git a/lib/pages/sign/widget/psd_text_field.dart b/lib/pages/sign/widget/psd_text_field.dart new file mode 100644 index 00000000..75bc50f8 --- /dev/null +++ b/lib/pages/sign/widget/psd_text_field.dart @@ -0,0 +1,66 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class PsdTextField extends StatefulWidget { + final TextEditingController controller; + final String? hintText; + + const PsdTextField({ + Key? key, + required this.controller, + this.hintText, + }) : super(key: key); + + @override + _PsdTextFieldState createState() => _PsdTextFieldState(); +} + +class _PsdTextFieldState extends State { + bool visible = false; + + @override + Widget build(BuildContext context) { + return Container( + width: 686.w, + height: 94.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(60.w), + color: Colors.black.withOpacity(0.06), + ), + child: TextField( + maxLength: 20, + onChanged: (text) { + setState(() {}); + }, + controller: widget.controller, + obscureText: !visible, + obscuringCharacter: '*', + decoration: InputDecoration( + isDense: false, + contentPadding: + EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), + border: InputBorder.none, + hintText: widget.hintText ?? '请输入密码', + counterText: '', + suffixIconConstraints: + BoxConstraints(minHeight: 50.w, maxHeight: 50.w), + suffixIcon: GestureDetector( + onTap: () { + visible = !visible; + setState(() {}); + }, + child: Padding( + padding: EdgeInsets.only(right: 20.w), + child: Icon( + visible ? CupertinoIcons.eye : CupertinoIcons.eye_slash, + color: Colors.black.withOpacity(0.4), + ), + ), + ), + hintStyle: TextStyle( + color: Colors.black.withOpacity(0.25), fontSize: 28.sp)), + ), + ); + } +} diff --git a/lib/pages/sign/widget/tel_text_field.dart b/lib/pages/sign/widget/tel_text_field.dart new file mode 100644 index 00000000..9f1bb897 --- /dev/null +++ b/lib/pages/sign/widget/tel_text_field.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class TelTextField extends StatefulWidget { + final TextEditingController controller; + const TelTextField({Key? key, required this.controller}) : super(key: key); + + @override + _TelTextFieldState createState() => _TelTextFieldState(); +} + +class _TelTextFieldState extends State { + @override + Widget build(BuildContext context) { + return Container( + width: 686.w, + height: 94.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(60.w), + color: Colors.black.withOpacity(0.06), + ), + child: TextField( + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + keyboardType: TextInputType.number, + controller: widget.controller, + decoration: InputDecoration( + isDense: true, + border: InputBorder.none, + prefixIcon: Center(child: '+86|'.text.black.make()), + prefixIconConstraints: BoxConstraints.loose(Size(60, 60)), + contentPadding: EdgeInsets.symmetric(vertical: 30.w), + hintText: '点击输入手机号', + hintStyle: + TextStyle(color: Colors.black.withOpacity(0.25), fontSize: 28.sp), + ), + ), + ); + } +} diff --git a/lib/pages/things_page/fixed_submit_page.dart b/lib/pages/things_page/fixed_submit_page.dart index b86db854..d1328df1 100644 --- a/lib/pages/things_page/fixed_submit_page.dart +++ b/lib/pages/things_page/fixed_submit_page.dart @@ -104,7 +104,7 @@ class _FixedSubmitPageState extends State { .size(32.sp) .make(), Spacer(), - BeeMap.fixState[model.status!]!.text + BeeMap.fixState[model.status]!.text .color(_getColor(model.status)) .size(24.sp) .make(), 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 7db9a56d..07689f93 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -195,10 +195,10 @@ class _AddFixedSubmitPageState extends State { _selectType! + 1, _textEditingController!.text, urls); - if (baseModel.status!) { + if (baseModel.success) { Get.off(() => FinishFixedSubmitPage()); } else - BotToast.showText(text: baseModel.message!); + BotToast.showText(text: baseModel.message); cancel(); } : () { diff --git a/lib/pages/things_page/widget/fixed_detail_page.dart b/lib/pages/things_page/widget/fixed_detail_page.dart index a8cff4c0..d6291b1a 100644 --- a/lib/pages/things_page/widget/fixed_detail_page.dart +++ b/lib/pages/things_page/widget/fixed_detail_page.dart @@ -406,9 +406,9 @@ class _FixedDetailPageState extends State { BaseModel baseModel = await ManagerFunc.reportRepairAlipay( _model.appReportRepairVo.id, (_model.appMaintenanceResultVo!.totalCost ?? 0).toDouble()); - if ((baseModel.status ?? false) && !baseModel.message.isEmptyOrNull) { + if ((baseModel.success) && !baseModel.message.isEmptyOrNull) { bool result = await PayUtil() - .callAliPay(baseModel.message!, API.pay.reportReapirCheck); + .callAliPay(baseModel.message, API.pay.reportReapirCheck); if (result) { Get.back(); Get.off(() => PayFinishPage()); @@ -424,12 +424,12 @@ class _FixedDetailPageState extends State { Function cancel = BotToast.showLoading(); BaseModel baseModel = await ManagerFunc.reportRepairComplete(_model.appReportRepairVo.id); - if ((baseModel.status ?? false)) { + if ((baseModel.success)) { Get.back(); Get.back(); } else { Get.back(); - BotToast.showText(text: baseModel.message!); + BotToast.showText(text: baseModel.message); } cancel(); } diff --git a/lib/pages/things_page/widget/fixed_evaluate_page.dart b/lib/pages/things_page/widget/fixed_evaluate_page.dart index 957b4c21..ce6fe012 100644 --- a/lib/pages/things_page/widget/fixed_evaluate_page.dart +++ b/lib/pages/things_page/widget/fixed_evaluate_page.dart @@ -112,7 +112,7 @@ class _FixedEvaluatePageState extends State { widget.model.appReportRepairVo.id, _rating, _textEditingController!.text); - if (baseModel.status!) { + if (baseModel.success) { Get.back(); } } diff --git a/lib/pages/visitor_access_page/visitor_access_page.dart b/lib/pages/visitor_access_page/visitor_access_page.dart index f08b0ea6..8b59442d 100644 --- a/lib/pages/visitor_access_page/visitor_access_page.dart +++ b/lib/pages/visitor_access_page/visitor_access_page.dart @@ -360,7 +360,7 @@ class _VisitorAccessPageState extends State { SizedBox(height: 64.w), _create( appProvider.selectedHouse!.estateId, - userProvider.userDetailModel!.type, + 4, _phoneNum.text, ), _tips(), diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart index 3dbbf4d0..090696d3 100644 --- a/lib/provider/app_provider.dart +++ b/lib/provider/app_provider.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:io'; import 'package:aku_new_community/constants/api.dart'; @@ -8,6 +9,9 @@ import 'package:aku_new_community/model/community/hot_topic_model.dart'; import 'package:aku_new_community/model/message/message_center_model.dart'; import 'package:aku_new_community/model/user/adress_model.dart'; import 'package:aku_new_community/model/user/car_parking_model.dart'; +import 'package:aku_new_community/models/login/community_model.dart'; +import 'package:aku_new_community/models/login/history_login_model.dart'; +import 'package:aku_new_community/models/login/picked_city_model.dart'; import 'package:aku_new_community/models/user/passed_house_list_model.dart'; import 'package:aku_new_community/utils/hive_store.dart'; import 'package:aku_new_community/utils/network/base_model.dart'; @@ -327,4 +331,48 @@ class AppProvider extends ChangeNotifier { } notifyListeners(); } + + HistoryLoginModel? _pickedCityAndCommunity; + + HistoryLoginModel? get pickedCityAndCommunity => _pickedCityAndCommunity; + + void setPickedCity({PickedCityModel? city, CommunityModel? community}) { + if (city != null) { + _pickedCityAndCommunity = HistoryLoginModel(cityModel: city); + } + if (community != null) { + _pickedCityAndCommunity!.communityModel = community; + } + } + + void resetPickedCity() { + _pickedCityAndCommunity = null; + notifyListeners(); + } + + int second = 60; + bool timerStart = false; + Timer? timer; + + void startTimer() { + timerStart = true; + timer = Timer.periodic(Duration(seconds: 1), (timer) { + if (second > 0) { + second--; + notifyListeners(); + } else { + stopTimer(); + } + }); + } + + void stopTimer() { + second = 60; + timerStart = false; + timer?.cancel(); + timer = null; + notifyListeners(); + } + + notifyListeners(); } diff --git a/lib/provider/data_provider.dart b/lib/provider/data_provider.dart index 085d344f..10a96e98 100644 --- a/lib/provider/data_provider.dart +++ b/lib/provider/data_provider.dart @@ -1,4 +1,4 @@ -import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; 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'; @@ -9,9 +9,10 @@ class DataProvider extends ChangeNotifier { Future init() async { updateCityList(); _loginHistories = HiveStore.dataBox! - .get('historyLogin') - .cast() - .toList(); + .get('historyLogin') + ?.cast() + .toList() ?? + []; } List _cityModel = []; @@ -19,8 +20,8 @@ class DataProvider extends ChangeNotifier { List get cityModel => _cityModel; Future updateCityList() async { - var model = await NetUtil().get(API.sarsApi.city.allCity); - if (model.status ?? false) { + var model = await NetUtil().get(SARSAPI.city.allCity); + if (model.success) { _cityModel = (model.data as List) .map((e) => ChinaRegionModel.fromJson(e)) .toList(); diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 65cc88e9..46e1842d 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:aku_new_community/constants/api.dart'; -import 'package:aku_new_community/model/user/user_detail_model.dart'; +import 'package:aku_new_community/models/user/my_house_model.dart'; import 'package:aku_new_community/models/user/user_config_model.dart'; import 'package:aku_new_community/models/user/user_info_model.dart'; import 'package:aku_new_community/pages/sign/sign_func.dart'; @@ -11,7 +11,7 @@ import 'package:aku_new_community/utils/hive_store.dart'; import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:aku_new_community/utils/websocket/web_socket_util.dart'; -import 'package:aku_new_community/widget/others/user_tool.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flustars/flustars.dart'; import 'package:flutter/foundation.dart'; import 'package:get/get.dart'; @@ -37,8 +37,8 @@ class UserProvider extends ChangeNotifier { .putIfAbsent('App-Admin-Token', () => token); HiveStore.appBox!.put('token', token); HiveStore.appBox!.put('login', true); - await updateProfile(); - await updateUserDetail(); + await updateUserInfo(); + await updateMyHouseInfo(); ///初始化用户配置 _userConfig = await HiveStore.userBox!.get('${_userInfoModel!.id}') ?? @@ -64,7 +64,7 @@ class UserProvider extends ChangeNotifier { _isLogin = false; _token = null; _userInfoModel = null; - _userDetailModel = null; + _myHouseInfo = null; NetUtil().get(API.user.logout, showMessage: true); NetUtil().dio!.options.headers.remove('App-Admin-Token'); HiveStore.appBox!.delete('token'); @@ -74,18 +74,23 @@ class UserProvider extends ChangeNotifier { notifyListeners(); } - Future updateProfile() async { + Future updateUserInfo() async { _userInfoModel = await SignFunc.getUserInfo(); - if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) {} + if (_userInfoModel == null) { + BotToast.showText(text: '获取用户信息失败'); + return false; + } + if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) { + SignFunc.checkNameAndAccount(); + } + notifyListeners(); + return true; } - Future updateUserDetail() async { - UserDetailModel? _model = await SignFunc.getUserDetail(); - if (_model != null) { - _userDetailModel = _model; - UserTool.appProveider.setCurrentHouseId(_model.nowEstateExamineId); - } + Future updateMyHouseInfo() async { + _myHouseInfo = await SignFunc.getMyHouseInfo(); + if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) {} notifyListeners(); } @@ -97,9 +102,9 @@ class UserProvider extends ChangeNotifier { UserInfoModel? get userInfoModel => _userInfoModel; - UserDetailModel? _userDetailModel; + MyHouseModel? _myHouseInfo; - UserDetailModel? get userDetailModel => _userDetailModel; + MyHouseModel? get myHouseInfo => _myHouseInfo; ///设置性别 Future setSex(int sex) async { @@ -108,8 +113,8 @@ class UserProvider extends ChangeNotifier { params: {'sex': sex}, showMessage: true, ); - if (baseModel.status!) { - _userInfoModel!.sex = sex; + if (baseModel.success) { + await updateUserInfo(); notifyListeners(); } } @@ -123,9 +128,9 @@ class UserProvider extends ChangeNotifier { }, showMessage: true, ); - if (baseModel.status!) { - _userInfoModel!.birthday = - DateUtil.formatDate(date, format: "yyyy-MM-dd HH:mm:ss"); + if (baseModel.success) { + // _userInfoModel!.birthday = + // DateUtil.formatDate(date, format: "yyyy-MM-dd HH:mm:ss"); notifyListeners(); } } @@ -137,8 +142,8 @@ class UserProvider extends ChangeNotifier { params: {'nickName': name}, showMessage: true, ); - if (baseModel.status!) { - _userInfoModel!.nickName = name; + if (baseModel.success) { + // _userInfoModel!.nickName = name; notifyListeners(); } } @@ -150,8 +155,8 @@ class UserProvider extends ChangeNotifier { params: {'oldTel': oldTel, 'newTel': newTel, 'code': code}, showMessage: true, ); - if (baseModel.status!) { - _userInfoModel!.tel = newTel; + if (baseModel.success) { + await updateUserInfo(); notifyListeners(); } } @@ -165,8 +170,8 @@ class UserProvider extends ChangeNotifier { }, showMessage: true, ); - if (model.status!) { - await updateProfile(); + if (model.success) { + await updateUserInfo(); } } diff --git a/lib/ui/community/community_views/add_new_event_page.dart b/lib/ui/community/community_views/add_new_event_page.dart index aa2a0bb7..c02f3b61 100644 --- a/lib/ui/community/community_views/add_new_event_page.dart +++ b/lib/ui/community/community_views/add_new_event_page.dart @@ -68,7 +68,7 @@ class _AddNewEventPageState extends State { showMessage: true, ); cancel(); - if (baseModel.status!) { + if (baseModel.success) { Get.back(result: true); } } diff --git a/lib/ui/community/community_views/community_page.dart b/lib/ui/community/community_views/community_page.dart index 1c15cac5..66fa9f15 100644 --- a/lib/ui/community/community_views/community_page.dart +++ b/lib/ui/community/community_views/community_page.dart @@ -23,7 +23,6 @@ import 'package:aku_new_community/utils/login_util.dart'; import 'package:aku_new_community/utils/network/base_list_model.dart'; import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/utils/network/net_util.dart'; -import 'package:aku_new_community/widget/tab_bar/bee_tab_bar.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -189,13 +188,11 @@ class _CommunityPageState extends State 16.hb, ..._newItems .map((e) => ChatCard( - model: e,onDelete:(){ - _easyRefreshController.callRefresh(); - setState(() { - - }); - } - )) + model: e, + onDelete: () { + _easyRefreshController.callRefresh(); + setState(() {}); + })) .toList() ], ), @@ -226,13 +223,11 @@ class _CommunityPageState extends State 16.hb, ..._newItems .map((e) => ChatCard( - model: e,onDelete:() { - _easyRefreshController.callRefresh(); - setState(() { - - }); - } - )) + model: e, + onDelete: () { + _easyRefreshController.callRefresh(); + setState(() {}); + })) .toList() ], ), @@ -303,7 +298,7 @@ class _CommunityPageState extends State final cancel = BotToast.showLoading(); BaseModel model = await NetUtil().get(API.news.category); List? category; - if (model.status == true && model.data != null) { + if (model.success == true && model.data != null) { category = (model.data as List) .map((e) => NewsCategoryModel.fromJson(e)) .toList(); @@ -495,7 +490,7 @@ class _CommunityPageState extends State _geSearch() { return Container( - padding: EdgeInsets.only(bottom: 20.w,left: 32.w,right: 32.w), + padding: EdgeInsets.only(bottom: 20.w, left: 32.w, right: 32.w), color: Colors.white, child: MaterialButton( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, diff --git a/lib/ui/community/facility/facility_preorder_page.dart b/lib/ui/community/facility/facility_preorder_page.dart index 1027b055..45cf7f08 100644 --- a/lib/ui/community/facility/facility_preorder_page.dart +++ b/lib/ui/community/facility/facility_preorder_page.dart @@ -175,7 +175,7 @@ class _FacilityPreorderPageState extends State { }, ); cancel(); - if (model.status == true) { + if (model.success == true) { BotToast.showText(text: '预约成功'); Get.back(result: true); } else if (model.message == '该时段已被预约') { diff --git a/lib/ui/home/public_infomation/public_information_detail_page.dart b/lib/ui/home/public_infomation/public_information_detail_page.dart index 77827b80..b56ec2e6 100644 --- a/lib/ui/home/public_infomation/public_information_detail_page.dart +++ b/lib/ui/home/public_infomation/public_information_detail_page.dart @@ -69,7 +69,7 @@ class _PublicInformationDetailPageState .get(API.manager.getPublicInformationDetail, params: { "newsId": widget.id, }); - if (baseModel.status! && baseModel.data != null) { + if (baseModel.success && baseModel.data != null) { _detailModel = NewsDetailModel.fromJson(baseModel.data); _parasedText = LinkTextParase.stringParase(_detailModel.content); } else { diff --git a/lib/ui/manager/advice/advice_add_comment_page.dart b/lib/ui/manager/advice/advice_add_comment_page.dart index 4d35a337..aa3dc66c 100644 --- a/lib/ui/manager/advice/advice_add_comment_page.dart +++ b/lib/ui/manager/advice/advice_add_comment_page.dart @@ -75,7 +75,7 @@ class _AdviceAddCommentPageState extends State { }, showMessage: true, ); - if (baseModel.status!) { + if (baseModel.success) { Get.back(result: true); } } diff --git a/lib/ui/manager/advice/advice_detail_page.dart b/lib/ui/manager/advice/advice_detail_page.dart index f101d699..fd54871f 100644 --- a/lib/ui/manager/advice/advice_detail_page.dart +++ b/lib/ui/manager/advice/advice_detail_page.dart @@ -219,10 +219,10 @@ class _AdviceDetailPageState extends State { await NetUtil().get(API.manager.completeFeedBack, params: { "adviceId": widget.model!.id, }); - if (baseModel.status ?? false) { + if (baseModel.success) { Get.to(() => AdviceEvaluatePage(id: widget.model!.id)); } - BotToast.showText(text: baseModel.message ?? '未知错误'); + BotToast.showText(text: baseModel.message); }, child: '完成沟通'.text.bold.make(), ), diff --git a/lib/ui/manager/advice/advice_evaluate_page.dart b/lib/ui/manager/advice/advice_evaluate_page.dart index 54d85179..955ba12d 100644 --- a/lib/ui/manager/advice/advice_evaluate_page.dart +++ b/lib/ui/manager/advice/advice_evaluate_page.dart @@ -72,7 +72,7 @@ class _AdviceEvaluatePageState extends State { params: {'id': widget.id, 'score': _rating}, showMessage: true, ); - if (baseModel.status!) { + if (baseModel.success) { Get.back(); Get.back(); } diff --git a/lib/ui/manager/advice/new_advice_page.dart b/lib/ui/manager/advice/new_advice_page.dart index 7ef6ae41..c38f01b2 100644 --- a/lib/ui/manager/advice/new_advice_page.dart +++ b/lib/ui/manager/advice/new_advice_page.dart @@ -105,7 +105,7 @@ class _NewAdvicePageState extends State { showMessage: true, ); cancel(); - if (baseModel.status!) { + if (baseModel.success) { Get.back(result: true); } } diff --git a/lib/ui/manager/house_keeping/house_keeping_func.dart b/lib/ui/manager/house_keeping/house_keeping_func.dart index e1535ca7..2b4462e5 100644 --- a/lib/ui/manager/house_keeping/house_keeping_func.dart +++ b/lib/ui/manager/house_keeping/house_keeping_func.dart @@ -17,7 +17,7 @@ class HouseKeepingFunc { "content": content, "submitImgUrls": urls }); - if (baseModel.status ?? false) { + if (baseModel.success) { return true; } else { return false; @@ -28,7 +28,7 @@ class HouseKeepingFunc { static Future getHouseKeepingProcess(int id) async { BaseModel baseModel = await NetUtil().get(API.manager.houseKeepingProcess, params: {"housekeepingServiceId": id}); - if (baseModel.status ?? false) { + if (baseModel.success) { return (baseModel.data as List) .map((e) => HouseKeepingProcessModel.fromJson(e)) .toList(); @@ -43,7 +43,7 @@ class HouseKeepingFunc { await NetUtil().get(API.manager.housekeepingCancel, params: { "housekeepingServiceId": id, }); - if (baseModel.status ?? false) { + if (baseModel.success) { BotToast.showText(text: '取消成功'); return true; } else { @@ -74,7 +74,7 @@ class HouseKeepingFunc { "evaluationContent": evaluationContent, "evaluationImgUrls": imgs, }); - return baseModel.status ?? false; + return baseModel.success; } ///支付宝支付:app 家政服务-服务费用支付 完成订单支付宝支付(生成 APP 支付订单信息) @@ -88,8 +88,8 @@ class HouseKeepingFunc { "payType": type, "payPrice": price }); - if (baseModel.status ?? false) { - return baseModel.message!; + if (baseModel.success) { + return baseModel.message; } else { return ''; } diff --git a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart index c996171a..e0945c4f 100644 --- a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart +++ b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart @@ -268,7 +268,7 @@ class _QuestionnaireDetailPageState extends State { BaseModel baseModel = await ManagerFunc.questionnaireSubmit( widget.id, _submitModels); Get.to(() => SubmitComplishPage( - status: baseModel.status, + status: baseModel.success, message: baseModel.message, )); }, diff --git a/lib/ui/market/collection/collection_func.dart b/lib/ui/market/collection/collection_func.dart index 00dffd37..920e66db 100644 --- a/lib/ui/market/collection/collection_func.dart +++ b/lib/ui/market/collection/collection_func.dart @@ -13,7 +13,7 @@ class CollectionFunc { /// 获取此供应商热度最高的商品 static Future> getCollectionList() async { BaseModel baseModel = await NetUtil().get(API.market.collectionList); - if (baseModel.status == true && baseModel.data != null) { + if (baseModel.success == true && baseModel.data != null) { return (baseModel.data as List) .map((e) => CollectionGoodsModel.fromJson(e)) .toList(); @@ -66,7 +66,7 @@ class CollectionFunc { // await NetUtil().get(API.market.suppliyerHotTop, params: { // "supplierId": supplierId, // }); -// if (baseModel.status == true && baseModel.data != null) { +// if (baseModel.success == true && baseModel.data != null) { // return (baseModel.data as List) // .map((e) => GoodsItem.fromJson(e)) // .toList(); @@ -78,7 +78,7 @@ class CollectionFunc { // static Future getOrderDetail(int goodsAppointmentId) async { // BaseModel baseModel = await NetUtil().get(API.market.orderDetail, // params: {"goodsAppointmentId": goodsAppointmentId}); -// if (baseModel.status! && baseModel.data != null) { +// if (baseModel.success && baseModel.data != null) { // return OrderDetailModel.fromJson(baseModel.data); // } // } diff --git a/lib/ui/market/goods/goods_detail_page.dart b/lib/ui/market/goods/goods_detail_page.dart index a5b5f859..bb89e5d5 100644 --- a/lib/ui/market/goods/goods_detail_page.dart +++ b/lib/ui/market/goods/goods_detail_page.dart @@ -87,7 +87,7 @@ class _GoodsDetailPageState extends State { API.market.goodsDetail, params: {"goodsId": widget.id}, ); - if (baseModel.status == true && baseModel.data != null) { + if (baseModel.success == true && baseModel.data != null) { _goodsModel = GoodsDetailModel.fromJson(baseModel.data); } else { _goodsModel = GoodsDetailModel.fail(); @@ -96,7 +96,7 @@ class _GoodsDetailPageState extends State { baseModel = await NetUtil().get(API.market.suppliyerHotTop, params: { "supplierId": _goodsModel.supplierId, }); - if (baseModel.status == true && baseModel.data != null) { + if (baseModel.success == true && baseModel.data != null) { _topGoods = (baseModel.data as List) .map((e) => GoodsItem.fromJson(e)) .toList(); diff --git a/lib/ui/market/goods/goods_order_detail_page.dart b/lib/ui/market/goods/goods_order_detail_page.dart index 12022244..9e6c0d79 100644 --- a/lib/ui/market/goods/goods_order_detail_page.dart +++ b/lib/ui/market/goods/goods_order_detail_page.dart @@ -13,7 +13,6 @@ import 'package:aku_new_community/widget/bee_divider.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:aku_new_community/widget/buttons/bee_numberic_button.dart'; import 'package:aku_new_community/widget/buttons/bottom_button.dart'; -import 'package:aku_new_community/widget/others/user_tool.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -62,7 +61,7 @@ class _GoodsOrderDetailPageState extends State { TextButton( onPressed: () { Get.to(() => HouseOwnersPage( - identify: UserTool.userProvider.userDetailModel!.type ?? 4, + identify: 4, )); }, child: '切换房屋'.text.size(28.sp).color(ktextPrimary).make()) @@ -101,8 +100,7 @@ class _GoodsOrderDetailPageState extends State { }, showMessage: false, ); - if ((baseModel.status ?? false) && - !baseModel.message.isEmptyOrNull) { + if ((baseModel.success) && !baseModel.message.isEmptyOrNull) { bool result = await PayUtil() .callAliPay(baseModel.message!, API.pay.shoppingCheck); if (result) { diff --git a/lib/ui/market/order/my_order_func.dart b/lib/ui/market/order/my_order_func.dart index 44551a17..5eb2eaed 100644 --- a/lib/ui/market/order/my_order_func.dart +++ b/lib/ui/market/order/my_order_func.dart @@ -50,7 +50,7 @@ class MyOrderFunc { await NetUtil().get(API.market.suppliyerHotTop, params: { "supplierId": supplierId, }); - if (baseModel.status == true && baseModel.data != null) { + if (baseModel.success == true && baseModel.data != null) { return (baseModel.data as List) .map((e) => GoodsItem.fromJson(e)) .toList(); @@ -62,7 +62,7 @@ class MyOrderFunc { static Future getOrderDetail(int goodsAppointmentId) async { BaseModel baseModel = await NetUtil().get(API.market.orderDetail, params: {"goodsAppointmentId": goodsAppointmentId}); - if (baseModel.status! && baseModel.data != null) { + if (baseModel.success && baseModel.data != null) { return OrderDetailModel.fromJson(baseModel.data); } } diff --git a/lib/ui/market/order/my_order_refund_page.dart b/lib/ui/market/order/my_order_refund_page.dart index 463ba70e..ea7bc744 100644 --- a/lib/ui/market/order/my_order_refund_page.dart +++ b/lib/ui/market/order/my_order_refund_page.dart @@ -56,7 +56,7 @@ class _MyOrderRefundPageState extends State { onPressed: () async { BaseModel baseModel = await MyOrderFunc.refundOrder( widget.model.id, _editingController.text, _type); - if (baseModel.status ?? false) { + if (baseModel.success) { Get.back(); } }, diff --git a/lib/ui/market/order/order_card.dart b/lib/ui/market/order/order_card.dart index 8fdefedc..9e9566a3 100644 --- a/lib/ui/market/order/order_card.dart +++ b/lib/ui/market/order/order_card.dart @@ -74,9 +74,9 @@ class _OrderCardState extends State { "payType": 1, //暂时写死 等待后续补充 "payPrice": widget.model.payPrice }); - if (baseModel.status ?? false) { + if (baseModel.success) { bool result = await PayUtil() - .callAliPay(baseModel.message!, API.pay.sharePayOrderCodeCheck); + .callAliPay(baseModel.message, API.pay.sharePayOrderCodeCheck); if (result) { Get.off(() => PayFinishPage()); } @@ -107,7 +107,7 @@ class _OrderCardState extends State { await NetUtil().get(API.market.deleteOrder, params: { "orderId": widget.model.id, }); - if (baseModel.status ?? false) { + if (baseModel.success) { BotToast.showText(text: '删除成功'); widget.callRefresh(); } @@ -136,7 +136,7 @@ class _OrderCardState extends State { Function cancel = BotToast.showLoading(); BaseModel baseModel = await NetUtil().get(API.market.cancelOrder, params: {"orderId": widget.model.id, 'cancelReasonCode': 4}); - if (baseModel.status ?? false) { + if (baseModel.success) { BotToast.showText(text: '取消成功'); widget.callRefresh(); } @@ -167,7 +167,7 @@ class _OrderCardState extends State { await NetUtil().get(API.market.confirmOrder, params: { "orderId": widget.model.id, }); - if (baseModel.status ?? false) { + if (baseModel.success) { BotToast.showText(text: '收货成功'); Get.back(); widget.callRefresh(); diff --git a/lib/ui/market/order/order_detail_page.dart b/lib/ui/market/order/order_detail_page.dart index a457d9dd..56feaaa6 100644 --- a/lib/ui/market/order/order_detail_page.dart +++ b/lib/ui/market/order/order_detail_page.dart @@ -61,9 +61,9 @@ class _OrderDetailPageState extends State { "payType": 1, //暂时写死 等待后续补充 "payPrice": widget.orderModel.payPrice }); - if (baseModel.status ?? false) { + if (baseModel.success) { bool result = await PayUtil() - .callAliPay(baseModel.message!, API.pay.jcookOrderCheckAlipay); + .callAliPay(baseModel.message, API.pay.jcookOrderCheckAlipay); if (result) { Get.off(() => OrderPage(initIndex: 2)); } else { @@ -96,7 +96,7 @@ class _OrderDetailPageState extends State { await NetUtil().get(API.market.deleteOrder, params: { "orderId": widget.orderModel.id, }); - if (baseModel.status ?? false) { + if (baseModel.success) { BotToast.showText(text: '删除成功'); Get.back(); widget.callRefresh(); @@ -126,7 +126,7 @@ class _OrderDetailPageState extends State { Function cancel = BotToast.showLoading(); BaseModel baseModel = await NetUtil().get(API.market.cancelOrder, params: {"orderId": widget.orderModel.id, 'cancelReasonCode': 4}); - if (baseModel.status ?? false) { + if (baseModel.success) { BotToast.showText(text: '取消成功'); Get.back(); widget.callRefresh(); @@ -158,7 +158,7 @@ class _OrderDetailPageState extends State { await NetUtil().get(API.market.confirmOrder, params: { "orderId": widget.orderModel.id, }); - if (baseModel.status ?? false) { + if (baseModel.success) { BotToast.showText(text: '收货成功'); Get.back(); widget.callRefresh(); @@ -548,7 +548,7 @@ class _OrderDetailPageState extends State { await NetUtil().get(API.market.findLogistics, params: { "orderId": widget.orderModel.id, }); - if (baseModel.status == true && baseModel.data != null) { + if (baseModel.success == true && baseModel.data != null) { logisticsModels = (baseModel.data as List) .map((e) => LogisticsModel.fromJson(e)) .toList(); diff --git a/lib/ui/market/search/search_func.dart b/lib/ui/market/search/search_func.dart index f5730471..ce5be22a 100644 --- a/lib/ui/market/search/search_func.dart +++ b/lib/ui/market/search/search_func.dart @@ -121,7 +121,7 @@ class SearchFunc { static Future getOrderDetail(int goodsAppointmentId) async { BaseModel baseModel = await NetUtil().get(API.market.orderDetail, params: {"goodsAppointmentId": goodsAppointmentId}); - if (baseModel.status! && baseModel.data != null) { + if (baseModel.success && baseModel.data != null) { return OrderDetailModel.fromJson(baseModel.data); } } diff --git a/lib/ui/market/search/submit_order_page.dart b/lib/ui/market/search/submit_order_page.dart index 5f0dc1d9..9c253703 100644 --- a/lib/ui/market/search/submit_order_page.dart +++ b/lib/ui/market/search/submit_order_page.dart @@ -134,9 +134,9 @@ class _SubmitOrderPageState extends State { "payType": 1, //暂时写死 等待后续补充 "payPrice": _allPrice }); - if (baseModel.status ?? false) { + if (baseModel.success) { bool result = await PayUtil().callAliPay( - baseModel.message!, API.pay.jcookOrderCheckAlipay); + baseModel.message, API.pay.jcookOrderCheckAlipay); if (result) { Get.off(() => OrderPage(initIndex: 2)); } else { @@ -728,10 +728,10 @@ class _SubmitOrderPageState extends State { var cancel = BotToast.showLoading(); var base = await NetUtil().post(API.market.shopCarChangeNum, params: {'jcookGoodsId': jcookGoodsId, 'num': num}); - if (!(base.status ?? false)) { - BotToast.showText(text: base.message ?? ''); + if (!(base.success)) { + BotToast.showText(text: base.message); } cancel(); - return base.status ?? false; + return base.success; } } diff --git a/lib/ui/market/search/submit_order_page_normal.dart b/lib/ui/market/search/submit_order_page_normal.dart index e4f2f07a..edfae781 100644 --- a/lib/ui/market/search/submit_order_page_normal.dart +++ b/lib/ui/market/search/submit_order_page_normal.dart @@ -122,9 +122,9 @@ class _SubmitOrderNormalPageState extends State { "payType": 1, //暂时写死 等待后续补充 "payPrice": _allPrice }); - if (baseModel.status ?? false) { + if (baseModel.success) { bool result = await PayUtil().callAliPay( - baseModel.message!, API.pay.jcookOrderCheckAlipay); + baseModel.message, API.pay.jcookOrderCheckAlipay); if (result) { Get.off(() => OrderPage(initIndex: 2)); } else { @@ -685,10 +685,10 @@ class _SubmitOrderNormalPageState extends State { var cancel = BotToast.showLoading(); var base = await NetUtil().post(API.market.shopCarChangeNum, params: {'jcookGoodsId': jcookGoodsId, 'num': num}); - if (!(base.status ?? false)) { - BotToast.showText(text: base.message ?? ''); + if (!(base.success)) { + BotToast.showText(text: base.message); } cancel(); - return base.status ?? false; + return base.success; } } diff --git a/lib/ui/market/shop_car/shop_car_page.dart b/lib/ui/market/shop_car/shop_car_page.dart index adcbbade..60a7189e 100644 --- a/lib/ui/market/shop_car/shop_car_page.dart +++ b/lib/ui/market/shop_car/shop_car_page.dart @@ -93,7 +93,7 @@ class _ShopCarPageState extends State { header: MaterialHeader(), onRefresh: () async { var base = await NetUtil().get(API.market.shopCarList); - if (base.status ?? false) { + if (base.success) { _models = (base.data as List) .map((e) => ShopCarListModel.fromJson(e)) .toList(); @@ -254,8 +254,8 @@ class _ShopCarPageState extends State { }, showMessage: true, ); - if (model.status != null) { - if (model.status!) { + if (model.success != null) { + if (model.success) { _selectIndex.clear(); _refreshController.callRefresh(); } @@ -609,11 +609,11 @@ class _ShopCarPageState extends State { var cancel = BotToast.showLoading(); var base = await NetUtil().post(API.market.shopCarChangeNum, params: {'jcookGoodsId': jcookGoodsId, 'num': num}); - if (!(base.status ?? false)) { - BotToast.showText(text: base.message ?? ''); + if (!(base.success)) { + BotToast.showText(text: base.message); } cancel(); - return base.status ?? false; + return base.success; } Future _changeNum() async { @@ -640,8 +640,8 @@ class _ShopCarPageState extends State { }, showMessage: true, ); - if (model.status != null) { - if (model.status!) { + if (model.success != null) { + if (model.success) { _selectIndex.clear(); _refreshController.callRefresh(); } diff --git a/lib/ui/profile/house/add_house_page.dart b/lib/ui/profile/house/add_house_page.dart index 3d919721..1d91d509 100644 --- a/lib/ui/profile/house/add_house_page.dart +++ b/lib/ui/profile/house/add_house_page.dart @@ -281,6 +281,6 @@ class _AddHousePageState extends State { showMessage: true, ); cancel(); - if (model.status!) Get.back(result: true); + if (model.success) Get.back(result: true); } } diff --git a/lib/ui/profile/house/house_func.dart b/lib/ui/profile/house/house_func.dart index e489b552..949ba6d9 100644 --- a/lib/ui/profile/house/house_func.dart +++ b/lib/ui/profile/house/house_func.dart @@ -15,7 +15,7 @@ class HouseFunc { ///查询所有的房屋审核信息 static Future> get examineHouses async { BaseModel model = await NetUtil().get(API.user.examineHouseList); - if (!model.status!) return []; + if (!model.success) return []; return (model.data as List) .map((e) => PassedHouseListModel.fromJson(e)) .toList(); @@ -24,7 +24,7 @@ class HouseFunc { ///查询用户所拥有的房屋信息 static Future> get passedHouses async { BaseModel model = await NetUtil().get(API.user.passedHouseList); - if (!model.status!) return []; + if (!model.success) return []; return (model.data as List) .map((e) => PassedHouseListModel.fromJson(e)) .toList(); @@ -44,7 +44,7 @@ class HouseFunc { "tel": tel, "idNumber": idNumber, }); - if (baseModel.status ?? false) { + if (baseModel.success) { BotToast.showText(text: '提交成功'); return true; } @@ -54,7 +54,7 @@ class HouseFunc { ///租赁认证信息回显 static Future leaseEcho() async { BaseModel baseModel = await NetUtil().get(API.house.leaseEcho); - if (baseModel.status ?? false) { + if (baseModel.success) { return LeaseEchoModel.fromJson(baseModel.data); } else { return LeaseEchoModel.fail(); @@ -66,7 +66,7 @@ class HouseFunc { BaseModel baseModel = await NetUtil().get(API.house.leaseFindByld, params: { "leaseId": leaseId, }); - if (baseModel.status ?? false) { + if (baseModel.success) { return LeaseDetailModel.fromJson(baseModel.data); } else { return null; @@ -110,7 +110,7 @@ class HouseFunc { "idCardFrontImgUrl": model.idCardFrontImgUrl, "idCardBackImgUrl": model.idCardBackImgUrl, }); - if (baseModel.status ?? false) { + if (baseModel.success) { return baseModel.data; } else { return ''; @@ -141,7 +141,7 @@ class HouseFunc { "contractSignatureImgUrl": sUrl, }); - if (baseModel.status ?? false) { + if (baseModel.success) { return baseModel.data; } else { return ''; @@ -166,7 +166,7 @@ class HouseFunc { "id": id, "leaseContractValidPdfUrl": urls, }); - return baseModel.status!; + return baseModel.success; } ///支付宝生成订单 @@ -178,8 +178,8 @@ class HouseFunc { "payType": type, "payPrice": price, }); - if (baseModel.status ?? false) { - return baseModel.message ?? ''; + if (baseModel.success) { + return baseModel.message; } else { return ''; } @@ -201,7 +201,7 @@ class HouseFunc { BaseModel baseModel = await NetUtil().post( API.house.submitTerminateApplication, params: {"id": id, "takeDate": takeDate, "clearingSingleImgUrl": urls}); - if (baseModel.status ?? false) { + if (baseModel.success) { return true; } else { return false; @@ -214,8 +214,8 @@ class HouseFunc { Future leaseRentOrder(int id, int type, double price) async { BaseModel baseModel = await NetUtil().post(API.pay.leaseRentOrderAlipay, params: {"sysLeaseId": id, "payType": type, "payPrice": price}); - if (baseModel.status ?? false) { - return baseModel.message!; + if (baseModel.success) { + return baseModel.message; } else { return ''; } @@ -228,7 +228,7 @@ class HouseFunc { "sysLeaseId": id, "payPrice": price, }); - return baseModel.status ?? false; + return baseModel.success; } ///我的房屋-合同终止:保证金退还申请 @@ -237,7 +237,7 @@ class HouseFunc { await NetUtil().get(API.house.refundApplication, params: { "sysLeaseId": id, }); - if (baseModel.status ?? false) { + if (baseModel.success) { return true; } else { return false; @@ -250,8 +250,8 @@ class HouseFunc { Future leaseRentBillOrder(int id, int type, double price) async { BaseModel baseModel = await NetUtil().post(API.pay.leaseRentBillorder, params: {"sysLeaseRentId": id, "payType": type, "payPrice": price}); - if (baseModel.status ?? false) { - return baseModel.message!; + if (baseModel.success) { + return baseModel.message; } else { return ''; } diff --git a/lib/ui/profile/house/house_owners_page.dart b/lib/ui/profile/house/house_owners_page.dart index 72083e26..e9504245 100644 --- a/lib/ui/profile/house/house_owners_page.dart +++ b/lib/ui/profile/house/house_owners_page.dart @@ -67,7 +67,7 @@ class _HouseOwnersPageState extends State { } bool get isOwner { - switch (UserTool.userProvider.userDetailModel!.type) { + switch (4) { case 1: return true; case 3: @@ -79,7 +79,7 @@ class _HouseOwnersPageState extends State { } bool get isTourist { - switch (UserTool.userProvider.userDetailModel!.type) { + switch (4) { case 1: return false; case 2: @@ -106,7 +106,7 @@ class _HouseOwnersPageState extends State { Future.delayed(Duration(milliseconds: 300), () async { Function cancel = BotToast.showLoading(); try { - await UserTool.userProvider.updateUserDetail(); + await UserTool.userProvider.updateMyHouseInfo(); UserTool.appProveider.updateHouses(await HouseFunc.passedHouses); } catch (e) { LoggerData.addData(e); diff --git a/lib/ui/search/bee_search.dart b/lib/ui/search/bee_search.dart index d04406f2..61423cf0 100644 --- a/lib/ui/search/bee_search.dart +++ b/lib/ui/search/bee_search.dart @@ -261,7 +261,7 @@ class _BeeSearchState extends State { onRefresh: () async { BaseModel baseModel = await NetUtil().get(API.search.homeSearch, params: {"searchName": _textEditingController.text}); - if (baseModel.status! && baseModel.data != null) { + if (baseModel.success && baseModel.data != null) { _searchModel = SearchModel.fromJson(baseModel.data); } setState(() {}); diff --git a/lib/utils/login_util.dart b/lib/utils/login_util.dart index 3d5b02ed..7858b0de 100644 --- a/lib/utils/login_util.dart +++ b/lib/utils/login_util.dart @@ -3,7 +3,6 @@ import 'package:aku_new_community/provider/app_provider.dart'; import 'package:aku_new_community/provider/user_provider.dart'; import 'package:aku_new_community/ui/profile/house/add_house_page.dart'; import 'package:aku_new_community/ui/profile/house/house_owners_page.dart'; -import 'package:aku_new_community/widget/others/user_tool.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; @@ -43,7 +42,7 @@ class LoginUtil { if (appProvider.selectedHouse == null) { BotToast.showText(text: '房屋审核中或审核失败'); Get.to(() => HouseOwnersPage( - identify: UserTool.userProvider.userDetailModel!.type ?? 4, + identify: 4, )); return false; } diff --git a/lib/utils/network/base_model.dart b/lib/utils/network/base_model.dart index af386218..cb4f958c 100644 --- a/lib/utils/network/base_model.dart +++ b/lib/utils/network/base_model.dart @@ -1,21 +1,25 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'base_model.g.dart'; + +@JsonSerializable() class BaseModel { - int? code; - String? message; - bool? status; + int code; + String message; + bool success; dynamic data; + factory BaseModel.fromJson(Map json) => + _$BaseModelFromJson(json); + BaseModel.err( + {this.message = '未知错误', + this.success = false, + this.data = null, + this.code = 0}); BaseModel({ - this.code, - this.message, - this.data, - this.status, + required this.code, + required this.message, + required this.success, + required this.data, }); - - BaseModel.err({this.message = '未知错误', this.status = false}); - - BaseModel.fromJson(Map json) { - message = json['message'] ?? ''; - data = json['data'] ?? null; - status = json['status'] ?? false; - } } diff --git a/lib/utils/network/base_model.g.dart b/lib/utils/network/base_model.g.dart new file mode 100644 index 00000000..4f0b9296 --- /dev/null +++ b/lib/utils/network/base_model.g.dart @@ -0,0 +1,14 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'base_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +BaseModel _$BaseModelFromJson(Map json) => BaseModel( + code: json['code'] as int, + message: json['message'] as String, + success: json['success'] as bool, + data: json['data'], + ); diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index 9f17038d..93b65aa7 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'dart:typed_data'; -import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/pages/sign/login/login_page.dart'; import 'package:aku_new_community/provider/user_provider.dart'; import 'package:aku_new_community/utils/developer_util.dart'; @@ -25,10 +25,10 @@ class NetUtil { NetUtil._internal() { BaseOptions options = BaseOptions( - baseUrl: API.baseURL, - connectTimeout: API.networkTimeOut, - receiveTimeout: API.networkTimeOut, - sendTimeout: API.networkTimeOut, + baseUrl: SARSAPI.baseURL, + connectTimeout: SARSAPI.networkTimeOut, + receiveTimeout: SARSAPI.networkTimeOut, + sendTimeout: SARSAPI.networkTimeOut, headers: {}, ); if (_dio == null) _dio = Dio(options); @@ -182,12 +182,12 @@ class NetUtil { _parseRequestError(BaseModel model, {bool showMessage = false}) { final userProvider = Provider.of(Get.context!, listen: false); - if (!model.status! && model.message == '登录失效,请登录' && userProvider.isLogin) { + if (!model.success && model.message == '登录失效,请登录' && userProvider.isLogin) { userProvider.logout(); Get.offAll(() => LoginPage()); } - if (!model.status! || showMessage) { - BotToast.showText(text: model.message!); + if (!model.success || showMessage) { + BotToast.showText(text: model.message); } } } diff --git a/lib/widget/bee_back_button.dart b/lib/widget/bee_back_button.dart index a432bb60..2481e2e0 100644 --- a/lib/widget/bee_back_button.dart +++ b/lib/widget/bee_back_button.dart @@ -1,6 +1,5 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:get/get.dart'; class BeeBackButton extends StatelessWidget { final Color color; @@ -11,7 +10,7 @@ class BeeBackButton extends StatelessWidget { Widget build(BuildContext context) { return Navigator.canPop(context) ? IconButton( - onPressed: () => Get.back(), + onPressed: () => Navigator.pop(context), icon: Icon( CupertinoIcons.chevron_back, color: color, diff --git a/lib/widget/picker/bee_city_picker.dart b/lib/widget/picker/bee_city_picker.dart index 11d00cb7..863bf181 100644 --- a/lib/widget/picker/bee_city_picker.dart +++ b/lib/widget/picker/bee_city_picker.dart @@ -25,7 +25,7 @@ class BeeCityPicker extends StatefulWidget { class _BeeCityPickerState extends State { List get provinces => - HiveStore.dataBox!.get('cities').cast().toList(); + HiveStore.dataBox!.get('cities')?.cast().toList() ?? []; late int _pickedProvinceIndex; late int _pickedCityIndex; diff --git a/pubspec.lock b/pubspec.lock index fdc06e5a..0f7ee381 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -898,6 +898,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "4.1.0" + pin_input_text_field: + dependency: transitive + description: + name: pin_input_text_field + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.1" platform: dependency: transitive description: @@ -1087,6 +1094,13 @@ packages: description: flutter source: sdk version: "0.0.99" + sms_autofill: + dependency: "direct main" + description: + name: sms_autofill + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" source_gen: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0b941c1d..3bd567bc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -109,6 +109,8 @@ dependencies: carousel_slider: ^4.0.0-nullsafety.0 #跳转索引列表 scroll_to_index: ^2.1.1 + #验证码自动填充 + sms_autofill: ^2.2.0 dev_dependencies: