1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import 'package:flutter/material.dart';
- import 'package:flutter_tzh/base/YSBase.dart';
- import 'package:flutter_tzh/home/view/YSInputView.dart';
- import 'package:flutter_tzh/tool/YSTools.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- import '../login/YSLogin.dart';
- import '../tool/YSNetWork.dart';
- class YSMineChangePassword extends StatefulWidget {
- const YSMineChangePassword({Key? key}) : super(key: key);
- @override
- YSMineChangePasswordState createState() => YSMineChangePasswordState();
- }
- class YSMineChangePasswordState extends State<YSMineChangePassword> {
- String _password1 = '';
- String _password2 = '';
- @override
- Widget build(BuildContext context) {
- return YSBase(
- ysTitle: '修改密码',
- ysChild: Container(
- padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(50)),
- child: Column(
- children: [
- YSInputView3(valueSetter: (value) {
- _password1 = value;
- }, title: '旧密码',isSec: true,),
- Padding(
- padding: EdgeInsets.only(top: hsp(12),bottom: hsp(61)),
- child: YSInputView3(valueSetter: (value) {
- _password2 = value;
- }, title: '新密码',isSec: true,),
- ),
- GestureDetector(
- onTap: () async{
- FocusScope.of(context).unfocus();
- if(_password1.isEmpty){
- ysFlutterToast('请输入旧密码');
- return;
- }
- if(_password2.isEmpty){
- ysFlutterToast('请输入新密码');
- return;
- }
- Map request = {};
- request['oldPassword'] = _password1;
- request['newPassword'] = _password2;
- // LogUtil.d(request);
- // return;
- YSNetWork.ysRequestHttp(context, type: RequestType.post, api: '/user/resetPassword', parameter: request, successSetter: (dict) async{
- ysFlutterToast(dict['msg']);
- SharedPreferences prefs = await SharedPreferences.getInstance();
- prefs.remove('token');
- if(!mounted)return;
- Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context){
- return const YSLogin();
- }), (route) => false);
- },isLoading: true);
- },
- child: Container(
- height: hsp(50),
- width: ysWidth(context)-hsp(80),
- decoration: const BoxDecoration(
- color: Color(0xFF09A171),
- borderRadius: BorderRadius.all(Radius.circular(8)),
- gradient: LinearGradient(colors: [Color(0xFF7ADF8D),Color(0xFF7ADF8D),Color(0xFF8FF0A0)])
- ),
- alignment: Alignment.center,
- child: const Text('确定',style: TextStyle(fontSize: 18,color: Colors.white,fontWeight: FontWeight.bold),),
- ),
- )
- ],
- ),
- ),
- );
- }
- }
|