我的接口补充

This commit is contained in:
2025-11-18 10:01:13 +08:00
parent 3a7f69d525
commit 5f12905eff
6 changed files with 144 additions and 30 deletions

View File

@@ -172,7 +172,7 @@ class ReservationPage extends GetView<ReservationController> {
const SizedBox(height: 10), const SizedBox(height: 10),
_buildInfoItem(Icons.help_outline, '价格信息将实时更新到用户端'), _buildInfoItem(Icons.help_outline, '价格信息将实时更新到用户端'),
const SizedBox(height: 10), const SizedBox(height: 10),
_buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系技术支持: 400-123-4567'), _buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系技术支持: 400-021-1773'),
], ],
), ),
), ),

View File

@@ -171,7 +171,7 @@ class SitePage extends GetView<SiteController> {
const SizedBox(height: 8), const SizedBox(height: 8),
_buildInfoItem(Icons.help_outline, '点击车牌号可查看详细信息'), _buildInfoItem(Icons.help_outline, '点击车牌号可查看详细信息'),
const SizedBox(height: 8), const SizedBox(height: 8),
_buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-123-4567'), _buildInfoItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-021-1773'),
], ],
), ),
), ),

View File

@@ -286,7 +286,7 @@ class CarInfoPage extends GetView<CarInfoController> {
const SizedBox(height: 10), const SizedBox(height: 10),
_buildTipItem(Icons.rule, '定期检查车辆状态和证件有效期'), _buildTipItem(Icons.rule, '定期检查车辆状态和证件有效期'),
const SizedBox(height: 10), const SizedBox(height: 10),
_buildTipItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-123-4567'), _buildTipItem(Icons.headset_mic_outlined, '如有疑问请联系客服: 400-021-1773'),
], ],
), ),
), ),

View File

@@ -1,4 +1,7 @@
import 'package:getx_scaffold/getx_scaffold.dart'; 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 'package:ln_jq_app/storage_service.dart';
import '../../login/view.dart'; import '../../login/view.dart';
@@ -12,6 +15,8 @@ class MineController extends GetxController with BaseControllerMixin {
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
renderData();
renderViolation();
} }
@override @override
@@ -19,9 +24,124 @@ class MineController extends GetxController with BaseControllerMixin {
super.onClose(); super.onClose();
} }
void logout() async{ void logout() async {
await StorageService.to.clearLoginInfo(); await StorageService.to.clearLoginInfo();
Get.offAll(() => LoginPage()); 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<void> _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<void> _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<void> _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<String, dynamic>.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<dynamic> violationList = result.data as List;
int totalScore = 0;
int disposeCount = 0;
for (var item in violationList) {
if (item is Map<String, dynamic>) {
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();
}
}
} }

View File

@@ -1,14 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:ln_jq_app/common/styles/theme.dart';
import 'package:ln_jq_app/storage_service.dart'; import 'package:ln_jq_app/storage_service.dart';
import 'controller.dart'; import 'controller.dart';
// 假设您的 Controller 在这里,如果还没有,可以先创建一个空类
// import 'controller.dart';
// 为了演示,我们先创建一个空的 Controller
// class MineController extends GetxController {}
class MinePage extends GetView<MineController> { class MinePage extends GetView<MineController> {
const MinePage({super.key}); const MinePage({super.key});
@@ -18,7 +13,6 @@ class MinePage extends GetView<MineController> {
init: MineController(), init: MineController(),
id: 'mine', id: 'mine',
builder: (_) { builder: (_) {
// 将所有 UI 构建逻辑放在这里
return Scaffold( return Scaffold(
backgroundColor: Colors.grey[100], backgroundColor: Colors.grey[100],
body: SingleChildScrollView( body: SingleChildScrollView(
@@ -28,14 +22,15 @@ class MinePage extends GetView<MineController> {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
_buildUserInfoCard(), _buildUserInfoCard(),
const SizedBox(height: 12), const SizedBox(height: 5),
_buildDriverScoreCard(), _buildDriverScoreCard(),
const SizedBox(height: 12), const SizedBox(height: 5),
_buildMonthlyRecordCard(), _buildMonthlyRecordCard(),
const SizedBox(height: 12), const SizedBox(height: 5),
_buildTipsCard(), _buildTipsCard(),
const SizedBox(height: 20), const SizedBox(height: 20),
_buildLogoutButton(), _buildLogoutButton(),
const SizedBox(height: 20),
], ],
), ),
), ),
@@ -114,9 +109,9 @@ class MinePage extends GetView<MineController> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
_buildStatItem('0', '违章总数'), _buildStatItem(controller.violationTotal, '违章总数'),
_buildStatItem('0', '扣分总数'), _buildStatItem(controller.violationScore, '扣分总数'),
_buildStatItem('0', '已处理'), _buildStatItem(controller.violationDispose, '已处理'),
], ],
), ),
), ),
@@ -160,7 +155,7 @@ class MinePage extends GetView<MineController> {
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
CircularProgressIndicator( CircularProgressIndicator(
value: 0.8, // 假设得分80% value: 10, // 假设得分80%
strokeWidth: 8, strokeWidth: 8,
backgroundColor: Colors.grey[200], backgroundColor: Colors.grey[200],
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue), valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
@@ -265,13 +260,15 @@ class MinePage extends GetView<MineController> {
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
_buildRecordRow(Icons.autorenew, '加氢预约践行率', '100%'), _buildRecordRow(Icons.rate_review, '加氢预约践行率', controller.rate),
const Divider(), const Divider(),
_buildRecordRow(Icons.report_problem_outlined, '违章', '0起'), _buildRecordRow(
Icons.report_problem_outlined,
'违章',
"${controller.historyBreakRules}",
),
const Divider(), const Divider(),
_buildRecordRow(Icons.warning_amber_rounded, '危险驾驶', '0起'), _buildRecordRow(Icons.car_crash_outlined, '交通事故', "${controller.accident}"),
const Divider(),
_buildRecordRow(Icons.car_crash_outlined, '交通事故', '0起'),
], ],
), ),
), ),
@@ -291,9 +288,7 @@ class MinePage extends GetView<MineController> {
trailing: Row( trailing: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text(value, style: const TextStyle(color: Colors.grey, fontSize: 14)), Text(value, style: const TextStyle(color: AppTheme.themeColor, fontSize: 14)),
const SizedBox(width: 8),
const Icon(Icons.arrow_forward_ios, size: 14, color: Colors.grey),
], ],
), ),
onTap: () { onTap: () {
@@ -315,7 +310,7 @@ class MinePage extends GetView<MineController> {
const SizedBox(height: 10), const SizedBox(height: 10),
_buildInfoItem(Icons.rule, '遵守交通规则,避免违章扣分'), _buildInfoItem(Icons.rule, '遵守交通规则,避免违章扣分'),
const SizedBox(height: 10), 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<MineController> {
); );
} }
/// 5. 构建退出登录按钮
Widget _buildLogoutButton() { Widget _buildLogoutButton() {
return ElevatedButton( return ElevatedButton(
onPressed: () { onPressed: () {

View File

@@ -56,7 +56,7 @@ class ReservationPage extends GetView<C_ReservationController> {
const SizedBox(height: 10), const SizedBox(height: 10),
_buildTipItem(Icons.rule, '请确保车辆证件齐全'), _buildTipItem(Icons.rule, '请确保车辆证件齐全'),
const SizedBox(height: 10), 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<C_ReservationController> {
), ),
), ),
buttonStyleData: ButtonStyleData( buttonStyleData: ButtonStyleData(
height: 60, // 增加高度以容纳两行文字 height: 40, // 增加高度以容纳两行文字
padding: const EdgeInsets.symmetric(horizontal: 12.0), padding: const EdgeInsets.symmetric(horizontal: 12.0),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),