* 'master' of http://192.168.2.201:8099/zhangmeng/aku_community_manager:
  对接:发送手机号修改验证码 对接:个人资料修改手机号
  添加修改手机页面
hmxc
小赖 4 years ago
commit 5b6937b59a

@ -36,6 +36,13 @@ class _User {
/// ///
String get updateNickName => '/user/personalData/updateNickName'; String get updateNickName => '/user/personalData/updateNickName';
///
String get sendTelUpdateCode => '/user/personalData/sendTelUpdateCode';
///
String get updateTel =>'/user/personalData/updateTel';
} }
class _Manage { class _Manage {

@ -87,9 +87,9 @@ class UserProvider extends ChangeNotifier {
_isSigned = true; _isSigned = true;
notifyListeners(); notifyListeners();
} }
///
setNickName(String name) { setNickName(String name) {
_userInfoModel.nickName = name; _infoModel.nickName = name;
notifyListeners(); notifyListeners();
} }
@ -97,4 +97,10 @@ class UserProvider extends ChangeNotifier {
_userInfoModel.avatar = file; _userInfoModel.avatar = file;
notifyListeners(); notifyListeners();
} }
///
setTel(String tel){
_infoModel.tel=tel;
notifyListeners();
}
} }

@ -0,0 +1,211 @@
import 'dart:async';
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/utils/network/base_model.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class TelChangePage extends StatefulWidget {
TelChangePage({Key key}) : super(key: key);
@override
_TelChangePageState createState() => _TelChangePageState();
}
class _TelChangePageState extends State<TelChangePage> {
TextEditingController _oldTelController;
TextEditingController _newTelController;
TextEditingController _codeController;
Timer _timer;
bool get validPhone => RegexUtil.isMobileSimple(_newTelController.text);
bool get _canGetCode {
bool timeActive = _timer?.isActive ?? false;
return (!timeActive) && validPhone;
}
startTick() {
_timer = Timer.periodic(Duration(seconds: 1), (_timer) {
if (_timer.tick >= 60) {
_timer.cancel();
_timer = null;
}
setState(() {});
});
}
@override
void initState() {
super.initState();
_codeController = TextEditingController();
_newTelController = TextEditingController();
_oldTelController = TextEditingController();
}
@override
void dispose() {
_codeController?.dispose();
_newTelController?.dispose();
_oldTelController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
UserProvider userProvider = Provider.of<UserProvider>(context);
return AkuScaffold(
title: '修改手机',
body: Material(
color: Colors.white,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w),
child: ListView(
children: [
55.w.heightBox,
'旧号码'.text.black.size(28.sp).make(),
TextFormField(
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[0-9]*'))
],
controller: _oldTelController,
decoration: InputDecoration(
contentPadding: EdgeInsets.zero,
hintText: '请输入旧号码',
hintStyle:
TextStyle(color: Color(0xFF999999), fontSize: 34.sp),
border: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFFEEEEEE),
width: 1.w,
)),
),
),
24.w.heightBox,
'新号码'.text.black.size(28.sp).make(),
TextFormField(
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[0-9]*')),
],
controller: _newTelController,
onChanged: (value) {
setState(() {});
},
decoration: InputDecoration(
suffixIconConstraints:
BoxConstraints(minHeight: 0.w, minWidth: 0.w),
suffixIcon: MaterialButton(
onPressed: _canGetCode
? () async {
BaseModel baseModel =
await UpdateUserInfoFunc.sendTelUpdateCode(
_newTelController.text);
if (baseModel.status) {
startTick();
} else {}
}
: () {},
child: _timer?.isActive ?? false
? '${60 - _timer.tick}'
.text
.color(Color(0xFFFFC40C))
.size(28.sp)
.make()
: '获取验证码'
.text
.color(Color(0xFFFFC40C))
.size(28.sp)
.make(),
padding: EdgeInsets.zero,
minWidth: 177.w,
height: 62.w,
elevation: 0,
hoverElevation: 0,
focusElevation: 0,
highlightElevation: 0,
disabledElevation: 0,
shape: RoundedRectangleBorder(
side: BorderSide(
color: Color(0xFFFFC40C),
width: 1.w,
)),
),
contentPadding: EdgeInsets.only(top: 20.w),
hintText: '请输入新号码',
hintStyle:
TextStyle(color: Color(0xFF999999), fontSize: 34.sp),
border: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFFEEEEEE),
width: 1.w,
),
),
),
),
24.w.heightBox,
'验证码'.text.black.size(28.sp).make(),
TextFormField(
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[0-9]*'))
],
controller: _codeController,
decoration: InputDecoration(
contentPadding: EdgeInsets.zero,
hintText: '请输入验证码',
hintStyle:
TextStyle(color: Color(0xFF999999), fontSize: 34.sp),
border: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFFEEEEEE),
width: 1.w,
)),
),
),
64.w.heightBox,
MaterialButton(
onPressed: () async {
if (TextUtil.isEmpty(_oldTelController.text)) {
BotToast.showText(text: '旧手机号不能为空');
} else if (TextUtil.isEmpty(_newTelController.text)) {
BotToast.showText(text: '新手机号不能为空');
} else if (TextUtil.isEmpty(_codeController.text)) {
BotToast.showText(text: '验证码不能为空');
} else {
BaseModel baseModel = await UpdateUserInfoFunc.updateTel(
_oldTelController.text,
_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(),
color: Color(0xFFFFC40C),
elevation: 0,
minWidth: 686.w,
height: 85.w,
),
24.w.heightBox,
'注:新手机号将作为您的登录凭证'
.text
.color(Color(0xFF999999))
.size(24.sp)
.maxLines(2)
.make()
],
),
),
),
);
}
}

@ -0,0 +1,23 @@
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/utils/network/base_model.dart';
import 'package:aku_community_manager/utils/network/net_util.dart';
class UpdateUserInfoFunc {
static Future<BaseModel> sendTelUpdateCode(String tel) async {
BaseModel baseModel =
await NetUtil().post(API.user.sendTelUpdateCode, params: {
'newTel': tel,
});
return baseModel;
}
static Future<BaseModel> updateTel(
String oldTel, String newTel, String code) async {
BaseModel baseModel = await NetUtil().post(API.user.updateTel, params: {
'oldTel': oldTel,
'newTel': newTel,
'code': code,
});
return baseModel;
}
}

@ -1,6 +1,7 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/tools/aku_divider.dart'; import 'package:aku_community_manager/tools/aku_divider.dart';
import 'package:aku_community_manager/ui/settings/nick_name_change_page.dart'; import 'package:aku_community_manager/ui/settings/nick_name_change_page.dart';
import 'package:aku_community_manager/ui/settings/tel_change_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
@ -52,7 +53,12 @@ class _UserInfoPageState extends State<UserInfoPage> {
suffix: Text(userProvider.infoModel.nickName), suffix: Text(userProvider.infoModel.nickName),
), ),
AkuTile( AkuTile(
onTap: () {}, onTap: () async{
await TelChangePage().to();
setState(() {
});
},
title: Text('手机'), title: Text('手机'),
suffix: Text(TextUtil.hideNumber(userProvider.profileModel.tel)), suffix: Text(TextUtil.hideNumber(userProvider.profileModel.tel)),
), ),

Loading…
Cancel
Save