ソースを参照

1、智能弹窗的立即省和券后价改读后台返回的字段

tags/0.0.17+2
PH2 3年前
コミット
4486515c66
2個のファイルの変更29行の追加18行の削除
  1. +7
    -6
      lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart
  2. +22
    -12
      lib/dialog/global_dialog/intellect_search_goods_dialog/model/intellect_dialog_data_model.dart

+ 7
- 6
lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart ファイルの表示

@@ -193,8 +193,8 @@ class _IntellectSearchGoodsDialogState extends State<IntellectSearchGoodsDialog>
),
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<IntellectSearchGoodsDialog>

// 取两位小数,不进行四舍五入
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<IntellectSearchGoodsDialog>
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),
),
)),


+ 22
- 12
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<String, dynamic> 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<String, dynamic> 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;
}
}

読み込み中…
キャンセル
保存