添加忘记密码功能模块

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

@ -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 {

@ -9,7 +9,7 @@ class UserInfoModel {
final int communityId;
final String? name;
final String tel;
final List<ImgModel> imgUrls;
// final List<ImgModel> 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,

@ -12,9 +12,6 @@ UserInfoModel _$UserInfoModelFromJson(Map<String, dynamic> json) =>
communityId: json['communityId'] as int,
name: json['name'] 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?,
nickName: json['nickName'] as String?,
isExistPassword: json['isExistPassword'] as bool,

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

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

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

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

@ -162,13 +162,13 @@ class _LifePrePayPageState extends State<LifePrePayPage> {
"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);

@ -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,25 +64,25 @@ class _ClockInPageState extends State<ClockInPage> {
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(

@ -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,25 +76,25 @@ class _PersonalIndexState extends State<PersonalIndex>
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(
@ -274,29 +273,29 @@ class _PersonalIndexState extends State<PersonalIndex>
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(

@ -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,7 +91,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
Hero(
tag: 'AVATAR',
child: ClipOval(
child:
// child:
// CachedNetworkImage(
// imageUrl: API.image(
// userProvider.userInfoModel!.imgUrls.isNotEmpty
@ -106,16 +105,16 @@ class _UserProfilePageState extends State<UserProfilePage> {
// 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,
),
// 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,

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

@ -20,6 +20,7 @@ class CodeMessagePage extends StatefulWidget {
class _CodeMessagePageState extends State<CodeMessagePage> {
String? _errorMessage;
TextEditingController _controller = TextEditingController();
String? _currentCode;
@override
void initState() {
@ -53,7 +54,7 @@ class _CodeMessagePageState extends State<CodeMessagePage> {
.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<CodeMessagePage> {
.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<CodeMessagePage> {
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<CodeMessagePage> {
_errorMessage = null;
UserTool.appProveider.startTimer();
} else {
BotToast.showText(text: base.message);
BotToast.showText(text: base.msg);
}
},
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/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<AppProvider>(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))

@ -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<OtherLoginPage> {
.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,20 +146,22 @@ class _OtherLoginPageState extends State<OtherLoginPage> {
TelTextField(controller: _tel),
100.w.heightBox,
LoginButtonWidget(
onTap: () async {
onTap: UserTool.appProveider.second < 60
? () {}
: () async {
var check = checkInput();
if (!check) {
return;
}
var base = await SignFunc.sendMessageCode(
_tel.text,
UserTool
.appProveider.pickedCityAndCommunity!.communityModel!.id);
UserTool.appProveider.pickedCityAndCommunity!
.communityModel!.id);
if (base.success) {
Get.to(() => CodeMessagePage(tel: _tel.text));
appProvider.startTimer();
} else {
BotToast.showText(text: base.message);
BotToast.showText(text: base.msg);
}
},
text: appProvider.timerStart

@ -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<SelectCommunity> {
onTap: () async {
var cancel = BotToast.showLoading();
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) {
_communities = (base.data as List)
.map((e) => CommunityModel.fromJson(e))
@ -101,6 +104,7 @@ class _SelectCommunityState extends State<SelectCommunity> {
}
cancel();
var _community = await BeeCommunityPicker.pick(context, _communities);
print(_community?.name);
if (_community != null) {
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/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<SetPsdPage> {
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<SetPsdPage> {
.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: '确认'),
],
),
);

@ -27,6 +27,16 @@ class SignFunc {
showMessage: true,
);
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 {
@ -56,7 +66,7 @@ class SignFunc {
static Future<Response> 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<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;
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 {
BaseModel baseModel = await NetUtil().get(
SARSAPI.profile.house.userHouse,

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

@ -406,9 +406,9 @@ class _FixedDetailPageState extends State<FixedDetailPage> {
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<FixedDetailPage> {
Get.back();
} else {
Get.back();
BotToast.showText(text: baseModel.message);
BotToast.showText(text: baseModel.msg);
}
cancel();
}

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

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

@ -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,14 +26,10 @@ class UserProvider extends ChangeNotifier {
bool get isNotLogin => !_isLogin;
Future setLogin(int token) async {
try {
// try {
final appProvider = Provider.of<AppProvider>(Get.context!, listen: false);
_isLogin = true;
NetUtil()
.dio!
.options
.headers
.putIfAbsent('App-Admin-Token', () => token);
NetUtil().dio!.options.headers['app-login-token'] = token;
HiveStore.appBox!.put('token', token);
HiveStore.appBox!.put('login', true);
await updateUserInfo();
@ -52,9 +47,9 @@ class UserProvider extends ChangeNotifier {
WebSocketUtil().startWebSocket();
}
notifyListeners();
} catch (e) {
LoggerData.addData(e);
}
// } 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<bool> 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();
}

@ -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();
}
///

@ -178,7 +178,7 @@ class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
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: '预约失败');

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

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

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

@ -91,7 +91,7 @@ class _GoodsDetailPageState extends State<GoodsDetailPage> {
_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,

@ -100,14 +100,14 @@ class _GoodsOrderDetailPageState extends State<GoodsOrderDetailPage> {
},
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();
},

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

@ -63,7 +63,7 @@ class _OrderDetailPageState extends State<OrderDetailPage> {
});
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 {

@ -74,8 +74,8 @@ class SearchFunc {
static Future<String> 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;
}
///

@ -136,7 +136,7 @@ class _SubmitOrderPageState extends State<SubmitOrderPage> {
});
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<SubmitOrderPage> {
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;

@ -124,7 +124,7 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
});
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<SubmitOrderNormalPage> {
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;

@ -610,7 +610,7 @@ class _ShopCarPageState extends State<ShopCarPage> {
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;

@ -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 '';
}

@ -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<String, dynamic> 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,
});
}

@ -8,7 +8,7 @@ part of 'base_model.dart';
BaseModel _$BaseModelFromJson(Map<String, dynamic> 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'],
);

@ -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<String, dynamic>? 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<String, dynamic>? 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<BaseListModel> getList(
@ -182,12 +192,14 @@ class NetUtil {
_parseRequestError(BaseModel model, {bool showMessage = 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();
Get.offAll(() => LoginPage());
}
if (!model.success || showMessage) {
BotToast.showText(text: model.message);
BotToast.showText(text: model.msg);
}
}
}

@ -88,9 +88,9 @@ class _BeeCityPickerState extends State<BeeCityPicker> {
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<BeeCityPicker> {
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<BeeCityPicker> {
),
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<BeeCityPicker> {
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<BeeCityPicker> {
),
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<BeeCityPicker> {
: 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),
),
))

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

Loading…
Cancel
Save