设备报修

This commit is contained in:
czz
2025-07-14 18:04:42 +08:00
parent a26834f56c
commit d5a5e3282d
13 changed files with 952 additions and 374 deletions

View File

@@ -1,3 +1,5 @@
import 'dart:ffi';
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -24,43 +26,43 @@ class _MinePageState extends State<NewMinePage> {
GlobalController globalController = Get.find();
UserInfoController userInfoController = Get.find();
ThemeController themeController = Get.find();
final GlobalKey _textKey = GlobalKey();
// final GlobalKey _textKey = GlobalKey();
double _textHalfWidth = 0;
@override
void initState() {
super.initState();
// double _textHalfWidth = 0;
// @override
// void initState() {
// super.initState();
final login = userInfoController.model.login;
String text;
// 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;
}
// if (login == 0) {
// text = '未命名'.tr;
// } else {
// final nickname = userInfoController.model.user?.nick_name;
// text = (nickname != null && nickname.isNotEmpty) ? nickname : '未命名'.tr;
// }
_calculateTextHalfWidth(text);
}
// _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;
});
}
// 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) {
@@ -128,139 +130,144 @@ class _MinePageState extends State<NewMinePage> {
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.only(top: 30.rpx),
child: Container(
width: 120.rpx,
height: 120.rpx,
clipBehavior: Clip.antiAlias,
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: login == 1
? (userInfoController.model.user!.avatar == null ||
userInfoController
.model.user!.avatar!.isEmpty
? Image.asset(
"assets/images/mine_avatar.png",
fit: BoxFit.cover,
)
: Image.network(
userInfoController.model.user!.avatar!,
fit: BoxFit.cover,
))
: Image.asset(
"assets/images/mine_avatar.png",
fit: BoxFit.cover,
),
),
),
Padding(
padding: EdgeInsetsDirectional.only(top: 19.rpx),
child: Container(
width: double.infinity,
decoration: const BoxDecoration(),
child: Stack(
alignment: Alignment.center, // 使子组件在Stack中居中
padding: EdgeInsets.only(
top: 30.rpx, left: 60.rpx, bottom: 70.rpx),
child: Row(
children: [
Obx(() {
return getUserInfo(userInfoController);
}),
Positioned(
left: MediaQuery.of(context).size.width / 2 +
_textHalfWidth +
30.rpx,
top: -10.rpx,
child: 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;
}
_calculateTextHalfWidth(text);
},
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,
Container(
width: 120.rpx,
height: 120.rpx,
clipBehavior: Clip.antiAlias,
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: login == 1
? (userInfoController.model.user!.avatar ==
null ||
userInfoController
.model.user!.avatar!.isEmpty
? Image.asset(
"assets/images/default_avatar.png",
fit: BoxFit.cover,
)
: Image.network(
userInfoController
.model.user!.avatar!,
fit: BoxFit.cover,
))
: Image.asset(
"assets/images/default_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,
),
),
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;
Container(
margin: EdgeInsets.only(
left: 30.rpx, right: 30.rpx, top: 94.rpx),
child: Text(
'对已绑定的智能设备进行个性化配置,以获得更好的体验',
style: TextStyle(
fontSize: 26.rpx,
color: const Color(0XFF929699),
height: 1),
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,
)),
)),
Padding(
padding: EdgeInsets.only(top: 46.rpx, bottom: 109.rpx),
child: ElevatedButton(
onPressed: () {
Get.toNamed("/deviceListPage");
},
style: ElevatedButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
backgroundColor: const Color(0XFF85F5FF),
side: const BorderSide(color: Color(0XFF74DAE5)),
// foregroundColor: Colors.cyanAccent,
minimumSize: Size(260.rpx, 60.rpx),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
),
),
child: Text(
'我的智能设备'.tr,
style: TextStyle(
fontSize: 26.rpx, color: const Color(0xFF003058)),
),
),
),
// 使用 Expanded 让滚动区域占据可用空间
// SizedBox(height: 109.rpx),
Expanded(
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
margin: EdgeInsets.symmetric(horizontal: 30.rpx),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.transparent,
@@ -269,9 +276,12 @@ class _MinePageState extends State<NewMinePage> {
// 直接使用 SingleChildScrollView
child: Column(
children: [
_buildListTile('assets/img/icon/mydevice.svg',
"我的智能设备", "我绑定或关联的智能床,智能床垫等智能设备",
showTopLine: true, path: "/deviceListPage"),
_buildListTile('assets/img/icon/order.svg',
'我的订单', '快捷查看我在网上的订单记录',
showTopLine: true, path: ""),
path: ""),
_buildListTile('assets/img/icon/store.svg',
'门店体验', '如果想免费体验智能设备,可在此进行提前预约',
path: "/experienceStorePage"),