车辆信息扫码

This commit is contained in:
2025-11-13 17:51:17 +08:00
parent 046bc0fb52
commit 20a34938a3
2 changed files with 72 additions and 25 deletions

View File

@@ -1,4 +1,6 @@
import 'package:getx_scaffold/getx_scaffold.dart'; import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:ln_jq_app/common/model/vehicle_info.dart';
import 'package:ln_jq_app/storage_service.dart';
class CarInfoController extends GetxController with BaseControllerMixin { class CarInfoController extends GetxController with BaseControllerMixin {
@override @override
@@ -6,8 +8,14 @@ class CarInfoController extends GetxController with BaseControllerMixin {
CarInfoController(); CarInfoController();
String plateNumber = "";
String vin = "未知";
String modelName = "未知";
String brandName = "未知";
@override @override
void onInit() { void onInit() {
getUserBindCarInfo();
super.onInit(); super.onInit();
} }
@@ -15,4 +23,19 @@ class CarInfoController extends GetxController with BaseControllerMixin {
void onClose() { void onClose() {
super.onClose(); super.onClose();
} }
void getUserBindCarInfo() {
if (StorageService.to.hasVehicleInfo) {
VehicleInfo? bean = StorageService.to.vehicleInfo;
if (bean == null) {
return;
}
plateNumber = bean.plateNumber;
vin = bean.vin;
modelName = bean.modelName;
brandName = bean.brandName;
updateUi();
}
}
} }

View File

@@ -1,5 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:ln_jq_app/pages/qr_code/view.dart';
import 'package:ln_jq_app/storage_service.dart';
// import 'package:getx_scaffold/getx_scaffold.dart'; // 如果不使用其中的扩展,可以注释掉 // import 'package:getx_scaffold/getx_scaffold.dart'; // 如果不使用其中的扩展,可以注释掉
import 'controller.dart'; import 'controller.dart';
@@ -145,23 +148,18 @@ class CarInfoPage extends GetView<CarInfoController> {
Expanded( Expanded(
child: Column( child: Column(
children: [ children: [
_buildInfoRow('车牌号:', '扫码绑定'), _buildInfoRow('车牌号: ${controller.plateNumber}', '扫码绑定'),
const SizedBox(height: 12), const SizedBox(height: 12),
_buildInfoRow('车架号:', '未知'), _buildInfoRow('车架号:', '${controller.vin}'),
const SizedBox(height: 12), const SizedBox(height: 12),
_buildInfoRow('车辆型号:', '未知'), _buildInfoRow('车辆型号:', '${controller.modelName}'),
const SizedBox(height: 12), const SizedBox(height: 12),
_buildInfoRow('车辆品牌:', '未知'), _buildInfoRow('车辆品牌:', '${controller.brandName}'),
], ],
), ),
), ),
const SizedBox(width: 16), const SizedBox(width: 8),
// 您图片中的图标类似储氢罐,这里用一个相近的图标代替 Icon(Icons.propane_rounded, size: 50, color: Colors.blue.withOpacity(0.5)),
Icon(
Icons.propane_tank_outlined,
size: 80,
color: Colors.blue.withOpacity(0.5),
),
], ],
), ),
), ),
@@ -173,24 +171,50 @@ class CarInfoPage extends GetView<CarInfoController> {
bool isButton = value == '扫码绑定'; bool isButton = value == '扫码绑定';
return Row( return Row(
children: [ children: [
Text(label, style: const TextStyle(color: Colors.grey, fontSize: 14)), Text(label, style: const TextStyle(fontSize: 13)),
const SizedBox(width: 8), const SizedBox(width: 8),
isButton isButton
? ElevatedButton.icon( ? GestureDetector(
onPressed: () { onTap: () async {
// TODO: 实现扫码绑定逻辑 //判断是否绑定成功
}, var scanResult = await Get.to(() => const QrCodePage());
icon: const Icon(Icons.qr_code_scanner, size: 16), if (scanResult == true) {
label: Text(value), controller.getUserBindCarInfo();
style: ElevatedButton.styleFrom( }
padding: const EdgeInsets.symmetric(horizontal: 12), },
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), child: Container(
margin: EdgeInsetsGeometry.only(left: 10.w),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
decoration: BoxDecoration(
border: Border.all(color: Colors.blue.shade300, width: 1),
borderRadius: BorderRadius.circular(5),
color: Colors.blue.withOpacity(0.05),
),
child: Row(
mainAxisSize: MainAxisSize.min, // Keep the row compact
children: [
Icon(
StorageService.to.hasVehicleInfo ? Icons.repeat : Icons.search,
size: 13,
color: Colors.blue,
), ),
) const SizedBox(width: 3),
Text(
StorageService.to.hasVehicleInfo ? "换车牌" : value,
style: const TextStyle(
color: Colors.blue,
fontSize: 11,
fontWeight: FontWeight.w500,
),
),
],
),
),
)
: Text( : Text(
value, value,
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500), style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500),
), ),
], ],
); );
} }