首次登录设置密码

master
戴余标 2 years ago
parent bd61a99d53
commit ec5abdf5db

@ -8,6 +8,7 @@ class UserInfoModel extends Equatable {
final int id; final int id;
final String name; final String name;
final String phone; final String phone;
final int havePwd;
final int isVip; final int isVip;
final int isTrial; final int isTrial;
final String tag; final String tag;
@ -26,6 +27,7 @@ class UserInfoModel extends Equatable {
id: 0, id: 0,
name: '', name: '',
phone: '', phone: '',
havePwd: 0,
isVip: 0, isVip: 0,
isTrial: 0, isTrial: 0,
tag: '', tag: '',
@ -40,6 +42,7 @@ class UserInfoModel extends Equatable {
required this.id, required this.id,
required this.name, required this.name,
required this.phone, required this.phone,
required this.havePwd,
required this.isVip, required this.isVip,
required this.isTrial, required this.isTrial,
required this.tag, required this.tag,
@ -55,6 +58,7 @@ class UserInfoModel extends Equatable {
id, id,
name, name,
phone, phone,
havePwd,
isVip, isVip,
isTrial, isTrial,
tag, tag,

@ -11,6 +11,7 @@ UserInfoModel _$UserInfoModelFromJson(Map<String, dynamic> json) =>
id: json['id'] as int, id: json['id'] as int,
name: json['name'] as String, name: json['name'] as String,
phone: json['phone'] as String, phone: json['phone'] as String,
havePwd: json['havePwd'] as int,
isVip: json['is_vip'] as int, isVip: json['is_vip'] as int,
isTrial: json['is_trial'] as int, isTrial: json['is_trial'] as int,
tag: json['tag'] as String, tag: json['tag'] as String,
@ -30,6 +31,7 @@ Map<String, dynamic> _$UserInfoModelToJson(UserInfoModel instance) =>
'id': instance.id, 'id': instance.id,
'name': instance.name, 'name': instance.name,
'phone': instance.phone, 'phone': instance.phone,
'havePwd': instance.havePwd,
'is_vip': instance.isVip, 'is_vip': instance.isVip,
'is_trial': instance.isTrial, 'is_trial': instance.isTrial,
'tag': instance.tag, 'tag': instance.tag,

@ -7,13 +7,17 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:project_telephony/ui/login/login_psd_page.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/ui/widget/plone_back_button.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:provider/provider.dart';
import '../../base/base_style.dart'; import '../../base/base_style.dart';
import '../../constants/api.dart'; import '../../constants/api.dart';
import '../../constants/environment/environment.dart'; import '../../constants/environment/environment.dart';
import '../../model/network/api_client.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/toast/cloud_toast.dart';
import '../../utils/user_tool.dart'; import '../../utils/user_tool.dart';
import '../tab_navigator.dart'; import '../tab_navigator.dart';
@ -40,8 +44,8 @@ class _LoginPageState extends State<LoginPage> {
int _countDownNum = 59; int _countDownNum = 59;
late TextEditingController _phoneController; late TextEditingController _phoneController;
late TextEditingController _smsCodeController; late TextEditingController _smsCodeController;
late TextEditingController _pwdCodeController;
late FocusNode _phoneFocusNode; late FocusNode _phoneFocusNode;
late FocusNode _smsCodeFocusNode; late FocusNode _smsCodeFocusNode;
bool _cantSelected = false; bool _cantSelected = false;
DateTime? _lastTap; DateTime? _lastTap;
@ -53,7 +57,7 @@ class _LoginPageState extends State<LoginPage> {
_smsCodeFocusNode = FocusNode(); _smsCodeFocusNode = FocusNode();
_phoneController = TextEditingController(); _phoneController = TextEditingController();
_smsCodeController = TextEditingController(); _smsCodeController = TextEditingController();
// final userProvider = Provider.of<UserProvider>(context, listen: false); _pwdCodeController = TextEditingController();
var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); var env = const String.fromEnvironment('ENV', defaultValue: 'dev');
if (kDebugMode) { if (kDebugMode) {
print('env :$env'); print('env :$env');
@ -70,11 +74,13 @@ class _LoginPageState extends State<LoginPage> {
_smsCodeFocusNode.unfocus(); _smsCodeFocusNode.unfocus();
_phoneController.dispose(); _phoneController.dispose();
_smsCodeController.dispose(); _smsCodeController.dispose();
_pwdCodeController.dispose();
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CloudScaffold( return CloudScaffold(
systemStyle: const SystemUiOverlayStyle( systemStyle: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.dark, statusBarIconBrightness: Brightness.dark,
@ -162,6 +168,9 @@ class _LoginPageState extends State<LoginPage> {
if (base.code == 0) { if (base.code == 0) {
await UserTool.userProvider.setToken(base.data['token']); await UserTool.userProvider.setToken(base.data['token']);
Get.offAll(const TabNavigator()); Get.offAll(const TabNavigator());
if (UserTool.userProvider.userInfo.havePwd == 0) {
Get.to(()=>const SetPasswordPage());
}
} else { } else {
CloudToast.show(base.msg); CloudToast.show(base.msg);
} }
@ -355,7 +364,13 @@ class LoginBoxWidget extends StatelessWidget {
final String text; final String text;
final int fontSize; final int fontSize;
final Widget plone; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -391,4 +406,3 @@ class LoginBoxWidget extends StatelessWidget {
); );
} }
} }

@ -52,6 +52,7 @@ class _LoginPsdPageState extends State<LoginPsdPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CloudScaffold( return CloudScaffold(
systemStyle: const SystemUiOverlayStyle( systemStyle: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.dark, statusBarIconBrightness: Brightness.dark,
@ -139,6 +140,7 @@ class _LoginPsdPageState extends State<LoginPsdPage> {
Get.offAll(const TabNavigator()); Get.offAll(const TabNavigator());
} else { } else {
CloudToast.show(base.msg); CloudToast.show(base.msg);
} }
} }
}, },
@ -178,15 +180,6 @@ class _LoginPsdPageState extends State<LoginPsdPage> {
style: style:
TextStyle(color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), TextStyle(color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp),
children: [ 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( TextSpan(
text: '《短信帮手隐私协议》', text: '《短信帮手隐私协议》',
style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp),

@ -76,6 +76,7 @@ class _SetPasswordPageState extends State<SetPasswordPage> {
child: Padding( child: Padding(
padding: EdgeInsets.only(left: 10.w), padding: EdgeInsets.only(left: 10.w),
child: TextField( child: TextField(
maxLength: 16,
onChanged: (value){ onChanged: (value){
_psdController.text=value; _psdController.text=value;
_psdController.value = TextEditingValue( _psdController.value = TextEditingValue(
@ -91,6 +92,7 @@ class _SetPasswordPageState extends State<SetPasswordPage> {
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r'[A-Za-z0-9_]'))], inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r'[A-Za-z0-9_]'))],
controller: _psdController, controller: _psdController,
decoration: const InputDecoration( decoration: const InputDecoration(
counterText: '',
hintText: '填写新密码', hintText: '填写新密码',
hintStyle: TextStyle( hintStyle: TextStyle(
color: Colors.black38, color: Colors.black38,

Loading…
Cancel
Save