更新消息设置
This commit is contained in:
@@ -3,9 +3,12 @@ import 'dart:io';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as edm;
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.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';
|
||||
@@ -13,11 +16,14 @@ 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});
|
||||
@@ -42,6 +48,53 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
|
||||
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
|
||||
@@ -103,6 +156,10 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
|
||||
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();
|
||||
}
|
||||
@@ -142,13 +199,13 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
|
||||
decoration: BoxDecoration(),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
60.rpx, 0.rpx, 60.rpx, 0.rpx),
|
||||
0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0.rpx, 76.rpx, 0.rpx, 0.rpx),
|
||||
60.rpx, 76.rpx, 60.rpx, 0.rpx),
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.213,
|
||||
height: MediaQuery.sizeOf(context).height * 0.098,
|
||||
@@ -158,6 +215,9 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
|
||||
),
|
||||
decoration: BoxDecoration(),
|
||||
child: Obx(() {
|
||||
var aa =
|
||||
userInfoController.model.user!.tmpNickName;
|
||||
print(aa);
|
||||
return getImageWidget(context);
|
||||
})),
|
||||
),
|
||||
@@ -165,7 +225,7 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: themeController.currentColor.sc16,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0.rpx, 44.rpx, 0.rpx, 44.rpx),
|
||||
60.rpx, 44.rpx, 60.rpx, 44.rpx),
|
||||
borderRadius: 0,
|
||||
onTap: () async {
|
||||
edm.EasyDartModule.logger
|
||||
@@ -196,7 +256,7 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0.rpx, 79.rpx, 0.rpx, 0.rpx),
|
||||
60.rpx, 79.rpx, 60.rpx, 0.rpx),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
@@ -310,6 +370,258 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
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.sc17,
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 22.rpx)),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(
|
||||
getTextByUserInfo('phone'),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
// color: Color(0xFFD9E3EB),
|
||||
color: themeController
|
||||
.currentColor.sc2,
|
||||
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,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 22.rpx)),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(
|
||||
getTextByUserInfo('email'),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
// color: Color(0xFFD9E3EB),
|
||||
color: themeController
|
||||
.currentColor.sc2,
|
||||
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, 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: getTextByUserInfo(
|
||||
'wechat') ==
|
||||
"解绑".tr
|
||||
? themeController
|
||||
.currentColor.sc4
|
||||
: themeController
|
||||
.currentColor.sc2,
|
||||
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)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -334,9 +646,8 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: head == null || head.isEmpty
|
||||
? Image.asset(
|
||||
'assets/img/avatar.png',
|
||||
fit: BoxFit.cover,
|
||||
? SvgPicture.asset(
|
||||
"assets/img/avatar.svg",
|
||||
)
|
||||
: Image.network(
|
||||
head,
|
||||
@@ -349,4 +660,34 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
|
||||
}
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user