import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_header_model.dart';

class HomeGoodsStyleModel {
  String listColumn;
  List<HomeGoodsHeaderModel> recommendList;
  List<String> hotRankIconList;
  String topMargin;
  String leftRighMargin;
  List<HomeGoodsStyleModelProviders> providers;
  String titleColor;
  String currentPriceColor;
  String marketPriceColor;
  String shopNameColor;
  String saleCountColor;
  String saleCountText;
  String shopIcon;
  HomeGoodsStyleModelCouponCommission couponCommission;
  HomeGoodsStyleModelHotRank hotRank;

  HomeGoodsStyleModel({
    this.listColumn,
    this.recommendList,
    this.hotRankIconList,
    this.topMargin,
    this.leftRighMargin,
    this.providers,
    this.titleColor,
    this.currentPriceColor,
    this.marketPriceColor,
    this.shopNameColor,
    this.saleCountColor,
    this.saleCountText,
    this.shopIcon,
    this.couponCommission,
    this.hotRank,
  });

  HomeGoodsStyleModel.fromJson(Map<String, dynamic> json) {
    listColumn = json['list_column']?.toString();
    if (json['recommend_list'] != null) {
      recommendList = new List<HomeGoodsHeaderModel>();
      json['recommend_list'].forEach((v) {
        recommendList.add(new HomeGoodsHeaderModel.fromJson(v));
      });
    }
    if(json['hot_rank_icon_list'] != null) {
      hotRankIconList = json['hot_rank_icon_list'].cast<String>();
    }
    topMargin = json['top_margin']?.toString();
    leftRighMargin = json['left_righ_margin']?.toString();
    if (json['providers'] != null) {
      providers = new List<HomeGoodsStyleModelProviders>();
      json['providers'].forEach((v) {
        providers.add(new HomeGoodsStyleModelProviders.fromJson(v));
      });
    }
    titleColor = json['title_color']?.toString();
    currentPriceColor = json['current_price_color']?.toString();
    marketPriceColor = json['market_price_color']?.toString();
    shopNameColor = json['shop_name_color']?.toString();
    saleCountColor = json['sale_count_color']?.toString();
    saleCountText = json['sale_count_text']?.toString();
    shopIcon = json['shop_icon']?.toString();
    couponCommission = json['coupon_commission'] != null ? new HomeGoodsStyleModelCouponCommission.fromJson(json['coupon_commission']) : null;
    hotRank = json['hot_rank'] != null ? new HomeGoodsStyleModelHotRank.fromJson(json['hot_rank']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['list_column'] = this.listColumn;
    if (this.recommendList != null) {
      data['recommend_list'] = this.recommendList.map((v) => v.toJson()).toList();
    }
    data['hot_rank_icon_list'] = this.hotRankIconList;
    data['top_margin'] = this.topMargin;
    data['left_righ_margin'] = this.leftRighMargin;
    if (this.providers != null) {
      data['providers'] = this.providers.map((v) => v.toJson()).toList();
    }
    data['title_color'] = this.titleColor;
    data['current_price_color'] = this.currentPriceColor;
    data['market_price_color'] = this.marketPriceColor;
    data['shop_name_color'] = this.shopNameColor;
    data['sale_count_color'] = this.saleCountColor;
    data['sale_count_text'] = this.saleCountText;
    data['shop_icon'] = this.shopIcon;
    if (this.couponCommission != null) {
      data['coupon_commission'] = this.couponCommission.toJson();
    }
    if (this.hotRank != null) {
      data['hot_rank'] = this.hotRank.toJson();
    }
    return data;
  }
}

class HomeGoodsStyleModelProviders {
  String type;
  String providerNameColor;
  String providerBgColor;

  HomeGoodsStyleModelProviders({this.type, this.providerNameColor, this.providerBgColor});

  HomeGoodsStyleModelProviders.fromJson(Map<String, dynamic> json) {
    type = json['type']?.toString();
    providerNameColor = json['provider_name_color']?.toString();
    providerBgColor = json['provider_bg_color']?.toString();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['type'] = this.type;
    data['provider_name_color'] = this.providerNameColor;
    data['provider_bg_color'] = this.providerBgColor;
    return data;
  }
}

class HomeGoodsStyleModelCouponCommission {
  HomeGoodsStyleModelCoupon coupon;
  HomeGoodsStyleModelCommission commission;

  HomeGoodsStyleModelCouponCommission({this.coupon, this.commission});

  HomeGoodsStyleModelCouponCommission.fromJson(Map<String, dynamic> json) {
    coupon = json['left'] != null ? new HomeGoodsStyleModelCoupon.fromJson(json['left']) : null;
    commission = json['right'] != null ? new HomeGoodsStyleModelCommission.fromJson(json['right']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.coupon != null) {
      data['left'] = this.coupon.toJson();
    }
    if (this.commission != null) {
      data['right'] = this.commission.toJson();
    }
    return data;
  }
}

class HomeGoodsStyleModelCoupon {
  String couonText;
  String couponFontColor;
  String couponBgColor;
  String couponBgImg;
  String isImg;

  HomeGoodsStyleModelCoupon({this.couonText, this.couponFontColor, this.couponBgColor, this.couponBgImg, this.isImg});

  HomeGoodsStyleModelCoupon.fromJson(Map<String, dynamic> json) {
    couonText = json['couon_text']?.toString();
    couponFontColor = json['coupon_font_color']?.toString();
    couponBgColor = json['coupon_bg_color']?.toString();
    couponBgImg = json['coupon_bg_img']?.toString();
    isImg = json['is_img']?.toString();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['couon_text'] = this.couonText;
    data['coupon_font_color'] = this.couponFontColor;
    data['coupon_bg_color'] = this.couponBgColor;
    data['coupon_bg_img'] = this.couponBgImg;
    data['is_img'] = this.isImg;
    return data;
  }
}

class HomeGoodsStyleModelCommission {
  String commissionText;
  String commissionFontColor;
  String commissionBgColor;
  String commissionBgImg;
  String isImg;

  HomeGoodsStyleModelCommission({this.commissionText, this.commissionFontColor, this.commissionBgColor, this.commissionBgImg, this.isImg});

  HomeGoodsStyleModelCommission.fromJson(Map<String, dynamic> json) {
    commissionText = json['commission_text']?.toString();
    commissionFontColor = json['commission_font_color']?.toString();
    commissionBgColor = json['commission_bg_color']?.toString();
    commissionBgImg = json['commission_bg_img']?.toString();
    isImg = json['is_img']?.toString();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['commission_text'] = this.commissionText;
    data['commission_font_color'] = this.commissionFontColor;
    data['commission_bg_color'] = this.commissionBgColor;
    data['commission_bg_img'] = this.commissionBgImg;
    data['is_img'] = this.isImg;
    return data;
  }
}

class HomeGoodsStyleModelHotRank {
  String isOpen;
  String bgColor;
  String fontColor;
  String hotSaleImg;
  String buyNowImg;

  HomeGoodsStyleModelHotRank({this.isOpen, this.bgColor, this.fontColor, this.hotSaleImg, this.buyNowImg});

  HomeGoodsStyleModelHotRank.fromJson(Map<String, dynamic> json) {
    isOpen = json['is_open']?.toString();
    bgColor = json['bg_color']?.toString();
    fontColor = json['font_color']?.toString();
    hotSaleImg = json['hot_sale_img']?.toString();
    buyNowImg = json['buy_now_img']?.toString();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['is_open'] = this.isOpen;
    data['bg_color'] = this.bgColor;
    data['font_color'] = this.fontColor;
    data['hot_sale_img'] = this.hotSaleImg;
    data['buy_now_img'] = this.buyNowImg;
    return data;
  }
}

// class HomeGoodsStyleModel {
//   String listColumn;
//   List<HomeGoodsHeaderModel> recommendList;
//   String providerNameColor;
//   String providerNameBackgroundColor;
//   String shopNameColor;
//   String shopIcon;
//   String couponFontColor;
//   String couponBgColor;
//   String commissionFontColor;
//   String commissionBgColor;
//   String marketPriceColor;
//   String currentPriceColor;
//
//   /// 2020-10-12日 新加
//   String title_color;
//   String sale_count_color;
//   String sale_count_text;
//   String top_margin;
//   String left_righ_margin;
//
//   HomeGoodsStyleModel({
//     this.listColumn,
//     this.recommendList,
//     this.providerNameColor,
//     this.providerNameBackgroundColor,
//     this.shopNameColor,
//     this.shopIcon,
//     this.couponFontColor,
//     this.couponBgColor,
//     this.commissionFontColor,
//     this.commissionBgColor,
//     this.marketPriceColor,
//     this.currentPriceColor,
//   });
//
//   HomeGoodsStyleModel.fromJson(Map<String, dynamic> json) {
//     listColumn = json['list_column']?.toString();
//     if (json['recommend_list'] != null) {
//       recommendList = new List<HomeGoodsHeaderModel>();
//       json['recommend_list'].forEach((v) {
//         recommendList.add(new HomeGoodsHeaderModel.fromJson(v));
//       });
//     }
//     providerNameColor = json['provider_name_color']?.toString();
//     providerNameBackgroundColor = json['provider_name_background_color']?.toString();
//     shopNameColor = json['shop_name_color']?.toString();
//     shopIcon = json['shop_icon']?.toString();
//     couponFontColor = json['coupon_font_color']?.toString();
//     couponBgColor = json['coupon_bg_color']?.toString();
//     commissionFontColor = json['commission_font_color']?.toString();
//     commissionBgColor = json['commission_bg_color']?.toString();
//     marketPriceColor = json['market_price_color']?.toString();
//     currentPriceColor = json['current_price_color']?.toString();
//   }
//
//   Map<String, dynamic> toJson() {
//     final Map<String, dynamic> data = new Map<String, dynamic>();
//     data['list_column'] = this.listColumn;
//     if (this.recommendList != null) {
//       data['recommend_list'] = this.recommendList.map((v) => v.toJson()).toList();
//     }
//     data['provider_name_color'] = this.providerNameColor;
//     data['provider_name_background_color'] = this.providerNameBackgroundColor;
//     data['shop_name_color'] = this.shopNameColor;
//     data['shop_icon'] = this.shopIcon;
//     data['coupon_font_color'] = this.couponFontColor;
//     data['coupon_bg_color'] = this.couponBgColor;
//     data['commission_font_color'] = this.commissionFontColor;
//     data['commission_bg_color'] = this.commissionBgColor;
//     data['market_price_color'] = this.marketPriceColor;
//     data['current_price_color'] = this.currentPriceColor;
//     return data;
//   }
// }
//
// class HomeGoodsStyleProvidersModel {
//   String type;
//   String provider_name_color;
//   String provider_bg_color;
//
//   HomeGoodsStyleProvidersModel({
//     this.type,
//     this.provider_name_color,
//     this.provider_bg_color,
//   });
//
//   factory HomeGoodsStyleProvidersModel.fromJson(Map<String, dynamic> json) {
//     return HomeGoodsStyleProvidersModel(
//       type: json['type']?.toString(),
//       provider_name_color: json['provider_name_color']?.toString(),
//       provider_bg_color: json['provider_bg_color']?.toString(),
//     );
//   }
//
//   Map<String, dynamic> toJson() {
//     final Map<String, dynamic> data = new Map<String, dynamic>();
//     data['type'] = this.type;
//     data['provider_name_color'] = this.provider_name_color;
//     data['provider_bg_color'] = this.provider_bg_color;
//     return data;
//   }
// }
//
// class HomeGoodsStyleCouponCommissionModel {
//   HomeGoodsStyleCouonModel couonModel;
//   HomeGoodsStyleCommissionModel commissionModel;
//
//   HomeGoodsStyleCouponCommissionModel({
//     this.couonModel,
//     this.commissionModel,
//   });
//
//   factory HomeGoodsStyleCouponCommissionModel.fromJson(Map<String, dynamic> json) {
//     return HomeGoodsStyleCouponCommissionModel(
//       couonModel: json.containsKey('left') ? HomeGoodsStyleCouonModel.fromJson(json['left']) : null,
//       commissionModel: json.containsKey('right') ? HomeGoodsStyleCommissionModel.fromJson(json['left']) : null,
//     );
//   }
// }
//
// class HomeGoodsStyleCouonModel {
//   String couon_text;
//   String coupon_font_color;
//   String coupon_bg_color;
//   String coupon_bg_img;
//   String is_img;
//
//   HomeGoodsStyleCouonModel({
//     this.couon_text,
//     this.coupon_font_color,
//     this.coupon_bg_color,
//     this.coupon_bg_img,
//     this.is_img,
//   });
//
//   factory HomeGoodsStyleCouonModel.fromJson(Map<String, dynamic> json) {
//     return HomeGoodsStyleCouonModel(
//       couon_text: json['couon_text']?.toString(),
//       coupon_font_color: json['coupon_font_color']?.toString(),
//       coupon_bg_color: json['coupon_bg_color']?.toString(),
//       coupon_bg_img: json['coupon_bg_img']?.toString(),
//       is_img: json['is_img']?.toString(),
//     );
//   }
//
//   Map<String, dynamic> toJson() {
//     final Map<String, dynamic> data = new Map<String, dynamic>();
//     data['couon_text'] = this.couon_text;
//     data['coupon_font_color'] = this.coupon_font_color;
//     data['coupon_bg_color'] = this.coupon_bg_color;
//     data['coupon_bg_img'] = this.coupon_bg_img;
//     data['is_img'] = this.is_img;
//     return data;
//   }
// }
//
// class HomeGoodsStyleCommissionModel {
//   String commission_text;
//   String commission_font_color;
//   String commission_bg_color;
//   String commission_bg_img;
//   String is_img;
//
//   HomeGoodsStyleCommissionModel({
//     this.commission_text,
//     this.commission_font_color,
//     this.commission_bg_color,
//     this.commission_bg_img,
//     this.is_img,
//   });
//
//   factory HomeGoodsStyleCommissionModel.fromJson(Map<String, dynamic> json) {
//     return HomeGoodsStyleCommissionModel(
//       commission_text: json['commission_text']?.toString(),
//       commission_font_color: json['commission_font_color']?.toString(),
//       commission_bg_color: json['commission_bg_color']?.toString(),
//       commission_bg_img: json['commission_bg_img']?.toString(),
//       is_img: json['is_img']?.toString(),
//     );
//   }
//
//   Map<String, dynamic> toJson() {
//     final Map<String, dynamic> data = new Map<String, dynamic>();
//     data['commission_text'] = this.commission_text;
//     data['commission_font_color'] = this.commission_font_color;
//     data['commission_bg_color'] = this.commission_bg_color;
//     data['commission_bg_img'] = this.commission_bg_img;
//     data['is_img'] = this.is_img;
//     return data;
//   }
// }
//
// class HomeGoodsStyleHotRankModel {
//   String is_open;
//   String bg_color;
//   String font_color;
//   String hot_sale_img;
//   String buy_now_img;
//
//   HomeGoodsStyleHotRankModel({
//     this.is_open,
//     this.bg_color,
//     this.font_color,
//     this.hot_sale_img,
//     this.buy_now_img,
//   });
//
//   factory HomeGoodsStyleHotRankModel.fromJson(Map<String, dynamic> json) {
//     return HomeGoodsStyleHotRankModel(
//       is_open: json['is_open']?.toString(),
//       bg_color: json['bg_color']?.toString(),
//       font_color: json['font_color']?.toString(),
//       hot_sale_img: json['hot_sale_img']?.toString(),
//       buy_now_img: json['buy_now_img']?.toString(),
//     );
//   }
//
//   Map<String, dynamic> toJson() {
//     final Map<String, dynamic> data = new Map<String, dynamic>();
//     data['is_open'] = this.is_open;
//     data['bg_color'] = this.bg_color;
//     data['font_color'] = this.font_color;
//     data['hot_sale_img'] = this.hot_sale_img;
//     data['buy_now_img'] = this.buy_now_img;
//     return data;
//   }
// }
