|
|
@ -1,7 +1,9 @@
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:aku_community_manager/provider/user_provider.dart';
|
|
|
|
import 'package:aku_community_manager/provider/user_provider.dart';
|
|
|
|
|
|
|
|
import 'package:aku_community_manager/ui/settings/update_userinfo_func.dart';
|
|
|
|
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
|
|
|
|
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
|
|
|
|
|
|
|
|
import 'package:aku_community_manager/utils/network/base_model.dart';
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
@ -28,7 +30,8 @@ class _TelChangePageState extends State<TelChangePage> {
|
|
|
|
bool timeActive = _timer?.isActive ?? false;
|
|
|
|
bool timeActive = _timer?.isActive ?? false;
|
|
|
|
return (!timeActive) && validPhone;
|
|
|
|
return (!timeActive) && validPhone;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
startTick() {
|
|
|
|
|
|
|
|
|
|
|
|
startTick() {
|
|
|
|
_timer = Timer.periodic(Duration(seconds: 1), (_timer) {
|
|
|
|
_timer = Timer.periodic(Duration(seconds: 1), (_timer) {
|
|
|
|
if (_timer.tick >= 60) {
|
|
|
|
if (_timer.tick >= 60) {
|
|
|
|
_timer.cancel();
|
|
|
|
_timer.cancel();
|
|
|
@ -37,23 +40,25 @@ class _TelChangePageState extends State<TelChangePage> {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
_codeController=TextEditingController();
|
|
|
|
_codeController = TextEditingController();
|
|
|
|
_newTelController=TextEditingController();
|
|
|
|
_newTelController = TextEditingController();
|
|
|
|
_oldTelController=TextEditingController();
|
|
|
|
_oldTelController = TextEditingController();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
void dispose() {
|
|
|
|
_codeController?.dispose();
|
|
|
|
_codeController?.dispose();
|
|
|
|
_newTelController?.dispose();
|
|
|
|
_newTelController?.dispose();
|
|
|
|
_oldTelController?.dispose();
|
|
|
|
_oldTelController?.dispose();
|
|
|
|
super.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
|
|
|
|
UserProvider userProvider = Provider.of<UserProvider>(context);
|
|
|
|
UserProvider userProvider = Provider.of<UserProvider>(context);
|
|
|
|
return AkuScaffold(
|
|
|
|
return AkuScaffold(
|
|
|
|
title: '修改手机',
|
|
|
|
title: '修改手机',
|
|
|
@ -97,8 +102,13 @@ class _TelChangePageState extends State<TelChangePage> {
|
|
|
|
BoxConstraints(minHeight: 0.w, minWidth: 0.w),
|
|
|
|
BoxConstraints(minHeight: 0.w, minWidth: 0.w),
|
|
|
|
suffixIcon: MaterialButton(
|
|
|
|
suffixIcon: MaterialButton(
|
|
|
|
onPressed: _canGetCode
|
|
|
|
onPressed: _canGetCode
|
|
|
|
? () {
|
|
|
|
? () async {
|
|
|
|
startTick();
|
|
|
|
BaseModel baseModel =
|
|
|
|
|
|
|
|
await UpdateUserInfoFunc.sendTelUpdateCode(
|
|
|
|
|
|
|
|
_newTelController.text);
|
|
|
|
|
|
|
|
if (baseModel.status) {
|
|
|
|
|
|
|
|
startTick();
|
|
|
|
|
|
|
|
} else {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
: () {},
|
|
|
|
: () {},
|
|
|
|
child: _timer?.isActive ?? false
|
|
|
|
child: _timer?.isActive ?? false
|
|
|
@ -107,7 +117,11 @@ class _TelChangePageState extends State<TelChangePage> {
|
|
|
|
.color(Color(0xFFFFC40C))
|
|
|
|
.color(Color(0xFFFFC40C))
|
|
|
|
.size(28.sp)
|
|
|
|
.size(28.sp)
|
|
|
|
.make()
|
|
|
|
.make()
|
|
|
|
: '获取验证码'.text.color(Color(0xFFFFC40C)).size(28.sp).make(),
|
|
|
|
: '获取验证码'
|
|
|
|
|
|
|
|
.text
|
|
|
|
|
|
|
|
.color(Color(0xFFFFC40C))
|
|
|
|
|
|
|
|
.size(28.sp)
|
|
|
|
|
|
|
|
.make(),
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
minWidth: 177.w,
|
|
|
|
minWidth: 177.w,
|
|
|
|
height: 62.w,
|
|
|
|
height: 62.w,
|
|
|
@ -155,7 +169,7 @@ class _TelChangePageState extends State<TelChangePage> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
64.w.heightBox,
|
|
|
|
64.w.heightBox,
|
|
|
|
MaterialButton(
|
|
|
|
MaterialButton(
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () async {
|
|
|
|
if (TextUtil.isEmpty(_oldTelController.text)) {
|
|
|
|
if (TextUtil.isEmpty(_oldTelController.text)) {
|
|
|
|
BotToast.showText(text: '旧手机号不能为空');
|
|
|
|
BotToast.showText(text: '旧手机号不能为空');
|
|
|
|
} else if (TextUtil.isEmpty(_newTelController.text)) {
|
|
|
|
} else if (TextUtil.isEmpty(_newTelController.text)) {
|
|
|
@ -163,9 +177,16 @@ class _TelChangePageState extends State<TelChangePage> {
|
|
|
|
} else if (TextUtil.isEmpty(_codeController.text)) {
|
|
|
|
} else if (TextUtil.isEmpty(_codeController.text)) {
|
|
|
|
BotToast.showText(text: '验证码不能为空');
|
|
|
|
BotToast.showText(text: '验证码不能为空');
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// userProvider.setTel(_oldTelController.text,
|
|
|
|
BaseModel baseModel = await UpdateUserInfoFunc.updateTel(
|
|
|
|
// _newTelController.text, _codeController.text);
|
|
|
|
_oldTelController.text,
|
|
|
|
Get.back();
|
|
|
|
_newTelController.text,
|
|
|
|
|
|
|
|
_codeController.text);
|
|
|
|
|
|
|
|
if (baseModel.status) {
|
|
|
|
|
|
|
|
userProvider.setTel(_newTelController.text);
|
|
|
|
|
|
|
|
Get.back();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
BotToast.showText(text: baseModel.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: '保存'.text.black.size(32.sp).make(),
|
|
|
|
child: '保存'.text.black.size(32.sp).make(),
|
|
|
@ -187,4 +208,4 @@ class _TelChangePageState extends State<TelChangePage> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|