diff --git a/circle_app/lib/app/account/view.dart b/circle_app/lib/app/account/view.dart index 1eb9838..9d01c24 100644 --- a/circle_app/lib/app/account/view.dart +++ b/circle_app/lib/app/account/view.dart @@ -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(); final logic = Get.find(); final state = Get .find() @@ -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: () { diff --git a/circle_app/lib/app/edit_pwd/binding.dart b/circle_app/lib/app/edit_pwd/binding.dart new file mode 100644 index 0000000..e5ca02d --- /dev/null +++ b/circle_app/lib/app/edit_pwd/binding.dart @@ -0,0 +1,10 @@ +import 'package:get/get.dart'; + +import 'logic.dart'; + +class Edit_pwdBinding extends Bindings { + @override + void dependencies() { + Get.lazyPut(() => Edit_pwdLogic()); + } +} diff --git a/circle_app/lib/app/edit_pwd/logic.dart b/circle_app/lib/app/edit_pwd/logic.dart new file mode 100644 index 0000000..27f720f --- /dev/null +++ b/circle_app/lib/app/edit_pwd/logic.dart @@ -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']); + } + } + } + +} diff --git a/circle_app/lib/app/edit_pwd/state.dart b/circle_app/lib/app/edit_pwd/state.dart new file mode 100644 index 0000000..f410a42 --- /dev/null +++ b/circle_app/lib/app/edit_pwd/state.dart @@ -0,0 +1,5 @@ +class Edit_pwdState { + Edit_pwdState() { + ///Initialize variables + } +} diff --git a/circle_app/lib/app/edit_pwd/view.dart b/circle_app/lib/app/edit_pwd/view.dart new file mode 100644 index 0000000..20eaa7a --- /dev/null +++ b/circle_app/lib/app/edit_pwd/view.dart @@ -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(); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return GetBuilder(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),), + ), + ) + ], + ), + ), + )), + ], + ); + }); + } +} diff --git a/circle_app/lib/app/login/login/logic.dart b/circle_app/lib/app/login/login/logic.dart index 7746207..734810b 100644 --- a/circle_app/lib/app/login/login/logic.dart +++ b/circle_app/lib/app/login/login/logic.dart @@ -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 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.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.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) { diff --git a/circle_app/lib/app/login/login/view.dart b/circle_app/lib/app/login/login/view.dart index 23e29b6..7022ea0 100644 --- a/circle_app/lib/app/login/login/view.dart +++ b/circle_app/lib/app/login/login/view.dart @@ -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() - .state; - + final state = Get.find().state; @override Widget build(BuildContext context) { @@ -34,257 +32,385 @@ class LoginPage extends StatelessWidget { backgroundColor: Colors.transparent, body: GetBuilder(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, + ), ), ), - ), - ], + ], + ), ), - ), - )) - - ], + )) + ], ); })), ), diff --git a/circle_app/lib/app/minefragment/logic.dart b/circle_app/lib/app/minefragment/logic.dart index b8c835a..d5c3847 100644 --- a/circle_app/lib/app/minefragment/logic.dart +++ b/circle_app/lib/app/minefragment/logic.dart @@ -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 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'], diff --git a/circle_app/lib/app/reset_pwd/binding.dart b/circle_app/lib/app/reset_pwd/binding.dart new file mode 100644 index 0000000..ec89350 --- /dev/null +++ b/circle_app/lib/app/reset_pwd/binding.dart @@ -0,0 +1,10 @@ +import 'package:get/get.dart'; + +import 'logic.dart'; + +class Reset_pwdBinding extends Bindings { + @override + void dependencies() { + Get.lazyPut(() => Reset_pwdLogic()); + } +} diff --git a/circle_app/lib/app/reset_pwd/logic.dart b/circle_app/lib/app/reset_pwd/logic.dart new file mode 100644 index 0000000..119885e --- /dev/null +++ b/circle_app/lib/app/reset_pwd/logic.dart @@ -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 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.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']); + } + } + } +} diff --git a/circle_app/lib/app/reset_pwd/state.dart b/circle_app/lib/app/reset_pwd/state.dart new file mode 100644 index 0000000..7d3d376 --- /dev/null +++ b/circle_app/lib/app/reset_pwd/state.dart @@ -0,0 +1,5 @@ +class Reset_pwdState { + Reset_pwdState() { + ///Initialize variables + } +} diff --git a/circle_app/lib/app/reset_pwd/view.dart b/circle_app/lib/app/reset_pwd/view.dart new file mode 100644 index 0000000..81a34ea --- /dev/null +++ b/circle_app/lib/app/reset_pwd/view.dart @@ -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(); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return GetBuilder(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, + ), + ), + ), + ), + ], + ), + ), + )), + ], + ); + }); + } +} diff --git a/circle_app/lib/app/setpassword/binding.dart b/circle_app/lib/app/setpassword/binding.dart new file mode 100644 index 0000000..c7da2c0 --- /dev/null +++ b/circle_app/lib/app/setpassword/binding.dart @@ -0,0 +1,10 @@ +import 'package:get/get.dart'; + +import 'logic.dart'; + +class SetpasswordBinding extends Bindings { + @override + void dependencies() { + Get.lazyPut(() => SetpasswordLogic()); + } +} diff --git a/circle_app/lib/app/setpassword/logic.dart b/circle_app/lib/app/setpassword/logic.dart new file mode 100644 index 0000000..fbc06b5 --- /dev/null +++ b/circle_app/lib/app/setpassword/logic.dart @@ -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.fromJson(data, (data) => data); + if (bean.isSuccess()) { + Get.offAllNamed(AppRoutes.Home); + } else { + showOKToast(bean.msg); + } + } + } +} \ No newline at end of file diff --git a/circle_app/lib/app/setpassword/state.dart b/circle_app/lib/app/setpassword/state.dart new file mode 100644 index 0000000..93c3e22 --- /dev/null +++ b/circle_app/lib/app/setpassword/state.dart @@ -0,0 +1,5 @@ +class SetpasswordState { + SetpasswordState() { + ///Initialize variables + } +} diff --git a/circle_app/lib/app/setpassword/view.dart b/circle_app/lib/app/setpassword/view.dart new file mode 100644 index 0000000..7ea8ec8 --- /dev/null +++ b/circle_app/lib/app/setpassword/view.dart @@ -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(); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return GetBuilder(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), + ], + ), + ), + )), + ], + ); + }); + } +} diff --git a/circle_app/lib/network/api.dart b/circle_app/lib/network/api.dart index bd99b30..a3e7269 100644 --- a/circle_app/lib/network/api.dart +++ b/circle_app/lib/network/api.dart @@ -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'; + + + } \ No newline at end of file diff --git a/circle_app/lib/router/app_pages.dart b/circle_app/lib/router/app_pages.dart index f23fe93..fc9fb91 100644 --- a/circle_app/lib/router/app_pages.dart +++ b/circle_app/lib/router/app_pages.dart @@ -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(), + ), ]; } diff --git a/circle_app/lib/router/app_routers.dart b/circle_app/lib/router/app_routers.dart index 16495c0..ce6ee49 100644 --- a/circle_app/lib/router/app_routers.dart +++ b/circle_app/lib/router/app_routers.dart @@ -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';