新ui调整

This commit is contained in:
2026-01-22 17:29:54 +08:00
parent 70a752b6e5
commit cf3ad579d3
14 changed files with 435 additions and 264 deletions

View File

@@ -1,4 +1,5 @@
import 'package:encrypt/encrypt.dart';
import 'package:flutter/material.dart' as ui;
class LoginUtil {
static final _keyString = '915eae87951a448c86c47796e44c1fcf';
@@ -26,5 +27,9 @@ class LoginUtil {
final decrypted = _encrypter.decrypt(encrypted);
return decrypted;
}
static ui.Image getAssImg(String imgName){
return ui.Image(image: ui.AssetImage('assets/images/$imgName.png'));
}
}

View File

@@ -5,7 +5,7 @@ class AppTheme {
static const String Font_YuYang = 'YuYang';
static const Color themeColor = Color(0xFF0c83c3);
static const Color themeColor = Color(0xFF017137);
//是否开放域名切换
static const bool is_show_host = true;

View File

@@ -35,9 +35,9 @@ class MineController extends GetxController with BaseControllerMixin {
String historyBreakRules = "";
String vin = "";
String plateNumber = "";
String violationTotal = "0";
String violationScore = "0";
String violationDispose = "0";
String violationTotal = "0";//违章总数
String violationScore = "0";//扣分总数
String violationDispose = "0";//已处理
bool isNotice = false;
void renderData() async {

View File

@@ -1,8 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:getx_scaffold/common/index.dart';
import 'package:getx_scaffold/common/widgets/index.dart';
import 'package:ln_jq_app/common/styles/theme.dart';
import 'package:ln_jq_app/common/login_util.dart';
import 'package:ln_jq_app/pages/c_page/message/view.dart';
import 'package:ln_jq_app/storage_service.dart';
import 'controller.dart';
@@ -17,25 +18,31 @@ class MinePage extends GetView<MineController> {
id: 'mine',
builder: (_) {
return Scaffold(
backgroundColor: Colors.grey[100],
backgroundColor: const Color.fromRGBO(247, 249, 251, 1),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_buildUserInfoCard(),
const SizedBox(height: 5),
_buildDriverScoreCard(),
const SizedBox(height: 5),
_buildMonthlyRecordCard(),
const SizedBox(height: 5),
_buildTipsCard(),
const SizedBox(height: 20),
_buildLogoutButton(),
const SizedBox(height: 20),
],
),
child: Column(
children: [
_buildUserInfoCard(),
const SizedBox(height: 8),
// 新 UI 模块开始
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Column(
children: [
_buildWalletCard(),
SizedBox(height: 16.h),
_buildGridMenu(),
SizedBox(height: 16.h),
_buildRecommendCard(context),
SizedBox(height: 8.h),
_buildSafetyReminderCard(),
SizedBox(height: 24.h),
_buildLogoutButton(),
],
),
),
// 新 UI 模块结束
],
),
),
);
@@ -43,79 +50,127 @@ class MinePage extends GetView<MineController> {
);
}
/// 1. 构建顶部用户信息卡片
/// 构建顶部用户信息卡片
Widget _buildUserInfoCard() {
return Card(
elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
elevation: 1,
color: Colors.white,
margin: EdgeInsets.zero,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
),
),
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 16, top: 40),
// 增加了顶部 padding 适配状态栏
child: Row(
children: [
const CircleAvatar(
radius: 25,
backgroundColor: Colors.blue,
child: Icon(Icons.person, color: Colors.white, size: 40),
Stack(
children: [
CircleAvatar(
radius: 25,
backgroundColor: Colors.white,
child: LoginUtil.getAssImg('ic_user_logo@2x'),
),
Positioned(
right: 0,
bottom: 0,
child: SizedBox(
height: 16.h,
width: 16.w,
child: LoginUtil.getAssImg('ic_logo@2x'),
),
),
],
),
const SizedBox(width: 16),
SizedBox(width: 8.w),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"${StorageService.to.name}",
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
Row(
children: [
Text(
"${StorageService.to.name}",
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
SizedBox(width: 8.w),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 2,
),
decoration: BoxDecoration(
color: const Color.fromRGBO(236, 255, 234, 1), // 极浅绿色背景
border: Border.all(color: const Color(0xFFB7E19F)), // 边框
borderRadius: BorderRadius.circular(12),
),
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.eco, size: 12, color: Color(0xFF52C41A)),
// 叶子图标
SizedBox(width: 4),
Text(
"绿色先锋",
style: TextStyle(
color: Color(0xFF52C41A),
fontSize: 10,
),
),
],
),
),
],
),
const SizedBox(height: 4),
Text(
"${StorageService.to.phone}",
style: TextStyle(color: Colors.grey, fontSize: 11),
),
const SizedBox(height: 4),
Text(
StorageService.to.hasVehicleInfo ? "已绑定车辆" : '未绑定车辆',
style: TextStyle(color: Colors.orange, fontSize: 12),
"羚牛ID${StorageService.to.phone}",
style: const TextStyle(color: Colors.grey, fontSize: 11),
),
],
),
),
IconButton(
onPressed: () {
// 跳转消息中心
Get.to(() => const MessagePage());
},
// 这里的 style 是为了模拟你图片里的灰色圆形背景
style: IconButton.styleFrom(
backgroundColor: Colors.grey[100],
padding: const EdgeInsets.all(8),
),
icon: Badge(
// label: Text('3'), // 如果你想显示数字,就加 label
smallSize: 8,
// 红点的大小
backgroundColor: controller.isNotice ? Colors.red : Colors.white,
// 红点颜色
child: Icon(
backgroundColor: controller.isNotice
? Colors.red
: Colors.transparent,
child: const Icon(
Icons.notifications_outlined,
color: Colors.black87,
size: 25,
size: 30,
),
),
),
],
),
),
const Divider(height: 1),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildStatItem(controller.violationTotal, '违章总数'),
_buildStatItem(controller.violationScore, '扣分总数'),
_buildStatItem(controller.violationDispose, '已处理'),
_buildModernStatItem('服务天数', 'service days', '156', ''),
const SizedBox(width: 8),
_buildModernStatItem('准时率', 'Punctuality', controller.rate, ''),
const SizedBox(width: 8),
_buildModernStatItem('司机评分', 'Driver rating', controller.rating, ''),
],
),
),
@@ -124,242 +179,351 @@ class MinePage extends GetView<MineController> {
);
}
// 用户信息卡片中的小统计项
Widget _buildStatItem(String value, String label) {
// 统计项
Widget _buildModernStatItem(String title, String subtitle, String value, String unit) {
return Expanded(
child: Container(
padding: const EdgeInsets.all(12.0),
decoration: BoxDecoration(
color: const Color(0xFFF8F9FA),
borderRadius: BorderRadius.circular(12),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
Text(subtitle, style: const TextStyle(fontSize: 9, color: Colors.grey)),
const SizedBox(height: 8),
Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Text(
value,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.black87,
),
),
Text(unit, style: const TextStyle(fontSize: 10, color: Colors.black54)),
],
),
],
),
),
);
}
/// 我的钱包卡片
Widget _buildWalletCard() {
return Card(
elevation: 1,
color: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"我的钱包",
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
),
Text("User wallet", style: TextStyle(fontSize: 12, color: Colors.grey)),
],
),
),
Text(
"¥ 0,00元",
style: TextStyle(
color: Colors.green[700],
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
),
);
}
/// 2x2 功能网格菜单
Widget _buildGridMenu() {
return Column(
children: [
Text(value, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 4),
Text(label, style: const TextStyle(color: Colors.grey, fontSize: 12)),
Row(
children: [
_buildGridItem(Icons.person_search_outlined, "客服评价", "3项可评"),
const SizedBox(width: 19),
_buildGridItem(
Icons.assignment_late_outlined,
"违章处理",
"${controller.historyBreakRules}项待办",
countColor: Colors.red,
),
],
),
const SizedBox(height: 16),
Row(
children: [
_buildGridItem(Icons.book_outlined, "安全培训", "0个待看"),
const SizedBox(width: 19),
_buildGridItem(
Icons.verified_user_outlined,
"诚信加氢值",
"845",
isSpecial: true,
backgroundColor: const Color(0xFF006633),
),
],
),
],
);
}
/// 2. 构建驾驶得分卡片
Widget _buildDriverScoreCard() {
return Card(
elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16.0),
Widget _buildGridItem(
IconData icon,
String title,
String subtitle, {
Color? countColor,
bool isSpecial = false,
Color? backgroundColor,
}) {
return Expanded(
child: Container(
height: 100,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: isSpecial ? backgroundColor : Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'驾驶得分',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
Icon(icon, color: isSpecial ? Colors.white : Colors.black87, size: 28),
const SizedBox(height: 8),
Text(
title,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: isSpecial ? Colors.white : Colors.black87,
),
),
const Text('本月表现', style: TextStyle(fontSize: 12, color: Colors.grey)),
const SizedBox(height: 20),
Center(
child: SizedBox(
width: 100,
height: 100,
child: Stack(
fit: StackFit.expand,
Text(
subtitle,
style: TextStyle(
fontSize: 12,
color: isSpecial
? Colors.white.withOpacity(0.8)
: (countColor ?? Colors.grey),
),
),
],
),
),
);
}
/// 我要推荐卡片
Widget _buildRecommendCard(BuildContext context) {
return Card(
elevation: 0,
color: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
children: [
const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircularProgressIndicator(
value: (double.tryParse(controller.rating) ?? 0) / 10,
strokeWidth: 8,
backgroundColor: Colors.grey[200],
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
Text(
"我要推荐",
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
),
Center(
child: Text(
controller.rating,
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
Text("Recommend", style: TextStyle(fontSize: 12, color: Colors.grey)),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text("累计奖励(积分)", style: TextStyle(fontSize: 11, color: Colors.grey)),
Text(
"0,00",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.green,
),
),
],
),
),
),
const SizedBox(height: 20),
_buildScoreDetailRow(Icons.directions_car, '安全驾驶', '无违章记录', true),
const Divider(),
_buildScoreDetailRow(Icons.timer, '准时率', '100%准时到达', true),
const Divider(),
_buildScoreDetailRow(Icons.thumb_up, '服务质量', '用户满意度高', true),
const Divider(),
Padding(
padding: const EdgeInsets.only(top: 12.0),
child: Row(
children: [
const Text(
'优秀驾驶员',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
),
const Spacer(),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(16),
),
child: const Text(
'A+',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
),
],
),
),
],
),
),
);
}
// 驾驶得分卡片中的评分项
Widget _buildScoreDetailRow(
IconData icon,
String title,
String subtitle,
bool isCompleted,
) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
children: [
CircleAvatar(
radius: 20,
backgroundColor: Colors.blue.withOpacity(0.1),
child: Icon(icon, color: Colors.blue, size: 24),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
),
Text(subtitle, style: const TextStyle(fontSize: 12, color: Colors.grey)),
],
),
),
if (isCompleted) const Icon(Icons.check_circle, color: Colors.blue),
],
),
);
}
/// 3. 构建本月记录卡
Widget _buildMonthlyRecordCard() {
return Card(
elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'本月记录',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () {
if (GetPlatform.isIOS) {
// 跳转到 iOS 应用商店 (这里使用一个通用的应用商店链接模板,请确保替换为正式的 AppID)
openWebPage("https://apps.apple.com/cn/app/羚牛氢能/6756245815");
} else if (GetPlatform.isAndroid) {
// Android 弹出二维码图
_showAndroidDownloadDialog(context);
}
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF006633),
foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 48),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
elevation: 0,
),
child: const Text(
"下载推荐",
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
),
const SizedBox(height: 8),
_buildRecordRow(Icons.rate_review, '加氢预约践行率', controller.rate),
const Divider(),
_buildRecordRow(
Icons.report_problem_outlined,
'违章',
"${controller.historyBreakRules}",
),
const Divider(),
_buildRecordRow(Icons.car_crash_outlined, '交通事故', "${controller.accident}"),
],
),
),
);
}
// 本月记录中的列表项
Widget _buildRecordRow(IconData icon, String title, String value) {
return ListTile(
contentPadding: EdgeInsets.zero,
leading: CircleAvatar(
radius: 20,
backgroundColor: Colors.blue.withOpacity(0.1),
child: Icon(icon, color: Colors.blue, size: 24),
/// Android 端下载二维码弹窗
void _showAndroidDownloadDialog(BuildContext context) {
Get.dialog(
Center(
child: Container(
width: 280.w,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
children: [
const Text(
"扫描二维码下载",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
const SizedBox(height: 20),
// 使用 LoginUtil.getAssImg 加载你的图片 android_apk_img.png
SizedBox(
width: 180.w,
height: 180.w,
child: LoginUtil.getAssImg('android_apk_img'),
),
const SizedBox(height: 16),
const Text(
"请让被推荐人扫描上方二维码进行下载安装",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 13, color: Colors.grey),
),
],
),
),
const Divider(height: 1),
TextButton(
onPressed: () => Get.back(),
style: TextButton.styleFrom(minimumSize: const Size(double.infinity, 50)),
child: const Text(
"确 定",
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
),
],
),
),
),
title: Text(title, style: const TextStyle(fontSize: 14)),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(value, style: const TextStyle(color: AppTheme.themeColor, fontSize: 14)),
],
),
onTap: () {
// TODO: 处理点击事件
},
);
}
/// 4. 构建提示信息卡片
Widget _buildTipsCard() {
return Card(
elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
_buildInfoItem(Icons.info_outline, '保持良好的驾驶习惯,提高安全评分'),
const SizedBox(height: 10),
_buildInfoItem(Icons.rule, '遵守交通规则,避免违章扣分'),
const SizedBox(height: 10),
_buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-021-1773'),
const SizedBox(height: 10),
Row(
children: [
Icon(Icons.verified_outlined, color: Colors.blue, size: 20),
const SizedBox(width: 10),
Expanded(
child: FutureBuilder<String>(
future: getVersion(),
builder: (context, snapshot) {
// 判断是否还在加载
if (snapshot.connectionState == ConnectionState.waiting) {
return const Text("");
}
// 如果加载完成且有数据
if (snapshot.hasData) {
return TextX.labelSmall(
"当前版本: ${snapshot.data}",
color: Colors.black54,
);
}
// 错误处理
/// 安全提醒卡片
Widget _buildSafetyReminderCard() {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: const Color.fromRGBO(242, 249, 248, 1), // 极浅绿色背景
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(Icons.info_outline, color: Colors.green[700], size: 24),
const SizedBox(width: 8),
Text(
"安全提醒",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.green[900],
),
),
],
),
const SizedBox(height: 12),
Text(
"请保持良好驾驶习惯,提高安全评分,遵守交通规则,避免违章扣分。",
style: TextStyle(fontSize: 13, color: Colors.green[800], height: 1.5),
),
const SizedBox(height: 8),
Text(
"如有疑问请联系客服400-021-1773",
style: TextStyle(fontSize: 13, color: Colors.green[800]),
),
Row(
children: [
Expanded(
child: FutureBuilder<String>(
future: getVersion(),
builder: (context, snapshot) {
// 判断是否还在加载
if (snapshot.connectionState == ConnectionState.waiting) {
return const Text("");
},
),
),
],
),
],
),
),
);
}
}
// 提示信息卡片中的列表项
Widget _buildInfoItem(IconData icon, String text) {
return Row(
children: [
Icon(icon, color: Colors.blue, size: 20),
const SizedBox(width: 10),
Expanded(
child: Text(text, style: const TextStyle(fontSize: 12, color: Colors.black54)),
),
],
// 如果加载完成且有数据
if (snapshot.hasData) {
return TextX.labelSmall(
"当前版本: ${snapshot.data}",
color: Colors.green[800],
);
}
// 错误处理
return const Text("");
},
),
),
],
),
],
),
);
}
@@ -369,7 +533,7 @@ class MinePage extends GetView<MineController> {
controller.logout();
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red[400],
backgroundColor: Color.fromRGBO(204, 52, 46, 1),
foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 48),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),

View File

@@ -89,7 +89,7 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
margin: EdgeInsets.all(15),
elevation: 4,
child: Container(
height: cLogin ? 290.h : 365.h,
height: cLogin ? 295.h : 370.h,
padding: EdgeInsets.all(15),
child: Column(
children: [

View File

@@ -10,12 +10,14 @@ class UrlHostController extends GetxController {
// 预设的域名列表
final List<String> presetUrls = [
'https://beta-esg.api.lnh2e.com/', // 测试环境
'http://47.101.201.13:8443/api/', // 测试环境
'http://192.168.110.44:8080/', // 沈辰本地
'http://192.168.110.222:8080/', // 何斐本地
];
final List<String> urlNames = [
'测试环境',
'线上环境',
'沈辰本地环境',
'何斐本地环境',
];