This commit is contained in:
2026-01-23 09:22:07 +08:00
parent cf3ad579d3
commit 5236670e7c
3 changed files with 243 additions and 72 deletions

View File

@@ -22,11 +22,33 @@ class CarInfoController extends GetxController with BaseControllerMixin {
final RxList<String> operationAttachments = <String>[].obs; final RxList<String> operationAttachments = <String>[].obs;
final RxList<String> hydrogenationAttachments = <String>[].obs; final RxList<String> hydrogenationAttachments = <String>[].obs;
final RxList<String> registerAttachments = <String>[].obs; final RxList<String> registerAttachments = <String>[].obs;
bool isNotice = false;
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
getUserBindCarInfo(); getUserBindCarInfo();
_msgNotice();
}
Future<void> _msgNotice() async {
final Map<String, dynamic> requestData = {
'appFlag': 1,
'isRead': 1,
'pageNum': 1,
'pageSize': 5,
};
final response = await HttpService.to.get(
'appointment/unread_notice/page',
params: requestData,
);
if (response != null) {
final result = BaseModel.fromJson(response.data);
if (result.code == 0 && result.data != null) {
String total = result.data["total"].toString();
isNotice = int.parse(total) > 0;
}
}
} }
@override @override

View File

@@ -1,6 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:getx_scaffold/getx_scaffold.dart'; import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:ln_jq_app/common/login_util.dart';
import 'package:ln_jq_app/common/styles/theme.dart'; import 'package:ln_jq_app/common/styles/theme.dart';
import 'package:ln_jq_app/pages/c_page/message/view.dart';
import 'package:ln_jq_app/pages/qr_code/view.dart'; import 'package:ln_jq_app/pages/qr_code/view.dart';
import 'package:ln_jq_app/storage_service.dart'; import 'package:ln_jq_app/storage_service.dart';
@@ -16,102 +18,201 @@ class CarInfoPage extends GetView<CarInfoController> {
id: 'car_info', id: 'car_info',
builder: (_) { builder: (_) {
return Scaffold( return Scaffold(
backgroundColor: Colors.grey[100], backgroundColor: Color.fromRGBO(240, 244, 247, 0.4),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Padding( child: Column(
children: [
_buildUserInfoCard(),
Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
_buildDriverInfoCard(),
const SizedBox(height: 5), const SizedBox(height: 5),
_buildCarBindingCard(), _buildCarBindingCard(),
const SizedBox(height: 5), const SizedBox(height: 5),
_buildCertificatesCard(), _buildCertificatesCard(),
const SizedBox(height: 5), const SizedBox(height: 5),
_buildTipsCard(), _buildSafetyReminderCard(),
], ],
), ),
), ),
],
),
), ),
); );
}, },
); );
} }
/// 构建顶部的司机信息卡片 Widget _buildUserInfoCard() {
Widget _buildDriverInfoCard() {
return Card( return Card(
elevation: 2, elevation: 1,
color: Colors.white,
margin: EdgeInsets.zero, margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
),
),
child: Column( child: Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all(16.0), padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 16, top: 40),
// 增加了顶部 padding 适配状态栏
child: Row( child: Row(
children: [ children: [
const CircleAvatar( Stack(
radius: 20, children: [
backgroundColor: Colors.blue, CircleAvatar(
child: Icon(Icons.person, color: Colors.white, size: 34), radius: 25,
backgroundColor: Colors.white,
child: LoginUtil.getAssImg('ic_user_logo@2x'),
), ),
const SizedBox(width: 12), Positioned(
right: 0,
bottom: 0,
child: SizedBox(
height: 16.h,
width: 16.w,
child: LoginUtil.getAssImg('ic_logo@2x'),
),
),
],
),
SizedBox(width: 8.w),
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [ children: [
Text( Text(
"${StorageService.to.name}", "${StorageService.to.name}",
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold), style: const TextStyle(
), fontSize: 14,
const SizedBox(height: 4),
Text(
"${StorageService.to.phone}",
style: TextStyle(color: Colors.grey, fontSize: 11),
),
],
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.blue[50],
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.blue, width: 0.5),
),
child: const Row(
children: [
Icon(Icons.shield_outlined, color: Colors.blue, size: 14),
SizedBox(width: 4),
Text(
'已认证',
style: TextStyle(
color: Colors.blue,
fontSize: 10,
fontWeight: FontWeight.bold, 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,
),
const Divider(height: 1, indent: 16, endIndent: 16),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
_buildStatItem('156', '服务天数'), Icon(Icons.eco, size: 12, color: Color(0xFF52C41A)),
_buildStatItem('4.9', '评分'), // 叶子图标
_buildStatItem('98%', '准时率'), SizedBox(width: 4),
Text(
"绿色先锋",
style: TextStyle(
color: Color(0xFF52C41A),
fontSize: 10,
),
),
], ],
), ),
), ),
], ],
), ),
const SizedBox(height: 4),
Text(
"羚牛ID${StorageService.to.phone}",
style: const TextStyle(color: Colors.grey, fontSize: 11),
),
],
),
),
IconButton(
onPressed: () {
Get.to(() => const MessagePage());
},
style: IconButton.styleFrom(
backgroundColor: Colors.grey[100],
padding: const EdgeInsets.all(8),
),
icon: Badge(
smallSize: 8,
backgroundColor: controller.isNotice
? Colors.red
: Colors.transparent,
child: const Icon(
Icons.notifications_outlined,
color: Colors.black87,
size: 30,
),
),
),
],
),
),
Padding(
padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildModernStatItem('本月里程数', 'Accumulated', '2,852km', ''),
const SizedBox(width: 8),
_buildModernStatItem('总里程', 'Refuel Count', "2.5W km", ''),
const SizedBox(width: 8),
_buildModernStatItem('服务评分', 'Driver rating', "4.9分", ''),
],
),
),
],
),
);
}
// 统计项
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)),
],
),
],
),
),
); );
} }
@@ -137,9 +238,9 @@ class CarInfoPage extends GetView<CarInfoController> {
Widget _buildCarBindingCard() { Widget _buildCarBindingCard() {
return Card( return Card(
elevation: 2, elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
child: Padding( child: Padding(
padding: const EdgeInsets.all(16.0), padding: EdgeInsets.only(left: 24.w, right: 24.w, bottom: 18,top: 16),
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
@@ -287,21 +388,68 @@ class CarInfoPage extends GetView<CarInfoController> {
); );
} }
Widget _buildTipsCard() { /// 安全提醒卡片
return Card( Widget _buildSafetyReminderCard() {
elevation: 2, return Container(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), padding: const EdgeInsets.all(16),
child: Padding( decoration: BoxDecoration(
padding: const EdgeInsets.all(16.0), color: const Color.fromRGBO(242, 249, 248, 1), // 极浅绿色背景
borderRadius: BorderRadius.circular(16),
),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
_buildTipItem(Icons.info_outline, '请确保车辆证件齐全有效'), Row(
const SizedBox(height: 10), children: [
_buildTipItem(Icons.rule, '定期检查车辆状态和证件有效期'), Icon(Icons.info_outline, color: Colors.green[700], size: 24),
const SizedBox(height: 10), const SizedBox(width: 8),
_buildTipItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-021-1773'), 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("");
}
// 如果加载完成且有数据
if (snapshot.hasData) {
return TextX.labelSmall(
"当前版本: ${snapshot.data}",
color: Colors.green[800],
);
}
// 错误处理
return const Text("");
},
),
),
],
),
],
), ),
); );
} }

View File

@@ -38,6 +38,7 @@ class MinePage extends GetView<MineController> {
_buildSafetyReminderCard(), _buildSafetyReminderCard(),
SizedBox(height: 24.h), SizedBox(height: 24.h),
_buildLogoutButton(), _buildLogoutButton(),
SizedBox(height: 24.h),
], ],
), ),
), ),