| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- import 'package:bbyyy/https/MyDio.dart';
- import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
- import 'package:bbyyy/my_tools/global.dart';
- import 'package:bbyyy/my_tools/my_apis.dart';
- import 'package:bbyyy/my_tools/my_colors.dart';
- import 'package:bbyyy/my_tools/my_cookie.dart';
- import 'package:bbyyy/my_tools/my_tools.dart';
- import 'package:bbyyy/my_tools/my_views.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_svg/svg.dart';
- class ChangePasswordPage extends StatefulWidget {
- @override
- _ChangePasswordPageState createState() => _ChangePasswordPageState();
- }
- class _ChangePasswordPageState extends State<ChangePasswordPage> {
- TextEditingController oldPW = TextEditingController();
- TextEditingController newPW = TextEditingController();
- bool seeOldPW = true;
- bool seeNewPW = true;
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: (){
- MyTools().hideKeyboard(context);
- },
- behavior: HitTestBehavior.translucent,
- child: Scaffold(
- body: Column(
- children: [
- MyViews().myAppBar('修改密码', context, []),
- Expanded(
- child: SingleChildScrollView(
- child: Column(
- children: [
- Container(
- child: Column(
- children: [
- Container(
- child: Row(
- children: [
- MyViews().myText('旧密码', MyColors.c333333, 16),
- Expanded(
- child: TextField(
- controller: oldPW,
- cursorColor: MyColors.cFF4233,
- textAlign: TextAlign.end,
- cursorWidth: 1.0,
- decoration: InputDecoration(
- border: InputBorder.none,
- disabledBorder: InputBorder.none,
- enabledBorder: InputBorder.none,
- focusedBorder: InputBorder.none,
- isDense: true,
- hintText: '请输入旧密码',
- hintStyle: TextStyle(
- color: MyColors.c999999, fontSize: 16),
- contentPadding: const EdgeInsets.fromLTRB(
- 14, 4.5, 8, 4.5),
- ),
- maxLines: 1,
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 16,
- height: 1.3,
- letterSpacing: 0.2),
- keyboardType: TextInputType.visiblePassword,
- obscureText: seeOldPW,
- onChanged: (t) {},
- )),
- GestureDetector(
- onTap: () {
- setState(() {
- seeOldPW = !seeOldPW;
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 35,
- width: 35,
- padding: EdgeInsets.all(6.5),
- child: SvgPicture.asset(seeOldPW
- ? 'images/svg/不显示.svg'
- : 'images/svg/显示.svg',color: MyColors.c333333,),
- ),
- ),
- ],
- ),
- padding:
- EdgeInsets.symmetric(horizontal: 15, vertical: 8),
- ),
- Container(
- height: 0.5,
- color: MyColors.cEFEFEF,
- ),
- Container(
- child: Row(
- children: [
- MyViews().myText('新密码', MyColors.c333333, 16),
- Expanded(
- child: TextField(
- controller: newPW,
- cursorColor: MyColors.cFF4233,
- textAlign: TextAlign.end,
- cursorWidth: 1.0,
- decoration: InputDecoration(
- border: InputBorder.none,
- disabledBorder: InputBorder.none,
- enabledBorder: InputBorder.none,
- focusedBorder: InputBorder.none,
- isDense: true,
- hintText: '请输入新密码',
- hintStyle: TextStyle(
- color: MyColors.c999999, fontSize: 16),
- contentPadding: const EdgeInsets.fromLTRB(
- 14, 4.5, 8, 4.5),
- ),
- maxLines: 1,
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 16,
- height: 1.3,
- letterSpacing: 0.2),
- keyboardType: TextInputType.visiblePassword,
- obscureText: seeNewPW,
- onChanged: (t) {},
- )),
- GestureDetector(
- onTap: () {
- setState(() {
- seeNewPW = !seeNewPW;
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 35,
- width: 35,
- padding: EdgeInsets.all(6.5),
- child: SvgPicture.asset(seeNewPW
- ? 'images/svg/不显示.svg'
- : 'images/svg/显示.svg',color: MyColors.c333333,),
- ),
- ),
- ],
- ),
- padding:
- EdgeInsets.symmetric(horizontal: 15, vertical: 8),
- ),
- ],
- ),
- color: Colors.white,
- margin: EdgeInsets.only(top: 10),
- ),
- GestureDetector(
- onTap: () {
- changePassword();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- color: Colors.white,
- height: 50,
- margin: EdgeInsets.only(top: 10),
- child: MyViews().myText('确认', MyColors.cFF4233, 16),
- alignment: Alignment.center,
- ),
- )
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- );
- }
- void changePassword() {
- if (oldPW.text.isEmpty) {
- showToast('请填写旧密码');
- return;
- }
- if (newPW.text.isEmpty) {
- showToast('请填写新密码');
- return;
- }
- // if (oldPW.text.toString() == newPW.text.toString()) {
- // showToast('新密码不能与旧密码一致');
- // return;
- // }
- EasyLoading.show();
- MyDio().post(MyApis.getApi('changePwd'), {
- 'old_password': MyTools.base64Encode(oldPW.text),
- 'new_password': MyTools.base64Encode(newPW.text),
- }, (response, hasError) {
- if (!hasError) {
- showToast('修改成功');
- MyCookie().clean();
- navigatorKey.currentState.pushNamedAndRemoveUntil('/loginPage', ModalRoute.withName("/loginPage"));
- }
- }, (error) {});
- }
- }
|