feat:称优化

This commit is contained in:
dzc committed 2025-03-18 11:40:02 +08:00
1 parent 277b86e0d9
commit 29db4faa73
1 file changed
+12 -15
@@ -24,7 +24,7 @@ class SteelyardController extends GetxController {
final app = Get.find<AppControl>();
// 称重商品
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),