diff --git a/lib/model/user_info_model.dart b/lib/model/user_info_model.dart index 0a7d636..c9643e2 100644 --- a/lib/model/user_info_model.dart +++ b/lib/model/user_info_model.dart @@ -8,6 +8,7 @@ class UserInfoModel extends Equatable { final int id; final String name; final String phone; + final int havePwd; final int isVip; final int isTrial; final String tag; @@ -26,6 +27,7 @@ class UserInfoModel extends Equatable { id: 0, name: '', phone: '', + havePwd: 0, isVip: 0, isTrial: 0, tag: '', @@ -40,6 +42,7 @@ class UserInfoModel extends Equatable { required this.id, required this.name, required this.phone, + required this.havePwd, required this.isVip, required this.isTrial, required this.tag, @@ -55,6 +58,7 @@ class UserInfoModel extends Equatable { id, name, phone, + havePwd, isVip, isTrial, tag, diff --git a/lib/model/user_info_model.g.dart b/lib/model/user_info_model.g.dart index f07ef90..71fd105 100644 --- a/lib/model/user_info_model.g.dart +++ b/lib/model/user_info_model.g.dart @@ -11,6 +11,7 @@ UserInfoModel _$UserInfoModelFromJson(Map json) => id: json['id'] as int, name: json['name'] as String, phone: json['phone'] as String, + havePwd: json['havePwd'] as int, isVip: json['is_vip'] as int, isTrial: json['is_trial'] as int, tag: json['tag'] as String, @@ -30,6 +31,7 @@ Map _$UserInfoModelToJson(UserInfoModel instance) => 'id': instance.id, 'name': instance.name, 'phone': instance.phone, + 'havePwd': instance.havePwd, 'is_vip': instance.isVip, 'is_trial': instance.isTrial, 'tag': instance.tag, diff --git a/lib/ui/login/login_page.dart b/lib/ui/login/login_page.dart index 4bd5c26..4cd92f8 100644 --- a/lib/ui/login/login_page.dart +++ b/lib/ui/login/login_page.dart @@ -7,13 +7,17 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:project_telephony/ui/login/login_psd_page.dart'; +import 'package:project_telephony/ui/user/set_password_page.dart'; import 'package:project_telephony/ui/widget/plone_back_button.dart'; import 'package:project_telephony/utils/headers.dart'; +import 'package:provider/provider.dart'; import '../../base/base_style.dart'; import '../../constants/api.dart'; import '../../constants/environment/environment.dart'; import '../../model/network/api_client.dart'; +import '../../model/network/base_model.dart'; +import '../../providers/user_provider.dart'; import '../../utils/toast/cloud_toast.dart'; import '../../utils/user_tool.dart'; import '../tab_navigator.dart'; @@ -40,8 +44,8 @@ class _LoginPageState extends State { int _countDownNum = 59; late TextEditingController _phoneController; late TextEditingController _smsCodeController; + late TextEditingController _pwdCodeController; late FocusNode _phoneFocusNode; - late FocusNode _smsCodeFocusNode; bool _cantSelected = false; DateTime? _lastTap; @@ -53,7 +57,7 @@ class _LoginPageState extends State { _smsCodeFocusNode = FocusNode(); _phoneController = TextEditingController(); _smsCodeController = TextEditingController(); - // final userProvider = Provider.of(context, listen: false); + _pwdCodeController = TextEditingController(); var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); if (kDebugMode) { print('env :$env'); @@ -70,11 +74,13 @@ class _LoginPageState extends State { _smsCodeFocusNode.unfocus(); _phoneController.dispose(); _smsCodeController.dispose(); + _pwdCodeController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { + return CloudScaffold( systemStyle: const SystemUiOverlayStyle( statusBarIconBrightness: Brightness.dark, @@ -162,6 +168,9 @@ class _LoginPageState extends State { if (base.code == 0) { await UserTool.userProvider.setToken(base.data['token']); Get.offAll(const TabNavigator()); + if (UserTool.userProvider.userInfo.havePwd == 0) { + Get.to(()=>const SetPasswordPage()); + } } else { CloudToast.show(base.msg); } @@ -355,7 +364,13 @@ class LoginBoxWidget extends StatelessWidget { final String text; final int fontSize; final Widget plone; - const LoginBoxWidget({Key? key, required this.text, required this.fontSize, required this.plone}) : super(key: key); + + const LoginBoxWidget( + {Key? key, + required this.text, + required this.fontSize, + required this.plone}) + : super(key: key); @override Widget build(BuildContext context) { @@ -391,4 +406,3 @@ class LoginBoxWidget extends StatelessWidget { ); } } - diff --git a/lib/ui/login/login_psd_page.dart b/lib/ui/login/login_psd_page.dart index 37784d1..ab21946 100644 --- a/lib/ui/login/login_psd_page.dart +++ b/lib/ui/login/login_psd_page.dart @@ -52,6 +52,7 @@ class _LoginPsdPageState extends State { @override Widget build(BuildContext context) { + return CloudScaffold( systemStyle: const SystemUiOverlayStyle( statusBarIconBrightness: Brightness.dark, @@ -139,6 +140,7 @@ class _LoginPsdPageState extends State { Get.offAll(const TabNavigator()); } else { CloudToast.show(base.msg); + } } }, @@ -178,15 +180,6 @@ class _LoginPsdPageState extends State { style: TextStyle(color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), children: [ - // TextSpan( - // text: '《用户服务协议》', - // style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), - // recognizer: _recognizer(context, 2)), - // TextSpan( - // text: "和", - // style: TextStyle( - // color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), - // ), TextSpan( text: '《短信帮手隐私协议》', style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), diff --git a/lib/ui/user/set_password_page.dart b/lib/ui/user/set_password_page.dart index bb9bc02..dc723ad 100644 --- a/lib/ui/user/set_password_page.dart +++ b/lib/ui/user/set_password_page.dart @@ -76,6 +76,7 @@ class _SetPasswordPageState extends State { child: Padding( padding: EdgeInsets.only(left: 10.w), child: TextField( + maxLength: 16, onChanged: (value){ _psdController.text=value; _psdController.value = TextEditingValue( @@ -91,6 +92,7 @@ class _SetPasswordPageState extends State { inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r'[A-Za-z0-9_]'))], controller: _psdController, decoration: const InputDecoration( + counterText: '', hintText: '填写新密码', hintStyle: TextStyle( color: Colors.black38,