diff --git a/ln_jq_app/lib/pages/c_page/car_info/controller.dart b/ln_jq_app/lib/pages/c_page/car_info/controller.dart index 2b43b99..a60f2cb 100644 --- a/ln_jq_app/lib/pages/c_page/car_info/controller.dart +++ b/ln_jq_app/lib/pages/c_page/car_info/controller.dart @@ -1,4 +1,6 @@ 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 { @override @@ -6,8 +8,14 @@ class CarInfoController extends GetxController with BaseControllerMixin { CarInfoController(); + String plateNumber = ""; + String vin = "未知"; + String modelName = "未知"; + String brandName = "未知"; + @override void onInit() { + getUserBindCarInfo(); super.onInit(); } @@ -15,4 +23,19 @@ class CarInfoController extends GetxController with BaseControllerMixin { void 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(); + } + } } 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 aaf2380..c373297 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 @@ -1,5 +1,8 @@ import 'package:flutter/material.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 'controller.dart'; @@ -145,23 +148,18 @@ class CarInfoPage extends GetView { Expanded( child: Column( children: [ - _buildInfoRow('车牌号:', '扫码绑定'), + _buildInfoRow('车牌号: ${controller.plateNumber}', '扫码绑定'), const SizedBox(height: 12), - _buildInfoRow('车架号:', '未知'), + _buildInfoRow('车架号:', '${controller.vin}'), const SizedBox(height: 12), - _buildInfoRow('车辆型号:', '未知'), + _buildInfoRow('车辆型号:', '${controller.modelName}'), const SizedBox(height: 12), - _buildInfoRow('车辆品牌:', '未知'), + _buildInfoRow('车辆品牌:', '${controller.brandName}'), ], ), ), - const SizedBox(width: 16), - // 您图片中的图标类似储氢罐,这里用一个相近的图标代替 - Icon( - Icons.propane_tank_outlined, - size: 80, - color: Colors.blue.withOpacity(0.5), - ), + const SizedBox(width: 8), + Icon(Icons.propane_rounded, size: 50, color: Colors.blue.withOpacity(0.5)), ], ), ), @@ -173,24 +171,50 @@ class CarInfoPage extends GetView { bool isButton = value == '扫码绑定'; return Row( children: [ - Text(label, style: const TextStyle(color: Colors.grey, fontSize: 14)), + Text(label, style: const TextStyle(fontSize: 13)), const SizedBox(width: 8), isButton - ? ElevatedButton.icon( - onPressed: () { - // TODO: 实现扫码绑定逻辑 - }, - icon: const Icon(Icons.qr_code_scanner, size: 16), - label: Text(value), - style: ElevatedButton.styleFrom( - padding: const EdgeInsets.symmetric(horizontal: 12), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + ? GestureDetector( + onTap: () async { + //判断是否绑定成功 + var scanResult = await Get.to(() => const QrCodePage()); + if (scanResult == true) { + controller.getUserBindCarInfo(); + } + }, + 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( - value, - style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500), - ), + value, + style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500), + ), ], ); }