多语言后端数据

This commit is contained in:
czz
2025-08-01 22:25:47 +08:00
parent 12a53ac36c
commit a199606f80
52 changed files with 1736 additions and 1142 deletions

View File

@@ -31,43 +31,6 @@ class _MinePageState extends State<NewMinePage> {
UserInfoController userInfoController = Get.find();
ThemeController themeController = Get.find();
MhMessageController messageController = Get.find();
// final GlobalKey _textKey = GlobalKey();
// double _textHalfWidth = 0;
// @override
// void initState() {
// super.initState();
// final login = userInfoController.model.login;
// String text;
// if (login == 0) {
// text = '未命名'.tr;
// } else {
// final nickname = userInfoController.model.user?.nick_name;
// text = (nickname != null && nickname.isNotEmpty) ? nickname : '未命名'.tr;
// }
// _calculateTextHalfWidth(text);
// }
// void _calculateTextHalfWidth(String text) {
// final textSpan = TextSpan(
// text: text,
// style: TextStyle(
// fontSize: 30.rpx,
// height: 1,
// ),
// );
// final textPainter = TextPainter(
// text: textSpan,
// textDirection: ui.TextDirection.ltr,
// );
// textPainter.layout(); // 计算文本宽度
// setState(() {
// _textHalfWidth = textPainter.width / 2;
// });
// }
@override
Widget build(BuildContext context) {
@@ -100,29 +63,35 @@ class _MinePageState extends State<NewMinePage> {
return ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: EdgeInsets.only(right: 38.rpx),
padding: EdgeInsets.only(right: 20.rpx),
onTap: () {
Get.toNamed('/messagePage');
},
child: Stack(
clipBehavior: Clip.none,
children: [
// 扩大点击区域但不影响SVG图标尺寸
Container(
height: 42.rpx,
width: 42.rpx,
child: SvgPicture.asset(
'assets/img/icon/message.svg',
color: Colors.white,
width: 60.rpx, // 比图标大
height: 60.rpx,
alignment: Alignment.center,
child: Container(
width: 42.rpx,
height: 42.rpx,
child: SvgPicture.asset(
'assets/img/icon/message.svg',
color: Colors.white,
),
),
),
if (messageController.model.body_message_read == 1 ||
messageController.model.system_message_read == 1)
Positioned(
top: 4.rpx,
right: -10.rpx,
top: 8.rpx,
right: -1.rpx,
child: Container(
width: 12.rpx,
height: 12.rpx,
width: 14.rpx,
height: 14.rpx,
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
@@ -143,11 +112,12 @@ class _MinePageState extends State<NewMinePage> {
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsets.only(
top: 30.rpx, left: 60.rpx, bottom: 190.rpx),
child: Row(
children: [
Container(
padding: EdgeInsets.only(
top: 30.rpx, left: 60.rpx, bottom: 190.rpx),
child: Row(
children: [
Obx(() {
return Container(
width: 120.rpx,
height: 120.rpx,
clipBehavior: Clip.antiAlias,
@@ -172,111 +142,110 @@ class _MinePageState extends State<NewMinePage> {
"assets/images/mine_avatar.png",
fit: BoxFit.cover,
),
),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
login == 1
? (userInfoController
.model.user!.nick_name ??
'未命名'.tr)
: "未命名".tr,
style: TextStyle(
fontFamily: 'Inter',
color: themeController.currentColor.sc3,
fontSize:
AppConstants().title_text_fontSize,
letterSpacing: 0.0,
),
);
}),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
login == 1
? (userInfoController
.model.user!.nick_name ??
'未命名'.tr)
: "未命名".tr,
style: TextStyle(
fontFamily: 'Inter',
color: themeController.currentColor.sc3,
fontSize:
AppConstants().title_text_fontSize,
letterSpacing: 0.0,
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: const Color(0xFF055466),
padding: EdgeInsets.zero,
onTap: () async {
if (userInfoController.model.login ==
null ||
userInfoController.model.login ==
0) {
TopSlideNotification.show(
context,
text: "必须登录提示".tr,
textColor: themeController
.currentColor.sc9,
);
Get.toNamed("/loginPage");
return;
}
await Get.toNamed(
"/editUserInfoPage");
await userInfoController
.getUserInfo();
userInfoController.updateAll();
final login =
userInfoController.model.login;
String text;
if (login == 0) {
text = '未命名'.tr;
} else {
final nickname = userInfoController
.model.user?.nick_name;
text = (nickname != null &&
nickname.isNotEmpty)
? nickname
: '未命名'.tr;
}
},
child: Container(
width: 42.rpx,
height: 42.rpx,
alignment: Alignment.center,
child: SvgPicture.asset(
'assets/images/edit.svg',
color: Colors.white,
width: 18.rpx,
height: 18.rpx,
),
)),
].divide(SizedBox(
width: 20.rpx,
)),
),
Text(
login == 1
? (() {
final user =
userInfoController.model.user!;
if (user.email != null &&
user.email!.isNotEmpty) {
return user.email!;
} else if (user.phone != null &&
user.phone!.isNotEmpty) {
return MyUtils.hidePhoneNumber(
user.phone!);
} else {
return "微信用户".tr;
}
})()
: "未知数据".tr,
style: TextStyle(
fontFamily: 'Inter',
color: themeController.currentColor.sc4,
fontSize:
AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: const Color(0xFF055466),
padding: EdgeInsets.zero,
onTap: () async {
if (userInfoController.model.login ==
null ||
userInfoController.model.login ==
0) {
TopSlideNotification.show(
context,
text: "必须登录提示".tr,
textColor: themeController
.currentColor.sc9,
);
Get.toNamed("/loginPage");
return;
}
await Get.toNamed("/editUserInfoPage");
await userInfoController.getUserInfo();
userInfoController.updateAll();
final login =
userInfoController.model.login;
String text;
if (login == 0) {
text = '未命名'.tr;
} else {
final nickname = userInfoController
.model.user?.nick_name;
text = (nickname != null &&
nickname.isNotEmpty)
? nickname
: '未命名'.tr;
}
},
child: Container(
width: 42.rpx,
height: 42.rpx,
alignment: Alignment.center,
child: SvgPicture.asset(
'assets/images/edit.svg',
color: Colors.white,
width: 18.rpx,
height: 18.rpx,
),
)),
].divide(SizedBox(
width: 20.rpx,
)),
),
Text(
login == 1
? (() {
final user =
userInfoController.model.user!;
if (user.email != null &&
user.email!.isNotEmpty) {
return user.email!;
} else if (user.phone != null &&
user.phone!.isNotEmpty) {
return MyUtils.hidePhoneNumber(
user.phone!);
} else {
return "微信用户".tr;
}
})()
: "未知数据".tr,
style: TextStyle(
fontFamily: 'Inter',
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
),
],
))
].divide(SizedBox(
width: 30.rpx,
)),
),
],
))
].divide(SizedBox(
width: 30.rpx,
)),
),
),
Expanded(
child: Container(
@@ -304,15 +273,15 @@ class _MinePageState extends State<NewMinePage> {
'当您的智能设备需要报修时,可以通过该功能联系解决,'.tr,
path: '/deviceRepairPage',
),
_buildListTile('assets/img/icon/mall.svg', '网上商城'.tr,
'最新的智能产品线上购买服务'.tr,
path: "", onTap: () {
_buildListTile('assets/img/icon/mall.svg',
'网上商城'.tr, '最新的智能产品线上购买服务'.tr, path: "",
onTap: () {
JDLauncher.openShop(
"https://mall.jd.com/index-14587480.html");
}),
_buildListTile('assets/img/icon/address.svg',
'地址管理'.tr, '用于收货和报修时联系您'.tr,
path: "/addressListPage"),
// _buildListTile('assets/img/icon/address.svg',
// '地址管理'.tr, '用于收货和报修时联系您'.tr,
// path: "/addressListPage"),
_buildListTile('assets/img/icon/help.svg',
'问题与帮助'.tr, '常见的问题汇总,如:智能床连接流程、如何查看睡眠报告'.tr,
path: "/issueListpage"),
@@ -474,8 +443,8 @@ class _MinePageState extends State<NewMinePage> {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.rpx)),
),
child:
Text('设置'.tr, style: TextStyle(fontSize: 26.rpx, color: Colors.white)),
child: Text('设置'.tr,
style: TextStyle(fontSize: 26.rpx, color: Colors.white)),
),
);
}