|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/provider/personnel_provider.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/event_bus.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/MyDivider.dart';
|
|
|
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/round_button.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
class PersonnelPasswordEditPage extends StatefulWidget {
|
|
|
|
final String idstr;
|
|
|
|
PersonnelPasswordEditPage({Key key, this.idstr}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_PersonnelPasswordEditPageState createState() =>
|
|
|
|
_PersonnelPasswordEditPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _PersonnelPasswordEditPageState extends State<PersonnelPasswordEditPage> {
|
|
|
|
bool show = false;
|
|
|
|
TextEditingController _pwdController = TextEditingController();
|
|
|
|
TextEditingController _pwdControllerConfirm = TextEditingController();
|
|
|
|
FocusNode _pwdFocusNode = FocusNode();
|
|
|
|
FocusNode _pwdFocusNodeConfirm = FocusNode();
|
|
|
|
bool warning = false;
|
|
|
|
PersonnelProvider personnelProvider;
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 修改密码
|
|
|
|
_updatePassword({bool showLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"kid": widget.idstr,
|
|
|
|
'password': _pwdControllerConfirm.text,
|
|
|
|
'keys': 'xiaotao666'
|
|
|
|
};
|
|
|
|
|
|
|
|
bool sucess = await personnelProvider.updatePassword(context, params,
|
|
|
|
showLoading: showLoading);
|
|
|
|
if (sucess) {
|
|
|
|
EventBus().emit('personnel_show_page');
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
personnelProvider = Provider.of<PersonnelProvider>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
'修改密码',
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: Padding(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(20)),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40),
|
|
|
|
),
|
|
|
|
height: ScreenUtil().setHeight(84),
|
|
|
|
// width: ScreenUtil().setWidth(611),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
"修改密码",
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_353535,
|
|
|
|
fontSize: ScreenUtil().setSp(30)),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
height: ScreenUtil().setHeight(84),
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: ScreenUtil().setWidth(20),
|
|
|
|
right: ScreenUtil().setWidth(20),
|
|
|
|
top: ScreenUtil().setWidth(8)),
|
|
|
|
child: TextField(
|
|
|
|
controller: _pwdController,
|
|
|
|
focusNode: _pwdFocusNode,
|
|
|
|
// autofocus: _sellerCodeController.text.isNotEmpty &&
|
|
|
|
// _accountController.text.isNotEmpty &&
|
|
|
|
// _pwdController.text.isEmpty,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_353535,
|
|
|
|
fontSize: ScreenUtil().setSp(28)),
|
|
|
|
decoration: InputDecoration(
|
|
|
|
hintText: "请输入密码",
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_c1c1c1,
|
|
|
|
fontSize: ScreenUtil().setSp(28)),
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide.none),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
),
|
|
|
|
onChanged: (value) {
|
|
|
|
if (!Utils.passwordRegExp(value)) {
|
|
|
|
setState(() {
|
|
|
|
warning = true;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setState(() {
|
|
|
|
warning = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
obscureText: true,
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
MyDivider(
|
|
|
|
double.infinity,
|
|
|
|
ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E0E0E0,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40),
|
|
|
|
),
|
|
|
|
height: ScreenUtil().setHeight(84),
|
|
|
|
// width: ScreenUtil().setWidth(611),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
"确认密码",
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_353535,
|
|
|
|
fontSize: ScreenUtil().setSp(30)),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
height: ScreenUtil().setHeight(84),
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: ScreenUtil().setWidth(20),
|
|
|
|
right: ScreenUtil().setWidth(20),
|
|
|
|
top: ScreenUtil().setWidth(8)),
|
|
|
|
child: TextField(
|
|
|
|
controller: _pwdControllerConfirm,
|
|
|
|
focusNode: _pwdFocusNodeConfirm,
|
|
|
|
// autofocus: _sellerCodeController.text.isNotEmpty &&
|
|
|
|
// _accountController.text.isNotEmpty &&
|
|
|
|
// _pwdController.text.isEmpty,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_353535,
|
|
|
|
fontSize: ScreenUtil().setSp(28)),
|
|
|
|
decoration: InputDecoration(
|
|
|
|
hintText: "请确认密码",
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_c1c1c1,
|
|
|
|
fontSize: ScreenUtil().setSp(28)),
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide.none),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
),
|
|
|
|
onChanged: (value) {},
|
|
|
|
obscureText: true,
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
MyDivider(
|
|
|
|
double.infinity,
|
|
|
|
ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E0E0E0,
|
|
|
|
),
|
|
|
|
VEmptyView(40),
|
|
|
|
Text(
|
|
|
|
'密码只能由数字和字母组成,最少6位,最多18位',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
color: warning
|
|
|
|
? MyColours.color_E14553
|
|
|
|
: MyColours.color_333333),
|
|
|
|
),
|
|
|
|
VEmptyView(60),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,
|
|
|
|
ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
|
|
|
|
child: RoundButton(
|
|
|
|
onPressed: () {
|
|
|
|
if (warning) {
|
|
|
|
Utils.showToast('密码只能由数字和字母组成,最少6位,最多18位');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_pwdController.text != _pwdControllerConfirm.text) {
|
|
|
|
Utils.showToast('两次密码输入不一致!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_pwdController.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入密码');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
_updatePassword();
|
|
|
|
},
|
|
|
|
text: '确认修改',
|
|
|
|
fontSize: 34,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
width: double.infinity,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|