diff --git a/lib/common/widgets/order/steelyard_container.dart b/lib/common/widgets/order/steelyard_container.dart index 09a6eb5..aae398f 100644 --- a/lib/common/widgets/order/steelyard_container.dart +++ b/lib/common/widgets/order/steelyard_container.dart @@ -24,7 +24,7 @@ class SteelyardController extends GetxController { final app = Get.find(); // 称重商品 - SupermarketSpuEntity? _widgetProduct; + SupermarketSpuEntity? _product; // 重量 RxDouble widget = RxDouble(0); @@ -68,14 +68,13 @@ class SteelyardController extends GetxController { // 打开称重 bool open(SupermarketSpuEntity current) { - // final isOpen = _openSerial(); - // if (!isOpen) { - // _closeStatus(); - // return false; - // } - // _closeStatus(); - // logger.i("|$_tag|称重,商品uniqueCode:|${current.serviceUniqueCode}|"); - _widgetProduct = current; + final isOpen = _openSerial(); + if (!isOpen) { + _closeStatus(); + return false; + } + _closeStatus(); + _product = current; return true; } @@ -86,7 +85,7 @@ class SteelyardController extends GetxController { // 清除状态 _closeStatus() { - _widgetProduct = null; + _product = null; widget.value = 0; callbackWidget.value = 0; price.value = 0; @@ -129,13 +128,11 @@ class SteelyardController extends GetxController { interval( callbackWidget, (callback) { - if (_widgetProduct != null) { + if (_product != null) { widget.value = callbackWidget.value; - final p = - callbackWidget.value * _widgetProduct!.retailPrice / 100 * 100; + final p = callbackWidget.value * _product!.retailPrice; price.value = int.parse(p.toStringAsFixed(2)); - logger.i( - "|$_tag|称重,重量:|${widget.value}|;价格:|${_widgetProduct!.retailPrice}|"); + logger.i("|$_tag|重量|${widget.value}|价格|${_product!.retailPrice}|"); } }, time: const Duration(seconds: 1),