mark_data_model.dart 9.35 KB
import 'dart:convert' as convert;

import 'package:one_key/models/recharge_list_model.dart';

import 'coupon_model.dart';

class MarkDataModel extends Object {
  String id;

  String sid;

  MarkHomeModel home;

  MarkReserveModel reserve;

  MarkStoreModel store;

  MarkChefModel chef;

  MarkSignboardModel signboard;

  MarkMarketingModel marketing;
  String isNewTemplate;

  MarkDataModel(this.id, this.sid, this.home, this.reserve, this.store,
      this.chef, this.signboard, this.marketing, this.isNewTemplate);

  MarkDataModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    sid = json['sid'];

    home = json['home'] != null
        ? new MarkHomeModel.fromJson(convert.jsonDecode(json['home']))
        : null; //首图形象
    reserve = json['reserve'] != null
        ? new MarkReserveModel.fromJson(convert.jsonDecode(json['reserve']))
        : null; //

    store = json['store'] != null
        ? new MarkStoreModel.fromJson(convert.jsonDecode(json['store']))
        : null; //

    chef = json['chef'] != null
        ? new MarkChefModel.fromJson(convert.jsonDecode(json['chef']))
        : null; //

    signboard = json['signboard'] != null
        ? new MarkSignboardModel.fromJson(convert.jsonDecode(json['signboard']))
        : null; //

    marketing = json['marketing'] != null
        ? new MarkMarketingModel.fromJson(convert.jsonDecode(json['marketing']))
        : null; //

    isNewTemplate = json['is_new_template'] ?? "0";
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['sid'] = this.sid;

    data['home'] = this.home;
    data['reserve'] = this.reserve;
    data['store'] = this.store;
    data['chef'] = this.chef;
    data['signboard'] = this.signboard;
    data['marketing'] = this.marketing;
    data['is_new_template'] = this.isNewTemplate;
    return data;
  }
}

class MarkHomeModel {
  String themeColor; //
  String title; //
  String slogan; //
  String image; //

  MarkHomeModel({
    this.themeColor,
    this.title,
    this.slogan,
    this.image,
  });

  MarkHomeModel.fromJson(Map<String, dynamic> json) {
    themeColor = json['theme_color'];
    title = json['title'];
    slogan = json['slogan'];
    image = json['image'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['theme_color'] = this.themeColor;
    data['title'] = this.title;
    data['slogan'] = this.slogan;
    data['image'] = this.image;
    return data;
  }
}

class MarkReserveModel {
  String swichPhone; //
  String swichManager; //
  String swichPark; //
  String parkInfo; //
  String sellerName; //

  String date; //
  String dsolt; //
  String room; //
  String pnum; //

  String address; //
  String sellerPhone; //
  String managerImage; //
  String managerName; //

  String managerPhone; //
  String managerWechat; //
  String long; //
  String lat; //

  MarkReserveModel(
      {this.swichPhone,
      this.swichManager,
      this.swichPark,
      this.parkInfo,
      this.sellerName,
      this.date,
      this.dsolt,
      this.room,
      this.pnum,
      this.address,
      this.lat,
      this.long,
      this.managerImage,
      this.managerName,
      this.managerPhone,
      this.managerWechat,
      this.sellerPhone});

  MarkReserveModel.fromJson(Map<String, dynamic> json) {
    swichPhone = json['swich_phone'];
    swichManager = json['swich_manager'];
    swichPark = json['swich_park'];

    parkInfo = json['park_info'];
    sellerName = json['seller_name'];

    date = json['date'];
    dsolt = json['dsolt'];

    room = json['room'];
    pnum = json['pnum'];

    address = json['address'] == 'null' ? '' : json['address'];
    sellerPhone = json['seller_phone'];

    managerImage = json['manager_image'];
    managerName = json['manager_name'];

    managerPhone = json['manager_phone'];
    managerWechat = json['manager_wechat'];

    long = json['long'];
    lat = json['lat'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['swich_phone'] = this.swichPhone;
    data['swich_manager'] = this.swichManager;
    data['swich_park'] = this.swichPark;
    data['park_info'] = this.parkInfo;
    data['seller_name'] = this.sellerName;
    data['date'] = this.date;
    data['dsolt'] = this.dsolt;
    data['room'] = this.room;
    data['pnum'] = this.pnum;
    data['address'] = this.address;
    data['seller_phone'] = this.sellerPhone;
    data['manager_image'] = this.managerImage;
    data['manager_name'] = this.managerName;

    data['manager_phone'] = this.managerPhone;
    data['manager_wechat'] = this.managerWechat;
    data['long'] = this.long;
    data['lat'] = this.lat;

    return data;
  }
}

class MarkStoreModel {
  String style; //
  String sellerName; //
  String introduce;
  List<String> images;

  MarkStoreModel({
    this.style,
    this.sellerName,
    this.introduce,
    this.images,
  });

  MarkStoreModel.fromJson(Map<String, dynamic> json) {
    style = json['style'];
    sellerName = json['seller_name'];
    introduce = json['introduce'];

    if (json['images'] != null) {
      images = <String>[];
      if (json['images'] is List) {
        json['images'].forEach((v) {
          images.add(v);
        });
      } else {
        convert.jsonDecode(json['images']).forEach((v) {
          images.add(v);
        });
      }
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['style'] = this.style;
    data['seller_name'] = this.sellerName;
    data['introduce'] = this.introduce;
    data['images'] = this.images;
    return data;
  }
}

class MarkChefModel {
  String style; //
  String sellerName; //
  String introduce;
  String chefName;
  String image;

  MarkChefModel({
    this.style,
    this.sellerName,
    this.introduce,
    this.chefName,
    this.image,
  });

  MarkChefModel.fromJson(Map<String, dynamic> json) {
    style = json['style'];
    sellerName = json['seller_name'];
    chefName = json['chef_name'];
    introduce = json['introduce'];
    image = json['image'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['style'] = this.style;
    data['seller_name'] = this.sellerName;
    data['chef_name'] = this.chefName;
    data['introduce'] = this.introduce;
    data['image'] = this.image;
    return data;
  }
}

class MarkSignboardModel {
  String swich; //

  List<String> images;

  MarkSignboardModel({
    this.swich,
    this.images,
  });

  MarkSignboardModel.fromJson(Map<String, dynamic> json) {
    swich = json['swich'];
    if (json['images'] != null) {
      images = <String>[];
      if (json['images'] is List) {
        json['images'].forEach((v) {
          images.add(v);
        });
      } else {
        convert.jsonDecode(json['images']).forEach((v) {
          images.add(v);
        });
      }
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['swich'] = this.swich;

    data['images'] = this.images;
    return data;
  }
}

class MarkMarketingModel {
  String isTranspond; //
  String isArrival; //
  String isOnlineBook; //
  String isOrder; //
  String isLink; //
  String wecomle; //
  String logo; //
  String isCoupon;
  String isRecharge;
  RechargeListSunModel rechargeData;

  List<CouponSunModel> couponDataList;

  MarkMarketingModel(
      {this.isArrival,
      this.isLink,
      this.isOnlineBook,
      this.isOrder,
      this.isTranspond,
      this.logo,
      this.wecomle,
      this.isCoupon,
      this.isRecharge});

  MarkMarketingModel.fromJson(Map<String, dynamic> json) {
    isTranspond = json['is_transpond'];
    isArrival = json['is_arrival'];
    isOnlineBook = json['is_online_book'];
    isOrder = json['is_order'];
    isLink = json['is_link'];
    wecomle = json['wecomle'];
    logo = json['logo'];
    isCoupon = json['is_coupon'];
    isRecharge = json['is_recharge'];
    rechargeData = json['recharge_data'] != null
        ? new RechargeListSunModel.fromJson(json['recharge_data'])
        : null;
    if (json['coupon_data'] != null) {
      couponDataList = <CouponSunModel>[];
      if (json['coupon_data'] is Map) {
        //旧数据map
        couponDataList.add(CouponSunModel.fromJson(json['coupon_data']));
      } else {
        var couponData = convert.jsonDecode(json['coupon_data']);
        if (couponData is List) {
          couponData.forEach((v) {
            couponDataList.add(CouponSunModel.fromJson(v));
          });
        } else if (couponData is Map) {
          // json['coupon_data'].forEach((v) {
          couponDataList.add(CouponSunModel.fromJson(couponData));
          // });
        } else {
          couponData.forEach((v) {
            couponDataList.add(v);
          });
        }
      }
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['is_transpond'] = this.isTranspond;
    data['is_arrival'] = this.isArrival;
    data['is_online_book'] = this.isOnlineBook;
    data['is_order'] = this.isOrder;
    data['is_link'] = this.isLink;
    data['wecomle'] = this.wecomle;
    data['logo'] = this.logo;
    data['is_coupon'] = this.isCoupon;
    data['is_recharge'] = this.isRecharge;
    data['recharge_data'] = this.rechargeData;
    data['coupon_data'] = this.couponDataList;

    return data;
  }
}