From ad6cd6fc8be1b59086c0caa8cdb1642273ad23a1 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Thu, 6 Jan 2022 19:10:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=98=E8=AE=B0=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E5=8A=9F=E8=83=BD=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/sars_api.dart | 9 + lib/models/user/user_info_model.dart | 3 +- lib/models/user/user_info_model.g.dart | 3 - .../event_activity/voting_detail_page.dart | 2 +- .../express_package_card.dart | 2 +- .../deto_create_page/deto_create_page.dart | 2 +- lib/pages/life_pay/life_pay_page.dart | 2 +- lib/pages/life_pay/life_pre_pay_page.dart | 6 +- .../personal/clock_in/clock_in_page.dart | 41 ++-- lib/pages/personal/personal_page.dart | 89 +++++---- lib/pages/personal/user_profile_page.dart | 51 +++-- lib/pages/share_pay_page/share_pay_page.dart | 2 +- lib/pages/sign/login/code_message_page.dart | 19 +- lib/pages/sign/login/forgot_psd_page.dart | 93 +++++++++ lib/pages/sign/login/forgot_set_psd_page.dart | 183 ++++++++++++++++++ lib/pages/sign/login/login_page.dart | 11 +- lib/pages/sign/login/other_login_page.dart | 47 +++-- ...munity.dart => select_community_page.dart} | 8 +- lib/pages/sign/login/set_psd_page.dart | 30 ++- lib/pages/sign/sign_func.dart | 39 +++- .../widget/add_fixed_submit_page.dart | 2 +- .../things_page/widget/fixed_detail_page.dart | 8 +- lib/provider/app_provider.dart | 1 + lib/provider/data_provider.dart | 4 +- lib/provider/user_provider.dart | 56 +++--- lib/ui/community/community_func.dart | 8 +- .../facility/facility_preorder_page.dart | 2 +- lib/ui/manager/advice/advice_detail_page.dart | 2 +- .../house_keeping/house_keeping_func.dart | 2 +- .../questionnaire_detail_page.dart | 2 +- lib/ui/market/goods/goods_detail_page.dart | 2 +- .../market/goods/goods_order_detail_page.dart | 6 +- lib/ui/market/order/order_card.dart | 2 +- lib/ui/market/order/order_detail_page.dart | 2 +- lib/ui/market/search/search_func.dart | 4 +- lib/ui/market/search/submit_order_page.dart | 4 +- .../search/submit_order_page_normal.dart | 4 +- lib/ui/market/shop_car/shop_car_page.dart | 2 +- lib/ui/profile/house/house_func.dart | 6 +- lib/utils/network/base_model.dart | 24 +-- lib/utils/network/base_model.g.dart | 2 +- lib/utils/network/net_util.dart | 38 ++-- lib/widget/picker/bee_city_picker.dart | 22 +-- lib/widget/picker/bee_community_picker.dart | 3 + 44 files changed, 604 insertions(+), 246 deletions(-) create mode 100644 lib/pages/sign/login/forgot_psd_page.dart create mode 100644 lib/pages/sign/login/forgot_set_psd_page.dart rename lib/pages/sign/login/{select_community.dart => select_community_page.dart} (95%) diff --git a/lib/constants/sars_api.dart b/lib/constants/sars_api.dart index e6d74846..1fec263c 100644 --- a/lib/constants/sars_api.dart +++ b/lib/constants/sars_api.dart @@ -28,6 +28,15 @@ class _City { class _User { ///用户资料 String get userProfile => '/app/user/findDetail'; + + ///设置密码(密码不存在时调用) + String get settingPsd => '/app/user/settingPassword'; + + ///提交修改的新密码(忘记密码) + String get settingForgotPsd => '/app/user/forgetPassword'; + + ///app用户发送手机号验证码(忘记密码) + String get sendForgotTelCode => '/app/user/sendTelCodeForgetPwd'; } class _Login { diff --git a/lib/models/user/user_info_model.dart b/lib/models/user/user_info_model.dart index 8d04bc0a..e20a360a 100644 --- a/lib/models/user/user_info_model.dart +++ b/lib/models/user/user_info_model.dart @@ -9,7 +9,7 @@ class UserInfoModel { final int communityId; final String? name; final String tel; - final List imgUrls; + // final List imgUrls; /// 性别 1.男 2.女 3.保密 final int? sex; @@ -40,7 +40,6 @@ class UserInfoModel { required this.communityId, this.name, required this.tel, - required this.imgUrls, this.sex, 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 a680aa3f..d160f8b5 100644 --- a/lib/models/user/user_info_model.g.dart +++ b/lib/models/user/user_info_model.g.dart @@ -12,9 +12,6 @@ UserInfoModel _$UserInfoModelFromJson(Map json) => 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(), sex: json['sex'] as int?, nickName: json['nickName'] as String?, isExistPassword: json['isExistPassword'] as bool, diff --git a/lib/pages/event_activity/voting_detail_page.dart b/lib/pages/event_activity/voting_detail_page.dart index 4b7ad43a..d08e1e99 100644 --- a/lib/pages/event_activity/voting_detail_page.dart +++ b/lib/pages/event_activity/voting_detail_page.dart @@ -280,7 +280,7 @@ class _VotingDetailPageState extends State { _hasVoted = true; setState(() {}); } else { - BotToast.showText(text: '${baseModel.message}'); + BotToast.showText(text: '${baseModel.msg}'); } } }, diff --git a/lib/pages/express_packages/express_package_card.dart b/lib/pages/express_packages/express_package_card.dart index 77f20a25..aff4a323 100644 --- a/lib/pages/express_packages/express_package_card.dart +++ b/lib/pages/express_packages/express_package_card.dart @@ -135,7 +135,7 @@ class _ExpressPackageCardState extends State { }, ); if (baseModel.success) { - BotToast.showText(text: baseModel.message); + BotToast.showText(text: baseModel.msg); } return baseModel.success; } 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 4f176506..a99a45a3 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 @@ -455,7 +455,7 @@ class _DetoCreatePageState extends State { if (baseModel.success) { Get.back(); } else - BotToast.showText(text: baseModel.message); + BotToast.showText(text: baseModel.msg); cancel(); } : () { diff --git a/lib/pages/life_pay/life_pay_page.dart b/lib/pages/life_pay/life_pay_page.dart index 1c1ce5f3..750d96a0 100644 --- a/lib/pages/life_pay/life_pay_page.dart +++ b/lib/pages/life_pay/life_pay_page.dart @@ -209,7 +209,7 @@ class _LifePayPageState extends State { }); if (baseModel.success) { bool result = await PayUtil() - .callAliPay(baseModel.message, API.pay.dailPayMentCheck); + .callAliPay(baseModel.msg, API.pay.dailPayMentCheck); if (result) { Get.off(() => PayFinishPage()); } diff --git a/lib/pages/life_pay/life_pre_pay_page.dart b/lib/pages/life_pay/life_pre_pay_page.dart index 0a044ff9..2124652c 100644 --- a/lib/pages/life_pay/life_pre_pay_page.dart +++ b/lib/pages/life_pay/life_pre_pay_page.dart @@ -162,13 +162,13 @@ class _LifePrePayPageState extends State { "payPrice": _editingController.text }); if (baseModel.success) { - bool result = await PayUtil().callAliPay( - baseModel.message, API.pay.dailPaymentPrePayCheck); + bool result = await PayUtil() + .callAliPay(baseModel.msg, API.pay.dailPaymentPrePayCheck); if (result) { Get.off(() => PayFinishPage()); } } else { - BotToast.showText(text: baseModel.message); + BotToast.showText(text: baseModel.msg); } } catch (e) { LoggerData.addData(e); diff --git a/lib/pages/personal/clock_in/clock_in_page.dart b/lib/pages/personal/clock_in/clock_in_page.dart index 41ad7bfe..7f5da0a8 100644 --- a/lib/pages/personal/clock_in/clock_in_page.dart +++ b/lib/pages/personal/clock_in/clock_in_page.dart @@ -1,5 +1,4 @@ import 'package:aku_new_community/base/base_style.dart'; -import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/extensions/num_ext.dart'; import 'package:aku_new_community/extensions/widget_list_ext.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; @@ -65,26 +64,26 @@ class _ClockInPageState extends State { Hero( tag: 'AVATAR', child: ClipOval( - child: FadeInImage.assetNetwork( - placeholder: Assets.images.placeholder.path, - image: API.image( - (UserTool.userProvider.userInfoModel?.imgUrls ?? []) - .isNotEmpty - ? UserTool - .userProvider.userInfoModel!.imgUrls.first.url - : ''), - height: 106.w, - width: 106.w, - fit: BoxFit.cover, - imageErrorBuilder: (context, error, stackTrace) { - return Image.asset( - Assets.icons.iconMySetting.path, - height: 106.w, - width: 106.w, - ); - }, - ), - ), + // child: FadeInImage.assetNetwork( + // placeholder: Assets.images.placeholder.path, + // image: API.image( + // (UserTool.userProvider.userInfoModel?.imgUrls ?? []) + // .isNotEmpty + // ? UserTool + // .userProvider.userInfoModel!.imgUrls.first.url + // : ''), + // height: 106.w, + // width: 106.w, + // fit: BoxFit.cover, + // imageErrorBuilder: (context, error, stackTrace) { + // return Image.asset( + // Assets.icons.iconMySetting.path, + // height: 106.w, + // width: 106.w, + // ); + // }, + // ), + ), ), Container( margin: EdgeInsets.only(left: 16.w), diff --git a/lib/pages/personal/personal_page.dart b/lib/pages/personal/personal_page.dart index b15cfd5f..6dc4c8c4 100644 --- a/lib/pages/personal/personal_page.dart +++ b/lib/pages/personal/personal_page.dart @@ -1,5 +1,4 @@ import 'package:aku_new_community/const/resource.dart'; -import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; import 'package:aku_new_community/pages/personal/clock_in/clock_in_page.dart'; import 'package:aku_new_community/pages/personal/user_profile_page.dart'; @@ -77,26 +76,26 @@ class _PersonalIndexState extends State Hero( tag: 'AVATAR1', child: ClipOval( - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(userProvider - .userInfoModel!.imgUrls.isNotEmpty - ? userProvider - .userInfoModel!.imgUrls.first.url - : ''), - height: 106.w, - width: 106.w, - fit: BoxFit.cover, - imageErrorBuilder: - (context, error, stackTrace) { - return Image.asset( - R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - height: 106.w, - width: 106.w, - ); - }, - ), - ), + // child: FadeInImage.assetNetwork( + // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + // image: API.image(userProvider + // .userInfoModel!.imgUrls.isNotEmpty + // ? userProvider + // .userInfoModel!.imgUrls.first.url + // : ''), + // height: 106.w, + // width: 106.w, + // fit: BoxFit.cover, + // imageErrorBuilder: + // (context, error, stackTrace) { + // return Image.asset( + // R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + // height: 106.w, + // width: 106.w, + // ); + // }, + // ), + ), ), Container( margin: EdgeInsets.only(left: 16.w), @@ -274,30 +273,30 @@ class _PersonalIndexState extends State Hero( tag: 'AVATAR', child: ClipOval( - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image((userProvider - .userInfoModel?.imgUrls ?? - []) - .isNotEmpty - ? (userProvider.userInfoModel?.imgUrls ?? - []) - .first - .url - : ''), - height: 106.w, - width: 106.w, - fit: BoxFit.cover, - imageErrorBuilder: - (context, error, stackTrace) { - return Image.asset( - R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - height: 106.w, - width: 106.w, - ); - }, - ), - ), + // child: FadeInImage.assetNetwork( + // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + // image: API.image((userProvider + // .userInfoModel?.imgUrls ?? + // []) + // .isNotEmpty + // ? (userProvider.userInfoModel?.imgUrls ?? + // []) + // .first + // .url + // : ''), + // height: 106.w, + // width: 106.w, + // fit: BoxFit.cover, + // imageErrorBuilder: + // (context, error, stackTrace) { + // return Image.asset( + // R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + // height: 106.w, + // width: 106.w, + // ); + // }, + // ), + ), ), Container( margin: EdgeInsets.only(left: 16.w), diff --git a/lib/pages/personal/user_profile_page.dart b/lib/pages/personal/user_profile_page.dart index d48c86a4..ed186552 100644 --- a/lib/pages/personal/user_profile_page.dart +++ b/lib/pages/personal/user_profile_page.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:aku_new_community/base/base_style.dart'; -import 'package:aku_new_community/const/resource.dart'; import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/pages/personal/change_nick_name_page.dart'; import 'package:aku_new_community/pages/personal/update_tel_page.dart'; @@ -92,31 +91,31 @@ class _UserProfilePageState extends State { Hero( tag: 'AVATAR', child: ClipOval( - child: - // CachedNetworkImage( - // imageUrl: API.image( - // userProvider.userInfoModel!.imgUrls.isNotEmpty - // ? userProvider.userInfoModel?.imgUrls.first.url - // : ''), - // height: 56.w, - // width: 56.w, - // placeholder: (context, url) => - // Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP), - // errorWidget: (context, url, error) => - // Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP), - // fit: BoxFit.fill, - // ), - FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image( - (userProvider.userInfoModel?.imgUrls ?? []).isNotEmpty - ? userProvider.userInfoModel?.imgUrls.first.url - : ''), - height: 56.w, - width: 56.w, - fit: BoxFit.cover, - ), - ), + // child: + // CachedNetworkImage( + // imageUrl: API.image( + // userProvider.userInfoModel!.imgUrls.isNotEmpty + // ? userProvider.userInfoModel?.imgUrls.first.url + // : ''), + // height: 56.w, + // width: 56.w, + // placeholder: (context, url) => + // Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP), + // errorWidget: (context, url, error) => + // Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP), + // fit: BoxFit.fill, + // ), + // FadeInImage.assetNetwork( + // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + // image: API.image( + // (userProvider.userInfoModel?.imgUrls ?? []).isNotEmpty + // ? userProvider.userInfoModel?.imgUrls.first.url + // : ''), + // height: 56.w, + // width: 56.w, + // fit: BoxFit.cover, + // ), + ), ), onPressed: _pickAvatar, ), diff --git a/lib/pages/share_pay_page/share_pay_page.dart b/lib/pages/share_pay_page/share_pay_page.dart index 77fc1d7d..a72ae1e1 100644 --- a/lib/pages/share_pay_page/share_pay_page.dart +++ b/lib/pages/share_pay_page/share_pay_page.dart @@ -198,7 +198,7 @@ class _SharePayPageState extends State { }); if (baseModel.success) { bool result = await PayUtil() - .callAliPay(baseModel.message, API.pay.sharePayOrderCodeCheck); + .callAliPay(baseModel.msg, API.pay.sharePayOrderCodeCheck); if (result) { Get.off(() => PayFinishPage()); } diff --git a/lib/pages/sign/login/code_message_page.dart b/lib/pages/sign/login/code_message_page.dart index 967d8e09..6961b6e2 100644 --- a/lib/pages/sign/login/code_message_page.dart +++ b/lib/pages/sign/login/code_message_page.dart @@ -20,6 +20,7 @@ class CodeMessagePage extends StatefulWidget { class _CodeMessagePageState extends State { String? _errorMessage; TextEditingController _controller = TextEditingController(); + String? _currentCode; @override void initState() { @@ -53,7 +54,7 @@ class _CodeMessagePageState extends State { .bold .make(), 16.w.heightBox, - _errorMessage == null + _errorMessage != null ? '${_errorMessage}'.text.color(Colors.red).size(28.sp).make() : '验证码已发送至' .richText @@ -69,6 +70,8 @@ class _CodeMessagePageState extends State { .make(), 80.w.heightBox, PinFieldAutoFill( + autoFocus: true, + currentCode: _currentCode, inputFormatters: [FilteringTextInputFormatter.digitsOnly], codeLength: 6, onCodeChanged: (code) async { @@ -79,18 +82,14 @@ class _CodeMessagePageState extends State { UserTool.appProveider.pickedCityAndCommunity! .communityModel!.id); if (re.data['success']) { - UserTool.userProvider.setLogin(re.data['data']); - var success = - await UserTool.userProvider.updateUserInfo(); - if (!success) { - return; - } + UserTool.userProvider.setLogin(re.data['data'] as int); } else { - _errorMessage = re.data['message']; - BotToast.showText(text: re.data['message']); + _errorMessage = re.data['msg']; + BotToast.showText(text: re.data['msg']); _controller.clear(); } } + _currentCode = code; }, decoration: UnderlineDecoration( colorBuilder: FixedColorListBuilder([ @@ -116,7 +115,7 @@ class _CodeMessagePageState extends State { _errorMessage = null; UserTool.appProveider.startTimer(); } else { - BotToast.showText(text: base.message); + BotToast.showText(text: base.msg); } }, child: (UserTool.appProveider.second >= 60 diff --git a/lib/pages/sign/login/forgot_psd_page.dart b/lib/pages/sign/login/forgot_psd_page.dart new file mode 100644 index 00000000..5dec80aa --- /dev/null +++ b/lib/pages/sign/login/forgot_psd_page.dart @@ -0,0 +1,93 @@ +import 'package:aku_new_community/pages/sign/login/forgot_set_psd_page.dart'; +import 'package:aku_new_community/pages/sign/widget/login_button_widget.dart'; +import 'package:aku_new_community/pages/sign/widget/tel_text_field.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:velocity_x/velocity_x.dart'; + +import '../sign_func.dart'; + +class ForgotPsdPage extends StatefulWidget { + const ForgotPsdPage({Key? key}) : super(key: key); + + @override + _ForgotPsdPageState createState() => _ForgotPsdPageState(); +} + +class _ForgotPsdPageState extends State { + TextEditingController _telController = TextEditingController(); + + @override + void dispose() { + _telController.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, + '为了安全,我们会向你的手机发送验证码' + .text + .size(28.sp) + .color(Colors.black.withOpacity(0.45)) + .make(), + Spacer(), + ], + ), + 144.w.heightBox, + TelTextField(controller: _telController), + 100.w.heightBox, + LoginButtonWidget( + onTap: _telController.text.isNotEmpty + ? () async { + if (!RegexUtil.isMobileSimple(_telController.text)) { + BotToast.showText(text: '请输入正确的手机号!'); + return; + } + var base = await SignFunc.sendForgotMessageCode( + _telController.text, + UserTool.appProveider.pickedCityAndCommunity! + .communityModel!.id); + if (base.success) { + Get.to(() => ForgotSetPsdPage( + tel: _telController.text, + )); + UserTool.appProveider.startTimer(); + } else { + BotToast.showText(text: base.msg); + } + } + : null, + text: '下一步'), + ], + ), + ); + } +} diff --git a/lib/pages/sign/login/forgot_set_psd_page.dart b/lib/pages/sign/login/forgot_set_psd_page.dart new file mode 100644 index 00000000..9420d653 --- /dev/null +++ b/lib/pages/sign/login/forgot_set_psd_page.dart @@ -0,0 +1,183 @@ +import 'package:aku_new_community/pages/sign/login/psd_verify.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/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:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +import 'login_page.dart'; + +class ForgotSetPsdPage extends StatefulWidget { + final String tel; + + const ForgotSetPsdPage({Key? key, required this.tel}) : super(key: key); + + @override + _ForgotSetPsdPageState createState() => _ForgotSetPsdPageState(); +} + +class _ForgotSetPsdPageState extends State { + TextEditingController _psdController = TextEditingController(); + TextEditingController _confirmPsdController = TextEditingController(); + TextEditingController _codeController = TextEditingController(); + + PSDVERIFY get psdCheck => + PsdVerify.check(_psdController.text, _confirmPsdController.text); + + @override + void initState() { + _psdController.addListener(() { + setState(() {}); + }); + _confirmPsdController.addListener(() { + setState(() {}); + }); + super.initState(); + } + + @override + void dispose() { + _psdController.removeListener(() {}); + _confirmPsdController.removeListener(() {}); + _psdController.dispose(); + _confirmPsdController.dispose(); + _codeController.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, + '已向 ' + .richText + .withTextSpanChildren([ + widget.tel.textSpan + .size(36.sp) + .color(Colors.red) + .bold + .make(), + ' 发送验证码' + .textSpan + .size(36.sp) + .color(Colors.black.withOpacity(0.65)) + .bold + .make() + ]) + .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, + Container( + width: 686.w, + height: 94.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(60.w), + color: Colors.black.withOpacity(0.06), + ), + child: TextField( + onChanged: (text) { + setState(() {}); + }, + keyboardType: TextInputType.number, + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + controller: _codeController, + decoration: InputDecoration( + isDense: false, + contentPadding: + EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), + border: InputBorder.none, + hintText: '请输入验证码', + suffixIconConstraints: + BoxConstraints(minHeight: 100.w, maxHeight: 100.w), + suffixIcon: GestureDetector( + onTap: () async { + var base = await SignFunc.sendMessageCode( + widget.tel, + UserTool.appProveider.pickedCityAndCommunity! + .communityModel!.id); + if (base.success) { + Get.to(() => ForgotSetPsdPage( + tel: widget.tel, + )); + UserTool.appProveider.startTimer(); + } else { + BotToast.showText(text: base.msg); + } + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + '|${UserTool.appProveider.second < 60 ? '${UserTool.appProveider.second}秒后重新获取' : '获取验证码'}' + .text + .size(28.sp) + .color(Color(0xFF5096F1)) + .make(), + 20.w.widthBox, + ], + ), + ), + hintStyle: TextStyle( + color: Colors.black.withOpacity(0.25), fontSize: 28.sp)), + ), + ), + 24.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 && + _codeController.text.isNotEmpty) + ? () async { + var result = await SignFunc.settingForgotPsd( + _psdController.text, + widget.tel, + _codeController.text); + if (result) { + Get.to(() => LoginPage()); + } + } + : null, + text: '确认'), + ], + ), + ); + } +} diff --git a/lib/pages/sign/login/login_page.dart b/lib/pages/sign/login/login_page.dart index 2f7cbd1f..fe8ed0b0 100644 --- a/lib/pages/sign/login/login_page.dart +++ b/lib/pages/sign/login/login_page.dart @@ -1,6 +1,6 @@ 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/pages/sign/login/select_community_page.dart'; import 'package:aku_new_community/provider/app_provider.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:flutter/material.dart'; @@ -120,21 +120,22 @@ class CommunityWidget extends StatelessWidget { @override Widget build(BuildContext context) { AppProvider appProveider = Provider.of(context, listen: true); + var hasSelect = appProveider.pickedCityAndCommunity != null && + appProveider.pickedCityAndCommunity!.communityModel != null; 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}' + (hasSelect + ? '${appProveider.pickedCityAndCommunity!.cityModel.district.name} ${appProveider.pickedCityAndCommunity!.communityModel!.name}' : '') .text .color(Colors.black) .make(), - '${appProveider.pickedCityAndCommunity == null ? '请先选择小区' : ' 切换'}' + '${hasSelect ? ' 切换' : '请先选择小区'}' .text .size(32.sp) .color(Color(0xFF5096F1)) diff --git a/lib/pages/sign/login/other_login_page.dart b/lib/pages/sign/login/other_login_page.dart index e29cf3e1..3f059b47 100644 --- a/lib/pages/sign/login/other_login_page.dart +++ b/lib/pages/sign/login/other_login_page.dart @@ -1,4 +1,5 @@ import 'package:aku_new_community/pages/sign/login/code_message_page.dart'; +import 'package:aku_new_community/pages/sign/login/forgot_psd_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'; @@ -104,22 +105,24 @@ class _OtherLoginPageState extends State { .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: '登录'), + 24.w.heightBox, + TextButton( + onPressed: () { + Get.to(() => ForgotPsdPage()); + }, + child: '忘记密码'.text.size(28.sp).color(Color(0xFF5096F1)).make()) ], ); } bool checkInput() { - if (!RegexUtil.isTel(_tel.text)) { + if (!RegexUtil.isMobileSimple(_tel.text)) { BotToast.showText(text: '请输入正确的手机号!'); return false; } @@ -143,22 +146,24 @@ class _OtherLoginPageState extends State { 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); - } - }, + onTap: UserTool.appProveider.second < 60 + ? () {} + : () 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.msg); + } + }, text: appProvider.timerStart ? '${appProvider.second}秒后重新获取' : '获取验证码'), diff --git a/lib/pages/sign/login/select_community.dart b/lib/pages/sign/login/select_community_page.dart similarity index 95% rename from lib/pages/sign/login/select_community.dart rename to lib/pages/sign/login/select_community_page.dart index e75fac50..71a384ff 100644 --- a/lib/pages/sign/login/select_community.dart +++ b/lib/pages/sign/login/select_community_page.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/community_model.dart'; import 'package:aku_new_community/models/login/history_login_model.dart'; import 'package:aku_new_community/utils/network/net_util.dart'; @@ -93,7 +93,10 @@ class _SelectCommunityState extends State { onTap: () async { var cancel = BotToast.showLoading(); List _communities = []; - var base = await NetUtil().get(API.login.allCommunity); + var base = await NetUtil().get(SARSAPI.login.allCommunity, params: { + 'cityId': UserTool + .appProveider.pickedCityAndCommunity!.cityModel.district.id, + }); if (base.success) { _communities = (base.data as List) .map((e) => CommunityModel.fromJson(e)) @@ -101,6 +104,7 @@ class _SelectCommunityState extends State { } cancel(); var _community = await BeeCommunityPicker.pick(context, _communities); + print(_community?.name); if (_community != null) { UserTool.appProveider.setPickedCity(community: _community); } diff --git a/lib/pages/sign/login/set_psd_page.dart b/lib/pages/sign/login/set_psd_page.dart index 454d7b45..3016fc02 100644 --- a/lib/pages/sign/login/set_psd_page.dart +++ b/lib/pages/sign/login/set_psd_page.dart @@ -1,10 +1,12 @@ +import 'package:aku_new_community/pages/sign/login/forgot_psd_page.dart'; import 'package:aku_new_community/pages/sign/login/psd_verify.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/widget/bee_scaffold.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; class SetPsdPage extends StatefulWidget { @@ -20,11 +22,22 @@ class _SetPsdPageState extends State { PSDVERIFY get psdCheck => PsdVerify.check(_psdController.text, _confirmPsdController.text); - bool _psdVisible = false; - bool _confirmVisible = false; + + @override + void initState() { + _psdController.addListener(() { + setState(() {}); + }); + _confirmPsdController.addListener(() { + setState(() {}); + }); + super.initState(); + } @override void dispose() { + _psdController.removeListener(() {}); + _confirmPsdController.removeListener(() {}); _psdController.dispose(); _confirmPsdController.dispose(); super.dispose(); @@ -75,7 +88,16 @@ class _SetPsdPageState extends State { .make(), 37.w.heightBox, LoginButtonWidget( - onTap: psdCheck == PSDVERIFY.correct ? () {} : null, text: '确认'), + onTap: psdCheck == PSDVERIFY.correct + ? () async { + var result = + await SignFunc.settingPsd(_psdController.text); + if (result) { + Get.to(() => ForgotPsdPage()); + } + } + : null, + text: '确认'), ], ), ); diff --git a/lib/pages/sign/sign_func.dart b/lib/pages/sign/sign_func.dart index f12e3da3..6e5cd943 100644 --- a/lib/pages/sign/sign_func.dart +++ b/lib/pages/sign/sign_func.dart @@ -27,6 +27,16 @@ class SignFunc { showMessage: true, ); return baseModel; + } //发送手机号验证码 + + static Future sendForgotMessageCode( + String phone, int communityId) async { + BaseModel baseModel = await NetUtil().post( + SARSAPI.user.sendForgotTelCode, + params: {'tel': phone, 'communityId': communityId}, + showMessage: true, + ); + return baseModel; } static Future sendNewMessageCode(String newTel) async { @@ -56,7 +66,7 @@ class SignFunc { static Future loginBySms( String phone, String code, int communityId) async { Response response = await NetUtil().dio!.post( - API.login.login, + SARSAPI.login.loginTelCode, data: { 'tel': phone, 'code': code, @@ -113,12 +123,37 @@ class SignFunc { return false; } + ///更新用户信息 static Future getUserInfo() async { - BaseModel baseModel = await NetUtil().get(API.user.userProfile); + BaseModel baseModel = await NetUtil().get(SARSAPI.user.userProfile); if (baseModel.data == null || !baseModel.success) return null; return UserInfoModel.fromJson(baseModel.data); } + ///设置密码(密码不存在时调用 + static Future settingPsd(String psd) async { + BaseModel baseModel = await NetUtil().get(SARSAPI.user.settingPsd, + params: {'password': psd}, showMessage: true); + if (baseModel.data == null || !baseModel.success) return false; + return true; + } + + ///提交修改的新密码(忘记密码) + static Future settingForgotPsd( + String psd, String tel, String telcode) async { + BaseModel baseModel = await NetUtil().get(SARSAPI.user.settingForgotPsd, + params: { + 'newPassword': psd, + 'tel': tel, + 'telCode': telcode, + 'communityId': + UserTool.appProveider.pickedCityAndCommunity!.communityModel!.id + }, + showMessage: true); + if (baseModel.data == null || !baseModel.success) return false; + return true; + } + static Future getMyHouseInfo() async { BaseModel baseModel = await NetUtil().get( SARSAPI.profile.house.userHouse, 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 07689f93..d833a0ef 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -198,7 +198,7 @@ class _AddFixedSubmitPageState extends State { if (baseModel.success) { Get.off(() => FinishFixedSubmitPage()); } else - BotToast.showText(text: baseModel.message); + BotToast.showText(text: baseModel.msg); cancel(); } : () { diff --git a/lib/pages/things_page/widget/fixed_detail_page.dart b/lib/pages/things_page/widget/fixed_detail_page.dart index d6291b1a..39f5d16c 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.success) && !baseModel.message.isEmptyOrNull) { - bool result = await PayUtil() - .callAliPay(baseModel.message, API.pay.reportReapirCheck); + if ((baseModel.success) && !baseModel.msg.isEmptyOrNull) { + bool result = + await PayUtil().callAliPay(baseModel.msg, API.pay.reportReapirCheck); if (result) { Get.back(); Get.off(() => PayFinishPage()); @@ -429,7 +429,7 @@ class _FixedDetailPageState extends State { Get.back(); } else { Get.back(); - BotToast.showText(text: baseModel.message); + BotToast.showText(text: baseModel.msg); } cancel(); } diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart index 090696d3..9f525815 100644 --- a/lib/provider/app_provider.dart +++ b/lib/provider/app_provider.dart @@ -343,6 +343,7 @@ class AppProvider extends ChangeNotifier { if (community != null) { _pickedCityAndCommunity!.communityModel = community; } + notifyListeners(); } void resetPickedCity() { diff --git a/lib/provider/data_provider.dart b/lib/provider/data_provider.dart index 10a96e98..d5280edd 100644 --- a/lib/provider/data_provider.dart +++ b/lib/provider/data_provider.dart @@ -7,12 +7,14 @@ import 'package:flutter/material.dart'; class DataProvider extends ChangeNotifier { Future init() async { - updateCityList(); _loginHistories = HiveStore.dataBox! .get('historyLogin') ?.cast() .toList() ?? []; + if (_loginHistories.isEmpty) { + updateCityList(); + } } List _cityModel = []; diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 46e1842d..4a862fa9 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -16,7 +16,6 @@ import 'package:flustars/flustars.dart'; import 'package:flutter/foundation.dart'; import 'package:get/get.dart'; import 'package:jpush_flutter/jpush_flutter.dart'; -import 'package:power_logger/power_logger.dart'; import 'package:provider/provider.dart'; class UserProvider extends ChangeNotifier { @@ -27,34 +26,30 @@ class UserProvider extends ChangeNotifier { bool get isNotLogin => !_isLogin; Future setLogin(int token) async { - try { - final appProvider = Provider.of(Get.context!, listen: false); - _isLogin = true; - NetUtil() - .dio! - .options - .headers - .putIfAbsent('App-Admin-Token', () => token); - HiveStore.appBox!.put('token', token); - HiveStore.appBox!.put('login', true); - await updateUserInfo(); - await updateMyHouseInfo(); - - ///初始化用户配置 - _userConfig = await HiveStore.userBox!.get('${_userInfoModel!.id}') ?? - UserConfigModel( - userId: _userInfoModel!.id, - clockRemind: false, - todayClocked: false); - await appProvider.updateHouses(await HouseFunc.passedHouses); - if (isLogin) { - WebSocketUtil().setUser(userInfoModel!.id.toString()); - WebSocketUtil().startWebSocket(); - } - notifyListeners(); - } catch (e) { - LoggerData.addData(e); + // try { + final appProvider = Provider.of(Get.context!, listen: false); + _isLogin = true; + NetUtil().dio!.options.headers['app-login-token'] = token; + HiveStore.appBox!.put('token', token); + HiveStore.appBox!.put('login', true); + await updateUserInfo(); + await updateMyHouseInfo(); + + ///初始化用户配置 + _userConfig = await HiveStore.userBox!.get('${_userInfoModel!.id}') ?? + UserConfigModel( + userId: _userInfoModel!.id, + clockRemind: false, + todayClocked: false); + await appProvider.updateHouses(await HouseFunc.passedHouses); + if (isLogin) { + WebSocketUtil().setUser(userInfoModel!.id.toString()); + WebSocketUtil().startWebSocket(); } + notifyListeners(); + // } catch (e) { + // LoggerData.addData(e); + // } } logout() { @@ -66,7 +61,7 @@ class UserProvider extends ChangeNotifier { _userInfoModel = null; _myHouseInfo = null; NetUtil().get(API.user.logout, showMessage: true); - NetUtil().dio!.options.headers.remove('App-Admin-Token'); + NetUtil().dio!.options.headers.remove('app-login-token'); HiveStore.appBox!.delete('token'); HiveStore.appBox!.delete('login'); WebSocketUtil().closeWebSocket(); @@ -76,11 +71,14 @@ class UserProvider extends ChangeNotifier { Future updateUserInfo() async { _userInfoModel = await SignFunc.getUserInfo(); + print('222'); + if (_userInfoModel == null) { BotToast.showText(text: '获取用户信息失败'); return false; } if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) { + print('111'); SignFunc.checkNameAndAccount(); } diff --git a/lib/ui/community/community_func.dart b/lib/ui/community/community_func.dart index 94c6ccb2..0e17540d 100644 --- a/lib/ui/community/community_func.dart +++ b/lib/ui/community/community_func.dart @@ -34,9 +34,7 @@ class CommunityFunc { params: {'pageNum': 1, 'size': 8}, ); if (model.tableList!.length == 0) return []; - return model.tableList! - .map((e) => MyEventItemModel.fromJson(e)) - .toList(); + return model.tableList!.map((e) => MyEventItemModel.fromJson(e)).toList(); } ///查询热门资讯 @@ -57,8 +55,8 @@ class CommunityFunc { 'newsId': newsId, }, ); - if (model.message == null) return ''; - return (model.message as String).toString(); + if (model.msg == null) return ''; + return (model.msg as String).toString(); } ///查询当天上架的商品数量 diff --git a/lib/ui/community/facility/facility_preorder_page.dart b/lib/ui/community/facility/facility_preorder_page.dart index 45cf7f08..061982bd 100644 --- a/lib/ui/community/facility/facility_preorder_page.dart +++ b/lib/ui/community/facility/facility_preorder_page.dart @@ -178,7 +178,7 @@ class _FacilityPreorderPageState extends State { if (model.success == true) { BotToast.showText(text: '预约成功'); Get.back(result: true); - } else if (model.message == '该时段已被预约') { + } else if (model.msg == '该时段已被预约') { await Get.dialog(_hasBeenOrder()); } else { BotToast.showText(text: '预约失败'); diff --git a/lib/ui/manager/advice/advice_detail_page.dart b/lib/ui/manager/advice/advice_detail_page.dart index fd54871f..098bd173 100644 --- a/lib/ui/manager/advice/advice_detail_page.dart +++ b/lib/ui/manager/advice/advice_detail_page.dart @@ -222,7 +222,7 @@ class _AdviceDetailPageState extends State { if (baseModel.success) { Get.to(() => AdviceEvaluatePage(id: widget.model!.id)); } - BotToast.showText(text: baseModel.message); + BotToast.showText(text: baseModel.msg); }, child: '完成沟通'.text.bold.make(), ), diff --git a/lib/ui/manager/house_keeping/house_keeping_func.dart b/lib/ui/manager/house_keeping/house_keeping_func.dart index 2b4462e5..6c51f8a5 100644 --- a/lib/ui/manager/house_keeping/house_keeping_func.dart +++ b/lib/ui/manager/house_keeping/house_keeping_func.dart @@ -89,7 +89,7 @@ class HouseKeepingFunc { "payPrice": price }); if (baseModel.success) { - return baseModel.message; + return baseModel.msg; } else { return ''; } diff --git a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart index e0945c4f..0ad527b2 100644 --- a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart +++ b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart @@ -269,7 +269,7 @@ class _QuestionnaireDetailPageState extends State { widget.id, _submitModels); Get.to(() => SubmitComplishPage( status: baseModel.success, - message: baseModel.message, + message: baseModel.msg, )); }, ), diff --git a/lib/ui/market/goods/goods_detail_page.dart b/lib/ui/market/goods/goods_detail_page.dart index bb89e5d5..a78508b1 100644 --- a/lib/ui/market/goods/goods_detail_page.dart +++ b/lib/ui/market/goods/goods_detail_page.dart @@ -91,7 +91,7 @@ class _GoodsDetailPageState extends State { _goodsModel = GoodsDetailModel.fromJson(baseModel.data); } else { _goodsModel = GoodsDetailModel.fail(); - BotToast.showText(text: baseModel.message ?? '未知错误'); + BotToast.showText(text: baseModel.msg ?? '未知错误'); } baseModel = await NetUtil().get(API.market.suppliyerHotTop, params: { "supplierId": _goodsModel.supplierId, diff --git a/lib/ui/market/goods/goods_order_detail_page.dart b/lib/ui/market/goods/goods_order_detail_page.dart index 9e6c0d79..18c841a5 100644 --- a/lib/ui/market/goods/goods_order_detail_page.dart +++ b/lib/ui/market/goods/goods_order_detail_page.dart @@ -100,14 +100,14 @@ class _GoodsOrderDetailPageState extends State { }, showMessage: false, ); - if ((baseModel.success) && !baseModel.message.isEmptyOrNull) { + if ((baseModel.success) && !baseModel.msg.isEmptyOrNull) { bool result = await PayUtil() - .callAliPay(baseModel.message!, API.pay.shoppingCheck); + .callAliPay(baseModel.msg!, API.pay.shoppingCheck); if (result) { Get.off(() => PayFinishPage()); } } else { - BotToast.showText(text: baseModel.message!); + BotToast.showText(text: baseModel.msg!); } cancel(); }, diff --git a/lib/ui/market/order/order_card.dart b/lib/ui/market/order/order_card.dart index 9e9566a3..74521a08 100644 --- a/lib/ui/market/order/order_card.dart +++ b/lib/ui/market/order/order_card.dart @@ -76,7 +76,7 @@ class _OrderCardState extends State { }); if (baseModel.success) { bool result = await PayUtil() - .callAliPay(baseModel.message, API.pay.sharePayOrderCodeCheck); + .callAliPay(baseModel.msg, API.pay.sharePayOrderCodeCheck); if (result) { Get.off(() => PayFinishPage()); } diff --git a/lib/ui/market/order/order_detail_page.dart b/lib/ui/market/order/order_detail_page.dart index 56feaaa6..96dd1a8c 100644 --- a/lib/ui/market/order/order_detail_page.dart +++ b/lib/ui/market/order/order_detail_page.dart @@ -63,7 +63,7 @@ class _OrderDetailPageState extends State { }); if (baseModel.success) { bool result = await PayUtil() - .callAliPay(baseModel.message, API.pay.jcookOrderCheckAlipay); + .callAliPay(baseModel.msg, API.pay.jcookOrderCheckAlipay); if (result) { Get.off(() => OrderPage(initIndex: 2)); } else { diff --git a/lib/ui/market/search/search_func.dart b/lib/ui/market/search/search_func.dart index ce5be22a..915c12bb 100644 --- a/lib/ui/market/search/search_func.dart +++ b/lib/ui/market/search/search_func.dart @@ -74,8 +74,8 @@ class SearchFunc { static Future addGoodsCar(int jcookGoodsId) async { BaseModel model = await NetUtil().post(API.market.insertShoppingCart, params: {'jcookGoodsId': jcookGoodsId}, showMessage: true); - if (model.message == null) return ''; - return model.message as String; + if (model.msg == null) return ''; + return model.msg as String; } ///确认收货 diff --git a/lib/ui/market/search/submit_order_page.dart b/lib/ui/market/search/submit_order_page.dart index 9c253703..accf9f64 100644 --- a/lib/ui/market/search/submit_order_page.dart +++ b/lib/ui/market/search/submit_order_page.dart @@ -136,7 +136,7 @@ class _SubmitOrderPageState extends State { }); if (baseModel.success) { bool result = await PayUtil().callAliPay( - baseModel.message, API.pay.jcookOrderCheckAlipay); + baseModel.msg, API.pay.jcookOrderCheckAlipay); if (result) { Get.off(() => OrderPage(initIndex: 2)); } else { @@ -729,7 +729,7 @@ class _SubmitOrderPageState extends State { var base = await NetUtil().post(API.market.shopCarChangeNum, params: {'jcookGoodsId': jcookGoodsId, 'num': num}); if (!(base.success)) { - BotToast.showText(text: base.message); + BotToast.showText(text: base.msg); } cancel(); 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 edfae781..53500c80 100644 --- a/lib/ui/market/search/submit_order_page_normal.dart +++ b/lib/ui/market/search/submit_order_page_normal.dart @@ -124,7 +124,7 @@ class _SubmitOrderNormalPageState extends State { }); if (baseModel.success) { bool result = await PayUtil().callAliPay( - baseModel.message, API.pay.jcookOrderCheckAlipay); + baseModel.msg, API.pay.jcookOrderCheckAlipay); if (result) { Get.off(() => OrderPage(initIndex: 2)); } else { @@ -686,7 +686,7 @@ class _SubmitOrderNormalPageState extends State { var base = await NetUtil().post(API.market.shopCarChangeNum, params: {'jcookGoodsId': jcookGoodsId, 'num': num}); if (!(base.success)) { - BotToast.showText(text: base.message); + BotToast.showText(text: base.msg); } cancel(); 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 60a7189e..f8e1e837 100644 --- a/lib/ui/market/shop_car/shop_car_page.dart +++ b/lib/ui/market/shop_car/shop_car_page.dart @@ -610,7 +610,7 @@ class _ShopCarPageState extends State { var base = await NetUtil().post(API.market.shopCarChangeNum, params: {'jcookGoodsId': jcookGoodsId, 'num': num}); if (!(base.success)) { - BotToast.showText(text: base.message); + BotToast.showText(text: base.msg); } cancel(); return base.success; diff --git a/lib/ui/profile/house/house_func.dart b/lib/ui/profile/house/house_func.dart index 949ba6d9..bd99b032 100644 --- a/lib/ui/profile/house/house_func.dart +++ b/lib/ui/profile/house/house_func.dart @@ -179,7 +179,7 @@ class HouseFunc { "payPrice": price, }); if (baseModel.success) { - return baseModel.message; + return baseModel.msg; } else { return ''; } @@ -215,7 +215,7 @@ class HouseFunc { BaseModel baseModel = await NetUtil().post(API.pay.leaseRentOrderAlipay, params: {"sysLeaseId": id, "payType": type, "payPrice": price}); if (baseModel.success) { - return baseModel.message; + return baseModel.msg; } else { return ''; } @@ -251,7 +251,7 @@ class HouseFunc { BaseModel baseModel = await NetUtil().post(API.pay.leaseRentBillorder, params: {"sysLeaseRentId": id, "payType": type, "payPrice": price}); if (baseModel.success) { - return baseModel.message; + return baseModel.msg; } else { return ''; } diff --git a/lib/utils/network/base_model.dart b/lib/utils/network/base_model.dart index cb4f958c..b976a7c8 100644 --- a/lib/utils/network/base_model.dart +++ b/lib/utils/network/base_model.dart @@ -2,24 +2,24 @@ import 'package:json_annotation/json_annotation.dart'; part 'base_model.g.dart'; -@JsonSerializable() +@JsonSerializable(includeIfNull: false) class BaseModel { - int code; - String message; - bool success; - dynamic data; + final int code; + final String msg; + final bool success; + final dynamic data; + factory BaseModel.fromJson(Map json) => _$BaseModelFromJson(json); - BaseModel.err( - {this.message = '未知错误', - this.success = false, - this.data = null, - this.code = 0}); + + static BaseModel error( + String? message, bool success, dynamic data, int code) => + BaseModel(code: code, msg: message ?? '未知错误', success: success); BaseModel({ required this.code, - required this.message, + required this.msg, required this.success, - required this.data, + this.data, }); } diff --git a/lib/utils/network/base_model.g.dart b/lib/utils/network/base_model.g.dart index 4f0b9296..4e7be45d 100644 --- a/lib/utils/network/base_model.g.dart +++ b/lib/utils/network/base_model.g.dart @@ -8,7 +8,7 @@ part of 'base_model.dart'; BaseModel _$BaseModelFromJson(Map json) => BaseModel( code: json['code'] as int, - message: json['message'] as String, + msg: json['msg'] 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 93b65aa7..2625903f 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -47,7 +47,7 @@ class NetUtil { ///call auth after login auth(String token) { - _dio!.options.headers.putIfAbsent('App-Admin-Token', () => token); + _dio!.options.headers['app-login-token'] = token; } static String getDate(DateTime date) => @@ -61,15 +61,21 @@ class NetUtil { Map? params, bool showMessage = false, }) async { + var _baseModel; try { Response res = await _dio!.get(path, queryParameters: params); - BaseModel baseModel = BaseModel.fromJson(res.data); - _parseRequestError(baseModel, showMessage: showMessage); - return baseModel; + if (!res.data['success']) { + _baseModel = BaseModel.error(res.data['message'], res.data['success'], + res.data['data'], res.data['code']); + _parseRequestError(_baseModel, showMessage: showMessage); + } else { + _baseModel = BaseModel.fromJson(res.data); + } } on DioError catch (e) { _parseErr(e); + _baseModel = BaseModel(code: 0, msg: '未知错误', success: false, data: null); } - return BaseModel.err(); + return _baseModel; } /// ## alias of Dio().post @@ -82,17 +88,21 @@ class NetUtil { Map? params, bool showMessage = false, }) async { + var _baseModel; try { Response res = await _dio!.post(path, data: params); - - BaseModel baseModel = BaseModel.fromJson(res.data); - _parseRequestError(baseModel, showMessage: showMessage); - - return baseModel; + if (!res.data['success']) { + _baseModel = BaseModel.error(res.data['message'], res.data['success'], + res.data['data'], res.data['code']); + _parseRequestError(_baseModel, showMessage: showMessage); + } else { + _baseModel = BaseModel.fromJson(res.data); + } } on DioError catch (e) { _parseErr(e); + _baseModel = BaseModel(code: 0, msg: '未知错误', success: false, data: null); } - return BaseModel.err(); + return _baseModel; } Future getList( @@ -182,12 +192,14 @@ class NetUtil { _parseRequestError(BaseModel model, {bool showMessage = false}) { final userProvider = Provider.of(Get.context!, listen: false); - if (!model.success && model.message == '登录失效,请登录' && userProvider.isLogin) { + if (!model.success && + (model.code == 10010 || model.msg == '登录失效,请重新登录') && + userProvider.isLogin) { userProvider.logout(); Get.offAll(() => LoginPage()); } if (!model.success || showMessage) { - BotToast.showText(text: model.message); + BotToast.showText(text: model.msg); } } } diff --git a/lib/widget/picker/bee_city_picker.dart b/lib/widget/picker/bee_city_picker.dart index 863bf181..30a39b45 100644 --- a/lib/widget/picker/bee_city_picker.dart +++ b/lib/widget/picker/bee_city_picker.dart @@ -88,9 +88,9 @@ class _BeeCityPickerState extends State { children: [ Expanded( child: CupertinoPicker( - itemExtent: 40.w, - magnification: 1.1, - offAxisFraction: -0.6, + itemExtent: 60.w, + magnification: 1.0, + // offAxisFraction: -0.6, looping: true, onSelectedItemChanged: (index) { _pickedProvinceIndex = index; @@ -101,7 +101,7 @@ class _BeeCityPickerState extends State { children: provinces .map((e) => Center( child: Padding( - padding: EdgeInsets.only(left: 24.w, right: 8.w), + padding: EdgeInsets.only(left: 20.w, right: 20.w), child: Text(e.name, textAlign: TextAlign.center), ), )) @@ -110,8 +110,8 @@ class _BeeCityPickerState extends State { ), Expanded( child: CupertinoPicker( - itemExtent: 40.w, - magnification: 1.1, + itemExtent: 60.w, + magnification: 1.0, looping: true, scrollController: _cityController, onSelectedItemChanged: (index) { @@ -122,7 +122,7 @@ class _BeeCityPickerState extends State { children: cities .map((e) => Center( child: Padding( - padding: EdgeInsets.symmetric(horizontal: 14.w), + padding: EdgeInsets.symmetric(horizontal: 20.w), child: Text(e.name, textAlign: TextAlign.center), ), )) @@ -131,9 +131,9 @@ class _BeeCityPickerState extends State { ), Expanded( child: CupertinoPicker( - itemExtent: 40.w, - magnification: 1.1, - offAxisFraction: 0.6, + itemExtent: 60.w, + magnification: 1.0, + // offAxisFraction: 0.6, looping: true, scrollController: _districtController, onSelectedItemChanged: (index) { @@ -145,7 +145,7 @@ class _BeeCityPickerState extends State { : districts .map((e) => Center( child: Padding( - padding: EdgeInsets.only(left: 4.w, right: 20.w), + padding: EdgeInsets.only(left: 20.w, right: 20.w), child: Text(e.name, textAlign: TextAlign.center), ), )) diff --git a/lib/widget/picker/bee_community_picker.dart b/lib/widget/picker/bee_community_picker.dart index 13da613d..bf661c45 100644 --- a/lib/widget/picker/bee_community_picker.dart +++ b/lib/widget/picker/bee_community_picker.dart @@ -45,6 +45,9 @@ class _BeeCommunityPickerState extends State { @override void initState() { _communities = widget.communities; + if (widget.communities.isNotEmpty) { + _pickedCommunity = widget.communities[0]; + } super.initState(); }