| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- import 'package:flutter/material.dart';
- import '../widget/ITextInput.dart';
- import '../widget/LinearButton.dart';
- import '../net/HttpManager.dart';
- import '../net/Result.dart';
- import 'package:redux/redux.dart';
- import 'package:flutter_redux/flutter_redux.dart';
- import '../redux/AppState.dart';
- import '../model/UserInfo.dart';
- import '../styles/totast.dart';
- class ChangePassword extends StatefulWidget {
- @override
- _ChangePasswordState createState() => _ChangePasswordState();
- }
- class _ChangePasswordState extends State<ChangePassword> with WidgetsBindingObserver {
- String password_old = '';
- String password_new = '';
- String password_se = '';
- @override
- Widget build(BuildContext context) {
- return StoreConnector<AppState, UserInfo>(
- converter: (Store store) => store.state.userInfo,
- builder: (context, userInfo) {
- return Scaffold(
- appBar: AppBar(
- title: Text('修改密码'),
- ),
- backgroundColor: Color(0xFF23253C),
- body: Column(
- children: <Widget>[
- Container(
- height: 10,
- ),
- ITextField(
- keyboardType: ITextInputType.password,
- prefixIcon: Container(
- child: Image.asset(
- 'images/list_icon_yanzhengma.png',
- width: 20,
- ),
- ),
- hintText: '请输入您的原始密码',
- hintStyle: TextStyle(
- fontSize: 16,
- color: Color(0xFF727785),
- ),
- textStyle: TextStyle(color: Colors.white),
- fieldCallBack: (content) {
- setState(() {
- password_old = content;
- });
- },
- counterStyle: TextStyle(color: Color(0xFF000000), fontSize: 0),
- ),
- Container(
- height: 10,
- ),
- ITextField(
- keyboardType: ITextInputType.password,
- prefixIcon: Container(
- child: Image.asset(
- 'images/list_icon_yanzhengma.png',
- width: 20,
- ),
- ),
- hintText: '请设置您的新密码',
- hintStyle: TextStyle(
- fontSize: 16,
- color: Color(0xFF727785),
- ),
- textStyle: TextStyle(color: Colors.white),
- fieldCallBack: (content) {
- setState(() {
- password_new = content;
- });
- },
- counterStyle: TextStyle(color: Color(0xFF000000), fontSize: 0),
- ),
- Container(
- height: 10,
- ),
- ITextField(
- keyboardType: ITextInputType.password,
- prefixIcon: Container(
- child: Image.asset(
- 'images/list_icon_yanzhengma.png',
- width: 20,
- ),
- ),
- hintText: '请确认您的新密码',
- hintStyle: TextStyle(
- fontSize: 16,
- color: Color(0xFF727785),
- ),
- textStyle: TextStyle(color: Colors.white),
- fieldCallBack: (content) {
- setState(() {
- password_se = content;
- });
- },
- counterStyle: TextStyle(color: Color(0xFF000000), fontSize: 0),
- ),
- Container(
- height: 52,
- ),
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 15),
- child: LinearButton(
- btnHeight: 48.0,
- btntext: '确认修改',
- textColor: (password_new == password_se && password_se != '' && password_old != '') ? Colors.white : Color(0xFF15151D),
- colorList: (password_new == password_se && password_se != '' && password_old != '')
- ? [Color(0xFFD4504B), Color(0xFFD4504B)]
- : [Color(0xFF727785), Color(0xFF727785)],
- onTapHomeMenu: (password_new == password_se && password_se != '' && password_old != '')
- ? () async {
- Toast.show(context, '加载中', -1, 'loading');
- Result res = await HttpManager.post('userInfo/changePassword',
- data: {"userId": userInfo.id, "oldPassword": password_old, "newPassword": password_new});
- Toast.hide();
- if (res.success) {
- Toast.show(context, '修改成功', 1500, 'success');
- Navigator.of(context).pop();
- } else {
- Toast.show(context, res.error, 1500, 'info');
- }
- }
- : null,
- ),
- )
- ],
- ),
- );
- });
- }
- }
|