home_model.dart 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import 'package:shuqi/model/novel.dart';
  2. class HomeModule {
  3. late String id;
  4. late String name;
  5. late int style;
  6. late List content;
  7. List<CarouselInfo>? carousels;
  8. List<MenuInfo>? menus;
  9. List<Novel>? books;
  10. HomeModule.fromJson(Map data) {
  11. id = data['id'];
  12. name = data['m_s_name'];
  13. content = data['content'];
  14. if (name == '顶部banner') {
  15. carousels = [];
  16. content.forEach((data) {
  17. carousels!.add(CarouselInfo.fromJson(data));
  18. });
  19. }
  20. if (name == '顶部导航') {
  21. menus = [];
  22. content.forEach((data) {
  23. menus!.add(MenuInfo.fromJson(data));
  24. });
  25. }
  26. if (data['m_s_style'] != null) {
  27. style = data['m_s_style'];
  28. books = [];
  29. content.forEach((data) {
  30. books!.add(Novel.fromJson(data));
  31. });
  32. }
  33. }
  34. }
  35. class MenuInfo {
  36. late String title;
  37. late String icon;
  38. MenuInfo.fromJson(Map data) {
  39. title = data['toTitle'];
  40. icon = data['icon'];
  41. }
  42. }
  43. class CarouselInfo {
  44. String? imageUrl;
  45. late String link;
  46. CarouselInfo.fromJson(Map data) {
  47. imageUrl = data['image_url'];
  48. link = data['link_url'];
  49. }
  50. }