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 003abb6..097e731 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 @@ -193,8 +193,8 @@ class _IntellectSearchGoodsDialogState extends State ), Expanded( child: Text( - formatNum((num.tryParse(widget?.model?.price ?? "0") - num.tryParse(widget?.model?.couponPrice ?? "0")), 2), - // ().toStringAsFixed(2) ?? "", + // formatNum((num.tryParse(widget?.model?.price ?? "0") - num.tryParse(widget?.model?.couponPrice ?? "0")), 2), + widget?.model?.finalPrice ?? '0', maxLines: 1, style: TextStyle( fontSize: 16, @@ -213,7 +213,8 @@ class _IntellectSearchGoodsDialogState extends State // 取两位小数,不进行四舍五入 String formatNum(var num, int position) { - String rlt = '0'; + String rlt = num?.toString() ?? '0'; + if (rlt.indexOf('.') == -1) return rlt; if ((num.toString().length - num.toString().lastIndexOf(".") - 1) < position) { //小数点后有几位小数 rlt = num.toStringAsFixed(position).substring(0, num.toString().lastIndexOf(".") + position + 1).toString(); @@ -239,10 +240,10 @@ class _IntellectSearchGoodsDialogState extends State child: Center( child: Padding( padding: const EdgeInsets.all(12.0), - child: Text( + child: Text( // 立省按钮文字 (_styleModel?.moduleList?.saveBtn?.content ?? "") + - " ¥" + - formatNum((num.tryParse(widget?.model?.couponPrice ?? "0") ?? 0) + num.tryParse(widget?.model?.commission ?? '0'), 2), + " ¥" + widget?.model?.earnPrice ?? '0' , + // formatNum((num.tryParse(widget?.model?.couponPrice ?? "0") ?? 0) + num.tryParse(widget?.model?.commission ?? '0'), 2), style: TextStyle(color: HexColor.fromHex(_styleModel?.moduleList?.saveBtn?.fontColor), fontSize: 12), ), )), diff --git a/lib/dialog/global_dialog/intellect_search_goods_dialog/model/intellect_dialog_data_model.dart b/lib/dialog/global_dialog/intellect_search_goods_dialog/model/intellect_dialog_data_model.dart index 623b6d9..6bafe11 100644 --- a/lib/dialog/global_dialog/intellect_search_goods_dialog/model/intellect_dialog_data_model.dart +++ b/lib/dialog/global_dialog/intellect_search_goods_dialog/model/intellect_dialog_data_model.dart @@ -10,19 +10,25 @@ class IntellectDialogDataModel { String couponUrl; String couponPrice; String appUrl; + // 券后价格 + String finalPrice; + String earnPrice; - IntellectDialogDataModel( - {this.itemId, - this.title, - this.price, - this.priceOriginal, - this.commission, - this.commissionRate, - this.thumbnail, - this.provider, - this.couponUrl, - this.couponPrice, - this.appUrl}); + IntellectDialogDataModel({ + this.itemId, + this.title, + this.price, + this.priceOriginal, + this.commission, + this.commissionRate, + this.thumbnail, + this.provider, + this.couponUrl, + this.couponPrice, + this.appUrl, + this.finalPrice, + this.earnPrice, + }); IntellectDialogDataModel.fromJson(Map json) { itemId = json['item_id'].toString(); @@ -36,6 +42,8 @@ class IntellectDialogDataModel { couponUrl = json['coupon_url'].toString(); couponPrice = json['coupon_price'].toString(); appUrl = json['app_url']; + finalPrice = json['final_price']; + earnPrice = json['earn_price']; } Map toJson() { @@ -51,6 +59,8 @@ class IntellectDialogDataModel { data['coupon_url'] = this.couponUrl; data['coupon_price'] = this.couponPrice; data['app_url']=this.appUrl; + data['final_price'] = this.finalPrice; + data['earn_price'] = this.earnPrice; return data; } }