From 5f12905eff05c9f528569c961eb94dbd085699f2 Mon Sep 17 00:00:00 2001 From: userGyl Date: Tue, 18 Nov 2025 10:01:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E6=8E=A5=E5=8F=A3=E8=A1=A5?= =?UTF-8?q?=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/pages/b_page/reservation/view.dart | 2 +- ln_jq_app/lib/pages/b_page/site/view.dart | 2 +- ln_jq_app/lib/pages/c_page/car_info/view.dart | 2 +- .../lib/pages/c_page/mine/controller.dart | 122 +++++++++++++++++- ln_jq_app/lib/pages/c_page/mine/view.dart | 42 +++--- .../lib/pages/c_page/reservation/view.dart | 4 +- 6 files changed, 144 insertions(+), 30 deletions(-) diff --git a/ln_jq_app/lib/pages/b_page/reservation/view.dart b/ln_jq_app/lib/pages/b_page/reservation/view.dart index 6320af6..b1f754a 100644 --- a/ln_jq_app/lib/pages/b_page/reservation/view.dart +++ b/ln_jq_app/lib/pages/b_page/reservation/view.dart @@ -172,7 +172,7 @@ class ReservationPage extends GetView { const SizedBox(height: 10), _buildInfoItem(Icons.help_outline, '价格信息将实时更新到用户端'), const SizedBox(height: 10), - _buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系技术支持: 400-123-4567'), + _buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系技术支持: 400-021-1773'), ], ), ), diff --git a/ln_jq_app/lib/pages/b_page/site/view.dart b/ln_jq_app/lib/pages/b_page/site/view.dart index d8f6eb5..f2b0469 100644 --- a/ln_jq_app/lib/pages/b_page/site/view.dart +++ b/ln_jq_app/lib/pages/b_page/site/view.dart @@ -171,7 +171,7 @@ class SitePage extends GetView { const SizedBox(height: 8), _buildInfoItem(Icons.help_outline, '点击车牌号可查看详细信息'), const SizedBox(height: 8), - _buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-123-4567'), + _buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-021-1773'), ], ), ), diff --git a/ln_jq_app/lib/pages/c_page/car_info/view.dart b/ln_jq_app/lib/pages/c_page/car_info/view.dart index 5e2a89f..dc13768 100644 --- a/ln_jq_app/lib/pages/c_page/car_info/view.dart +++ b/ln_jq_app/lib/pages/c_page/car_info/view.dart @@ -286,7 +286,7 @@ class CarInfoPage extends GetView { const SizedBox(height: 10), _buildTipItem(Icons.rule, '定期检查车辆状态和证件有效期'), const SizedBox(height: 10), - _buildTipItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-123-4567'), + _buildTipItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-021-1773'), ], ), ), diff --git a/ln_jq_app/lib/pages/c_page/mine/controller.dart b/ln_jq_app/lib/pages/c_page/mine/controller.dart index 3bebccc..c873609 100644 --- a/ln_jq_app/lib/pages/c_page/mine/controller.dart +++ b/ln_jq_app/lib/pages/c_page/mine/controller.dart @@ -1,4 +1,7 @@ import 'package:getx_scaffold/getx_scaffold.dart'; +import 'package:ln_jq_app/common/model/base_model.dart'; +import 'package:ln_jq_app/common/model/vehicle_info.dart'; +import 'package:ln_jq_app/common/styles/theme.dart'; import 'package:ln_jq_app/storage_service.dart'; import '../../login/view.dart'; @@ -12,6 +15,8 @@ class MineController extends GetxController with BaseControllerMixin { @override void onInit() { super.onInit(); + renderData(); + renderViolation(); } @override @@ -19,9 +24,124 @@ class MineController extends GetxController with BaseControllerMixin { super.onClose(); } - void logout() async{ + void logout() async { await StorageService.to.clearLoginInfo(); Get.offAll(() => LoginPage()); } + + String rate = ""; + String accident = ""; + String historyBreakRules = ""; + String vin = ""; + String plateNumber = ""; + String violationTotal = "0"; + String violationScore = "0"; + String violationDispose = "0"; + + void renderData() async { + if (StorageService.to.hasVehicleInfo) { + VehicleInfo? bean = StorageService.to.vehicleInfo; + if (bean == null) { + return; + } + vin = bean.vin; + plateNumber = bean.plateNumber; + } + + showLoading("加载中"); + + try { + await Future.wait([ + _fetchCompletionRate(), // 请求1:完成率 + _fetchAccidentCount(), // 请求2:事故数 + _fetchBreakRulesCount(), // 请求3:违章数 + ]); + } catch (e, stackTrace) { + showErrorToast("加载数据失败,请稍后重试 $e"); + } finally { + dismissLoading(); + updateUi(); + } + } + + Future _fetchCompletionRate() async { + final response = await HttpService.to.get( + 'appointment/orderAddHyd/driverAppointmentCompletionRate?phone=${StorageService.to.phone}', + ); + + if (response != null) { + final result = BaseModel.fromJson(response.data); + if (result.code == 0 && result.data != null) { + rate = result.data.toString(); + } + } + } + + /// 获取历史事故数 + Future _fetchAccidentCount() async { + final response = await HttpService.to.get( + 'appointment/truck/historyTrafficAccidentCount?vin=${vin}', + ); + if (response != null) { + final result = BaseModel.fromJson(response.data); + if (result.code == 0 && result.data != null) { + accident = result.data.toString(); + } + } + } + + /// 获取历史违章数 + Future _fetchBreakRulesCount() async { + final response = await HttpService.to.get( + 'appointment/truck/historyBreakRulesCount?vin=${vin}', + ); + if (response != null) { + final result = BaseModel.fromJson(response.data); + if (result.code == 0 && result.data != null) { + historyBreakRules = result.data.toString(); + } + } + } + + void renderViolation() async { + // 违章信息查询 + final originalHeaders = Map.from(HttpService.to.dio.options.headers); + try { + HttpService.to.setBaseUrl(AppTheme.jiaqing_service_url); + HttpService.to.dio.options.headers['appId'] = '97ad10eeb6b346f79e0d6ffd81e4d3c3'; + + var responseData = await HttpService.to.get( + "vehicleService/violation/queryViolationInfo_V2?plateNum=${plateNumber}", + ); + + if (responseData == null || responseData.data == null) { + return; + } + + var result = BaseModel.fromJson(responseData.data); + + if (result.code == 0 && result.data != null && result.data is List) { + List violationList = result.data as List; + int totalScore = 0; + int disposeCount = 0; + for (var item in violationList) { + if (item is Map) { + totalScore += (item['score'] as num?)?.toInt() ?? 0; + if (item['isDispose'] == 1) { + disposeCount++; + } + } + } + violationTotal = violationList.length.toString(); + violationScore = totalScore.toString(); + violationDispose = disposeCount.toString(); + } + } catch (e) { + } finally { + HttpService.to.setBaseUrl(AppTheme.test_service_url); + HttpService.to.dio.options.headers = originalHeaders; + updateUi(); + } + } } diff --git a/ln_jq_app/lib/pages/c_page/mine/view.dart b/ln_jq_app/lib/pages/c_page/mine/view.dart index 274a64e..b9c67ee 100644 --- a/ln_jq_app/lib/pages/c_page/mine/view.dart +++ b/ln_jq_app/lib/pages/c_page/mine/view.dart @@ -1,14 +1,9 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:ln_jq_app/common/styles/theme.dart'; import 'package:ln_jq_app/storage_service.dart'; import 'controller.dart'; -// 假设您的 Controller 在这里,如果还没有,可以先创建一个空类 -// import 'controller.dart'; - -// 为了演示,我们先创建一个空的 Controller -// class MineController extends GetxController {} - class MinePage extends GetView { const MinePage({super.key}); @@ -18,7 +13,6 @@ class MinePage extends GetView { init: MineController(), id: 'mine', builder: (_) { - // 将所有 UI 构建逻辑放在这里 return Scaffold( backgroundColor: Colors.grey[100], body: SingleChildScrollView( @@ -28,14 +22,15 @@ class MinePage extends GetView { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ _buildUserInfoCard(), - const SizedBox(height: 12), + const SizedBox(height: 5), _buildDriverScoreCard(), - const SizedBox(height: 12), + const SizedBox(height: 5), _buildMonthlyRecordCard(), - const SizedBox(height: 12), + const SizedBox(height: 5), _buildTipsCard(), const SizedBox(height: 20), _buildLogoutButton(), + const SizedBox(height: 20), ], ), ), @@ -114,9 +109,9 @@ class MinePage extends GetView { child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - _buildStatItem('0', '违章总数'), - _buildStatItem('0', '扣分总数'), - _buildStatItem('0', '已处理'), + _buildStatItem(controller.violationTotal, '违章总数'), + _buildStatItem(controller.violationScore, '扣分总数'), + _buildStatItem(controller.violationDispose, '已处理'), ], ), ), @@ -160,7 +155,7 @@ class MinePage extends GetView { fit: StackFit.expand, children: [ CircularProgressIndicator( - value: 0.8, // 假设得分80% + value: 10, // 假设得分80% strokeWidth: 8, backgroundColor: Colors.grey[200], valueColor: AlwaysStoppedAnimation(Colors.blue), @@ -265,13 +260,15 @@ class MinePage extends GetView { style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), const SizedBox(height: 8), - _buildRecordRow(Icons.autorenew, '加氢预约践行率', '100%'), + _buildRecordRow(Icons.rate_review, '加氢预约践行率', controller.rate), const Divider(), - _buildRecordRow(Icons.report_problem_outlined, '违章', '0起'), + _buildRecordRow( + Icons.report_problem_outlined, + '违章', + "${controller.historyBreakRules}起", + ), const Divider(), - _buildRecordRow(Icons.warning_amber_rounded, '危险驾驶', '0起'), - const Divider(), - _buildRecordRow(Icons.car_crash_outlined, '交通事故', '0起'), + _buildRecordRow(Icons.car_crash_outlined, '交通事故', "${controller.accident}起"), ], ), ), @@ -291,9 +288,7 @@ class MinePage extends GetView { trailing: Row( mainAxisSize: MainAxisSize.min, children: [ - Text(value, style: const TextStyle(color: Colors.grey, fontSize: 14)), - const SizedBox(width: 8), - const Icon(Icons.arrow_forward_ios, size: 14, color: Colors.grey), + Text(value, style: const TextStyle(color: AppTheme.themeColor, fontSize: 14)), ], ), onTap: () { @@ -315,7 +310,7 @@ class MinePage extends GetView { const SizedBox(height: 10), _buildInfoItem(Icons.rule, '遵守交通规则,避免违章扣分'), const SizedBox(height: 10), - _buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-123-4567'), + _buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-021-1773'), ], ), ), @@ -335,7 +330,6 @@ class MinePage extends GetView { ); } - /// 5. 构建退出登录按钮 Widget _buildLogoutButton() { return ElevatedButton( onPressed: () { diff --git a/ln_jq_app/lib/pages/c_page/reservation/view.dart b/ln_jq_app/lib/pages/c_page/reservation/view.dart index 09f677f..c8bf5be 100644 --- a/ln_jq_app/lib/pages/c_page/reservation/view.dart +++ b/ln_jq_app/lib/pages/c_page/reservation/view.dart @@ -56,7 +56,7 @@ class ReservationPage extends GetView { const SizedBox(height: 10), _buildTipItem(Icons.rule, '请确保车辆证件齐全'), const SizedBox(height: 10), - _buildTipItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-123-4567'), + _buildTipItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-021-1773'), ], ), ), @@ -457,7 +457,7 @@ class ReservationPage extends GetView { ), ), buttonStyleData: ButtonStyleData( - height: 60, // 增加高度以容纳两行文字 + height: 40, // 增加高度以容纳两行文字 padding: const EdgeInsets.symmetric(horizontal: 12.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(8),