diff --git a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart index 5609773..a716664 100644 --- a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart +++ b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart @@ -250,11 +250,8 @@ class _IntellectSearchGoodsDialogState ), Expanded( child: Text( - (num.tryParse(widget?.model?.price ?? "0") - - num.tryParse( - widget?.model?.couponPrice ?? "0")) - .toStringAsFixed(2) ?? - "", + formatNum((num.tryParse(widget?.model?.price ?? "0") - num.tryParse(widget?.model?.couponPrice ?? "0")), 2), + // ().toStringAsFixed(2) ?? "", maxLines: 1, style: TextStyle( fontSize: 16, @@ -272,6 +269,18 @@ class _IntellectSearchGoodsDialogState ); } + // 取两位小数,不进行四舍五入 + String formatNum(var num, int position) { + String rlt = '0'; + if ((num.toString().length - num.toString().lastIndexOf(".") - 1) < position) { + //小数点后有几位小数 + rlt = num.toStringAsFixed(position).substring(0, num.toString().lastIndexOf(".") + position + 1).toString(); + } else { + rlt = num.toString().substring(0, num.toString().lastIndexOf(".") + position + 1).toString(); + } + return rlt; + } + _buildBottomItem() { return Column( children: [ @@ -294,10 +303,7 @@ class _IntellectSearchGoodsDialogState child: Text( (_styleModel?.moduleList?.saveBtn?.content ?? "") + " ¥" + - ((num.tryParse(widget?.model?.couponPrice ?? "0") ?? - 0) + - num.tryParse(widget?.model?.commission ?? '0')) - .toString(), + formatNum((num.tryParse(widget?.model?.couponPrice ?? "0") ?? 0) + num.tryParse(widget?.model?.commission ?? '0'), 2), style: TextStyle( color: HexColor.fromHex( _styleModel?.moduleList?.saveBtn?.fontColor), diff --git a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart index c5b1501..7ff7e21 100644 --- a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart +++ b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart @@ -61,6 +61,18 @@ class _IntellectSearchNoGoodsDialogState extends State openSearchResultPage(), ), ) ],