添加忘记密码功能模块

pull/1/head
张萌 3 years ago
parent f69decf4ae
commit ad6cd6fc8b

@ -28,6 +28,15 @@ class _City {
class _User { class _User {
/// ///
String get userProfile => '/app/user/findDetail'; 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 { class _Login {

@ -9,7 +9,7 @@ class UserInfoModel {
final int communityId; final int communityId;
final String? name; final String? name;
final String tel; final String tel;
final List<ImgModel> imgUrls; // final List<ImgModel> imgUrls;
/// 1. 2. 3. /// 1. 2. 3.
final int? sex; final int? sex;
@ -40,7 +40,6 @@ class UserInfoModel {
required this.communityId, required this.communityId,
this.name, this.name,
required this.tel, required this.tel,
required this.imgUrls,
this.sex, this.sex,
this.nickName, this.nickName,
required this.isExistPassword, required this.isExistPassword,

@ -12,9 +12,6 @@ UserInfoModel _$UserInfoModelFromJson(Map<String, dynamic> json) =>
communityId: json['communityId'] as int, communityId: json['communityId'] as int,
name: json['name'] as String?, name: json['name'] as String?,
tel: json['tel'] as String, tel: json['tel'] as String,
imgUrls: (json['imgUrls'] as List<dynamic>)
.map((e) => ImgModel.fromJson(e as Map<String, dynamic>))
.toList(),
sex: json['sex'] as int?, sex: json['sex'] as int?,
nickName: json['nickName'] as String?, nickName: json['nickName'] as String?,
isExistPassword: json['isExistPassword'] as bool, isExistPassword: json['isExistPassword'] as bool,

@ -280,7 +280,7 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
_hasVoted = true; _hasVoted = true;
setState(() {}); setState(() {});
} else { } else {
BotToast.showText(text: '${baseModel.message}'); BotToast.showText(text: '${baseModel.msg}');
} }
} }
}, },

@ -135,7 +135,7 @@ class _ExpressPackageCardState extends State<ExpressPackageCard> {
}, },
); );
if (baseModel.success) { if (baseModel.success) {
BotToast.showText(text: baseModel.message); BotToast.showText(text: baseModel.msg);
} }
return baseModel.success; return baseModel.success;
} }

@ -455,7 +455,7 @@ class _DetoCreatePageState extends State<DetoCreatePage> {
if (baseModel.success) { if (baseModel.success) {
Get.back(); Get.back();
} else } else
BotToast.showText(text: baseModel.message); BotToast.showText(text: baseModel.msg);
cancel(); cancel();
} }
: () { : () {

@ -209,7 +209,7 @@ class _LifePayPageState extends State<LifePayPage> {
}); });
if (baseModel.success) { if (baseModel.success) {
bool result = await PayUtil() bool result = await PayUtil()
.callAliPay(baseModel.message, API.pay.dailPayMentCheck); .callAliPay(baseModel.msg, API.pay.dailPayMentCheck);
if (result) { if (result) {
Get.off(() => PayFinishPage()); Get.off(() => PayFinishPage());
} }

@ -162,13 +162,13 @@ class _LifePrePayPageState extends State<LifePrePayPage> {
"payPrice": _editingController.text "payPrice": _editingController.text
}); });
if (baseModel.success) { if (baseModel.success) {
bool result = await PayUtil().callAliPay( bool result = await PayUtil()
baseModel.message, API.pay.dailPaymentPrePayCheck); .callAliPay(baseModel.msg, API.pay.dailPaymentPrePayCheck);
if (result) { if (result) {
Get.off(() => PayFinishPage()); Get.off(() => PayFinishPage());
} }
} else { } else {
BotToast.showText(text: baseModel.message); BotToast.showText(text: baseModel.msg);
} }
} catch (e) { } catch (e) {
LoggerData.addData(e); LoggerData.addData(e);

@ -1,5 +1,4 @@
import 'package:aku_new_community/base/base_style.dart'; 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/num_ext.dart';
import 'package:aku_new_community/extensions/widget_list_ext.dart'; import 'package:aku_new_community/extensions/widget_list_ext.dart';
import 'package:aku_new_community/gen/assets.gen.dart'; import 'package:aku_new_community/gen/assets.gen.dart';
@ -65,26 +64,26 @@ class _ClockInPageState extends State<ClockInPage> {
Hero( Hero(
tag: 'AVATAR', tag: 'AVATAR',
child: ClipOval( child: ClipOval(
child: FadeInImage.assetNetwork( // child: FadeInImage.assetNetwork(
placeholder: Assets.images.placeholder.path, // placeholder: Assets.images.placeholder.path,
image: API.image( // image: API.image(
(UserTool.userProvider.userInfoModel?.imgUrls ?? []) // (UserTool.userProvider.userInfoModel?.imgUrls ?? [])
.isNotEmpty // .isNotEmpty
? UserTool // ? UserTool
.userProvider.userInfoModel!.imgUrls.first.url // .userProvider.userInfoModel!.imgUrls.first.url
: ''), // : ''),
height: 106.w, // height: 106.w,
width: 106.w, // width: 106.w,
fit: BoxFit.cover, // fit: BoxFit.cover,
imageErrorBuilder: (context, error, stackTrace) { // imageErrorBuilder: (context, error, stackTrace) {
return Image.asset( // return Image.asset(
Assets.icons.iconMySetting.path, // Assets.icons.iconMySetting.path,
height: 106.w, // height: 106.w,
width: 106.w, // width: 106.w,
); // );
}, // },
), // ),
), ),
), ),
Container( Container(
margin: EdgeInsets.only(left: 16.w), margin: EdgeInsets.only(left: 16.w),

@ -1,5 +1,4 @@
import 'package:aku_new_community/const/resource.dart'; 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/gen/assets.gen.dart';
import 'package:aku_new_community/pages/personal/clock_in/clock_in_page.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'; import 'package:aku_new_community/pages/personal/user_profile_page.dart';
@ -77,26 +76,26 @@ class _PersonalIndexState extends State<PersonalIndex>
Hero( Hero(
tag: 'AVATAR1', tag: 'AVATAR1',
child: ClipOval( child: ClipOval(
child: FadeInImage.assetNetwork( // child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(userProvider // image: API.image(userProvider
.userInfoModel!.imgUrls.isNotEmpty // .userInfoModel!.imgUrls.isNotEmpty
? userProvider // ? userProvider
.userInfoModel!.imgUrls.first.url // .userInfoModel!.imgUrls.first.url
: ''), // : ''),
height: 106.w, // height: 106.w,
width: 106.w, // width: 106.w,
fit: BoxFit.cover, // fit: BoxFit.cover,
imageErrorBuilder: // imageErrorBuilder:
(context, error, stackTrace) { // (context, error, stackTrace) {
return Image.asset( // return Image.asset(
R.ASSETS_IMAGES_PLACEHOLDER_WEBP, // R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
height: 106.w, // height: 106.w,
width: 106.w, // width: 106.w,
); // );
}, // },
), // ),
), ),
), ),
Container( Container(
margin: EdgeInsets.only(left: 16.w), margin: EdgeInsets.only(left: 16.w),
@ -274,30 +273,30 @@ class _PersonalIndexState extends State<PersonalIndex>
Hero( Hero(
tag: 'AVATAR', tag: 'AVATAR',
child: ClipOval( child: ClipOval(
child: FadeInImage.assetNetwork( // child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image((userProvider // image: API.image((userProvider
.userInfoModel?.imgUrls ?? // .userInfoModel?.imgUrls ??
[]) // [])
.isNotEmpty // .isNotEmpty
? (userProvider.userInfoModel?.imgUrls ?? // ? (userProvider.userInfoModel?.imgUrls ??
[]) // [])
.first // .first
.url // .url
: ''), // : ''),
height: 106.w, // height: 106.w,
width: 106.w, // width: 106.w,
fit: BoxFit.cover, // fit: BoxFit.cover,
imageErrorBuilder: // imageErrorBuilder:
(context, error, stackTrace) { // (context, error, stackTrace) {
return Image.asset( // return Image.asset(
R.ASSETS_IMAGES_PLACEHOLDER_WEBP, // R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
height: 106.w, // height: 106.w,
width: 106.w, // width: 106.w,
); // );
}, // },
), // ),
), ),
), ),
Container( Container(
margin: EdgeInsets.only(left: 16.w), margin: EdgeInsets.only(left: 16.w),

@ -1,7 +1,6 @@
import 'dart:io'; import 'dart:io';
import 'package:aku_new_community/base/base_style.dart'; 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/constants/api.dart';
import 'package:aku_new_community/pages/personal/change_nick_name_page.dart'; import 'package:aku_new_community/pages/personal/change_nick_name_page.dart';
import 'package:aku_new_community/pages/personal/update_tel_page.dart'; import 'package:aku_new_community/pages/personal/update_tel_page.dart';
@ -92,31 +91,31 @@ class _UserProfilePageState extends State<UserProfilePage> {
Hero( Hero(
tag: 'AVATAR', tag: 'AVATAR',
child: ClipOval( child: ClipOval(
child: // child:
// CachedNetworkImage( // CachedNetworkImage(
// imageUrl: API.image( // imageUrl: API.image(
// userProvider.userInfoModel!.imgUrls.isNotEmpty // userProvider.userInfoModel!.imgUrls.isNotEmpty
// ? userProvider.userInfoModel?.imgUrls.first.url // ? userProvider.userInfoModel?.imgUrls.first.url
// : ''), // : ''),
// height: 56.w, // height: 56.w,
// width: 56.w, // width: 56.w,
// placeholder: (context, url) => // placeholder: (context, url) =>
// Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP), // Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP),
// errorWidget: (context, url, error) => // errorWidget: (context, url, error) =>
// Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP), // Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP),
// fit: BoxFit.fill, // fit: BoxFit.fill,
// ), // ),
FadeInImage.assetNetwork( // FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image( // image: API.image(
(userProvider.userInfoModel?.imgUrls ?? []).isNotEmpty // (userProvider.userInfoModel?.imgUrls ?? []).isNotEmpty
? userProvider.userInfoModel?.imgUrls.first.url // ? userProvider.userInfoModel?.imgUrls.first.url
: ''), // : ''),
height: 56.w, // height: 56.w,
width: 56.w, // width: 56.w,
fit: BoxFit.cover, // fit: BoxFit.cover,
), // ),
), ),
), ),
onPressed: _pickAvatar, onPressed: _pickAvatar,
), ),

@ -198,7 +198,7 @@ class _SharePayPageState extends State<SharePayPage> {
}); });
if (baseModel.success) { if (baseModel.success) {
bool result = await PayUtil() bool result = await PayUtil()
.callAliPay(baseModel.message, API.pay.sharePayOrderCodeCheck); .callAliPay(baseModel.msg, API.pay.sharePayOrderCodeCheck);
if (result) { if (result) {
Get.off(() => PayFinishPage()); Get.off(() => PayFinishPage());
} }

@ -20,6 +20,7 @@ class CodeMessagePage extends StatefulWidget {
class _CodeMessagePageState extends State<CodeMessagePage> { class _CodeMessagePageState extends State<CodeMessagePage> {
String? _errorMessage; String? _errorMessage;
TextEditingController _controller = TextEditingController(); TextEditingController _controller = TextEditingController();
String? _currentCode;
@override @override
void initState() { void initState() {
@ -53,7 +54,7 @@ class _CodeMessagePageState extends State<CodeMessagePage> {
.bold .bold
.make(), .make(),
16.w.heightBox, 16.w.heightBox,
_errorMessage == null _errorMessage != null
? '${_errorMessage}'.text.color(Colors.red).size(28.sp).make() ? '${_errorMessage}'.text.color(Colors.red).size(28.sp).make()
: '验证码已发送至' : '验证码已发送至'
.richText .richText
@ -69,6 +70,8 @@ class _CodeMessagePageState extends State<CodeMessagePage> {
.make(), .make(),
80.w.heightBox, 80.w.heightBox,
PinFieldAutoFill( PinFieldAutoFill(
autoFocus: true,
currentCode: _currentCode,
inputFormatters: [FilteringTextInputFormatter.digitsOnly], inputFormatters: [FilteringTextInputFormatter.digitsOnly],
codeLength: 6, codeLength: 6,
onCodeChanged: (code) async { onCodeChanged: (code) async {
@ -79,18 +82,14 @@ class _CodeMessagePageState extends State<CodeMessagePage> {
UserTool.appProveider.pickedCityAndCommunity! UserTool.appProveider.pickedCityAndCommunity!
.communityModel!.id); .communityModel!.id);
if (re.data['success']) { if (re.data['success']) {
UserTool.userProvider.setLogin(re.data['data']); UserTool.userProvider.setLogin(re.data['data'] as int);
var success =
await UserTool.userProvider.updateUserInfo();
if (!success) {
return;
}
} else { } else {
_errorMessage = re.data['message']; _errorMessage = re.data['msg'];
BotToast.showText(text: re.data['message']); BotToast.showText(text: re.data['msg']);
_controller.clear(); _controller.clear();
} }
} }
_currentCode = code;
}, },
decoration: UnderlineDecoration( decoration: UnderlineDecoration(
colorBuilder: FixedColorListBuilder([ colorBuilder: FixedColorListBuilder([
@ -116,7 +115,7 @@ class _CodeMessagePageState extends State<CodeMessagePage> {
_errorMessage = null; _errorMessage = null;
UserTool.appProveider.startTimer(); UserTool.appProveider.startTimer();
} else { } else {
BotToast.showText(text: base.message); BotToast.showText(text: base.msg);
} }
}, },
child: (UserTool.appProveider.second >= 60 child: (UserTool.appProveider.second >= 60

@ -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<ForgotPsdPage> {
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: '下一步'),
],
),
);
}
}

@ -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<ForgotSetPsdPage> {
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: '确认'),
],
),
);
}
}

@ -1,6 +1,6 @@
import 'package:aku_new_community/base/base_style.dart'; 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/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/provider/app_provider.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -120,21 +120,22 @@ class CommunityWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
AppProvider appProveider = Provider.of<AppProvider>(context, listen: true); AppProvider appProveider = Provider.of<AppProvider>(context, listen: true);
var hasSelect = appProveider.pickedCityAndCommunity != null &&
appProveider.pickedCityAndCommunity!.communityModel != null;
return GestureDetector( return GestureDetector(
onTap: () async { onTap: () async {
await Get.to(() => SelectCommunity()); await Get.to(() => SelectCommunity());
// setState();
}, },
child: Row( child: Row(
mainAxisAlignment: align ?? MainAxisAlignment.center, mainAxisAlignment: align ?? MainAxisAlignment.center,
children: [ children: [
(appProveider.pickedCityAndCommunity != null (hasSelect
? '${appProveider.pickedCityAndCommunity?.cityModel.district.name ?? ''} ${appProveider.pickedCityAndCommunity!.communityModel!.name}' ? '${appProveider.pickedCityAndCommunity!.cityModel.district.name} ${appProveider.pickedCityAndCommunity!.communityModel!.name}'
: '') : '')
.text .text
.color(Colors.black) .color(Colors.black)
.make(), .make(),
'${appProveider.pickedCityAndCommunity == null ? '请先选择小区' : ' 切换'}' '${hasSelect ? ' 切换' : '请先选择小区'}'
.text .text
.size(32.sp) .size(32.sp)
.color(Color(0xFF5096F1)) .color(Color(0xFF5096F1))

@ -1,4 +1,5 @@
import 'package:aku_new_community/pages/sign/login/code_message_page.dart'; 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/login/login_page.dart';
import 'package:aku_new_community/pages/sign/sign_func.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/login_button_widget.dart';
@ -104,22 +105,24 @@ class _OtherLoginPageState extends State<OtherLoginPage> {
.appProveider.pickedCityAndCommunity!.communityModel!.id); .appProveider.pickedCityAndCommunity!.communityModel!.id);
if (response.data['success']) { if (response.data['success']) {
UserTool.userProvider.setLogin(response.data['data']); UserTool.userProvider.setLogin(response.data['data']);
var success = await UserTool.userProvider.updateUserInfo();
if (!success) {
return;
}
} else { } else {
BotToast.showText(text: response.data['message']); BotToast.showText(text: response.data['message']);
} }
cancel(); cancel();
}, },
text: '登录'), text: '登录'),
24.w.heightBox,
TextButton(
onPressed: () {
Get.to(() => ForgotPsdPage());
},
child: '忘记密码'.text.size(28.sp).color(Color(0xFF5096F1)).make())
], ],
); );
} }
bool checkInput() { bool checkInput() {
if (!RegexUtil.isTel(_tel.text)) { if (!RegexUtil.isMobileSimple(_tel.text)) {
BotToast.showText(text: '请输入正确的手机号!'); BotToast.showText(text: '请输入正确的手机号!');
return false; return false;
} }
@ -143,22 +146,24 @@ class _OtherLoginPageState extends State<OtherLoginPage> {
TelTextField(controller: _tel), TelTextField(controller: _tel),
100.w.heightBox, 100.w.heightBox,
LoginButtonWidget( LoginButtonWidget(
onTap: () async { onTap: UserTool.appProveider.second < 60
var check = checkInput(); ? () {}
if (!check) { : () async {
return; var check = checkInput();
} if (!check) {
var base = await SignFunc.sendMessageCode( return;
_tel.text, }
UserTool var base = await SignFunc.sendMessageCode(
.appProveider.pickedCityAndCommunity!.communityModel!.id); _tel.text,
if (base.success) { UserTool.appProveider.pickedCityAndCommunity!
Get.to(() => CodeMessagePage(tel: _tel.text)); .communityModel!.id);
appProvider.startTimer(); if (base.success) {
} else { Get.to(() => CodeMessagePage(tel: _tel.text));
BotToast.showText(text: base.message); appProvider.startTimer();
} } else {
}, BotToast.showText(text: base.msg);
}
},
text: appProvider.timerStart text: appProvider.timerStart
? '${appProvider.second}秒后重新获取' ? '${appProvider.second}秒后重新获取'
: '获取验证码'), : '获取验证码'),

@ -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/community_model.dart';
import 'package:aku_new_community/models/login/history_login_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/utils/network/net_util.dart';
@ -93,7 +93,10 @@ class _SelectCommunityState extends State<SelectCommunity> {
onTap: () async { onTap: () async {
var cancel = BotToast.showLoading(); var cancel = BotToast.showLoading();
List<CommunityModel> _communities = []; List<CommunityModel> _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) { if (base.success) {
_communities = (base.data as List) _communities = (base.data as List)
.map((e) => CommunityModel.fromJson(e)) .map((e) => CommunityModel.fromJson(e))
@ -101,6 +104,7 @@ class _SelectCommunityState extends State<SelectCommunity> {
} }
cancel(); cancel();
var _community = await BeeCommunityPicker.pick(context, _communities); var _community = await BeeCommunityPicker.pick(context, _communities);
print(_community?.name);
if (_community != null) { if (_community != null) {
UserTool.appProveider.setPickedCity(community: _community); UserTool.appProveider.setPickedCity(community: _community);
} }

@ -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/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/login_button_widget.dart';
import 'package:aku_new_community/pages/sign/widget/psd_text_field.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/bee_scaffold.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
class SetPsdPage extends StatefulWidget { class SetPsdPage extends StatefulWidget {
@ -20,11 +22,22 @@ class _SetPsdPageState extends State<SetPsdPage> {
PSDVERIFY get psdCheck => PSDVERIFY get psdCheck =>
PsdVerify.check(_psdController.text, _confirmPsdController.text); PsdVerify.check(_psdController.text, _confirmPsdController.text);
bool _psdVisible = false;
bool _confirmVisible = false; @override
void initState() {
_psdController.addListener(() {
setState(() {});
});
_confirmPsdController.addListener(() {
setState(() {});
});
super.initState();
}
@override @override
void dispose() { void dispose() {
_psdController.removeListener(() {});
_confirmPsdController.removeListener(() {});
_psdController.dispose(); _psdController.dispose();
_confirmPsdController.dispose(); _confirmPsdController.dispose();
super.dispose(); super.dispose();
@ -75,7 +88,16 @@ class _SetPsdPageState extends State<SetPsdPage> {
.make(), .make(),
37.w.heightBox, 37.w.heightBox,
LoginButtonWidget( 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: '确认'),
], ],
), ),
); );

@ -27,6 +27,16 @@ class SignFunc {
showMessage: true, showMessage: true,
); );
return baseModel; return baseModel;
} //
static Future<BaseModel> 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 { static Future sendNewMessageCode(String newTel) async {
@ -56,7 +66,7 @@ class SignFunc {
static Future<Response> loginBySms( static Future<Response> loginBySms(
String phone, String code, int communityId) async { String phone, String code, int communityId) async {
Response response = await NetUtil().dio!.post( Response response = await NetUtil().dio!.post(
API.login.login, SARSAPI.login.loginTelCode,
data: { data: {
'tel': phone, 'tel': phone,
'code': code, 'code': code,
@ -113,12 +123,37 @@ class SignFunc {
return false; return false;
} }
///
static Future<UserInfoModel?> getUserInfo() async { static Future<UserInfoModel?> 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; if (baseModel.data == null || !baseModel.success) return null;
return UserInfoModel.fromJson(baseModel.data); return UserInfoModel.fromJson(baseModel.data);
} }
///
static Future<bool> 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<bool> 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<MyHouseModel?> getMyHouseInfo() async { static Future<MyHouseModel?> getMyHouseInfo() async {
BaseModel baseModel = await NetUtil().get( BaseModel baseModel = await NetUtil().get(
SARSAPI.profile.house.userHouse, SARSAPI.profile.house.userHouse,

@ -198,7 +198,7 @@ class _AddFixedSubmitPageState extends State<AddFixedSubmitPage> {
if (baseModel.success) { if (baseModel.success) {
Get.off(() => FinishFixedSubmitPage()); Get.off(() => FinishFixedSubmitPage());
} else } else
BotToast.showText(text: baseModel.message); BotToast.showText(text: baseModel.msg);
cancel(); cancel();
} }
: () { : () {

@ -406,9 +406,9 @@ class _FixedDetailPageState extends State<FixedDetailPage> {
BaseModel baseModel = await ManagerFunc.reportRepairAlipay( BaseModel baseModel = await ManagerFunc.reportRepairAlipay(
_model.appReportRepairVo.id, _model.appReportRepairVo.id,
(_model.appMaintenanceResultVo!.totalCost ?? 0).toDouble()); (_model.appMaintenanceResultVo!.totalCost ?? 0).toDouble());
if ((baseModel.success) && !baseModel.message.isEmptyOrNull) { if ((baseModel.success) && !baseModel.msg.isEmptyOrNull) {
bool result = await PayUtil() bool result =
.callAliPay(baseModel.message, API.pay.reportReapirCheck); await PayUtil().callAliPay(baseModel.msg, API.pay.reportReapirCheck);
if (result) { if (result) {
Get.back(); Get.back();
Get.off(() => PayFinishPage()); Get.off(() => PayFinishPage());
@ -429,7 +429,7 @@ class _FixedDetailPageState extends State<FixedDetailPage> {
Get.back(); Get.back();
} else { } else {
Get.back(); Get.back();
BotToast.showText(text: baseModel.message); BotToast.showText(text: baseModel.msg);
} }
cancel(); cancel();
} }

@ -343,6 +343,7 @@ class AppProvider extends ChangeNotifier {
if (community != null) { if (community != null) {
_pickedCityAndCommunity!.communityModel = community; _pickedCityAndCommunity!.communityModel = community;
} }
notifyListeners();
} }
void resetPickedCity() { void resetPickedCity() {

@ -7,12 +7,14 @@ import 'package:flutter/material.dart';
class DataProvider extends ChangeNotifier { class DataProvider extends ChangeNotifier {
Future init() async { Future init() async {
updateCityList();
_loginHistories = HiveStore.dataBox! _loginHistories = HiveStore.dataBox!
.get('historyLogin') .get('historyLogin')
?.cast<HistoryLoginModel>() ?.cast<HistoryLoginModel>()
.toList() ?? .toList() ??
[]; [];
if (_loginHistories.isEmpty) {
updateCityList();
}
} }
List<ChinaRegionModel> _cityModel = []; List<ChinaRegionModel> _cityModel = [];

@ -16,7 +16,6 @@ import 'package:flustars/flustars.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:power_logger/power_logger.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class UserProvider extends ChangeNotifier { class UserProvider extends ChangeNotifier {
@ -27,34 +26,30 @@ class UserProvider extends ChangeNotifier {
bool get isNotLogin => !_isLogin; bool get isNotLogin => !_isLogin;
Future setLogin(int token) async { Future setLogin(int token) async {
try { // try {
final appProvider = Provider.of<AppProvider>(Get.context!, listen: false); final appProvider = Provider.of<AppProvider>(Get.context!, listen: false);
_isLogin = true; _isLogin = true;
NetUtil() NetUtil().dio!.options.headers['app-login-token'] = token;
.dio! HiveStore.appBox!.put('token', token);
.options HiveStore.appBox!.put('login', true);
.headers await updateUserInfo();
.putIfAbsent('App-Admin-Token', () => token); await updateMyHouseInfo();
HiveStore.appBox!.put('token', token);
HiveStore.appBox!.put('login', true); ///
await updateUserInfo(); _userConfig = await HiveStore.userBox!.get('${_userInfoModel!.id}') ??
await updateMyHouseInfo(); UserConfigModel(
userId: _userInfoModel!.id,
/// clockRemind: false,
_userConfig = await HiveStore.userBox!.get('${_userInfoModel!.id}') ?? todayClocked: false);
UserConfigModel( await appProvider.updateHouses(await HouseFunc.passedHouses);
userId: _userInfoModel!.id, if (isLogin) {
clockRemind: false, WebSocketUtil().setUser(userInfoModel!.id.toString());
todayClocked: false); WebSocketUtil().startWebSocket();
await appProvider.updateHouses(await HouseFunc.passedHouses);
if (isLogin) {
WebSocketUtil().setUser(userInfoModel!.id.toString());
WebSocketUtil().startWebSocket();
}
notifyListeners();
} catch (e) {
LoggerData.addData(e);
} }
notifyListeners();
// } catch (e) {
// LoggerData.addData(e);
// }
} }
logout() { logout() {
@ -66,7 +61,7 @@ class UserProvider extends ChangeNotifier {
_userInfoModel = null; _userInfoModel = null;
_myHouseInfo = null; _myHouseInfo = null;
NetUtil().get(API.user.logout, showMessage: true); 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('token');
HiveStore.appBox!.delete('login'); HiveStore.appBox!.delete('login');
WebSocketUtil().closeWebSocket(); WebSocketUtil().closeWebSocket();
@ -76,11 +71,14 @@ class UserProvider extends ChangeNotifier {
Future<bool> updateUserInfo() async { Future<bool> updateUserInfo() async {
_userInfoModel = await SignFunc.getUserInfo(); _userInfoModel = await SignFunc.getUserInfo();
print('222');
if (_userInfoModel == null) { if (_userInfoModel == null) {
BotToast.showText(text: '获取用户信息失败'); BotToast.showText(text: '获取用户信息失败');
return false; return false;
} }
if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) { if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) {
print('111');
SignFunc.checkNameAndAccount(); SignFunc.checkNameAndAccount();
} }

@ -34,9 +34,7 @@ class CommunityFunc {
params: {'pageNum': 1, 'size': 8}, params: {'pageNum': 1, 'size': 8},
); );
if (model.tableList!.length == 0) return []; if (model.tableList!.length == 0) return [];
return model.tableList! return model.tableList!.map((e) => MyEventItemModel.fromJson(e)).toList();
.map((e) => MyEventItemModel.fromJson(e))
.toList();
} }
/// ///
@ -57,8 +55,8 @@ class CommunityFunc {
'newsId': newsId, 'newsId': newsId,
}, },
); );
if (model.message == null) return ''; if (model.msg == null) return '';
return (model.message as String).toString(); return (model.msg as String).toString();
} }
/// ///

@ -178,7 +178,7 @@ class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
if (model.success == true) { if (model.success == true) {
BotToast.showText(text: '预约成功'); BotToast.showText(text: '预约成功');
Get.back(result: true); Get.back(result: true);
} else if (model.message == '该时段已被预约') { } else if (model.msg == '该时段已被预约') {
await Get.dialog(_hasBeenOrder()); await Get.dialog(_hasBeenOrder());
} else { } else {
BotToast.showText(text: '预约失败'); BotToast.showText(text: '预约失败');

@ -222,7 +222,7 @@ class _AdviceDetailPageState extends State<AdviceDetailPage> {
if (baseModel.success) { if (baseModel.success) {
Get.to(() => AdviceEvaluatePage(id: widget.model!.id)); Get.to(() => AdviceEvaluatePage(id: widget.model!.id));
} }
BotToast.showText(text: baseModel.message); BotToast.showText(text: baseModel.msg);
}, },
child: '完成沟通'.text.bold.make(), child: '完成沟通'.text.bold.make(),
), ),

@ -89,7 +89,7 @@ class HouseKeepingFunc {
"payPrice": price "payPrice": price
}); });
if (baseModel.success) { if (baseModel.success) {
return baseModel.message; return baseModel.msg;
} else { } else {
return ''; return '';
} }

@ -269,7 +269,7 @@ class _QuestionnaireDetailPageState extends State<QuestionnaireDetailPage> {
widget.id, _submitModels); widget.id, _submitModels);
Get.to(() => SubmitComplishPage( Get.to(() => SubmitComplishPage(
status: baseModel.success, status: baseModel.success,
message: baseModel.message, message: baseModel.msg,
)); ));
}, },
), ),

@ -91,7 +91,7 @@ class _GoodsDetailPageState extends State<GoodsDetailPage> {
_goodsModel = GoodsDetailModel.fromJson(baseModel.data); _goodsModel = GoodsDetailModel.fromJson(baseModel.data);
} else { } else {
_goodsModel = GoodsDetailModel.fail(); _goodsModel = GoodsDetailModel.fail();
BotToast.showText(text: baseModel.message ?? '未知错误'); BotToast.showText(text: baseModel.msg ?? '未知错误');
} }
baseModel = await NetUtil().get(API.market.suppliyerHotTop, params: { baseModel = await NetUtil().get(API.market.suppliyerHotTop, params: {
"supplierId": _goodsModel.supplierId, "supplierId": _goodsModel.supplierId,

@ -100,14 +100,14 @@ class _GoodsOrderDetailPageState extends State<GoodsOrderDetailPage> {
}, },
showMessage: false, showMessage: false,
); );
if ((baseModel.success) && !baseModel.message.isEmptyOrNull) { if ((baseModel.success) && !baseModel.msg.isEmptyOrNull) {
bool result = await PayUtil() bool result = await PayUtil()
.callAliPay(baseModel.message!, API.pay.shoppingCheck); .callAliPay(baseModel.msg!, API.pay.shoppingCheck);
if (result) { if (result) {
Get.off(() => PayFinishPage()); Get.off(() => PayFinishPage());
} }
} else { } else {
BotToast.showText(text: baseModel.message!); BotToast.showText(text: baseModel.msg!);
} }
cancel(); cancel();
}, },

@ -76,7 +76,7 @@ class _OrderCardState extends State<OrderCard> {
}); });
if (baseModel.success) { if (baseModel.success) {
bool result = await PayUtil() bool result = await PayUtil()
.callAliPay(baseModel.message, API.pay.sharePayOrderCodeCheck); .callAliPay(baseModel.msg, API.pay.sharePayOrderCodeCheck);
if (result) { if (result) {
Get.off(() => PayFinishPage()); Get.off(() => PayFinishPage());
} }

@ -63,7 +63,7 @@ class _OrderDetailPageState extends State<OrderDetailPage> {
}); });
if (baseModel.success) { if (baseModel.success) {
bool result = await PayUtil() bool result = await PayUtil()
.callAliPay(baseModel.message, API.pay.jcookOrderCheckAlipay); .callAliPay(baseModel.msg, API.pay.jcookOrderCheckAlipay);
if (result) { if (result) {
Get.off(() => OrderPage(initIndex: 2)); Get.off(() => OrderPage(initIndex: 2));
} else { } else {

@ -74,8 +74,8 @@ class SearchFunc {
static Future<String> addGoodsCar(int jcookGoodsId) async { static Future<String> addGoodsCar(int jcookGoodsId) async {
BaseModel model = await NetUtil().post(API.market.insertShoppingCart, BaseModel model = await NetUtil().post(API.market.insertShoppingCart,
params: {'jcookGoodsId': jcookGoodsId}, showMessage: true); params: {'jcookGoodsId': jcookGoodsId}, showMessage: true);
if (model.message == null) return ''; if (model.msg == null) return '';
return model.message as String; return model.msg as String;
} }
/// ///

@ -136,7 +136,7 @@ class _SubmitOrderPageState extends State<SubmitOrderPage> {
}); });
if (baseModel.success) { if (baseModel.success) {
bool result = await PayUtil().callAliPay( bool result = await PayUtil().callAliPay(
baseModel.message, API.pay.jcookOrderCheckAlipay); baseModel.msg, API.pay.jcookOrderCheckAlipay);
if (result) { if (result) {
Get.off(() => OrderPage(initIndex: 2)); Get.off(() => OrderPage(initIndex: 2));
} else { } else {
@ -729,7 +729,7 @@ class _SubmitOrderPageState extends State<SubmitOrderPage> {
var base = await NetUtil().post(API.market.shopCarChangeNum, var base = await NetUtil().post(API.market.shopCarChangeNum,
params: {'jcookGoodsId': jcookGoodsId, 'num': num}); params: {'jcookGoodsId': jcookGoodsId, 'num': num});
if (!(base.success)) { if (!(base.success)) {
BotToast.showText(text: base.message); BotToast.showText(text: base.msg);
} }
cancel(); cancel();
return base.success; return base.success;

@ -124,7 +124,7 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
}); });
if (baseModel.success) { if (baseModel.success) {
bool result = await PayUtil().callAliPay( bool result = await PayUtil().callAliPay(
baseModel.message, API.pay.jcookOrderCheckAlipay); baseModel.msg, API.pay.jcookOrderCheckAlipay);
if (result) { if (result) {
Get.off(() => OrderPage(initIndex: 2)); Get.off(() => OrderPage(initIndex: 2));
} else { } else {
@ -686,7 +686,7 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
var base = await NetUtil().post(API.market.shopCarChangeNum, var base = await NetUtil().post(API.market.shopCarChangeNum,
params: {'jcookGoodsId': jcookGoodsId, 'num': num}); params: {'jcookGoodsId': jcookGoodsId, 'num': num});
if (!(base.success)) { if (!(base.success)) {
BotToast.showText(text: base.message); BotToast.showText(text: base.msg);
} }
cancel(); cancel();
return base.success; return base.success;

@ -610,7 +610,7 @@ class _ShopCarPageState extends State<ShopCarPage> {
var base = await NetUtil().post(API.market.shopCarChangeNum, var base = await NetUtil().post(API.market.shopCarChangeNum,
params: {'jcookGoodsId': jcookGoodsId, 'num': num}); params: {'jcookGoodsId': jcookGoodsId, 'num': num});
if (!(base.success)) { if (!(base.success)) {
BotToast.showText(text: base.message); BotToast.showText(text: base.msg);
} }
cancel(); cancel();
return base.success; return base.success;

@ -179,7 +179,7 @@ class HouseFunc {
"payPrice": price, "payPrice": price,
}); });
if (baseModel.success) { if (baseModel.success) {
return baseModel.message; return baseModel.msg;
} else { } else {
return ''; return '';
} }
@ -215,7 +215,7 @@ class HouseFunc {
BaseModel baseModel = await NetUtil().post(API.pay.leaseRentOrderAlipay, BaseModel baseModel = await NetUtil().post(API.pay.leaseRentOrderAlipay,
params: {"sysLeaseId": id, "payType": type, "payPrice": price}); params: {"sysLeaseId": id, "payType": type, "payPrice": price});
if (baseModel.success) { if (baseModel.success) {
return baseModel.message; return baseModel.msg;
} else { } else {
return ''; return '';
} }
@ -251,7 +251,7 @@ class HouseFunc {
BaseModel baseModel = await NetUtil().post(API.pay.leaseRentBillorder, BaseModel baseModel = await NetUtil().post(API.pay.leaseRentBillorder,
params: {"sysLeaseRentId": id, "payType": type, "payPrice": price}); params: {"sysLeaseRentId": id, "payType": type, "payPrice": price});
if (baseModel.success) { if (baseModel.success) {
return baseModel.message; return baseModel.msg;
} else { } else {
return ''; return '';
} }

@ -2,24 +2,24 @@ import 'package:json_annotation/json_annotation.dart';
part 'base_model.g.dart'; part 'base_model.g.dart';
@JsonSerializable() @JsonSerializable(includeIfNull: false)
class BaseModel { class BaseModel {
int code; final int code;
String message; final String msg;
bool success; final bool success;
dynamic data; final dynamic data;
factory BaseModel.fromJson(Map<String, dynamic> json) => factory BaseModel.fromJson(Map<String, dynamic> json) =>
_$BaseModelFromJson(json); _$BaseModelFromJson(json);
BaseModel.err(
{this.message = '未知错误', static BaseModel error(
this.success = false, String? message, bool success, dynamic data, int code) =>
this.data = null, BaseModel(code: code, msg: message ?? '未知错误', success: success);
this.code = 0});
BaseModel({ BaseModel({
required this.code, required this.code,
required this.message, required this.msg,
required this.success, required this.success,
required this.data, this.data,
}); });
} }

@ -8,7 +8,7 @@ part of 'base_model.dart';
BaseModel _$BaseModelFromJson(Map<String, dynamic> json) => BaseModel( BaseModel _$BaseModelFromJson(Map<String, dynamic> json) => BaseModel(
code: json['code'] as int, code: json['code'] as int,
message: json['message'] as String, msg: json['msg'] as String,
success: json['success'] as bool, success: json['success'] as bool,
data: json['data'], data: json['data'],
); );

@ -47,7 +47,7 @@ class NetUtil {
///call auth after login ///call auth after login
auth(String token) { auth(String token) {
_dio!.options.headers.putIfAbsent('App-Admin-Token', () => token); _dio!.options.headers['app-login-token'] = token;
} }
static String getDate(DateTime date) => static String getDate(DateTime date) =>
@ -61,15 +61,21 @@ class NetUtil {
Map<String, dynamic>? params, Map<String, dynamic>? params,
bool showMessage = false, bool showMessage = false,
}) async { }) async {
var _baseModel;
try { try {
Response res = await _dio!.get(path, queryParameters: params); Response res = await _dio!.get(path, queryParameters: params);
BaseModel baseModel = BaseModel.fromJson(res.data); if (!res.data['success']) {
_parseRequestError(baseModel, showMessage: showMessage); _baseModel = BaseModel.error(res.data['message'], res.data['success'],
return baseModel; res.data['data'], res.data['code']);
_parseRequestError(_baseModel, showMessage: showMessage);
} else {
_baseModel = BaseModel.fromJson(res.data);
}
} on DioError catch (e) { } on DioError catch (e) {
_parseErr(e); _parseErr(e);
_baseModel = BaseModel(code: 0, msg: '未知错误', success: false, data: null);
} }
return BaseModel.err(); return _baseModel;
} }
/// ## alias of Dio().post /// ## alias of Dio().post
@ -82,17 +88,21 @@ class NetUtil {
Map<String, dynamic>? params, Map<String, dynamic>? params,
bool showMessage = false, bool showMessage = false,
}) async { }) async {
var _baseModel;
try { try {
Response res = await _dio!.post(path, data: params); Response res = await _dio!.post(path, data: params);
if (!res.data['success']) {
BaseModel baseModel = BaseModel.fromJson(res.data); _baseModel = BaseModel.error(res.data['message'], res.data['success'],
_parseRequestError(baseModel, showMessage: showMessage); res.data['data'], res.data['code']);
_parseRequestError(_baseModel, showMessage: showMessage);
return baseModel; } else {
_baseModel = BaseModel.fromJson(res.data);
}
} on DioError catch (e) { } on DioError catch (e) {
_parseErr(e); _parseErr(e);
_baseModel = BaseModel(code: 0, msg: '未知错误', success: false, data: null);
} }
return BaseModel.err(); return _baseModel;
} }
Future<BaseListModel> getList( Future<BaseListModel> getList(
@ -182,12 +192,14 @@ class NetUtil {
_parseRequestError(BaseModel model, {bool showMessage = false}) { _parseRequestError(BaseModel model, {bool showMessage = false}) {
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false); final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
if (!model.success && model.message == '登录失效,请登录' && userProvider.isLogin) { if (!model.success &&
(model.code == 10010 || model.msg == '登录失效,请重新登录') &&
userProvider.isLogin) {
userProvider.logout(); userProvider.logout();
Get.offAll(() => LoginPage()); Get.offAll(() => LoginPage());
} }
if (!model.success || showMessage) { if (!model.success || showMessage) {
BotToast.showText(text: model.message); BotToast.showText(text: model.msg);
} }
} }
} }

@ -88,9 +88,9 @@ class _BeeCityPickerState extends State<BeeCityPicker> {
children: [ children: [
Expanded( Expanded(
child: CupertinoPicker( child: CupertinoPicker(
itemExtent: 40.w, itemExtent: 60.w,
magnification: 1.1, magnification: 1.0,
offAxisFraction: -0.6, // offAxisFraction: -0.6,
looping: true, looping: true,
onSelectedItemChanged: (index) { onSelectedItemChanged: (index) {
_pickedProvinceIndex = index; _pickedProvinceIndex = index;
@ -101,7 +101,7 @@ class _BeeCityPickerState extends State<BeeCityPicker> {
children: provinces children: provinces
.map((e) => Center( .map((e) => Center(
child: Padding( 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), child: Text(e.name, textAlign: TextAlign.center),
), ),
)) ))
@ -110,8 +110,8 @@ class _BeeCityPickerState extends State<BeeCityPicker> {
), ),
Expanded( Expanded(
child: CupertinoPicker( child: CupertinoPicker(
itemExtent: 40.w, itemExtent: 60.w,
magnification: 1.1, magnification: 1.0,
looping: true, looping: true,
scrollController: _cityController, scrollController: _cityController,
onSelectedItemChanged: (index) { onSelectedItemChanged: (index) {
@ -122,7 +122,7 @@ class _BeeCityPickerState extends State<BeeCityPicker> {
children: cities children: cities
.map((e) => Center( .map((e) => Center(
child: Padding( child: Padding(
padding: EdgeInsets.symmetric(horizontal: 14.w), padding: EdgeInsets.symmetric(horizontal: 20.w),
child: Text(e.name, textAlign: TextAlign.center), child: Text(e.name, textAlign: TextAlign.center),
), ),
)) ))
@ -131,9 +131,9 @@ class _BeeCityPickerState extends State<BeeCityPicker> {
), ),
Expanded( Expanded(
child: CupertinoPicker( child: CupertinoPicker(
itemExtent: 40.w, itemExtent: 60.w,
magnification: 1.1, magnification: 1.0,
offAxisFraction: 0.6, // offAxisFraction: 0.6,
looping: true, looping: true,
scrollController: _districtController, scrollController: _districtController,
onSelectedItemChanged: (index) { onSelectedItemChanged: (index) {
@ -145,7 +145,7 @@ class _BeeCityPickerState extends State<BeeCityPicker> {
: districts : districts
.map((e) => Center( .map((e) => Center(
child: Padding( 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), child: Text(e.name, textAlign: TextAlign.center),
), ),
)) ))

@ -45,6 +45,9 @@ class _BeeCommunityPickerState extends State<BeeCommunityPicker> {
@override @override
void initState() { void initState() {
_communities = widget.communities; _communities = widget.communities;
if (widget.communities.isNotEmpty) {
_pickedCommunity = widget.communities[0];
}
super.initState(); super.initState();
} }

Loading…
Cancel
Save