From e90a3a856aef8e25cc704102bb69c3b78ac9a73b Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Mon, 18 Jan 2021 19:44:18 +0800 Subject: [PATCH] add update tel page --- lib/constants/api.dart | 3 + lib/pages/personal/change_nick_name_page.dart | 5 +- lib/pages/personal/update_tel_page.dart | 143 ++++++++++++++++++ lib/pages/personal/user_profile_page.dart | 5 +- lib/provider/user_provider.dart | 13 ++ 5 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 lib/pages/personal/update_tel_page.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index fe7b27c8..997a8e47 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -38,4 +38,7 @@ class _User { ///修改用户昵称 String get updateNickName =>'/user/personalData/updateNickName'; + + ///修改用户手机号 + String get updateTel =>'/user/personalData/updateTel'; } diff --git a/lib/pages/personal/change_nick_name_page.dart b/lib/pages/personal/change_nick_name_page.dart index eb88ae78..32ce4a46 100644 --- a/lib/pages/personal/change_nick_name_page.dart +++ b/lib/pages/personal/change_nick_name_page.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; -import 'package:random_character/random_character.dart'; import 'package:velocity_x/velocity_x.dart'; class ChangeNickName extends StatefulWidget { @@ -49,6 +48,10 @@ class _ChangeNickNameState extends State { decoration: InputDecoration( contentPadding: EdgeInsets.zero, hintText: '${userProvider.userInfoModel.nickName}', + hintStyle: TextStyle( + color: Color(0xFF999999), + fontSize: 34.sp + ), border: UnderlineInputBorder( borderSide: BorderSide( color: Color(0xFFEEEEEE), diff --git a/lib/pages/personal/update_tel_page.dart b/lib/pages/personal/update_tel_page.dart new file mode 100644 index 00000000..898b1808 --- /dev/null +++ b/lib/pages/personal/update_tel_page.dart @@ -0,0 +1,143 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:flutter/material.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 UpdateTelPage extends StatefulWidget { + UpdateTelPage({Key key}) : super(key: key); + + @override + _UpdateTelPageState createState() => _UpdateTelPageState(); +} + +class _UpdateTelPageState extends State { + TextEditingController _oldTelController; + TextEditingController _newTelController; + TextEditingController _codeController; + @override + void initState() { + // final userProvider = Provider.of(context, listen: false); + _oldTelController = TextEditingController(); + _newTelController = TextEditingController(); + _codeController = TextEditingController(); + super.initState(); + } + + @override + void dispose() { + _codeController?.dispose(); + _oldTelController?.dispose(); + _newTelController?.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final userProvider = Provider.of(context); + return BeeScaffold( + title: '修改手机号', + body: Material( + color: Colors.white, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: ListView( + children: [ + 55.heightBox, + '旧号码'.text.black.size(28.sp).make(), + TextFormField( + 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.heightBox, + '新号码'.text.black.size(28.sp).make(), + TextFormField( + controller: _newTelController, + decoration: InputDecoration( + suffixIconConstraints: + BoxConstraints(minHeight: 0.w, minWidth: 0.w), + suffixIcon: MaterialButton( + onPressed: () {}, + child: '获取验证码'.text.color(kPrimaryColor).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: kDarkPrimaryColor, + 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.heightBox, + '验证码'.text.black.size(28.sp).make(), + TextFormField( + 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.heightBox, + MaterialButton( + onPressed: () { + userProvider.updateTel(_oldTelController.text, + _newTelController.text, _codeController.text); + Get.back(); + }, + child: '保存'.text.black.size(32.sp).make(), + color: Color(0xFFFFC40C), + elevation: 0, + minWidth: 686.w, + height: 85.w, + ), + 24.heightBox, + '注:新手机号将作为您的登录凭证' + .text + .color(Color(0xFF999999)) + .size(24.sp) + .maxLines(2) + .make() + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/personal/user_profile_page.dart b/lib/pages/personal/user_profile_page.dart index 991fead2..06396197 100644 --- a/lib/pages/personal/user_profile_page.dart +++ b/lib/pages/personal/user_profile_page.dart @@ -1,5 +1,6 @@ import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/pages/personal/change_nick_name_page.dart'; +import 'package:akuCommunity/pages/personal/update_tel_page.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/utils/headers.dart'; @@ -78,7 +79,9 @@ class _UserProfilePageState extends State { _buildTile( '手机号', TextUtil.hideNumber(userProvider.userInfoModel.tel).text.make(), - onPressed: () {}, + onPressed: () { + UpdateTelPage().to(); + }, ), _buildTile( '性别', diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 84cc8463..315724be 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -86,4 +86,17 @@ class UserProvider extends ChangeNotifier { notifyListeners(); } } + + //修改手机号 + Future updateTel(String oldTel, String newTel, String code) async { + BaseModel baseModel = await NetUtil().post( + API.user.updateTel, + params: {'oldTel': oldTel, 'newTel': newTel, 'code': code}, + showMessage: true, + ); + if (baseModel.status) { + _userInfoModel.tel = newTel; + notifyListeners(); + } + } }