增加密码登录,修改密码,忘记密码功能
This commit is contained in:
parent
a417a5cc69
commit
39220fc37f
@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:circle_app/app/minefragment/logic.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -11,6 +12,7 @@ import 'logic.dart';
|
||||
class AccountPage extends StatelessWidget {
|
||||
AccountPage({Key? key}) : super(key: key);
|
||||
|
||||
final mineLogic = Get.find<MinefragmentLogic>();
|
||||
final logic = Get.find<AccountLogic>();
|
||||
final state = Get
|
||||
.find<AccountLogic>()
|
||||
@ -37,26 +39,34 @@ class AccountPage extends StatelessWidget {
|
||||
child: ListView(
|
||||
padding: EdgeInsets.all(16.0.sp),
|
||||
children: [
|
||||
// Container(
|
||||
// margin: EdgeInsets.only(top: 16.0),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Text(
|
||||
// "消息提醒",
|
||||
// style: TextStyle(
|
||||
// color: Color(0xFFF7FAFA),
|
||||
// fontSize: 16.0,
|
||||
// ),
|
||||
// ),
|
||||
// Spacer(),
|
||||
// Image.asset(
|
||||
// getHomeImage("icon_in"),
|
||||
// width: 24.0,
|
||||
// height: 24.0,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
if (mineLogic.has_pwd)
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
Get.toNamed(AppRoutes.EditPwd);
|
||||
},
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
Text(
|
||||
"修改密码",
|
||||
style: TextStyle(
|
||||
color: Color(0xFFF7FAFA),
|
||||
fontSize: 16.0,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
Image.asset(
|
||||
getHomeImage("icon_in"),
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
|
||||
10
circle_app/lib/app/edit_pwd/binding.dart
Normal file
10
circle_app/lib/app/edit_pwd/binding.dart
Normal file
@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class Edit_pwdBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => Edit_pwdLogic());
|
||||
}
|
||||
}
|
||||
46
circle_app/lib/app/edit_pwd/logic.dart
Normal file
46
circle_app/lib/app/edit_pwd/logic.dart
Normal file
@ -0,0 +1,46 @@
|
||||
import 'package:circle_app/network/api.dart';
|
||||
import 'package:circle_app/network/dio_manager.dart';
|
||||
import 'package:circle_app/util/util.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'state.dart';
|
||||
|
||||
class Edit_pwdLogic extends GetxController {
|
||||
final Edit_pwdState state = Edit_pwdState();
|
||||
|
||||
var passwordController = TextEditingController();
|
||||
var new_passwordController = TextEditingController();
|
||||
var config_passwordController = TextEditingController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
passwordController.dispose();
|
||||
new_passwordController.dispose();
|
||||
config_passwordController.dispose();
|
||||
}
|
||||
|
||||
void setPassword() async {
|
||||
if (passwordController.text.isEmpty) {
|
||||
showOKToast('请输入原密码');
|
||||
} else if (new_passwordController.text.isEmpty) {
|
||||
showOKToast('请输入6-12位新密码');
|
||||
} else if (config_passwordController.text.isEmpty) {
|
||||
showOKToast('再次输入新密码');
|
||||
} else if (new_passwordController.text == passwordController.text) {
|
||||
showOKToast('新密码不能和原密码相同哦');
|
||||
} else if (new_passwordController.text != config_passwordController.text) {
|
||||
showOKToast('新密码和确认密码不一致哦');
|
||||
} else {
|
||||
var result = await DioManager.instance.post(url: Api.userUpdatePassword,params: {'newPassword':new_passwordController.text,'oldPassword':passwordController.text});
|
||||
if (result['code'] == 200) {
|
||||
showOKToast('密码修改成功');
|
||||
Get.back();
|
||||
} else {
|
||||
showOKToast(result['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
5
circle_app/lib/app/edit_pwd/state.dart
Normal file
5
circle_app/lib/app/edit_pwd/state.dart
Normal file
@ -0,0 +1,5 @@
|
||||
class Edit_pwdState {
|
||||
Edit_pwdState() {
|
||||
///Initialize variables
|
||||
}
|
||||
}
|
||||
185
circle_app/lib/app/edit_pwd/view.dart
Normal file
185
circle_app/lib/app/edit_pwd/view.dart
Normal file
@ -0,0 +1,185 @@
|
||||
import 'package:circle_app/common/colors/app_color.dart';
|
||||
import 'package:circle_app/components/my_app_bar.dart';
|
||||
import 'package:circle_app/router/app_routers.dart';
|
||||
import 'package:circle_app/util/util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class Edit_pwdPage extends StatelessWidget {
|
||||
Edit_pwdPage({Key? key}) : super(key: key);
|
||||
|
||||
final logic = Get.find<Edit_pwdLogic>();
|
||||
final state = Get.find<Edit_pwdLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<Edit_pwdLogic>(builder: (logic) {
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: Get.width,
|
||||
height: Get.height,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(getBaseImage('home_back')),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: const MyAppBar(
|
||||
centerTitle: '修改密码',
|
||||
),
|
||||
body: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 40.sp,
|
||||
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.sp,vertical: 10.sp),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.sp),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff282733),
|
||||
borderRadius: BorderRadius.circular(8.sp)
|
||||
),
|
||||
child: TextFormField(
|
||||
controller: logic.passwordController,
|
||||
// onChanged: (msg) {
|
||||
// logic.isSuccess = msg.length > 5 ? true : false;
|
||||
// logic.update();
|
||||
// },
|
||||
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
hintText: '请输入原密码',
|
||||
hintStyle: TextStyle(color: Color(0xFFB7BECC)),
|
||||
counterText: ''
|
||||
),
|
||||
maxLength: 12,
|
||||
style: const TextStyle(color: Color(0xFFB7BECC)),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 40.sp,
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.sp,vertical: 10.sp),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.sp),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff282733),
|
||||
borderRadius: BorderRadius.circular(8.sp)
|
||||
),
|
||||
child: TextFormField(
|
||||
controller: logic.new_passwordController,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(
|
||||
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
hintText: '请输入6-12位新密码',
|
||||
hintStyle: TextStyle(color: Color(0xFFB7BECC)),
|
||||
counterText: ''
|
||||
),
|
||||
maxLength: 12,
|
||||
style: const TextStyle(color: Color(0xFFB7BECC)),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 40.sp,
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.sp,vertical: 10.sp),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.sp),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff282733),
|
||||
borderRadius: BorderRadius.circular(8.sp)
|
||||
),
|
||||
child: TextFormField(
|
||||
controller: logic.config_passwordController,
|
||||
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
hintText: '再次输入新密码',
|
||||
hintStyle: TextStyle(color: Color(0xFFB7BECC)),
|
||||
counterText: ''
|
||||
),
|
||||
maxLength: 12,
|
||||
style: const TextStyle(color: Color(0xFFB7BECC)),
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
margin: EdgeInsets.only(left: 16.sp),
|
||||
child: Text('温馨提示:修改后下次只能通过新密码登录',style: TextStyle(color: Colors.white.withOpacity(0.75),fontSize: 14.sp),),
|
||||
),
|
||||
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
logic.setPassword();
|
||||
},
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.symmetric(horizontal: 97.sp,vertical: 20.sp),
|
||||
height: 48.sp,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColor.mainVerLinearGradient,
|
||||
borderRadius: BorderRadius.circular(24.sp),
|
||||
),
|
||||
child: Text(
|
||||
'确定',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18.sp,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(AppRoutes.ResetPwd);
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
// margin: EdgeInsets.only(top: 10.sp),
|
||||
child: Text('忘记密码',style: TextStyle(color: Colors.white.withOpacity(0.7),fontSize: 15.sp),),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:circle_app/app/minefragment/logic.dart';
|
||||
import 'package:circle_app/network/dio_manager.dart';
|
||||
import 'package:circle_app/router/app_routers.dart';
|
||||
import 'package:circle_app/util/util.dart';
|
||||
@ -17,6 +18,8 @@ import 'state.dart';
|
||||
class LoginLogic extends GetxController {
|
||||
bool check = false;
|
||||
|
||||
// 0短信 1密码
|
||||
int loginType = 0;
|
||||
bool isGetCode = false;
|
||||
|
||||
@override
|
||||
@ -31,7 +34,9 @@ class LoginLogic extends GetxController {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
|
||||
String loginPhone = await sharedPreferences.getString(SharedPreferencesHelper.LOGINPHONE) ?? "";
|
||||
String loginPhone =
|
||||
await sharedPreferences.getString(SharedPreferencesHelper.LOGINPHONE) ??
|
||||
"";
|
||||
print(loginPhone);
|
||||
phoneEditingController.text = loginPhone;
|
||||
if (GetUtils.isPhoneNumber(loginPhone) && loginPhone.length == 11) {
|
||||
@ -44,6 +49,7 @@ class LoginLogic extends GetxController {
|
||||
final LoginState state = LoginState();
|
||||
TextEditingController phoneEditingController = TextEditingController();
|
||||
TextEditingController codeEditingController = TextEditingController();
|
||||
TextEditingController pwdEditingController = TextEditingController();
|
||||
|
||||
bool sendCodeBtn = false; //判断发送短信按钮是否点击过标志
|
||||
int seconds = 60;
|
||||
@ -52,7 +58,7 @@ class LoginLogic extends GetxController {
|
||||
//倒计时
|
||||
starDownTimer() {
|
||||
if (sendCodeBtn == false && seconds == 60) {
|
||||
sendCodeBtn = true;
|
||||
sendCodeBtn = true;
|
||||
isPhone = true;
|
||||
getCode();
|
||||
}
|
||||
@ -98,20 +104,37 @@ class LoginLogic extends GetxController {
|
||||
showOKToast('请输入正确的手机号');
|
||||
return;
|
||||
}
|
||||
if (codeEditingController.text == '') {
|
||||
if (codeEditingController.text == '' && loginType == 0) {
|
||||
showOKToast('请输入验证码');
|
||||
return;
|
||||
}
|
||||
|
||||
if (pwdEditingController.text == '' && loginType == 1) {
|
||||
showOKToast('请输入密码');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!check) {
|
||||
showOKToast('请勾选同意用户协议和隐私协议');
|
||||
return;
|
||||
}
|
||||
SmartDialog.showLoading(msg: '正在登录中...');
|
||||
var data = await DioManager.instance.post(url: Api.login, params: {
|
||||
"phone": phoneEditingController.text,
|
||||
"code": codeEditingController.text
|
||||
});
|
||||
|
||||
Map<String, dynamic> params = {};
|
||||
|
||||
if (loginType == 0) {
|
||||
params = {
|
||||
"phone": phoneEditingController.text,
|
||||
"code": codeEditingController.text
|
||||
};
|
||||
} else {
|
||||
params = {
|
||||
"phone": phoneEditingController.text,
|
||||
"password": pwdEditingController.text
|
||||
};
|
||||
}
|
||||
|
||||
var data = await DioManager.instance.post(url: loginType == 0 ? Api.login : Api.new_login, params: params);
|
||||
SmartDialog.dismiss();
|
||||
var bean = BaseResponse<LoginData>.fromJson(
|
||||
data, (data) => LoginData.fromJson(data));
|
||||
@ -123,6 +146,21 @@ class LoginLogic extends GetxController {
|
||||
bean.data!.Authorization.toString());
|
||||
});
|
||||
|
||||
if (loginType == 0) {
|
||||
var data = await DioManager.instance.get(url: Api.getUserMine);
|
||||
if (data['code'] == 200) {
|
||||
var bean = BaseResponse<MineResponseBean>.fromJson(
|
||||
data, (data) => MineResponseBean.fromJson(data));
|
||||
if (bean.isSuccess()) {
|
||||
if (!bean.data.has_pwd) {
|
||||
Get.offNamed(AppRoutes.SetPasswordActivity);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Get.offNamed(AppRoutes.Home);
|
||||
return;
|
||||
} else if (bean.code == 30002) {
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:circle_app/util/util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -6,18 +5,17 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
const loginBgWidget = Image(
|
||||
image: AssetImage('assets/images/base/bg.png'),
|
||||
fit: BoxFit.fill,
|
||||
);
|
||||
|
||||
class LoginPage extends StatelessWidget {
|
||||
LoginPage({Key? key}) : super(key: key);
|
||||
|
||||
final logic = Get.put(LoginLogic());
|
||||
final state = Get
|
||||
.find<LoginLogic>()
|
||||
.state;
|
||||
|
||||
final state = Get.find<LoginLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -34,257 +32,385 @@ class LoginPage extends StatelessWidget {
|
||||
backgroundColor: Colors.transparent,
|
||||
body: GetBuilder<LoginLogic>(builder: (logic) {
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 180.sp,
|
||||
child: Image.asset(
|
||||
getBaseImage("ic_launcher"),
|
||||
width: 120.sp,
|
||||
height: 120.sp,
|
||||
)),
|
||||
Container(
|
||||
width: Get.width,
|
||||
height: Get.height,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
// margin: EdgeInsets.only(
|
||||
// top: MediaQuery.of(context).padding.top + 100.sp),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned(
|
||||
// bottom: 0,
|
||||
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 180.sp,
|
||||
child: Image.asset(getBaseImage("ic_launcher"),width: 120.sp,height: 120.sp,)),
|
||||
|
||||
Container(
|
||||
width: Get.width,
|
||||
height: Get.height,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
// margin: EdgeInsets.only(
|
||||
// top: MediaQuery.of(context).padding.top + 100.sp),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned(
|
||||
// bottom: 0,
|
||||
|
||||
child: Container(
|
||||
width: 280.sp,
|
||||
height: 60.sp,
|
||||
decoration: BoxDecoration(
|
||||
child: Container(
|
||||
width: 280.sp,
|
||||
height: 60.sp,
|
||||
decoration: BoxDecoration(
|
||||
// color: Colors.white60,
|
||||
borderRadius: BorderRadius.circular(30.sp),
|
||||
border: Border.all(color: Colors.white60,width: 0.5.sp)
|
||||
),)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
' +86',
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 16.sp),
|
||||
),
|
||||
Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: 200.sp,
|
||||
child: TextField(
|
||||
onChanged: (msg){
|
||||
if (GetUtils.isPhoneNumber(msg)&& msg.length==11) {
|
||||
logic.isPhone = true;
|
||||
}else{
|
||||
logic.isPhone = false;
|
||||
}
|
||||
logic.update();
|
||||
},
|
||||
controller: logic.phoneEditingController,
|
||||
keyboardType: TextInputType.phone,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
FilteringTextInputFormatter.deny(RegExp('[^0-9]')),
|
||||
],
|
||||
maxLength: 11,
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 16.sp),
|
||||
decoration: InputDecoration(
|
||||
hintText: '请输入手机号',
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 16.sp),
|
||||
border: InputBorder.none,
|
||||
counterText: '',
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 16.sp)),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 25.sp),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned(
|
||||
// bottom: 0,
|
||||
|
||||
child: Container(
|
||||
width: 280.sp,
|
||||
height: 60.sp,
|
||||
decoration: BoxDecoration(
|
||||
// color: Colors.white60,
|
||||
borderRadius: BorderRadius.circular(30.sp),
|
||||
border: Border.all(color: Colors.white60,width: 0.5.sp)
|
||||
),)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'验证码',
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 16.sp),
|
||||
),
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 200.sp,
|
||||
child: TextField(
|
||||
controller: logic.codeEditingController,
|
||||
keyboardType: TextInputType.phone,
|
||||
maxLength: 8,
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 16.sp),
|
||||
decoration: InputDecoration(
|
||||
hintText: '请输入验证码',
|
||||
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 16.sp),
|
||||
border: InputBorder.none,
|
||||
counterText: '',
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 16.sp)),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if(logic.isPhone){
|
||||
logic.starDownTimer();
|
||||
borderRadius:
|
||||
BorderRadius.circular(30.sp),
|
||||
border: Border.all(
|
||||
color: Colors.white60,
|
||||
width: 0.5.sp)),
|
||||
)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
' +86',
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 16.sp),
|
||||
),
|
||||
Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: 200.sp,
|
||||
child: TextField(
|
||||
onChanged: (msg) {
|
||||
if (GetUtils.isPhoneNumber(msg) &&
|
||||
msg.length == 11) {
|
||||
logic.isPhone = true;
|
||||
} else {
|
||||
logic.isPhone = false;
|
||||
}
|
||||
logic.update();
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 76.sp,
|
||||
height: 29.sp,
|
||||
decoration: BoxDecoration(
|
||||
color:logic.isPhone ? logic.sendCodeBtn? Colors.white30:const Color(0xff0AFCFF) : Colors.white30,
|
||||
borderRadius: BorderRadius.circular(
|
||||
29.sp / 2)
|
||||
),
|
||||
child: Text(logic.sendCodeBtn ? '${logic.seconds}s' : '获取验证码', style: TextStyle(
|
||||
color: logic.isPhone ? logic.sendCodeBtn? Colors.white:Colors.black : Colors.white, fontSize: 12.sp),),
|
||||
),
|
||||
)),
|
||||
controller:
|
||||
logic.phoneEditingController,
|
||||
keyboardType: TextInputType.phone,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter
|
||||
.digitsOnly,
|
||||
FilteringTextInputFormatter.deny(
|
||||
RegExp('[^0-9]')),
|
||||
],
|
||||
maxLength: 11,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.sp),
|
||||
decoration: InputDecoration(
|
||||
hintText: '请输入手机号',
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 16.sp),
|
||||
border: InputBorder.none,
|
||||
counterText: '',
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 16.sp)),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (logic.loginType == 0)
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 25.sp),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned(
|
||||
// bottom: 0,
|
||||
|
||||
child: Container(
|
||||
width: 280.sp,
|
||||
height: 60.sp,
|
||||
decoration: BoxDecoration(
|
||||
// color: Colors.white60,
|
||||
borderRadius:
|
||||
BorderRadius.circular(30.sp),
|
||||
border: Border.all(
|
||||
color: Colors.white60,
|
||||
width: 0.5.sp)),
|
||||
)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'验证码',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.sp),
|
||||
),
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 200.sp,
|
||||
child: TextField(
|
||||
controller:
|
||||
logic.codeEditingController,
|
||||
keyboardType: TextInputType.phone,
|
||||
maxLength: 8,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.sp),
|
||||
decoration: InputDecoration(
|
||||
hintText: '请输入验证码',
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 16.sp),
|
||||
border: InputBorder.none,
|
||||
counterText: '',
|
||||
contentPadding:
|
||||
EdgeInsets.only(
|
||||
left: 16.sp)),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (logic.isPhone) {
|
||||
logic.starDownTimer();
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 76.sp,
|
||||
height: 29.sp,
|
||||
decoration: BoxDecoration(
|
||||
color: logic.isPhone
|
||||
? logic.sendCodeBtn
|
||||
? Colors.white30
|
||||
: const Color(
|
||||
0xff0AFCFF)
|
||||
: Colors.white30,
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
29.sp / 2)),
|
||||
child: Text(
|
||||
logic.sendCodeBtn
|
||||
? '${logic.seconds}s'
|
||||
: '获取验证码',
|
||||
style: TextStyle(
|
||||
color: logic.isPhone
|
||||
? logic.sendCodeBtn
|
||||
? Colors.white
|
||||
: Colors.black
|
||||
: Colors.white,
|
||||
fontSize: 12.sp),
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (logic.loginType == 1)
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 25.sp),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned(
|
||||
// bottom: 0,
|
||||
|
||||
],
|
||||
child: Container(
|
||||
width: 280.sp,
|
||||
height: 60.sp,
|
||||
decoration: BoxDecoration(
|
||||
// color: Colors.white60,
|
||||
borderRadius:
|
||||
BorderRadius.circular(30.sp),
|
||||
border: Border.all(
|
||||
color: Colors.white60,
|
||||
width: 0.5.sp)),
|
||||
)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'密码',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.sp),
|
||||
),
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 200.sp,
|
||||
child: TextField(
|
||||
controller:
|
||||
logic.pwdEditingController,
|
||||
maxLength: 12,
|
||||
obscureText: true,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.sp),
|
||||
decoration: InputDecoration(
|
||||
hintText: '请输入密码',
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 16.sp),
|
||||
border: InputBorder.none,
|
||||
counterText: '',
|
||||
contentPadding:
|
||||
EdgeInsets.only(
|
||||
left: 16.sp)),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
logic.loginType = logic.loginType == 0 ? 1 : 0;
|
||||
logic.update();
|
||||
},
|
||||
child: Container(
|
||||
width:280.sp,
|
||||
margin: EdgeInsets.only(top: 15.sp,right: 0.sp),
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(
|
||||
logic.loginType == 1 ? '验证码登录' : '密码登录',
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 14.sp),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 182.sp,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
logic.login();
|
||||
},
|
||||
child: Container(
|
||||
width: 200.sp,
|
||||
height: 50.sp,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(25.sp),
|
||||
gradient: const LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [Color(0xff0AFCFF), Color(0xffD739EA)])),
|
||||
child: Text(
|
||||
'登录',
|
||||
style: TextStyle(color: Colors.white, fontSize: 16.sp,fontWeight: FontWeight.w500),
|
||||
Positioned(
|
||||
bottom: 182.sp,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
logic.login();
|
||||
},
|
||||
child: Container(
|
||||
width: 200.sp,
|
||||
height: 50.sp,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(25.sp),
|
||||
gradient: const LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [
|
||||
Color(0xff0AFCFF),
|
||||
Color(0xffD739EA)
|
||||
])),
|
||||
child: Text(
|
||||
'登录',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.sp,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 17.sp + MediaQuery.of(context).padding.bottom,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
logic.check = !logic.check;
|
||||
logic.update();
|
||||
},
|
||||
child: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
!logic.check ? Container(width: 18.sp,height: 18.sp,decoration: BoxDecoration(border: Border.all(color: Colors.white70,width: 1.sp),borderRadius: BorderRadius.circular(10)),): Icon(Icons.check_circle_rounded,size: 19.sp,color: Color(0xff00FFF4),),
|
||||
SizedBox(width: 4.sp,),
|
||||
Text(
|
||||
'同意',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
SizedBox(
|
||||
width: 2.sp,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: (){
|
||||
navigateToUserAgreement();
|
||||
},
|
||||
child: Text(
|
||||
'《用户协议》',
|
||||
Positioned(
|
||||
bottom: 17.sp + MediaQuery.of(context).padding.bottom,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
logic.check = !logic.check;
|
||||
logic.update();
|
||||
},
|
||||
child: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
!logic.check
|
||||
? Container(
|
||||
width: 18.sp,
|
||||
height: 18.sp,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.white70,
|
||||
width: 1.sp),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10)),
|
||||
)
|
||||
: Icon(
|
||||
Icons.check_circle_rounded,
|
||||
size: 19.sp,
|
||||
color: Color(0xff00FFF4),
|
||||
),
|
||||
SizedBox(
|
||||
width: 4.sp,
|
||||
),
|
||||
Text(
|
||||
'同意',
|
||||
style: TextStyle(
|
||||
color: Color(0xff00FFF4),
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.white,
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
SizedBox(
|
||||
width: 2.sp,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
navigateToUserAgreement();
|
||||
},
|
||||
child: Text(
|
||||
'《用户协议》',
|
||||
style: TextStyle(
|
||||
color: Color(0xff00FFF4),
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'和',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
SizedBox(
|
||||
width: 2.sp,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: (){
|
||||
navigateToPrivacyPolicy();
|
||||
},
|
||||
child: Text(
|
||||
'《隐私协议》',
|
||||
Text(
|
||||
'和',
|
||||
style: TextStyle(
|
||||
color: Color(0xff00FFF4),
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.white,
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
SizedBox(
|
||||
width: 2.sp,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
navigateToPrivacyPolicy();
|
||||
},
|
||||
child: Text(
|
||||
'《隐私协议》',
|
||||
style: TextStyle(
|
||||
color: Color(0xff00FFF4),
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
))
|
||||
|
||||
],
|
||||
))
|
||||
],
|
||||
);
|
||||
})),
|
||||
),
|
||||
|
||||
@ -28,6 +28,8 @@ class MinefragmentLogic extends GetxController {
|
||||
int age = -1;
|
||||
int orientation = -1;
|
||||
|
||||
bool has_pwd = false;
|
||||
|
||||
String enterHomeInfoMsg = "进入主页";
|
||||
String joinedCircle = "";
|
||||
String vipMsg = "十几种专属特权等你领取";
|
||||
@ -59,7 +61,7 @@ class MinefragmentLogic extends GetxController {
|
||||
joinedCircle = "${"加入了${bean.data.joininterestcount}"}个圈子";
|
||||
enterHomeInfoMsg = bean.data.mainGuideText;
|
||||
|
||||
|
||||
has_pwd = bean.data.has_pwd;
|
||||
SharedPreferences sharedPreferences =
|
||||
await SharedPreferences.getInstance();
|
||||
if(bean.data.user.vip>0){
|
||||
@ -110,6 +112,7 @@ class MinefragmentLogic extends GetxController {
|
||||
|
||||
class User {
|
||||
int id;
|
||||
bool has_pwd;
|
||||
String nickname;
|
||||
String avatar;
|
||||
String signature;
|
||||
@ -126,6 +129,7 @@ class User {
|
||||
|
||||
User({
|
||||
required this.id,
|
||||
required this.has_pwd,
|
||||
required this.nickname,
|
||||
required this.avatar,
|
||||
required this.signature,
|
||||
@ -144,6 +148,7 @@ class User {
|
||||
factory User.fromJson(Map<String, dynamic> json) {
|
||||
return User(
|
||||
id: json['id'],
|
||||
has_pwd: json['has_pwd'] ?? false,
|
||||
nickname: json['nickname'],
|
||||
avatar: json['avatar'],
|
||||
signature: json['signature'],
|
||||
@ -168,6 +173,7 @@ class MineResponseBean {
|
||||
int recentVisitCount;
|
||||
String? vipExpireDate;
|
||||
int? vipExpireDays;
|
||||
bool? has_pwd;
|
||||
String phone;
|
||||
int? joininterestcount;
|
||||
String mainGuideText;
|
||||
@ -180,6 +186,7 @@ class MineResponseBean {
|
||||
this.vipExpireDate,
|
||||
this.vipExpireDays,
|
||||
required this.phone,
|
||||
required this.has_pwd,
|
||||
required this.joininterestcount,
|
||||
required this.mainGuideText});
|
||||
|
||||
@ -187,6 +194,7 @@ class MineResponseBean {
|
||||
return MineResponseBean(
|
||||
user: User.fromJson(json['user']),
|
||||
likeCount: json['like_count'],
|
||||
has_pwd: json['has_pwd'],
|
||||
phone: json['phone'],
|
||||
likeMeCount: json['like_me_count'],
|
||||
recentVisitCount: json['recent_visit_count'],
|
||||
|
||||
10
circle_app/lib/app/reset_pwd/binding.dart
Normal file
10
circle_app/lib/app/reset_pwd/binding.dart
Normal file
@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class Reset_pwdBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => Reset_pwdLogic());
|
||||
}
|
||||
}
|
||||
94
circle_app/lib/app/reset_pwd/logic.dart
Normal file
94
circle_app/lib/app/reset_pwd/logic.dart
Normal file
@ -0,0 +1,94 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:circle_app/network/api.dart';
|
||||
import 'package:circle_app/network/dio_manager.dart';
|
||||
import 'package:circle_app/util/SharedPreferencesHelper.dart';
|
||||
import 'package:circle_app/util/util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../login/login/logic.dart';
|
||||
import 'state.dart';
|
||||
|
||||
class Reset_pwdLogic extends GetxController {
|
||||
final Reset_pwdState state = Reset_pwdState();
|
||||
var codeController = TextEditingController();
|
||||
var new_passwordController = TextEditingController();
|
||||
var config_passwordController = TextEditingController();
|
||||
|
||||
bool sendCodeBtn = false; //判断发送短信按钮是否点击过标志
|
||||
int seconds = 60;
|
||||
Timer? t;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
codeController.dispose();
|
||||
new_passwordController.dispose();
|
||||
config_passwordController.dispose();
|
||||
t?.cancel();
|
||||
}
|
||||
|
||||
|
||||
//倒计时
|
||||
starDownTimer() async {
|
||||
if (sendCodeBtn == false && seconds == 60) {
|
||||
sendCodeBtn = true;
|
||||
|
||||
getCode();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getCode() async {
|
||||
SmartDialog.showLoading(msg: '正在发送中');
|
||||
var sp = await SharedPreferencesHelper.getInstance();
|
||||
var data = await DioManager.instance.post(
|
||||
url: Api.sendCode, params: {"phone": sp.getString(SharedPreferencesHelper.LOGINPHONE)});
|
||||
var bean = BaseResponse<Data>.fromJson(data, (data) => Data.fromJson(data));
|
||||
|
||||
SmartDialog.dismiss();
|
||||
if (bean.code == 200) {
|
||||
showOKToast('验证码已发送,稍后可前往短信查看');
|
||||
if (bean.data!.code != null) {
|
||||
codeController.text = bean.data!.code.toString();
|
||||
update();
|
||||
}
|
||||
|
||||
t = Timer.periodic(const Duration(milliseconds: 1000), (timer) {
|
||||
seconds--;
|
||||
if (seconds == 0) {
|
||||
t?.cancel(); //清除
|
||||
sendCodeBtn = false;
|
||||
seconds = 60;
|
||||
}
|
||||
update();
|
||||
});
|
||||
} else {
|
||||
sendCodeBtn = false;
|
||||
showOKToast(bean.msg);
|
||||
}
|
||||
}
|
||||
|
||||
void setPassword() async {
|
||||
if (codeController.text.isEmpty) {
|
||||
showOKToast('请输入验证码');
|
||||
} else if (new_passwordController.text.isEmpty) {
|
||||
showOKToast('请输入6-12位新密码');
|
||||
} else if (config_passwordController.text.isEmpty) {
|
||||
showOKToast('再次输入新密码');
|
||||
} else if (new_passwordController.text != config_passwordController.text) {
|
||||
showOKToast('新密码和确认密码不一致哦');
|
||||
} else {
|
||||
var sp = await SharedPreferencesHelper.getInstance();
|
||||
var result = await DioManager.instance.put(url: Api.resetPassword,params: {'new_password':new_passwordController.text,'phone':sp.getString(SharedPreferencesHelper.LOGINPHONE),'verify_code':codeController.text});
|
||||
if (result['code'] == 200) {
|
||||
showOKToast('密码重置成功');
|
||||
Get.back();
|
||||
Get.back();
|
||||
} else {
|
||||
showOKToast(result['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
5
circle_app/lib/app/reset_pwd/state.dart
Normal file
5
circle_app/lib/app/reset_pwd/state.dart
Normal file
@ -0,0 +1,5 @@
|
||||
class Reset_pwdState {
|
||||
Reset_pwdState() {
|
||||
///Initialize variables
|
||||
}
|
||||
}
|
||||
198
circle_app/lib/app/reset_pwd/view.dart
Normal file
198
circle_app/lib/app/reset_pwd/view.dart
Normal file
@ -0,0 +1,198 @@
|
||||
import 'package:circle_app/common/colors/app_color.dart';
|
||||
import 'package:circle_app/components/my_app_bar.dart';
|
||||
import 'package:circle_app/util/util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class Reset_pwdPage extends StatelessWidget {
|
||||
Reset_pwdPage({Key? key}) : super(key: key);
|
||||
|
||||
final logic = Get.find<Reset_pwdLogic>();
|
||||
final state = Get.find<Reset_pwdLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<Reset_pwdLogic>(builder: (logic) {
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: Get.width,
|
||||
height: Get.height,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(getBaseImage('home_back')),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: const MyAppBar(
|
||||
centerTitle: '重置密码',
|
||||
),
|
||||
body: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 40.sp,
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.sp,vertical: 10.sp),
|
||||
|
||||
// decoration: BoxDecoration(
|
||||
// color: Color(0xff282733),
|
||||
// borderRadius: BorderRadius.circular(8.sp)
|
||||
// ),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.sp),
|
||||
margin: EdgeInsets.only(right: 15.sp),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff282733),
|
||||
borderRadius: BorderRadius.circular(8.sp)
|
||||
),
|
||||
child: TextFormField(
|
||||
controller: logic.codeController,
|
||||
|
||||
decoration: const InputDecoration(
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
hintText: '请输入验证码',
|
||||
hintStyle: TextStyle(color: Color(0xFFB7BECC)),
|
||||
counterText: ''
|
||||
),
|
||||
maxLength: 6,
|
||||
style: const TextStyle(color: Color(0xFFB7BECC)),
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
logic.starDownTimer();
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 76.sp,
|
||||
height: 29.sp,
|
||||
decoration: BoxDecoration(
|
||||
color: logic.sendCodeBtn
|
||||
? Colors.white30
|
||||
: const Color(
|
||||
0xff0AFCFF),
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
29.sp / 2)),
|
||||
child: Text(
|
||||
logic.sendCodeBtn
|
||||
? '${logic.seconds}s'
|
||||
: '获取验证码',
|
||||
style: TextStyle(
|
||||
color: logic.sendCodeBtn
|
||||
? Colors.white
|
||||
: Colors.black,
|
||||
fontSize: 12.sp),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 40.sp,
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.sp,vertical: 10.sp),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.sp),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff282733),
|
||||
borderRadius: BorderRadius.circular(8.sp)
|
||||
),
|
||||
child: TextFormField(
|
||||
controller: logic.new_passwordController,
|
||||
decoration: const InputDecoration(
|
||||
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
hintText: '请输入6-12位新密码',
|
||||
hintStyle: TextStyle(color: Color(0xFFB7BECC)),
|
||||
counterText: ''
|
||||
),
|
||||
maxLength: 12,
|
||||
style: const TextStyle(color: Color(0xFFB7BECC)),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 40.sp,
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.sp,vertical: 10.sp),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.sp),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff282733),
|
||||
borderRadius: BorderRadius.circular(8.sp)
|
||||
),
|
||||
child: TextFormField(
|
||||
controller: logic.config_passwordController,
|
||||
decoration: const InputDecoration(
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
hintText: '再次输入新密码',
|
||||
hintStyle: TextStyle(color: Color(0xFFB7BECC)),
|
||||
counterText: ''
|
||||
),
|
||||
maxLength: 12,
|
||||
style: const TextStyle(color: Color(0xFFB7BECC)),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
logic.setPassword();
|
||||
},
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.symmetric(horizontal: 97.sp,vertical: 10.sp),
|
||||
height: 48.sp,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColor.mainVerLinearGradient,
|
||||
borderRadius: BorderRadius.circular(24.sp),
|
||||
),
|
||||
child: Text(
|
||||
'确定',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18.sp,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
10
circle_app/lib/app/setpassword/binding.dart
Normal file
10
circle_app/lib/app/setpassword/binding.dart
Normal file
@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class SetpasswordBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SetpasswordLogic());
|
||||
}
|
||||
}
|
||||
29
circle_app/lib/app/setpassword/logic.dart
Normal file
29
circle_app/lib/app/setpassword/logic.dart
Normal file
@ -0,0 +1,29 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../network/api.dart';
|
||||
import '../../network/dio_manager.dart';
|
||||
import '../../router/app_routers.dart';
|
||||
import '../../util/util.dart';
|
||||
import 'state.dart';
|
||||
|
||||
class SetpasswordLogic extends GetxController {
|
||||
final SetpasswordState state = SetpasswordState();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
bool isSuccess = false;
|
||||
|
||||
setPassword() async {
|
||||
if (isSuccess) {
|
||||
var data = await DioManager.instance.put(
|
||||
url: Api.UpdataUserInfo, params: {
|
||||
'password': passwordController.text,
|
||||
});
|
||||
var bean = BaseResponse<String>.fromJson(data, (data) => data);
|
||||
if (bean.isSuccess()) {
|
||||
Get.offAllNamed(AppRoutes.Home);
|
||||
} else {
|
||||
showOKToast(bean.msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
5
circle_app/lib/app/setpassword/state.dart
Normal file
5
circle_app/lib/app/setpassword/state.dart
Normal file
@ -0,0 +1,5 @@
|
||||
class SetpasswordState {
|
||||
SetpasswordState() {
|
||||
///Initialize variables
|
||||
}
|
||||
}
|
||||
126
circle_app/lib/app/setpassword/view.dart
Normal file
126
circle_app/lib/app/setpassword/view.dart
Normal file
@ -0,0 +1,126 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:circle_app/common/colors/app_color.dart';
|
||||
import 'package:circle_app/components/my_app_bar.dart';
|
||||
import 'package:circle_app/router/app_routers.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../util/util.dart';
|
||||
import 'logic.dart';
|
||||
|
||||
class SetpasswordPage extends StatelessWidget {
|
||||
SetpasswordPage({Key? key}) : super(key: key);
|
||||
|
||||
final logic = Get.find<SetpasswordLogic>();
|
||||
final state = Get.find<SetpasswordLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<SetpasswordLogic>(builder: (logic) {
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: Get.width,
|
||||
height: Get.height,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(getBaseImage('bg')),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: const MyAppBar(
|
||||
centerTitle: '设置密码',
|
||||
),
|
||||
body: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Container(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
height: 200.sp,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 73.sp),
|
||||
child: TextFormField(
|
||||
controller: logic.passwordController,
|
||||
onChanged: (msg) {
|
||||
logic.isSuccess = msg.length > 5 ? true : false;
|
||||
logic.update();
|
||||
},
|
||||
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: AppColor.mainColor),
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: AppColor.mainColor),
|
||||
),
|
||||
hintText: '请输入至少6-12位数密码',
|
||||
hintStyle: TextStyle(color: Color(0xFFB7BECC)),
|
||||
),
|
||||
maxLength: 12,
|
||||
style: const TextStyle(color: Color(0xFFB7BECC)),
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 73.sp),
|
||||
child: Text(
|
||||
'可输入字母或数字做密码',
|
||||
style: TextStyle(
|
||||
color: const Color(0xFFB7BECC),
|
||||
fontSize: 14.sp,
|
||||
),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
logic.setPassword();
|
||||
},
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.symmetric(horizontal: 97.sp),
|
||||
height: 48.sp,
|
||||
alignment: Alignment.center,
|
||||
decoration: logic.isSuccess
|
||||
? BoxDecoration(
|
||||
gradient: AppColor.mainVerLinearGradient,
|
||||
borderRadius: BorderRadius.circular(24.sp),
|
||||
)
|
||||
: BoxDecoration(
|
||||
color: Color(0x4DFFFFFF),
|
||||
borderRadius: BorderRadius.circular(24.sp),
|
||||
),
|
||||
child: Text(
|
||||
'下一步',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18.sp,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 360),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,8 @@ class Api {
|
||||
|
||||
// 登录
|
||||
static const login = 'user-service/login/smscode';
|
||||
|
||||
// 登录
|
||||
static const new_login = 'user-service/login/password';
|
||||
|
||||
|
||||
//获取七牛token
|
||||
@ -289,4 +290,13 @@ class Api {
|
||||
//发现单个用户数据
|
||||
static const getFindPageUserByUserId = 'user-service/findPage/getUserByUserId';
|
||||
|
||||
//修改密码
|
||||
static const userUpdatePassword = 'user-service/userUpdatePassword';
|
||||
|
||||
|
||||
//重置密码
|
||||
static const resetPassword = '/user-service/register/user/password/reset';
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -11,6 +11,8 @@ import 'package:circle_app/app/chat/binding.dart';
|
||||
import 'package:circle_app/app/chat/view.dart';
|
||||
import 'package:circle_app/app/circle/discover_page.dart';
|
||||
import 'package:circle_app/app/circle/view.dart';
|
||||
import 'package:circle_app/app/edit_pwd/binding.dart';
|
||||
import 'package:circle_app/app/edit_pwd/view.dart';
|
||||
import 'package:circle_app/app/feedback/binding.dart';
|
||||
import 'package:circle_app/app/feedback/view.dart';
|
||||
import 'package:circle_app/app/friendslist/binding.dart';
|
||||
@ -41,8 +43,12 @@ import 'package:circle_app/app/photoinfo/view.dart';
|
||||
import 'package:circle_app/app/privacy/view.dart';
|
||||
import 'package:circle_app/app/report/binding.dart';
|
||||
import 'package:circle_app/app/report/view.dart';
|
||||
import 'package:circle_app/app/reset_pwd/binding.dart';
|
||||
import 'package:circle_app/app/reset_pwd/view.dart';
|
||||
import 'package:circle_app/app/select_circle/binding.dart';
|
||||
import 'package:circle_app/app/select_circle/view.dart';
|
||||
import 'package:circle_app/app/setpassword/binding.dart';
|
||||
import 'package:circle_app/app/setpassword/view.dart';
|
||||
import 'package:circle_app/app/setup/binding.dart';
|
||||
import 'package:circle_app/app/setup/view.dart';
|
||||
import 'package:circle_app/app/login/complete_material/binding.dart';
|
||||
@ -216,6 +222,21 @@ class AppPages {
|
||||
page: () => InvitePage(),
|
||||
binding: InviteBinding(),
|
||||
),
|
||||
GetPage(name: AppRoutes.DisCover, page: () => DiscoverPage())
|
||||
GetPage(name: AppRoutes.DisCover, page: () => DiscoverPage()),
|
||||
GetPage(
|
||||
name: AppRoutes.SetPasswordActivity,
|
||||
page: () => SetpasswordPage(),
|
||||
binding: SetpasswordBinding(),
|
||||
),
|
||||
GetPage(
|
||||
name: AppRoutes.EditPwd,
|
||||
page: () => Edit_pwdPage(),
|
||||
binding: Edit_pwdBinding(),
|
||||
),
|
||||
GetPage(
|
||||
name: AppRoutes.ResetPwd,
|
||||
page: () => Reset_pwdPage(),
|
||||
binding: Reset_pwdBinding(),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ abstract class AppRoutes {
|
||||
static const SelectCircleActivity = '/user/SelectCircleActivity';
|
||||
static const SplashActivity = '/user/SplashActivity';
|
||||
static const MyCircle = '/myCircle';
|
||||
|
||||
static const SetPasswordActivity = '/SetPasswordActivity';
|
||||
static const MyFeedBackListActivity = '/mine/MyFeedBackListActivity';
|
||||
|
||||
static const Sys_notify_list = '/msg/Sys_notify_list';
|
||||
@ -38,7 +38,8 @@ abstract class AppRoutes {
|
||||
|
||||
static const DisCover = '/DisCover';
|
||||
|
||||
|
||||
static const EditPwd = '/mine/EditPwd';
|
||||
static const ResetPwd = '/mine/EditPwd/ResetPwd';
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user