Files
tuiche/lib/pages/mh_page/new_mine_page.dart
2026-04-07 14:49:31 +08:00

530 lines
23 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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/util/CommonVariables.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/TopSlideNotification.dart';
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
import 'package:vbvs_app/controller/mh_controller/message_controller.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
import 'package:vbvs_app/pages/mh_page/component/jd.dart';
import 'dart:ui' as ui;
import 'package:vbvs_app/pages/mh_page/user/controller/mht_login_controller.dart';
class NewMinePage extends StatefulWidget {
const NewMinePage({super.key});
@override
State<NewMinePage> createState() => _MinePageState();
}
class _MinePageState extends State<NewMinePage> {
GlobalController globalController = Get.find();
UserInfoController userInfoController = Get.find();
ThemeController themeController = Get.find();
MhMessageController messageController = Get.find();
@override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent, // 这里设置你希望的颜色
statusBarIconBrightness: Brightness.light, // 状态栏图标的亮度
));
int login = userInfoController.model.login!;
return LayoutBuilder(
builder: (context, bodySize) => GestureDetector(
// onTap: () => FocusScope.of(context).unfocus(),,
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/new_background.png'), // 本地图片
fit: BoxFit.fill, // 填满整个 Container
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.transparent, // 状态栏背景色
statusBarIconBrightness: Brightness.light, // 图标颜色Android
statusBarBrightness: Brightness.light, // 图标颜色iOS
),
elevation: 0,
surfaceTintColor: Colors.transparent,
backgroundColor: Colors.transparent,
iconTheme: const IconThemeData(color: Colors.white),
automaticallyImplyLeading: false,
titleSpacing: 0,
actions: [
Obx(() {
return ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: EdgeInsets.only(right: 20.rpx),
onTap: () {
Get.toNamed('/messagePage');
},
child: Stack(
clipBehavior: Clip.none,
children: [
// 扩大点击区域但不影响SVG图标尺寸
Container(
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: 8.rpx,
right: -1.rpx,
child: Container(
width: 14.rpx,
height: 14.rpx,
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
),
),
],
),
);
})
],
),
body: SafeArea(
top: true,
child: Container(
height: bodySize.maxHeight,
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsets.only(
top: 30.rpx, left: 60.rpx, bottom: 190.rpx),
child: Row(
children: [
Obx(() {
userInfoController.model.login!;
return 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,
),
);
}),
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,
// ),
// ),
Text(
limitText(
login == 1
? ((userInfoController.model.user
?.nick_name ==
null ||
userInfoController.model.user
?.nick_name ==
"")
? '未命名'.tr
: userInfoController
.model.user?.nick_name)
: '未命名'.tr,
AppConstants()
.text_length, // 这里设置最大长度,按你需求改,比如 6~10 字符
),
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,
),
),
],
))
].divide(SizedBox(
width: 30.rpx,
)),
),
),
Expanded(
child: Container(
margin: EdgeInsets.symmetric(horizontal: 30.rpx),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.transparent,
),
child: SingleChildScrollView(
// 直接使用 SingleChildScrollView
child: Column(
children: [
_buildListTile('assets/img/icon/mydevice.svg',
"我的智能设备".tr, "我绑定或关联的智能床,智能床垫等智能设备".tr,
showTopLine: true, path: "/deviceListPage"),
// _buildListTile('assets/img/icon/order.svg',
// '我的订单', '快捷查看我在网上的订单记录',
// path: ""),
_buildListTile('assets/img/icon/store.svg',
'门店体验'.tr, '如果想免费体验智能设备,可在此进行提前预约'.tr,
path: "/experienceStorePage"),
_buildListTile(
'assets/img/icon/repair.svg',
'设备报修'.tr,
'当您的智能设备需要报修时,可以通过该功能联系解决,'.tr,
path: '/deviceRepairPage',
),
_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/help.svg',
'问题与帮助'.tr, '常见的问题汇总,如:智能床连接流程、如何查看睡眠报告'.tr,
path: "/issueListpage"),
_buildListTile(
'assets/img/icon/customer_service.svg',
'在线客服'.tr,
'购买和使用智能床过程中,如果遇到疑问可与客服进行联系'.tr,
path: "",
onTap: () async {
UserInfoController userInfoController =
Get.find();
int loginStatus =
userInfoController.model.login!;
if (loginStatus != 1) {
TopSlideNotification.show(
context,
text: "必须登录提示".tr,
textColor:
themeController.currentColor.sc9,
);
Get.toNamed("/loginPage");
return;
}
MHTLoginController mhtLoginController =
Get.find<MHTLoginController>();
await mhtLoginController
.openWeChatCustomerService(context);
},
),
],
),
),
),
), // 使用 Expanded 让滚动区域占据可用空间
Padding(
padding:
EdgeInsets.fromLTRB(30.rpx, 24.rpx, 30.rpx, 50.rpx),
child: _buildSettingButton(),
),
],
),
// Column(
// mainAxisSize: MainAxisSize.max,
// children: [
// ],
// ),
),
),
),
),
),
);
}
/// 构建列表项(带分隔线)
Widget _buildListTile(
String svgPath,
String title,
String subtitle, {
String? path,
bool showTopLine = false,
VoidCallback? onTap, // ✅ 新增可选 onTap 参数
}) {
return ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.white,
padding: EdgeInsets.all(0.rpx),
onTap: () {
if (onTap != null) {
onTap(); // ✅ 使用外部传入的 onTap
} else {
if (path == null || path.isEmpty) {
TopSlideNotification.show(context, text: "待开发功能".tr);
} else {
Get.toNamed(path);
}
}
},
child: Container(
decoration: BoxDecoration(
border: Border(
top: showTopLine
? BorderSide(color: Color(0xFF929699), width: 0.5.rpx)
: BorderSide.none,
bottom: BorderSide(color: Color(0xFF929699), width: 0.5.rpx),
),
),
height: 116.rpx,
child: Padding(
padding: EdgeInsets.fromLTRB(40.rpx, 0.rpx, 40.rpx, 0.rpx),
child: Row(
children: [
SvgPicture.asset(
svgPath,
width: 42.rpx,
height: 42.rpx,
),
SizedBox(width: 30.rpx),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
title,
style: TextStyle(
color: Colors.white,
fontSize: 30.rpx,
),
),
Text(
subtitle,
style: TextStyle(
color: Color(0xFF929699),
fontSize: 20.rpx,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: true,
),
],
),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: EdgeInsets.only(right: 0),
onTap: () {},
child: Container(
height: 30.rpx,
width: 30.rpx,
child: SvgPicture.asset(
'assets/img/icon/expand.svg',
color: Colors.white,
),
),
),
],
),
),
),
);
}
Widget _buildSettingButton() {
return Container(
width: double.infinity,
height: MediaQuery.sizeOf(context).height * 0.055,
constraints: BoxConstraints(
minHeight: 90.rpx,
),
child: ElevatedButton(
onPressed: () {
Get.toNamed("/settingPage");
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF04345E),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.rpx)),
),
child: Text('设置'.tr,
style: TextStyle(fontSize: 26.rpx, color: Colors.white)),
),
);
}
Widget getUserInfo(UserInfoController userInfoController) {
int login = userInfoController.model.login!;
return Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
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,
),
),
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(height: 20.rpx)),
);
}
}
String limitText(String? text, int maxLength) {
if (text == null || text.isEmpty) return '';
if (text.characters.length <= maxLength) return text;
return text.characters.take(maxLength).toString() + '...';
}