769 lines
37 KiB
Dart
769 lines
37 KiB
Dart
import 'package:EasyDartModule/EasyDartModule.dart' as edm;
|
||
import 'package:ef/ef.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter/services.dart';
|
||
import 'package:flutter_svg/svg.dart';
|
||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||
import 'package:fluwx/fluwx.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/CommonVariables.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/ClickableContainer.dart';
|
||
import 'package:vbvs_app/component/tool/CustomCard.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/user_info_controller.dart';
|
||
import 'package:vbvs_app/model/api_response.dart';
|
||
import 'package:vbvs_app/model/user_data.dart';
|
||
import 'package:vbvs_app/pages/user/wx_unbind_dialog.dart';
|
||
|
||
class UpdateUserPage extends StatefulWidget {
|
||
const UpdateUserPage({super.key});
|
||
|
||
@override
|
||
State<UpdateUserPage> createState() => _UpdateUserPageState();
|
||
}
|
||
|
||
class _UpdateUserPageState extends State<UpdateUserPage> {
|
||
GlobalController globalController = Get.find();
|
||
UserInfoController userInfoController = Get.find();
|
||
BlueteethBindController blueteethBindController = Get.find();
|
||
PersonController personController = Get.find();
|
||
ThemeController themeController = 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;
|
||
|
||
Fluwx fluwx = userInfoController.fluwx;
|
||
userInfoController.fluwxCancelable = fluwx.addSubscriber((response) async {
|
||
if (response is WeChatAuthResponse) {
|
||
debugPrint('state :${response.state} \n code:${response.code}');
|
||
int errCode = response.errCode ?? -9999;
|
||
if (errCode == 0) {
|
||
// TODO 微信登录成功 传递code给后台 再操作逻辑
|
||
String code = response.code ?? "";
|
||
//把微信登录返回的code传给后台,剩下的事就交给后台处理
|
||
//首次未注册的用户引导去手机号填写页面
|
||
//已注册的用户直接跳转首页
|
||
if (CommonVariables.isNetWorkOn == false) {
|
||
TopSlideNotification.show(context,
|
||
text: "网络未连接,请开启设备网络后重试".tr,
|
||
textColor: themeController.currentColor.sc9);
|
||
// showToast("网络未连接,请开启设备网络后重试");
|
||
return;
|
||
}
|
||
ApiResponse apiResponse =
|
||
await userInfoController.updateData(code: code);
|
||
TopSlideNotification.show(
|
||
context,
|
||
text: apiResponse.msg!,
|
||
textColor: apiResponse.code == HttpStatusCodes.ok
|
||
? themeController.currentColor.sc2
|
||
: themeController.currentColor.sc9,
|
||
);
|
||
// TODO 操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听
|
||
// fluwxCancelable?.cancel();
|
||
} else if (errCode == -4) {
|
||
TopSlideNotification.show(context,
|
||
text: "用户拒绝授权".tr, textColor: themeController.currentColor.sc9);
|
||
// showToast("用户拒绝授权");
|
||
} else if (errCode == -2) {
|
||
TopSlideNotification.show(context,
|
||
text: "用户取消授权".tr, textColor: themeController.currentColor.sc9);
|
||
// showToast("用户取消授权");
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
@override
|
||
void dispose() {
|
||
userInfoController.fluwxCancelable?.cancel();
|
||
super.dispose();
|
||
}
|
||
|
||
@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 {
|
||
ApiResponse apiResponse =
|
||
await userInfoController.updateData();
|
||
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;
|
||
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(
|
||
0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||
child: Column(
|
||
mainAxisSize: MainAxisSize.max,
|
||
children: [
|
||
Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
60.rpx, 76.rpx, 60.rpx, 0.rpx),
|
||
child: Container(
|
||
width: MediaQuery.sizeOf(context).width * 0.213,
|
||
height: MediaQuery.sizeOf(context).height * 0.098,
|
||
constraints: BoxConstraints(
|
||
minWidth: 160.rpx,
|
||
minHeight: 160.rpx,
|
||
),
|
||
decoration: BoxDecoration(),
|
||
child: Obx(() {
|
||
var aa =
|
||
userInfoController.model.user!.tmpNickName;
|
||
print(aa);
|
||
return getImageWidget(context);
|
||
})),
|
||
),
|
||
ClickableContainer(
|
||
backgroundColor: Colors.transparent,
|
||
highlightColor: themeController.currentColor.sc16,
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
60.rpx, 44.rpx, 60.rpx, 44.rpx),
|
||
borderRadius: 0,
|
||
onTap: () async {
|
||
edm.EasyDartModule.logger
|
||
.info("${userInfoController.model.user!}点击上传头像");
|
||
DailyLogUtils.writeLog(
|
||
"${userInfoController.model.user!}点击上传头像");
|
||
ApiResponse apiResponse =
|
||
await userInfoController.uploadImg();
|
||
TopSlideNotification.show(
|
||
context,
|
||
text: apiResponse.msg!,
|
||
textColor: apiResponse.code == HttpStatusCodes.ok
|
||
? themeController.currentColor.sc2
|
||
: themeController.currentColor.sc9,
|
||
);
|
||
},
|
||
child: Center(
|
||
child: Text(
|
||
'修改资料页.点击更换头像'.tr,
|
||
style: TextStyle(
|
||
fontFamily: 'Inter',
|
||
fontSize: 26.rpx,
|
||
letterSpacing: 0.0,
|
||
color: themeController.currentColor.sc2,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
60.rpx, 79.rpx, 60.rpx, 0.rpx),
|
||
child: Container(
|
||
width: double.infinity,
|
||
decoration: BoxDecoration(
|
||
border: Border(
|
||
top: BorderSide(
|
||
color: themeController.currentColor.sc4
|
||
.withOpacity(0.5),
|
||
width: AppConstants().border_width,
|
||
),
|
||
bottom: BorderSide(
|
||
color: themeController.currentColor.sc4
|
||
.withOpacity(0.5),
|
||
width: AppConstants().border_width,
|
||
),
|
||
),
|
||
),
|
||
child: Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
Expanded(
|
||
child: Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
children: [
|
||
Expanded(
|
||
child: Container(
|
||
width: 100.rpx,
|
||
height: 100.rpx,
|
||
decoration: BoxDecoration(),
|
||
child: Align(
|
||
alignment: AlignmentDirectional(0, 0),
|
||
child: TextFormField(
|
||
initialValue: userInfoController
|
||
.model.user!.nick_name,
|
||
onChanged: (value) {
|
||
userInfoController.model.user!
|
||
.tmpNickName = 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(
|
||
width: 1.rpx,
|
||
),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
8.rpx),
|
||
),
|
||
focusedErrorBorder:
|
||
OutlineInputBorder(
|
||
borderSide: BorderSide(
|
||
width: 1.rpx,
|
||
),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
8.rpx),
|
||
),
|
||
filled: false,
|
||
),
|
||
style: TextStyle(
|
||
fontFamily: 'Inter',
|
||
fontSize: 30.rpx,
|
||
letterSpacing: 0.0,
|
||
color: themeController
|
||
.currentColor.sc3,
|
||
),
|
||
textAlign: TextAlign.center,
|
||
cursorColor: themeController
|
||
.currentColor.sc3,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
].divide(SizedBox(width: 27.rpx)),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
SizedBox(
|
||
height: 100.rpx,
|
||
),
|
||
Padding(
|
||
padding: EdgeInsets.fromLTRB(40.rpx, 0, 40.rpx, 0),
|
||
child: Container(
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(
|
||
AppConstants().normal_container_radius),
|
||
color: themeController.currentColor.sc5,
|
||
),
|
||
child: Column(
|
||
children: [
|
||
Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
20.rpx, 20.rpx, 20.rpx, 0.rpx),
|
||
child: ClickableContainer(
|
||
backgroundColor: Colors.transparent, // 容器背景色
|
||
highlightColor: themeController
|
||
.currentColor.sc21, // 点击时的背景色
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||
onTap: () async {
|
||
Get.toNamed('/updateUserTelPage');
|
||
},
|
||
child: Container(
|
||
child: Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
20.rpx, 30.rpx, 20.rpx, 30.rpx),
|
||
child: Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
mainAxisAlignment:
|
||
MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
children: [
|
||
Text(
|
||
'手机号码'.tr,
|
||
style: TextStyle(
|
||
fontFamily: 'Inter',
|
||
color: themeController
|
||
.currentColor.sc3,
|
||
fontSize: AppConstants()
|
||
.title_text_fontSize,
|
||
letterSpacing: 0.0,
|
||
),
|
||
),
|
||
SizedBox(width: 22.rpx),
|
||
getNowInfoByType('phone'),
|
||
],
|
||
),
|
||
Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
children: [
|
||
Text(
|
||
getTextByUserInfo('phone'),
|
||
style: TextStyle(
|
||
fontFamily: 'Inter',
|
||
color: getColorByUserInfo(
|
||
'phone'),
|
||
fontSize: 26.rpx,
|
||
letterSpacing: 0.0,
|
||
),
|
||
),
|
||
SvgPicture.asset(
|
||
'assets/img/icon/arrow_right.svg',
|
||
width: 8.rpx,
|
||
height: 15
|
||
.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
|
||
color: themeController
|
||
.currentColor.sc3,
|
||
),
|
||
].divide(SizedBox(width: 28.rpx)),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
40.rpx, 20.rpx, 40.rpx, 0.rpx),
|
||
child: ClickableContainer(
|
||
backgroundColor: Colors.transparent, // 容器背景色
|
||
highlightColor: themeController
|
||
.currentColor.sc21, // 点击时的背景色
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||
onTap: () async {
|
||
Get.toNamed('/updateUserEmailPage');
|
||
},
|
||
child: Container(
|
||
child: Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
0.rpx, 30.rpx, 0.rpx, 30.rpx),
|
||
child: Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
mainAxisAlignment:
|
||
MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
children: [
|
||
Text(
|
||
'邮箱'.tr,
|
||
style: TextStyle(
|
||
fontFamily: 'Inter',
|
||
color: themeController
|
||
.currentColor.sc3,
|
||
fontSize: AppConstants()
|
||
.title_text_fontSize,
|
||
letterSpacing: 0.0,
|
||
),
|
||
),
|
||
SizedBox(width: 22.rpx),
|
||
getNowInfoByType('email'),
|
||
],
|
||
),
|
||
Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
children: [
|
||
Text(
|
||
getTextByUserInfo('email'),
|
||
style: TextStyle(
|
||
fontFamily: 'Inter',
|
||
// color: Color(0xFFD9E3EB),
|
||
color: getColorByUserInfo(
|
||
'email'),
|
||
fontSize: 26.rpx,
|
||
letterSpacing: 0.0,
|
||
),
|
||
),
|
||
SvgPicture.asset(
|
||
'assets/img/icon/arrow_right.svg',
|
||
width: 8.rpx,
|
||
height: 15
|
||
.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
|
||
color: themeController
|
||
.currentColor.sc3,
|
||
),
|
||
].divide(SizedBox(width: 28.rpx)),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
if (AppConstants().ent_type == 1)
|
||
Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
40.rpx, 20.rpx, 40.rpx, 20.rpx),
|
||
child: ClickableContainer(
|
||
backgroundColor:
|
||
Colors.transparent, // 容器背景色
|
||
highlightColor: themeController
|
||
.currentColor.sc21, // 点击时的背景色
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||
onTap: () async {
|
||
if (userInfoController
|
||
.model.user!.bindWx ==
|
||
null ||
|
||
userInfoController
|
||
.model.user!.bindWx ==
|
||
false) {
|
||
//微信绑定
|
||
LoginController loginController =
|
||
Get.find();
|
||
await loginController.wxLoginSendAuth(
|
||
context,
|
||
login: false);
|
||
} else {
|
||
//取消微信绑定
|
||
// LoginController loginController =
|
||
// Get.find();
|
||
// await loginController.wxLoginSendAuth(
|
||
// context,
|
||
// login: false);
|
||
// TopSlideNotification.show(context,
|
||
// text: "暂不支持微信解绑授权".tr,
|
||
// textColor:
|
||
// themeController.currentColor.sc9);
|
||
// return;
|
||
showUnbindWxConfirmDialog(context);
|
||
}
|
||
},
|
||
child: Container(
|
||
child: Padding(
|
||
padding: EdgeInsetsDirectional.fromSTEB(
|
||
0.rpx, 30.rpx, 0.rpx, 30.rpx),
|
||
child: Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
mainAxisAlignment:
|
||
MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
children: [
|
||
Text(
|
||
'微信'.tr,
|
||
style: TextStyle(
|
||
fontFamily: 'Inter',
|
||
color: themeController
|
||
.currentColor.sc3,
|
||
fontSize: AppConstants()
|
||
.title_text_fontSize,
|
||
letterSpacing: 0.0,
|
||
),
|
||
),
|
||
].divide(SizedBox(width: 22.rpx)),
|
||
),
|
||
Row(
|
||
mainAxisSize: MainAxisSize.max,
|
||
children: [
|
||
Obx(() {
|
||
var aa = userInfoController
|
||
.model.user!.tmpNickName;
|
||
print(aa);
|
||
return Text(
|
||
getTextByUserInfo('wechat'),
|
||
style: TextStyle(
|
||
fontFamily: 'Inter',
|
||
// color: Color(0xFFD9E3EB),
|
||
color: getColorByUserInfo(
|
||
'wechat'),
|
||
fontSize: 26.rpx,
|
||
letterSpacing: 0.0,
|
||
),
|
||
);
|
||
}),
|
||
SvgPicture.asset(
|
||
'assets/img/icon/arrow_right.svg',
|
||
width: 8.rpx,
|
||
height: 15
|
||
.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
|
||
color: themeController
|
||
.currentColor.sc3,
|
||
),
|
||
].divide(SizedBox(width: 28.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
|
||
? SvgPicture.asset(
|
||
"assets/img/avatar.svg",
|
||
)
|
||
: 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 "";
|
||
}
|
||
|
||
Color getColorByUserInfo(String type) {
|
||
final text = getTextByUserInfo(type);
|
||
// 去绑定 = 未绑定
|
||
return text == "去绑定".tr
|
||
? themeController.currentColor.sc4
|
||
: themeController.currentColor.sc2;
|
||
}
|
||
|
||
getNowInfoByType(String type) {
|
||
UserInfoController userInfoController = Get.find();
|
||
UserModel userInfo = userInfoController.model.user!;
|
||
if (type == "phone") {
|
||
if (userInfo.phone == null || userInfo.phone!.isEmpty) {
|
||
return Text(
|
||
"(" + "暂未绑定".tr + ")",
|
||
style: TextStyle(
|
||
color: themeController.currentColor.sc4,
|
||
fontSize: AppConstants().normal_text_fontSize,
|
||
),
|
||
);
|
||
} else {
|
||
return Text(
|
||
"(" + "${getHidePhone()}" + ")",
|
||
style: TextStyle(
|
||
color: themeController.currentColor.sc4,
|
||
fontSize: AppConstants().normal_text_fontSize,
|
||
),
|
||
);
|
||
}
|
||
}
|
||
if (type == "email") {
|
||
if (userInfo.email == null || userInfo.email!.isEmpty) {
|
||
return Text(
|
||
"(" + "暂未绑定".tr + ")",
|
||
style: TextStyle(
|
||
color: themeController.currentColor.sc4,
|
||
fontSize: AppConstants().normal_text_fontSize,
|
||
),
|
||
);
|
||
} else {
|
||
return Text(
|
||
"(" + "${getHideEmail()}" + ")",
|
||
style: TextStyle(
|
||
color: themeController.currentColor.sc4,
|
||
fontSize: AppConstants().normal_text_fontSize,
|
||
),
|
||
);
|
||
}
|
||
}
|
||
|
||
return Container();
|
||
}
|
||
|
||
getHidePhone() {
|
||
UserModel userModel = userInfoController.model.user!;
|
||
if (userModel.phone == null || userModel.phone == "") {
|
||
return "暂无".tr;
|
||
}
|
||
return "${userModel.phone!.substring(0, 3)}****${userModel.phone!.substring(7, 11)}";
|
||
}
|
||
|
||
getHideEmail() {
|
||
UserModel userModel = userInfoController.model.user!;
|
||
if (userModel.email == null || userModel.email == "") {
|
||
return "暂无".tr;
|
||
}
|
||
return userModel.email!
|
||
.replaceRange(3, userModel.email!.length - 3, "****");
|
||
}
|
||
}
|