import 'package:zhiying_comm/zhiying_comm.dart';

class GoodsDetailsFooterModel {
  String name;
  String desc;
  String moduleType;
  String moduleKey;
  String isTopMargin;
  String isLeftRightMargin;
  String isShow;
  String topMargin;
  String leftRightMargin;
  String topLeftRadius;
  String topRightRadius;
  String bottomLeftRadius;
  String bottomRightRadius;
  String bgColor;
  ListStyle listStyle;

  String share_value;
  String self_buy_value;

  String isFav;
  String buyUrl;
  String shareUrl;
  FavArgs favArgs;
  ShareUrlArgs shareUrlArgs;
  ConvertArgs convertArgs;
  String provider;
  String good_id;

  factory GoodsDetailsFooterModel.fromJson(Map<String, dynamic> json) {
    return GoodsDetailsFooterModel(
        isFav: json['is_fav'],
        buyUrl: json['buy_url'],
        shareUrl: json['share_url'],
        favArgs: json['fav_args'] != null ? new FavArgs.fromJson(json['fav_args']) : null,
        shareUrlArgs: json['share_url_args'] != null ? new ShareUrlArgs.fromJson(json['share_url_args']) : null,
        share_value: json['share_value'],
        self_buy_value: json['self_buy_value'],
        good_id: json['good_id'],
        provider: json['provider'],
        convertArgs: json['convert_args'] != null ? ConvertArgs.fromJson(json['convert_args']) : null,
        // 修改
        name: json['name'],
        desc: json['desc'],
        moduleType: json['module_type'],
        moduleKey: json['module_key'],
        isTopMargin: json['is_top_margin'],
        isLeftRightMargin: json['is_left_right_margin'],
        isShow: json['is_show'],
        topMargin: json['top_margin'],
        leftRightMargin: json['left_right_margin'],
        topLeftRadius: json['top_left_radius'],
        topRightRadius: json['top_right_radius'],
        bottomLeftRadius: json['bottom_left_radius'],
        bottomRightRadius: json['bottom_right_radius'],
        bgColor: json['bg_color'],
        listStyle: json['list_style'] != null ? new ListStyle.fromJson(json['list_style']) : null);
  }

  GoodsDetailsFooterModel({
    this.buyUrl,
    this.favArgs,
    this.isFav,
    this.shareUrl,
    this.shareUrlArgs,
    this.share_value,
    this.self_buy_value,
    this.good_id,
    this.provider,
    this.convertArgs,
    // 修改
    this.name,
    this.desc,
    this.moduleType,
    this.moduleKey,
    this.isTopMargin,
    this.isLeftRightMargin,
    this.isShow,
    this.topMargin,
    this.leftRightMargin,
    this.topLeftRadius,
    this.topRightRadius,
    this.bottomLeftRadius,
    this.bottomRightRadius,
    this.bgColor,
    this.listStyle,
  });

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();

    data['share_value'] = this.share_value;
    data['self_buy_value'] = this.self_buy_value;
    data['is_fav'] = this.isFav;
    data['buy_url'] = this.buyUrl;
    data['share_url'] = this.shareUrl;
    if (this.favArgs != null) {
      data['fav_args'] = this.favArgs.toJson();
    }
    if (this.shareUrlArgs != null) {
      data['share_url_args'] = this.shareUrlArgs.toJson();
    }
    data['provider'] = this.provider;
    data['good_id'] = this.good_id;
    if (this.convertArgs != null) {
      data['convert_args'] = this.convertArgs.toJson();
    }

    data['name'] = this.name;
    data['desc'] = this.desc;
    data['module_type'] = this.moduleType;
    data['module_key'] = this.moduleKey;
    data['is_top_margin'] = this.isTopMargin;
    data['is_left_right_margin'] = this.isLeftRightMargin;
    data['is_show'] = this.isShow;
    data['top_margin'] = this.topMargin;
    data['left_right_margin'] = this.leftRightMargin;
    data['top_left_radius'] = this.topLeftRadius;
    data['top_right_radius'] = this.topRightRadius;
    data['bottom_left_radius'] = this.bottomLeftRadius;
    data['bottom_right_radius'] = this.bottomRightRadius;
    data['bg_color'] = this.bgColor;
    if (this.listStyle != null) {
      data['list_style'] = this.listStyle.toJson();
    }

    return data;
  }
}

class FavArgs {
  String provider;
  String providerName;
  String goodId;
  String goodImage;
  String goodTitle;
  String shopName;
  String coupon;
  String couponUrl;
  String commission;
  String marketPrice;
  String currentPrice;
  String inorderCount;
  dynamic detailData;

  FavArgs(
      {this.provider,
      this.providerName,
      this.goodId,
      this.goodImage,
      this.goodTitle,
      this.shopName,
      this.coupon,
      this.couponUrl,
      this.commission,
      this.marketPrice,
      this.currentPrice,
      this.inorderCount,
      this.detailData});

  FavArgs.fromJson(Map<String, dynamic> json) {
    provider = json['provider'];
    providerName = json['provider_name'];
    goodId = json['good_id'];
    goodImage = json['good_image'];
    goodTitle = json['good_title'];
    shopName = json['shop_name'];
    coupon = json['coupon'];
    couponUrl = json['coupon_url'];
    commission = json['commission'];
    marketPrice = json['market_price'];
    currentPrice = json['current_price'];
    inorderCount = json['inorder_count'];
    detailData = json['detail_data'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['provider'] = this.provider;
    data['provider_name'] = this.providerName;
    data['good_id'] = this.goodId;
    data['good_image'] = this.goodImage;
    data['good_title'] = this.goodTitle;
    data['shop_name'] = this.shopName;
    data['coupon'] = this.coupon;
    data['coupon_url'] = this.couponUrl;
    data['commission'] = this.commission;
    data['market_price'] = this.marketPrice;
    data['current_price'] = this.currentPrice;
    data['inorder_count'] = this.inorderCount;
    data['detail_data'] = this.detailData;
    return data;
  }
}

class ShareUrlArgs {
  String buyUrl;
  String coupon;
  String couponPrice;
  String marketPrice;
  String posterImage;
  String selfbuyCommission;
  String title;
  String type;
  List<dynamic> imageUrlList;

  ShareUrlArgs({this.buyUrl, this.coupon, this.couponPrice, this.marketPrice, this.posterImage, this.selfbuyCommission, this.title, this.type,this.imageUrlList});

  ShareUrlArgs.fromJson(Map<String, dynamic> json) {
    if (json['image_url_list'] != null) {
      imageUrlList = List.from(json['image_url_list']).map((e) => e.toString()).toList();
    }
    buyUrl = json['buy_url'];
    coupon = json['coupon'];
    couponPrice = json['coupon_price'];
    marketPrice = json['market_price'];
    posterImage = json['poster_image'];
    selfbuyCommission = json['selfbuy_commission'];
    title = json['title'];

    type = json['type'];

  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['buy_url'] = this.buyUrl;
    data['coupon'] = this.coupon;
    data['coupon_price'] = this.couponPrice;
    data['market_price'] = this.marketPrice;
    data['poster_image'] = this.posterImage;
    data['selfbuy_commission'] = this.selfbuyCommission;
    data['title'] = this.title;
    data['type'] = this.type;
    data['image_url_list']=this.imageUrlList;
    return data;
  }
}

class ConvertArgs {
  String gid;
  String goodUrl;
  String couponUrl;
  String couponPrice;
  String activityUrl;
  String isShare;
  String commission;

  ConvertArgs({this.gid, this.goodUrl, this.couponUrl, this.couponPrice, this.activityUrl, this.isShare, this.commission});

  ConvertArgs.fromJson(Map<String, dynamic> json) {
    gid = json['gid'];
    goodUrl = json['good_url'];
    couponUrl = json['coupon_url'];
    couponPrice = json['coupon_price'];
    activityUrl = json['activity_url'];
    isShare = json['is_share'];
    commission = json['commission'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['gid'] = this.gid;
    data['good_url'] = this.goodUrl;
    data['coupon_url'] = this.couponUrl;
    data['coupon_price'] = this.couponPrice;
    data['activity_url'] = this.activityUrl;
    data['is_share'] = this.isShare;
    data['commission'] = this.commission;
    return data;
  }
}

class ListStyle {
  LeftIcon1 leftIcon1;
  LeftIcon1 leftIcon2;
  RightIcon1 rightIcon1;
  RightIcon1 rightIcon2;
  BuyBubbleTip buyBubbleTip;
  BuyBubbleTip buyShareTip;

  ListStyle({this.leftIcon1, this.leftIcon2, this.rightIcon1, this.rightIcon2, this.buyBubbleTip, this.buyShareTip});

  ListStyle.fromJson(Map<String, dynamic> json) {
    leftIcon1 = json['left_icon1'] != null ? new LeftIcon1.fromJson(json['left_icon1']) : null;
    leftIcon2 = json['left_icon2'] != null ? new LeftIcon1.fromJson(json['left_icon2']) : null;
    rightIcon1 = json['right_icon1'] != null ? new RightIcon1.fromJson(json['right_icon1']) : null;
    rightIcon2 = json['right_icon2'] != null ? new RightIcon1.fromJson(json['right_icon2']) : null;
    buyBubbleTip = json['buy_bubble_tip'] != null ? new BuyBubbleTip.fromJson(json['buy_bubble_tip']) : null;
    buyShareTip = json['buy_share_tip'] != null ? new BuyBubbleTip.fromJson(json['buy_share_tip']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.leftIcon1 != null) {
      data['left_icon1'] = this.leftIcon1.toJson();
    }
    if (this.leftIcon2 != null) {
      data['left_icon2'] = this.leftIcon2.toJson();
    }
    if (this.rightIcon1 != null) {
      data['right_icon1'] = this.rightIcon1.toJson();
    }
    if (this.rightIcon2 != null) {
      data['right_icon2'] = this.rightIcon2.toJson();
    }
    if (this.buyBubbleTip != null) {
      data['buy_bubble_tip'] = this.buyBubbleTip.toJson();
    }
    if (this.buyShareTip != null) {
      data['buy_share_tip'] = this.buyShareTip.toJson();
    }
    return data;
  }
}

class LeftIcon1 extends SkipModel {
  String text;
  String color;
  String beforeIcon;
  String afterIcon;
  String skipIdentifier;
  String requiredLogin;
  String requiredTaobaoAuth;
  String isJump;
  String isShow;

  LeftIcon1({this.text, this.color, this.beforeIcon, this.afterIcon, this.skipIdentifier, this.requiredLogin, this.requiredTaobaoAuth, this.isJump});

  LeftIcon1.fromJson(Map<String, dynamic> json) {
    super.fromJson(json);
    text = json['text'];
    color = json['color'];
    beforeIcon = json['before_icon'];
    afterIcon = json['after_icon'];
    skipIdentifier = json['skip_identifier'];
    requiredLogin = json['required_login'];
    requiredTaobaoAuth = json['required_taobao_auth'];
    isJump = json['is_jump'];
    isShow = json['is_show'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = super.toJson();
    data['text'] = this.text;
    data['color'] = this.color;
    data['before_icon'] = this.beforeIcon;
    data['after_icon'] = this.afterIcon;
    data['skip_identifier'] = this.skipIdentifier;
    data['required_login'] = this.requiredLogin;
    data['required_taobao_auth'] = this.requiredTaobaoAuth;
    data['is_jump'] = this.isJump;
    return data;
  }
}

class RightIcon1 {
  String text;
  String color;
  String btnStr;
  String bgImage;
  String functionType;
  List<String> sourceList;
  String isShow;

  RightIcon1({this.text, this.color, this.btnStr, this.bgImage, this.functionType, this.sourceList});

  RightIcon1.fromJson(Map<String, dynamic> json) {
    text = json['text'];
    color = json['color'];
    btnStr = json['btn_str'];
    bgImage = json['bg_image'];
    functionType = json['function_type'];
    sourceList = json['source_list'].cast<String>();
    isShow = json['is_show'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['text'] = this.text;
    data['color'] = this.color;
    data['btn_str'] = this.btnStr;
    data['bg_image'] = this.bgImage;
    data['function_type'] = this.functionType;
    data['source_list'] = this.sourceList;
    return data;
  }
}

class BuyBubbleTip {
  String textStr;
  String textColor;
  String priceIcon;
  String bgImage;
  String closeIcon;
  String isShow;
  List<String> sourceList;

  BuyBubbleTip({this.textStr, this.textColor, this.priceIcon, this.bgImage, this.closeIcon, this.isShow, this.sourceList});

  BuyBubbleTip.fromJson(Map<String, dynamic> json) {
    textStr = json['text_str'];
    textColor = json['text_color'];
    priceIcon = json['price_icon'];
    bgImage = json['bg_image'];
    closeIcon = json['close_icon'];
    isShow = json['is_show'];
    sourceList = json['source_list'].cast<String>();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['text_str'] = this.textStr;
    data['text_color'] = this.textColor;
    data['price_icon'] = this.priceIcon;
    data['bg_image'] = this.bgImage;
    data['close_icon'] = this.closeIcon;
    data['is_show'] = this.isShow;
    data['source_list'] = this.sourceList;
    return data;
  }
}
