diff --git a/lib/constants/saas_api.dart b/lib/constants/saas_api.dart index 9610434a..03cf5a29 100644 --- a/lib/constants/saas_api.dart +++ b/lib/constants/saas_api.dart @@ -47,6 +47,15 @@ class _City { } class _User { + ///app用户发送手机号验证码(修改手机号) + String get sendTelCodeUpdateTel => '/app/user/sendTelCodeUpdateTel'; + + ///提交修改的新手机号(修改手机号) + String get updateTel => '/app/user/updateTel'; + + ///修改性别 + String get updateSex => '/app/user/updateSex'; + ///用户资料 String get userProfile => '/app/user/findDetail'; diff --git a/lib/pages/personal/change_nick_name_page.dart b/lib/pages/personal/change_nick_name_page.dart index f1fd189f..b3dca890 100644 --- a/lib/pages/personal/change_nick_name_page.dart +++ b/lib/pages/personal/change_nick_name_page.dart @@ -1,13 +1,11 @@ +import 'package:aku_new_community/provider/user_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'; -import 'package:aku_new_community/provider/user_provider.dart'; -import 'package:aku_new_community/widget/bee_scaffold.dart'; - class ChangeNickName extends StatefulWidget { ChangeNickName({Key? key}) : super(key: key); diff --git a/lib/pages/sign/login/select_community_page.dart b/lib/pages/sign/login/select_community_page.dart index a26d3796..f8646a21 100644 --- a/lib/pages/sign/login/select_community_page.dart +++ b/lib/pages/sign/login/select_community_page.dart @@ -173,7 +173,9 @@ class _SelectCommunityState extends State { borderRadius: BorderRadius.circular(4.w), ), color: kPrimaryColor, - onPressed: (){Navigator.pop(context);}, + onPressed: () { + Navigator.pop(context); + }, child: '提交'.text.size(34.sp).make(), ).centered(), ), @@ -192,22 +194,32 @@ class _SelectCommunityState extends State { } Widget _historyTile(HistoryLoginModel model) { - return Container( - padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), - child: Row( - children: [ - Icon( - CupertinoIcons.search, - size: 30.w, - color: Colors.black.withOpacity(0.2), + return GestureDetector( + onTap: () { + UserTool.appProvider.setPickedCity( + city: model.cityModel, community: model.communityModel); + setState(() {}); + }, + child: Material( + color: Colors.transparent, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), + child: Row( + 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(), + ], ), - 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/sign_func.dart b/lib/pages/sign/sign_func.dart index 8a1d9b44..93908842 100644 --- a/lib/pages/sign/sign_func.dart +++ b/lib/pages/sign/sign_func.dart @@ -40,7 +40,7 @@ class SignFunc { static Future sendNewMessageCode(String newTel) async { BaseModel baseModel = await NetUtil().post( - API.login.sendNewMSCode, + SAASAPI.user.sendTelCodeUpdateTel, params: {'newTel': newTel}, showMessage: true, ); diff --git a/lib/provider/data_provider.dart b/lib/provider/data_provider.dart index 4eeec073..84cb77b3 100644 --- a/lib/provider/data_provider.dart +++ b/lib/provider/data_provider.dart @@ -43,10 +43,13 @@ class DataProvider extends ChangeNotifier { List get loginHistories => _loginHistories; Future addHistories() async { - _loginHistories.insert(0, UserTool.appProvider.pickedCityAndCommunity!); - if (_loginHistories.length > 4) { - _loginHistories.removeAt(_loginHistories.length - 1); + if (!_loginHistories + .contains(UserTool.appProvider.pickedCityAndCommunity!)) { + _loginHistories.insert(0, UserTool.appProvider.pickedCityAndCommunity!); + if (_loginHistories.length > 4) { + _loginHistories.removeAt(_loginHistories.length - 1); + } + HiveStore.dataBox!.put('historyLogin', _loginHistories); } - HiveStore.dataBox!.put('historyLogin', _loginHistories); } } diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 178f15f6..01220767 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -111,8 +111,8 @@ class UserProvider extends ChangeNotifier { ///设置性别 Future setSex(int sex) async { - BaseModel baseModel = await NetUtil().post( - API.user.setSex, + BaseModel baseModel = await NetUtil().get( + SAASAPI.user.updateSex, params: {'sex': sex}, showMessage: true, ); @@ -139,12 +139,8 @@ class UserProvider extends ChangeNotifier { //修改昵称 Future setName(String name) async { - BaseModel baseModel = await NetUtil().post( - API.user.updateNickName, - params: {'nickName': name}, - showMessage: true, - ); - if (baseModel.success) { + var re = await SignFunc.setNickName(name); + if (re) { await updateUserInfo(); notifyListeners(); } @@ -153,8 +149,8 @@ class UserProvider extends ChangeNotifier { //修改手机号 Future updateTel(String oldTel, String newTel, String code) async { BaseModel baseModel = await NetUtil().post( - API.user.updateTel, - params: {'oldTel': oldTel, 'newTel': newTel, 'code': code}, + SAASAPI.user.updateTel, + params: {'tel': oldTel, 'newTel': newTel, 'telCode': code}, showMessage: true, ); if (baseModel.success) { diff --git a/lib/saas_model/login/community_model.dart b/lib/saas_model/login/community_model.dart index 857eba33..1c7a9080 100644 --- a/lib/saas_model/login/community_model.dart +++ b/lib/saas_model/login/community_model.dart @@ -1,3 +1,4 @@ +import 'package:equatable/equatable.dart'; import 'package:hive_flutter/adapters.dart'; import 'package:json_annotation/json_annotation.dart'; @@ -5,7 +6,7 @@ part 'community_model.g.dart'; @JsonSerializable() @HiveType(typeId: 7) -class CommunityModel { +class CommunityModel extends Equatable { @HiveField(0) final int id; @HiveField(1) @@ -14,6 +15,7 @@ class CommunityModel { final String address; @HiveField(3) final String addressDetails; + factory CommunityModel.fromJson(Map json) => _$CommunityModelFromJson(json); @@ -23,4 +25,7 @@ class CommunityModel { required this.address, required this.addressDetails, }); + + @override + List get props => [id, name, address, addressDetails]; } diff --git a/lib/saas_model/login/history_login_model.dart b/lib/saas_model/login/history_login_model.dart index 3dee5349..6e6e41ec 100644 --- a/lib/saas_model/login/history_login_model.dart +++ b/lib/saas_model/login/history_login_model.dart @@ -13,11 +13,45 @@ class HistoryLoginModel { PickedCityModel cityModel; @HiveField(1) CommunityModel? communityModel; + factory HistoryLoginModel.fromJson(Map json) => _$HistoryLoginModelFromJson(json); +// + HistoryLoginModel({ required this.cityModel, this.communityModel, }); + + @override + bool operator ==(Object other) => + identical(this, other) || + (other is HistoryLoginModel && + runtimeType == other.runtimeType && + cityModel == other.cityModel && + communityModel == other.communityModel); + + @override + int get hashCode => cityModel.hashCode ^ communityModel.hashCode; + + @override + String toString() { + return 'HistoryLoginModel{' + + ' cityModel: $cityModel,' + + ' communityModel: $communityModel,' + + '}'; + } + + HistoryLoginModel copyWith({ + PickedCityModel? cityModel, + CommunityModel? communityModel, + }) { + return HistoryLoginModel( + cityModel: cityModel ?? this.cityModel, + communityModel: communityModel ?? this.communityModel, + ); + } + +// } diff --git a/lib/saas_model/login/picked_city_model.dart b/lib/saas_model/login/picked_city_model.dart index f9768724..c4ccd7a9 100644 --- a/lib/saas_model/login/picked_city_model.dart +++ b/lib/saas_model/login/picked_city_model.dart @@ -1,4 +1,5 @@ import 'package:aku_new_community/utils/hive_store.dart'; +import 'package:equatable/equatable.dart'; import 'package:hive/hive.dart'; import 'package:json_annotation/json_annotation.dart'; @@ -8,13 +9,14 @@ part 'picked_city_model.g.dart'; @JsonSerializable() @HiveType(typeId: 6) -class PickedCityModel { +class PickedCityModel extends Equatable { @HiveField(0) final ChinaRegionModel province; @HiveField(1) final ChinaRegionModel city; @HiveField(2) final ChinaRegionModel district; + factory PickedCityModel.fromJson(Map json) => _$PickedCityModelFromJson(json); @@ -23,6 +25,7 @@ class PickedCityModel { required this.city, required this.district, }); + factory PickedCityModel.fromId( {required int provinceId, required int cityId, required int distrctId}) { var provinces = @@ -44,4 +47,7 @@ class PickedCityModel { String get address => province.name + city.name + district.name; int get id => district.id; + + @override + List get props => [province, city, district]; } diff --git a/lib/ui/function_and_service/work_order/work_order_page.dart b/lib/ui/function_and_service/work_order/work_order_page.dart index aec48667..7cc985bb 100644 --- a/lib/ui/function_and_service/work_order/work_order_page.dart +++ b/lib/ui/function_and_service/work_order/work_order_page.dart @@ -10,6 +10,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:power_logger/power_logger.dart'; import 'package:velocity_x/velocity_x.dart'; class WorkOrderPage extends StatefulWidget { @@ -47,8 +48,9 @@ class _WorkOrderPageState extends State title: '报事报修', actions: [ IconButton( - onPressed: () { - Get.to(() => PublishWorkOrderPage()); + onPressed: () async { + await Get.to(() => PublishWorkOrderPage()); + _refreshController.callRefresh(); }, icon: Icon( CupertinoIcons.plus_circle, @@ -69,16 +71,23 @@ class _WorkOrderPageState extends State Widget _getOrderView(int index) { return EasyRefresh( firstRefresh: true, + controller: _refreshController, header: MaterialHeader(), + footer: MaterialFooter(), onRefresh: () async { _page = 1; - var base = await NetUtil().getList(SAASAPI.workOrder.list, params: { - 'pageNum': _page, - 'size': _size, - 'status': index == 0 ? null : index, - }); - _models = - base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList(); + _models.clear(); + try { + var base = await NetUtil().getList(SAASAPI.workOrder.list, params: { + 'pageNum': _page, + 'size': _size, + 'status': index == 0 ? null : index, + }); + _models = + base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList(); + } catch (e) { + LoggerData.addData(e.toString()); + } setState(() {}); }, onLoad: () async { @@ -93,7 +102,7 @@ class _WorkOrderPageState extends State base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList()); setState(() {}); } else { - _refreshController.finishLoad(); + _refreshController.finishLoad(noMore: true); } }, child: ListView.separated( diff --git a/lib/widget/picker/bee_city_picker.dart b/lib/widget/picker/bee_city_picker.dart index c649fa9d..51604d6c 100644 --- a/lib/widget/picker/bee_city_picker.dart +++ b/lib/widget/picker/bee_city_picker.dart @@ -88,7 +88,7 @@ class _BeeCityPickerState extends State { children: [ Expanded( child: CupertinoPicker( - itemExtent: 60.w, + itemExtent: 80.w, magnification: 1.0, // offAxisFraction: -0.6, looping: true, @@ -110,7 +110,7 @@ class _BeeCityPickerState extends State { ), Expanded( child: CupertinoPicker( - itemExtent: 60.w, + itemExtent: 80.w, magnification: 1.0, looping: true, scrollController: _cityController, @@ -131,7 +131,7 @@ class _BeeCityPickerState extends State { ), Expanded( child: CupertinoPicker( - itemExtent: 60.w, + itemExtent: 80.w, magnification: 1.0, // offAxisFraction: 0.6, looping: true, @@ -145,7 +145,7 @@ class _BeeCityPickerState extends State { : districts .map((e) => Center( child: Padding( - padding: EdgeInsets.only(left: 20.w, right: 20.w), + padding: EdgeInsets.only(left: 20.w, right: 20.w,top: 10.w,bottom: 10.w), child: Text(e.name, textAlign: TextAlign.center), ), ))