666 lines
36 KiB
Dart
666 lines
36 KiB
Dart
import 'package:EasyDartModule/EasyDartModule.dart' as edm;
|
||
import 'package:ef/ef.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||
import 'package:vbvs_app/component/tool/CustomCard.dart';
|
||
import 'package:vbvs_app/component/tool/NewTopSlideNotification.dart';
|
||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
|
||
import 'package:vbvs_app/controller/login/login_controller.dart';
|
||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||
import 'package:vbvs_app/controller/person/person_controller.dart';
|
||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||
import 'package:vbvs_app/controller/time/countdown_controller.dart';
|
||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||
import 'package:vbvs_app/model/api_response.dart';
|
||
import 'package:vbvs_app/model/user_data.dart';
|
||
import 'package:flutter/services.dart';
|
||
|
||
class UpdateUserEmailPage extends StatefulWidget {
|
||
const UpdateUserEmailPage({super.key});
|
||
|
||
@override
|
||
State<UpdateUserEmailPage> createState() => _UpdateUserEmailPageState();
|
||
}
|
||
|
||
class _UpdateUserEmailPageState extends State<UpdateUserEmailPage> {
|
||
GlobalController globalController = Get.find();
|
||
UserInfoController userInfoController = Get.find();
|
||
BlueteethBindController blueteethBindController = Get.find();
|
||
PersonController personController = Get.find();
|
||
ThemeController themeController = Get.find();
|
||
LoginController loginController = Get.find();
|
||
|
||
@override
|
||
void initState() {
|
||
super.initState();
|
||
userInfoController.model.user!.tmpHead = null;
|
||
userInfoController.model.user!.tmpNickName = null;
|
||
userInfoController.model.user!.tmpHead =
|
||
userInfoController.model.user!.avatar;
|
||
userInfoController.model.user!.tmpNickName =
|
||
userInfoController.model.user!.nick_name;
|
||
loginController.model.updatePhone = null;
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
int login = userInfoController.model.login!;
|
||
return LayoutBuilder(
|
||
builder: (context, bodySize) => GestureDetector(
|
||
// onTap: () => FocusScope.of(context).unfocus(),,
|
||
child: Container(
|
||
decoration: BoxDecoration(
|
||
image: DecorationImage(
|
||
image: AssetImage(getBackgroundImageNoImage()),
|
||
fit: BoxFit.fill,
|
||
),
|
||
),
|
||
child: Scaffold(
|
||
backgroundColor: Colors.transparent,
|
||
appBar: AppBar(
|
||
systemOverlayStyle: SystemUiOverlayStyle(
|
||
statusBarColor: Colors.transparent, // 状态栏背景色
|
||
statusBarIconBrightness: Brightness.light, // 图标颜色(Android)
|
||
statusBarBrightness: Brightness.light, // 图标颜色(iOS)
|
||
),
|
||
backgroundColor: themeController.currentColor.sc5,
|
||
automaticallyImplyLeading: false,
|
||
iconTheme: IconThemeData(
|
||
color: themeController.currentColor.sc3,
|
||
),
|
||
titleSpacing: 0,
|
||
title: Container(
|
||
width: double.infinity,
|
||
height: 180.rpx,
|
||
child: Stack(
|
||
alignment: Alignment.center,
|
||
children: [
|
||
Text(
|
||
'更换邮箱'.tr,
|
||
style: TextStyle(
|
||
fontFamily: 'Readex Pro',
|
||
color: themeController.currentColor.sc3,
|
||
letterSpacing: 0,
|
||
fontSize: 30.rpx,
|
||
),
|
||
),
|
||
Positioned(
|
||
left: 0,
|
||
child: returnIconButtom,
|
||
),
|
||
Positioned(
|
||
right: 20.rpx,
|
||
child: CustomCard(
|
||
borderRadius: 20.rpx,
|
||
onTap: () async {
|
||
if (loginController.model.updatePhone == null ||
|
||
loginController.model.updatePhone == '') {
|
||
NewTopSlideNotification.show(
|
||
text: "请输入邮箱号".tr,
|
||
textColor: themeController.currentColor.sc9,
|
||
);
|
||
return;
|
||
}
|
||
ApiResponse apiResponse =
|
||
await userInfoController.updateData(
|
||
email: loginController.model.updatePhone);
|
||
TopSlideNotification.show(
|
||
context,
|
||
text: apiResponse.msg!,
|
||
textColor: apiResponse.code == HttpStatusCodes.ok
|
||
? themeController.currentColor.sc2
|
||
: themeController.currentColor.sc9,
|
||
);
|
||
if (apiResponse.code == HttpStatusCodes.ok) {
|
||
userInfoController.model.user!.tmpHead = null;
|
||
userInfoController.model.user!.tmpNickName = null;
|
||
loginController.model.updatePhone = null;
|
||
await userInfoController.getUserInfo();
|
||
userInfoController.model.user!.tmpNickName =
|
||
userInfoController.model.user!.nick_name;
|
||
userInfoController.model.user!.tmpHead =
|
||
userInfoController.model.user!.avatar;
|
||
userInfoController.updateAll();
|
||
Get.back();
|
||
}
|
||
},
|
||
colors: [
|
||
themeController.currentColor.sc1,
|
||
themeController.currentColor.sc2,
|
||
],
|
||
child: Container(
|
||
width: 100.rpx,
|
||
height: 60.rpx,
|
||
alignment: Alignment.center,
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
16.rpx, 0.rpx, 16.rpx, 0.rpx),
|
||
child: Text(
|
||
'修改资料页.保存'.tr,
|
||
style: TextStyle(
|
||
fontFamily: 'Inter Tight',
|
||
color: themeController.currentColor.sc3,
|
||
letterSpacing: 0.0,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
actions: [],
|
||
centerTitle: false,
|
||
),
|
||
body: SafeArea(
|
||
top: true,
|
||
child: Container(
|
||
width: double.infinity,
|
||
height: double.infinity,
|
||
decoration: BoxDecoration(),
|
||
child: Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||
child: Column(
|
||
mainAxisSize: MainAxisSize.max,
|
||
children: [
|
||
Align(
|
||
alignment: AlignmentDirectional(-1, 0),
|
||
child: Padding(
|
||
padding:
|
||
EdgeInsetsDirectional.fromSTEB(0, 20.rpx, 0, 0),
|
||
child: Container(
|
||
alignment: Alignment.centerLeft,
|
||
width: double.infinity,
|
||
height: bodySize.maxHeight * 0.056,
|
||
constraints: BoxConstraints(
|
||
minHeight: 120.rpx,
|
||
),
|
||
child: Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
60.rpx, 0, 35.rpx, 0),
|
||
child: Text(
|
||
"原邮箱号".tr + ":" + "${getHideEmail()}",
|
||
style: TextStyle(
|
||
color: themeController.currentColor.sc3,
|
||
fontSize: AppConstants().normal_text_fontSize,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
Container(
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(
|
||
AppConstants().normal_container_radius),
|
||
color: themeController.currentColor.sc5,
|
||
),
|
||
child: Column(
|
||
children: [
|
||
Align(
|
||
alignment: AlignmentDirectional(-1, 0),
|
||
child: Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
0, 20.rpx, 0, 20.rpx),
|
||
child: Container(
|
||
width: double.infinity,
|
||
height: bodySize.maxHeight * 0.056,
|
||
decoration: BoxDecoration(
|
||
color: Colors.transparent,
|
||
borderRadius: BorderRadius.circular(
|
||
0,
|
||
),
|
||
),
|
||
constraints: BoxConstraints(
|
||
minHeight: 90.rpx,
|
||
),
|
||
child: Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
35.rpx, 0, 35.rpx, 0),
|
||
child: Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
mainAxisAlignment:
|
||
MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
// Padding(
|
||
// padding: EdgeInsetsDirectional.fromSTEB(
|
||
// 26.rpx, 0, 0, 0),
|
||
// child: Row(
|
||
// mainAxisSize: MainAxisSize.max,
|
||
// children: [
|
||
// InkWell(
|
||
// onTap: () async {},
|
||
// child: Container(
|
||
// alignment: Alignment.center,
|
||
// // constraints: BoxConstraints(
|
||
// // minWidth: 150.rpx,
|
||
// // ),
|
||
// child: Text(
|
||
// "+86",
|
||
// style: TextStyle(
|
||
// fontFamily: 'Readex Pro',
|
||
// color: themeController
|
||
// .currentColor.sc4,
|
||
// fontSize: AppConstants()
|
||
// .middler_text_fontSize,
|
||
// letterSpacing: 0,
|
||
// ),
|
||
// ),
|
||
// ),
|
||
// ),
|
||
// SizedBox(
|
||
// height: 30.rpx,
|
||
// child: VerticalDivider(
|
||
// thickness: 2.rpx,
|
||
// color: themeController
|
||
// .currentColor.sc4,
|
||
// ),
|
||
// ),
|
||
// ].divide(SizedBox(width: 10.rpx)),
|
||
// ),
|
||
// ),
|
||
|
||
Expanded(
|
||
child: Container(
|
||
child: Align(
|
||
alignment:
|
||
AlignmentDirectional(-1, 0),
|
||
child: TextFormField(
|
||
onChanged: (value) {
|
||
loginController.model
|
||
.updatePhone = value;
|
||
},
|
||
autofocus: false,
|
||
obscureText: false,
|
||
decoration: InputDecoration(
|
||
isDense: true,
|
||
labelStyle: TextStyle(
|
||
fontFamily: 'Inter',
|
||
fontSize: 26.rpx,
|
||
letterSpacing: 0.0,
|
||
),
|
||
hintText: '输入邮箱号码'.tr,
|
||
hintStyle: TextStyle(
|
||
fontFamily: 'Inter',
|
||
fontSize: 26.rpx,
|
||
letterSpacing: 0.0,
|
||
color: themeController
|
||
.currentColor.sc4,
|
||
),
|
||
enabledBorder:
|
||
OutlineInputBorder(
|
||
borderSide: BorderSide(
|
||
color: Color(0x00000000),
|
||
width: 1.rpx,
|
||
),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
8.rpx),
|
||
),
|
||
focusedBorder:
|
||
OutlineInputBorder(
|
||
borderSide: BorderSide(
|
||
color: Color(0x00000000),
|
||
width: 1.rpx,
|
||
),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
8.rpx),
|
||
),
|
||
errorBorder:
|
||
OutlineInputBorder(
|
||
borderSide: BorderSide(
|
||
color: Colors.red,
|
||
width: 1.rpx,
|
||
),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
8.rpx),
|
||
),
|
||
focusedErrorBorder:
|
||
OutlineInputBorder(
|
||
borderSide: BorderSide(
|
||
color: Colors.red,
|
||
width: 1.rpx,
|
||
),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
8.rpx),
|
||
),
|
||
filled: false,
|
||
fillColor: Colors.white,
|
||
),
|
||
style: TextStyle(
|
||
fontFamily: 'Inter',
|
||
fontSize: 26.rpx,
|
||
letterSpacing: 0.0,
|
||
color: themeController
|
||
.currentColor.sc3,
|
||
),
|
||
cursorColor: themeController
|
||
.currentColor.sc3,
|
||
// validator: _model
|
||
// .textControllerValidator
|
||
// .asValidator(context),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
Align(
|
||
alignment: AlignmentDirectional(-1, 0),
|
||
child: Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
0, 0.rpx, 0, 20.rpx),
|
||
child: Container(
|
||
height: bodySize.maxHeight * 0.056,
|
||
width: double.infinity,
|
||
constraints: BoxConstraints(
|
||
minHeight: 90.rpx,
|
||
),
|
||
child: Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
35.rpx, 0, 35.rpx, 0),
|
||
child: Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
mainAxisAlignment:
|
||
MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
Expanded(
|
||
child: Container(
|
||
child: Align(
|
||
alignment:
|
||
AlignmentDirectional(-1, 0),
|
||
child: TextFormField(
|
||
onChanged: (value) {
|
||
loginController
|
||
.model.updateCode = value;
|
||
},
|
||
autofocus: false,
|
||
obscureText: false,
|
||
decoration: InputDecoration(
|
||
isDense: true,
|
||
labelStyle: TextStyle(
|
||
fontFamily: 'Inter',
|
||
fontSize: 26.rpx,
|
||
letterSpacing: 0.0,
|
||
),
|
||
hintText: '其他手机登录页.输入验证码'.tr,
|
||
hintStyle: TextStyle(
|
||
fontFamily: 'Inter',
|
||
fontSize: 26.rpx,
|
||
letterSpacing: 0.0,
|
||
color: themeController
|
||
.currentColor.sc4,
|
||
),
|
||
enabledBorder:
|
||
OutlineInputBorder(
|
||
borderSide: BorderSide(
|
||
color: Color(0x00000000),
|
||
width: 1.rpx,
|
||
),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
8.rpx),
|
||
),
|
||
focusedBorder:
|
||
OutlineInputBorder(
|
||
borderSide: BorderSide(
|
||
color: Color(0x00000000),
|
||
width: 1.rpx,
|
||
),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
8.rpx),
|
||
),
|
||
errorBorder:
|
||
OutlineInputBorder(
|
||
borderSide: BorderSide(
|
||
color: Colors.red,
|
||
width: 1.rpx,
|
||
),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
8.rpx),
|
||
),
|
||
focusedErrorBorder:
|
||
OutlineInputBorder(
|
||
borderSide: BorderSide(
|
||
color: Colors.red,
|
||
width: 1.rpx,
|
||
),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
8.rpx),
|
||
),
|
||
filled: true,
|
||
fillColor: Colors.transparent,
|
||
),
|
||
style: TextStyle(
|
||
fontFamily: 'Inter',
|
||
fontSize: 26.rpx,
|
||
letterSpacing: 0.0,
|
||
color: themeController
|
||
.currentColor.sc3,
|
||
),
|
||
cursorColor: themeController
|
||
.currentColor.sc3,
|
||
// validator: _model
|
||
// .textControllerValidator
|
||
// .asValidator(context),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
Padding(
|
||
padding:
|
||
EdgeInsetsDirectional.fromSTEB(
|
||
26.rpx, 0, 0, 0),
|
||
child: Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
children: [
|
||
SizedBox(
|
||
height: 30.rpx,
|
||
child: VerticalDivider(
|
||
thickness: 2.rpx,
|
||
color: themeController
|
||
.currentColor.sc7,
|
||
),
|
||
),
|
||
Obx(() {
|
||
final CountdownController
|
||
countdownController =
|
||
Get.find<
|
||
CountdownController>();
|
||
return InkWell(
|
||
onTap: () async {
|
||
try {
|
||
DailyLogUtils.writeLog(
|
||
"点击获取验证码");
|
||
if (countdownController
|
||
.countdown
|
||
.value !=
|
||
0) {
|
||
return;
|
||
}
|
||
ApiResponse apiResponse =
|
||
await loginController
|
||
.getUpdateTelCode(
|
||
context);
|
||
if (apiResponse.code !=
|
||
HttpStatusCodes.ok) {
|
||
TopSlideNotification
|
||
.show(
|
||
context,
|
||
text:
|
||
apiResponse.msg!,
|
||
textColor:
|
||
themeController
|
||
.currentColor
|
||
.sc9,
|
||
);
|
||
await DailyLogUtils
|
||
.writeLog(
|
||
"获取验证码成功,${apiResponse}");
|
||
return;
|
||
} else {
|
||
TopSlideNotification
|
||
.show(
|
||
context,
|
||
text:
|
||
apiResponse.msg!,
|
||
textColor:
|
||
themeController
|
||
.currentColor
|
||
.sc2,
|
||
);
|
||
await DailyLogUtils
|
||
.writeLog(
|
||
"获取验证码失败,${apiResponse}");
|
||
}
|
||
countdownController
|
||
.countdown
|
||
.value ==
|
||
0
|
||
? countdownController
|
||
.startCountdown(
|
||
AppConstants
|
||
.code_time)
|
||
: null;
|
||
} catch (e) {
|
||
await DailyLogUtils
|
||
.writeLog(
|
||
"获取验证码异常,${e}");
|
||
edm.EasyDartModule.logger
|
||
.info("获取验证码异常:${e}");
|
||
}
|
||
},
|
||
child: Container(
|
||
alignment: Alignment.center,
|
||
constraints: BoxConstraints(
|
||
minWidth: 150.rpx,
|
||
),
|
||
child: Text(
|
||
countdownController
|
||
.countdown
|
||
.value ==
|
||
0
|
||
? '其他手机登录页.获取验证码'.tr
|
||
: '${countdownController.countdown.value}' +
|
||
"其他手机登录页.秒".tr,
|
||
style: TextStyle(
|
||
fontFamily:
|
||
'Readex Pro',
|
||
color: themeController
|
||
.currentColor.sc2,
|
||
fontSize: AppConstants()
|
||
.middler_text_fontSize,
|
||
letterSpacing: 0,
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}),
|
||
].divide(SizedBox(width: 26.rpx)),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget getImageWidget(BuildContext context) {
|
||
try {
|
||
UserInfoController controller = Get.find();
|
||
var head = controller.model.user!.tmpHead;
|
||
return Container(
|
||
width: 200.rpx,
|
||
height: 200.rpx,
|
||
child: Container(
|
||
clipBehavior: Clip.antiAlias,
|
||
decoration: BoxDecoration(
|
||
shape: BoxShape.circle,
|
||
),
|
||
child: head == null || head.isEmpty
|
||
? Image.asset(
|
||
'assets/img/avatar.png',
|
||
fit: BoxFit.cover,
|
||
)
|
||
: Image.network(
|
||
head,
|
||
fit: BoxFit.cover,
|
||
),
|
||
),
|
||
);
|
||
} catch (e) {
|
||
print(e);
|
||
}
|
||
return Container();
|
||
}
|
||
|
||
String getTextByUserInfo(String type) {
|
||
UserInfoController userInfoController = Get.find();
|
||
UserModel userInfo = userInfoController.model.user!;
|
||
if (userInfo == null) {
|
||
return "";
|
||
}
|
||
if (type == "phone") {
|
||
if (userInfo.phone == null || userInfo.phone!.isEmpty) {
|
||
return "更换".tr;
|
||
} else {
|
||
return "换绑".tr;
|
||
}
|
||
}
|
||
if (type == "email") {
|
||
if (userInfo.email == null || userInfo.email!.isEmpty) {
|
||
return "绑定".tr;
|
||
} else {
|
||
return "换绑".tr;
|
||
}
|
||
}
|
||
if (type == "wechat") {
|
||
if (userInfo.bindWx == null || userInfo.bindWx == false) {
|
||
return "绑定".tr;
|
||
} else {
|
||
return "解绑".tr;
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
|
||
getHideEmail() {
|
||
UserModel userModel = userInfoController.model.user!;
|
||
if (userModel.email == null || userModel.email == "") {
|
||
return "暂无".tr;
|
||
}
|
||
return userModel.email!
|
||
.replaceRange(3, userModel.email!.length - 3, "****");
|
||
}
|
||
}
|