From a092c8a473e655c484619b41c31ddd6108443712 Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Wed, 23 Sep 2020 14:47:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0json=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dart_tool/package_config.json | 238 +--------------- example/ios/Podfile.lock | 6 + .../mine_detail_page/mine_detail_bloc.dart | 4 +- .../models/mine_detail_model.dart | 65 +++-- .../models/setting_page_style_item_model.dart | 57 ++-- lib/pages/setting_page/setting_page.dart | 2 +- lib/register.dart | 7 +- lib/widgets/home/home_auth/home_auth.dart | 16 +- .../home_auth/models/home_auth_model.dart | 81 +++--- .../home/home_banner/home_banner_widget.dart | 2 +- .../home_banner/model/HomeBannerModel.dart | 4 +- lib/widgets/home/home_goods/home_goods.dart | 32 ++- .../home/home_goods/home_goods_item.dart | 52 ++-- .../home_goods/home_goods_item_single.dart | 263 ++++++++++++++++++ .../models/home_goods_header_model.dart | 57 ++-- .../home_goods/models/home_goods_model.dart | 87 +++--- .../models/home_goods_style_model.dart | 103 +++---- .../home/home_notice/home_notice_widget.dart | 2 +- .../home_notice/model/home_notice_model.dart | 4 +- .../home_quick_entry/home_quick_entry.dart | 2 +- .../home_slide_banner/home_slide_banner.dart | 2 +- .../home/home_sreach/home_sreach_creater.dart | 4 +- .../home/home_sreach/home_sreach_widget.dart | 18 +- lib/widgets/mine/mine_data/mine_data.dart | 20 +- .../mine/mine_data/mine_data_widget.dart | 4 +- .../mine/mine_data/model/mine_data_model.dart | 106 +++---- .../mine_header/mine_header_container.dart | 2 +- .../mine_header_static_container.dart | 4 +- .../mine_header/model/mine_header_model.dart | 99 +++---- .../mine_header/model/mine_profile_model.dart | 97 ++++--- lib/widgets/mine/mine_nav/mine_nav.dart | 32 +-- .../mine_quick_entry/mine_quick_entry.dart | 16 +- .../model/mine_quick_model.dart | 120 ++++---- pubspec.yaml | 4 - 34 files changed, 857 insertions(+), 755 deletions(-) diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 9b53158..d0b9c77 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -1,18 +1,6 @@ { "configVersion": 2, "packages": [ - { - "name": "_fe_analyzer_shared", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/_fe_analyzer_shared-6.0.0", - "packageUri": "lib/", - "languageVersion": "2.2" - }, - { - "name": "analyzer", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.39.14", - "packageUri": "lib/", - "languageVersion": "2.6" - }, { "name": "archive", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/archive-2.0.11", @@ -43,54 +31,6 @@ "packageUri": "lib/", "languageVersion": "2.0" }, - { - "name": "build", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build-1.3.0", - "packageUri": "lib/", - "languageVersion": "2.7" - }, - { - "name": "build_config", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_config-0.4.2", - "packageUri": "lib/", - "languageVersion": "2.6" - }, - { - "name": "build_daemon", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_daemon-2.1.4", - "packageUri": "lib/", - "languageVersion": "2.6" - }, - { - "name": "build_resolvers", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_resolvers-1.3.11", - "packageUri": "lib/", - "languageVersion": "2.7" - }, - { - "name": "build_runner", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_runner-1.10.1", - "packageUri": "lib/", - "languageVersion": "2.6" - }, - { - "name": "build_runner_core", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_runner_core-6.0.1", - "packageUri": "lib/", - "languageVersion": "2.7" - }, - { - "name": "built_collection", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/built_collection-4.3.2", - "packageUri": "lib/", - "languageVersion": "2.6" - }, - { - "name": "built_value", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/built_value-7.1.0", - "packageUri": "lib/", - "languageVersion": "2.3" - }, { "name": "cached_network_image", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/cached_network_image-2.2.0+1", @@ -103,30 +43,12 @@ "packageUri": "lib/", "languageVersion": "1.0" }, - { - "name": "checked_yaml", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/checked_yaml-1.0.2", - "packageUri": "lib/", - "languageVersion": "2.3" - }, - { - "name": "cli_util", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/cli_util-0.1.4", - "packageUri": "lib/", - "languageVersion": "2.0" - }, { "name": "clock", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/clock-1.0.1", "packageUri": "lib/", "languageVersion": "2.0" }, - { - "name": "code_builder", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/code_builder-3.4.1", - "packageUri": "lib/", - "languageVersion": "2.7" - }, { "name": "collection", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/collection-1.14.11", @@ -145,18 +67,6 @@ "packageUri": "lib/", "languageVersion": "2.1" }, - { - "name": "csslib", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/csslib-0.16.2", - "packageUri": "lib/", - "languageVersion": "2.2" - }, - { - "name": "dart_style", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/dart_style-1.3.6", - "packageUri": "lib/", - "languageVersion": "2.7" - }, { "name": "device_info", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/device_info-0.4.2+7", @@ -199,12 +109,6 @@ "packageUri": "lib/", "languageVersion": "2.2" }, - { - "name": "fixnum", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/fixnum-0.10.11", - "packageUri": "lib/", - "languageVersion": "2.1" - }, { "name": "flutter", "rootUri": "file:///Users/fnuser/Documents/flutter-sdk/packages/flutter", @@ -283,36 +187,12 @@ "packageUri": "lib/", "languageVersion": "2.0" }, - { - "name": "glob", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/glob-1.2.0", - "packageUri": "lib/", - "languageVersion": "2.1" - }, - { - "name": "graphs", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/graphs-0.2.0", - "packageUri": "lib/", - "languageVersion": "2.0" - }, - { - "name": "html", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/html-0.14.0+3", - "packageUri": "lib/", - "languageVersion": "2.3" - }, { "name": "http", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/http-0.12.2", "packageUri": "lib/", "languageVersion": "2.4" }, - { - "name": "http_multi_server", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/http_multi_server-2.2.0", - "packageUri": "lib/", - "languageVersion": "2.1" - }, { "name": "http_parser", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/http_parser-3.1.4", @@ -349,42 +229,12 @@ "packageUri": "lib/", "languageVersion": "2.5" }, - { - "name": "io", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/io-0.3.4", - "packageUri": "lib/", - "languageVersion": "2.0" - }, { "name": "jdsdk", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/jdsdk-0.0.1", "packageUri": "lib/", "languageVersion": "2.1" }, - { - "name": "js", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/js-0.6.2", - "packageUri": "lib/", - "languageVersion": "2.0" - }, - { - "name": "json_annotation", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/json_annotation-3.0.1", - "packageUri": "lib/", - "languageVersion": "2.6" - }, - { - "name": "json_serializable", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/json_serializable-3.4.1", - "packageUri": "lib/", - "languageVersion": "2.7" - }, - { - "name": "logging", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/logging-0.11.4", - "packageUri": "lib/", - "languageVersion": "2.0" - }, { "name": "matcher", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/matcher-0.12.6", @@ -397,36 +247,12 @@ "packageUri": "lib/", "languageVersion": "1.12" }, - { - "name": "mime", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/mime-0.9.7", - "packageUri": "lib/", - "languageVersion": "2.0" - }, { "name": "nested", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/nested-0.0.4", "packageUri": "lib/", "languageVersion": "2.2" }, - { - "name": "node_interop", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/node_interop-1.1.1", - "packageUri": "lib/", - "languageVersion": "2.0" - }, - { - "name": "node_io", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/node_io-1.1.1", - "packageUri": "lib/", - "languageVersion": "2.2" - }, - { - "name": "package_config", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/package_config-1.9.3", - "packageUri": "lib/", - "languageVersion": "2.7" - }, { "name": "package_info", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/package_info-0.4.3", @@ -441,7 +267,7 @@ }, { "name": "path_provider", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.16", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.17", "packageUri": "lib/", "languageVersion": "2.1" }, @@ -499,12 +325,6 @@ "packageUri": "lib/", "languageVersion": "2.1" }, - { - "name": "pool", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/pool-1.4.0", - "packageUri": "lib/", - "languageVersion": "2.0" - }, { "name": "process", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/process-3.0.13", @@ -523,12 +343,6 @@ "packageUri": "lib/", "languageVersion": "2.0" }, - { - "name": "pubspec_parse", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/pubspec_parse-0.1.5", - "packageUri": "lib/", - "languageVersion": "2.2" - }, { "name": "pull_to_refresh", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/pull_to_refresh-1.6.2", @@ -549,7 +363,7 @@ }, { "name": "shared_preferences", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.10", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.11", "packageUri": "lib/", "languageVersion": "2.1" }, @@ -578,17 +392,11 @@ "languageVersion": "2.1" }, { - "name": "shelf", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shelf-0.7.9", + "name": "shared_preferences_windows", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_windows-0.0.1+1", "packageUri": "lib/", "languageVersion": "2.1" }, - { - "name": "shelf_web_socket", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shelf_web_socket-0.2.3", - "packageUri": "lib/", - "languageVersion": "2.0" - }, { "name": "shimmer", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shimmer-1.1.1", @@ -601,12 +409,6 @@ "packageUri": "lib/", "languageVersion": "1.11" }, - { - "name": "source_gen", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/source_gen-0.9.6", - "packageUri": "lib/", - "languageVersion": "2.7" - }, { "name": "source_span", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/source_span-1.5.5", @@ -637,12 +439,6 @@ "packageUri": "lib/", "languageVersion": "2.0" }, - { - "name": "stream_transform", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/stream_transform-1.2.0", - "packageUri": "lib/", - "languageVersion": "2.6" - }, { "name": "string_scanner", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/string_scanner-1.0.5", @@ -667,12 +463,6 @@ "packageUri": "lib/", "languageVersion": "2.2" }, - { - "name": "timing", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/timing-0.1.1+2", - "packageUri": "lib/", - "languageVersion": "2.2" - }, { "name": "transformer_page_view", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/transformer_page_view-0.1.6", @@ -733,18 +523,6 @@ "packageUri": "lib/", "languageVersion": "2.0" }, - { - "name": "watcher", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/watcher-0.9.7+15", - "packageUri": "lib/", - "languageVersion": "2.2" - }, - { - "name": "web_socket_channel", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/web_socket_channel-1.1.0", - "packageUri": "lib/", - "languageVersion": "2.0" - }, { "name": "webview_flutter", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.23", @@ -769,12 +547,6 @@ "packageUri": "lib/", "languageVersion": "2.3" }, - { - "name": "yaml", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/yaml-2.2.1", - "packageUri": "lib/", - "languageVersion": "2.4" - }, { "name": "zhiying_comm", "rootUri": "../../zhiying_comm", @@ -788,7 +560,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-09-22T12:40:39.852808Z", + "generated": "2020-09-23T04:06:39.433861Z", "generator": "pub", "generatorVersion": "2.7.2" } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index f84f969..b0fe556 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -53,6 +53,8 @@ PODS: - Flutter - shared_preferences_web (0.0.1): - Flutter + - shared_preferences_windows (0.0.1): + - Flutter - sqflite (0.0.1): - Flutter - FMDB (~> 2.7.2) @@ -101,6 +103,7 @@ DEPENDENCIES: - shared_preferences_linux (from `.symlinks/plugins/shared_preferences_linux/ios`) - shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`) - shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`) + - shared_preferences_windows (from `.symlinks/plugins/shared_preferences_windows/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`) - url_launcher_linux (from `.symlinks/plugins/url_launcher_linux/ios`) @@ -162,6 +165,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/shared_preferences_macos/ios" shared_preferences_web: :path: ".symlinks/plugins/shared_preferences_web/ios" + shared_preferences_windows: + :path: ".symlinks/plugins/shared_preferences_windows/ios" sqflite: :path: ".symlinks/plugins/sqflite/ios" url_launcher: @@ -207,6 +212,7 @@ SPEC CHECKSUMS: shared_preferences_linux: afefbfe8d921e207f01ede8b60373d9e3b566b78 shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9 + shared_preferences_windows: 36b76d6f54e76ead957e60b49e2f124b4cd3e6ae sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0 TOCropViewController: 20a14b6a7a098308bf369e7c8d700dc983a974e6 url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef diff --git a/lib/pages/mine_detail_page/mine_detail_bloc.dart b/lib/pages/mine_detail_page/mine_detail_bloc.dart index a20d054..9cf9f0f 100644 --- a/lib/pages/mine_detail_page/mine_detail_bloc.dart +++ b/lib/pages/mine_detail_page/mine_detail_bloc.dart @@ -98,8 +98,8 @@ class MineDetailBloc extends BlocBase { print(filename); String imageUrl = '${_user.fileBucketUrl.toString()}${filename.toString()}'; - if (_user.format != null && _user.format != '') { - imageUrl += _user.format; + if (_user.fileFormat != null && _user.fileFormat != '') { + imageUrl += _user.fileFormat; imageUrl += '/${DateTime.now().millisecondsSinceEpoch.toString()}'; } else { imageUrl += '?${DateTime.now().millisecondsSinceEpoch.toString()}'; diff --git a/lib/pages/mine_detail_page/models/mine_detail_model.dart b/lib/pages/mine_detail_page/models/mine_detail_model.dart index df982ac..9319c07 100644 --- a/lib/pages/mine_detail_page/models/mine_detail_model.dart +++ b/lib/pages/mine_detail_page/models/mine_detail_model.dart @@ -1,42 +1,41 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'mine_detail_model.g.dart'; - -@JsonSerializable() -class MineDetailModel extends Object { - @JsonKey(name: 'avatar') +class MineDetailModel { String avatar; - - @JsonKey(name: 'nickname') String nickname; - - @JsonKey(name: 'gender') String gender; - - @JsonKey(name: 'birthday') String birthday; - - @JsonKey(name: 'register_time') String registerTime; - - @JsonKey(name: 'file_bucket_url') String fileBucketUrl; - - @JsonKey(name: 'file_format') - String format; + String fileFormat; MineDetailModel( - this.avatar, - this.nickname, - this.gender, - this.birthday, - this.registerTime, - this.fileBucketUrl, - this.format, - ); - - factory MineDetailModel.fromJson(Map srcJson) => - _$MineDetailModelFromJson(srcJson); - - Map toJson() => _$MineDetailModelToJson(this); + {this.avatar, + this.nickname, + this.gender, + this.birthday, + this.registerTime, + this.fileBucketUrl, + this.fileFormat}); + + MineDetailModel.fromJson(Map json) { + avatar = json['avatar']; + nickname = json['nickname']; + gender = json['gender']; + birthday = json['birthday']; + registerTime = json['register_time']; + fileBucketUrl = json['file_bucket_url']; + fileFormat = json['file_format']; + } + + Map toJson() { + final Map data = new Map(); + data['avatar'] = this.avatar; + data['nickname'] = this.nickname; + data['gender'] = this.gender; + data['birthday'] = this.birthday; + data['register_time'] = this.registerTime; + data['file_bucket_url'] = this.fileBucketUrl; + data['file_format'] = this.fileFormat; + return data; + } } + diff --git a/lib/pages/setting_page/models/setting_page_style_item_model.dart b/lib/pages/setting_page/models/setting_page_style_item_model.dart index b79808a..f9c7585 100644 --- a/lib/pages/setting_page/models/setting_page_style_item_model.dart +++ b/lib/pages/setting_page/models/setting_page_style_item_model.dart @@ -1,38 +1,39 @@ -import 'package:json_annotation/json_annotation.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; -part 'setting_page_style_item_model.g.dart'; - -@JsonSerializable() -class SettingPageStyleItemModel extends Object { - @JsonKey(name: 'name') +class SettingPageStyleItemModel extends SkipModel { String name; - - @JsonKey(name: 'name_color') String nameColor; - - @JsonKey(name: 'desc') String desc; - - @JsonKey(name: 'desc_color') String descColor; - - @JsonKey(name: 'skip_identifier') String skipIdentifier; - - @JsonKey(name: 'url') String url; SettingPageStyleItemModel( - this.name, - this.nameColor, - this.desc, - this.descColor, - this.skipIdentifier, - this.url, - ); - - factory SettingPageStyleItemModel.fromJson(Map srcJson) => - _$SettingPageStyleItemModelFromJson(srcJson); - - Map toJson() => _$SettingPageStyleItemModelToJson(this); + {this.name, + this.nameColor, + this.desc, + this.descColor, + this.skipIdentifier, + this.url}); + + SettingPageStyleItemModel.fromJson(Map json) { + name = json['name']; + nameColor = json['name_color']; + desc = json['desc']; + descColor = json['desc_color']; + skipIdentifier = json['skip_identifier']; + url = json['url']; + } + + Map toJson() { + final Map data = new Map(); + data['name'] = this.name; + data['name_color'] = this.nameColor; + data['desc'] = this.desc; + data['desc_color'] = this.descColor; + data['skip_identifier'] = this.skipIdentifier; + data['url'] = this.url; + return data; + } } + diff --git a/lib/pages/setting_page/setting_page.dart b/lib/pages/setting_page/setting_page.dart index cae5319..9ccc5c1 100644 --- a/lib/pages/setting_page/setting_page.dart +++ b/lib/pages/setting_page/setting_page.dart @@ -147,7 +147,7 @@ class _SettingContainerState extends State<_SettingContainer> { ), ), onTap: () { - RouterUtil.route(item.toJson(), context); + RouterUtil.route(item, item.toJson(), context); }, ); } diff --git a/lib/register.dart b/lib/register.dart index 669fdd2..f17f3e2 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -18,6 +18,7 @@ import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_widget. import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_creater.dart'; import 'package:zhiying_base_widget/widgets/home/home_notice/home_notice_widget.dart'; import 'package:zhiying_base_widget/widgets/home/home_slide_banner/home_slide_banner_creater.dart'; +import 'package:zhiying_base_widget/widgets/home/home_sreach/home_sreach_creater.dart'; import 'package:zhiying_base_widget/widgets/home/home_sreach/home_sreach_widget.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header.dart'; @@ -76,9 +77,9 @@ class BaseWidgetRegister { // ==================== 首页 // WidgetFactory.regist('index_title', NormalNavCreater()); /// 首页搜索栏 - // WidgetFactory.regist('index_search', HomeSreachCreater()); - WidgetFactory.regist('index_search', - DefaultWidgetCreater((model) => HomeSreachWidget(model))); + WidgetFactory.regist('index_search', HomeSreachCreater()); + // WidgetFactory.regist('index_search', + // DefaultWidgetCreater((model) => HomeSreachWidget(model))); /// 可滚动banner WidgetFactory.regist('index_carousel', HomeSlideBannerCreater()); diff --git a/lib/widgets/home/home_auth/home_auth.dart b/lib/widgets/home/home_auth/home_auth.dart index cd5d250..0dbfee6 100644 --- a/lib/widgets/home/home_auth/home_auth.dart +++ b/lib/widgets/home/home_auth/home_auth.dart @@ -23,12 +23,12 @@ class HomeAuth extends StatelessWidget { width: double.infinity, margin: EdgeInsets.only(left: 12, right: 12, top: 4, bottom: 4), decoration: BoxDecoration( - color: HexColor.fromHex(_style?.bgColor ?? 'ffffff'), + color: HexColor.fromHex(_style?.taoaboTipBgColor ?? 'ffffff'), borderRadius: BorderRadius.circular(17), boxShadow: [ BoxShadow( offset: Offset(2, 1), //x,y轴 - color: HexColor.fromHex(_style?.shadowColor ?? '767676') + color: HexColor.fromHex(_style?.taoaboTipShadowColor ?? '767676') .withAlpha(70), //投影颜色 blurRadius: 5 //投影距离 ) @@ -40,18 +40,18 @@ class HomeAuth extends StatelessWidget { width: 20, height: 20, child: CachedNetworkImage( - imageUrl: _style.icon, + imageUrl: _style.taobaoAuthIcon, fit: BoxFit.contain, ), ), Expanded( child: Text( - _style?.text ?? '', + _style?.taoaboTipText ?? '', maxLines: 1, style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, - color: HexColor.fromHex(_style?.textColor ?? '333333'), + color: HexColor.fromHex(_style?.taoaboTipTextColor ?? '333333'), ), ), ), @@ -60,13 +60,13 @@ class HomeAuth extends StatelessWidget { padding: EdgeInsets.only(left: 12, right: 12, top: 3, bottom: 3), margin: EdgeInsets.only(left: 8, right: 8), decoration: BoxDecoration( - color: HexColor.fromHex(_style?.tipBtnBgColor ?? 'FF4242'), + color: HexColor.fromHex(_style?.taoaboTipBtnBgColor ?? 'FF4242'), borderRadius: BorderRadius.circular(20)), child: Text( - _style?.tipBtnText ?? '', + _style?.taoaboTipBtnText ?? '', style: TextStyle( fontSize: 12, - color: HexColor.fromHex(_style?.tipBtnTextColor ?? 'ffffff'), + color: HexColor.fromHex(_style?.taoaboTipBtnTextColor ?? 'ffffff'), ), ), ), diff --git a/lib/widgets/home/home_auth/models/home_auth_model.dart b/lib/widgets/home/home_auth/models/home_auth_model.dart index 3b9a562..dd03a19 100644 --- a/lib/widgets/home/home_auth/models/home_auth_model.dart +++ b/lib/widgets/home/home_auth/models/home_auth_model.dart @@ -1,40 +1,45 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'home_auth_model.g.dart'; - -@JsonSerializable() -class HomeAuthModel extends Object { - - @JsonKey(name: 'taobao_auth_icon') - String icon; - - @JsonKey(name: 'taoabo_tip_bg_color') - String bgColor; - - @JsonKey(name: 'taoabo_tip_shadow_color') - String shadowColor; - - @JsonKey(name: 'taoabo_tip_text_color') - String textColor; - - @JsonKey(name: 'taoabo_tip_text') - String text; - - @JsonKey(name: 'taoabo_tip_btn_text_color') - String tipBtnTextColor; - - @JsonKey(name: 'taoabo_tip_btn_bg_color') - String tipBtnBgColor; - - @JsonKey(name: 'taoabo_tip_btn_text') - String tipBtnText; - - HomeAuthModel(this.icon,this.bgColor,this.shadowColor,this.textColor,this.text,this.tipBtnTextColor,this.tipBtnBgColor,this.tipBtnText,); - - factory HomeAuthModel.fromJson(Map srcJson) => _$HomeAuthModelFromJson(srcJson); - - Map toJson() => _$HomeAuthModelToJson(this); - +class HomeAuthModel { + String taobaoAuthIcon; + String taoaboTipBgColor; + String taoaboTipShadowColor; + String taoaboTipTextColor; + String taoaboTipText; + String taoaboTipBtnTextColor; + String taoaboTipBtnBgColor; + String taoaboTipBtnText; + + HomeAuthModel( + {this.taobaoAuthIcon, + this.taoaboTipBgColor, + this.taoaboTipShadowColor, + this.taoaboTipTextColor, + this.taoaboTipText, + this.taoaboTipBtnTextColor, + this.taoaboTipBtnBgColor, + this.taoaboTipBtnText}); + + HomeAuthModel.fromJson(Map json) { + taobaoAuthIcon = json['taobao_auth_icon']; + taoaboTipBgColor = json['taoabo_tip_bg_color']; + taoaboTipShadowColor = json['taoabo_tip_shadow_color']; + taoaboTipTextColor = json['taoabo_tip_text_color']; + taoaboTipText = json['taoabo_tip_text']; + taoaboTipBtnTextColor = json['taoabo_tip_btn_text_color']; + taoaboTipBtnBgColor = json['taoabo_tip_btn_bg_color']; + taoaboTipBtnText = json['taoabo_tip_btn_text']; + } + + Map toJson() { + final Map data = new Map(); + data['taobao_auth_icon'] = this.taobaoAuthIcon; + data['taoabo_tip_bg_color'] = this.taoaboTipBgColor; + data['taoabo_tip_shadow_color'] = this.taoaboTipShadowColor; + data['taoabo_tip_text_color'] = this.taoaboTipTextColor; + data['taoabo_tip_text'] = this.taoaboTipText; + data['taoabo_tip_btn_text_color'] = this.taoaboTipBtnTextColor; + data['taoabo_tip_btn_bg_color'] = this.taoaboTipBtnBgColor; + data['taoabo_tip_btn_text'] = this.taoaboTipBtnText; + return data; + } } - diff --git a/lib/widgets/home/home_banner/home_banner_widget.dart b/lib/widgets/home/home_banner/home_banner_widget.dart index 34ca54b..eab1ad3 100644 --- a/lib/widgets/home/home_banner/home_banner_widget.dart +++ b/lib/widgets/home/home_banner/home_banner_widget.dart @@ -45,7 +45,7 @@ class _HomeBannerContainerState extends State { /// 点击事件 void _itemOnClick(HomeBannerListItemModel model){ print('${model?.skip_identifier}'); - RouterUtil.route(model.toJson(), context); + RouterUtil.route(model, model.toJson(), context); } @override diff --git a/lib/widgets/home/home_banner/model/HomeBannerModel.dart b/lib/widgets/home/home_banner/model/HomeBannerModel.dart index dc4da8c..720493f 100644 --- a/lib/widgets/home/home_banner/model/HomeBannerModel.dart +++ b/lib/widgets/home/home_banner/model/HomeBannerModel.dart @@ -1,3 +1,5 @@ +import 'package:zhiying_comm/zhiying_comm.dart'; + class HomeBannerModel { List list; @@ -18,7 +20,7 @@ class HomeBannerModel { } } -class HomeBannerListItemModel { +class HomeBannerListItemModel extends SkipModel{ String img; String skip_identifier; diff --git a/lib/widgets/home/home_goods/home_goods.dart b/lib/widgets/home/home_goods/home_goods.dart index 2f31f85..70d62f2 100644 --- a/lib/widgets/home/home_goods/home_goods.dart +++ b/lib/widgets/home/home_goods/home_goods.dart @@ -8,6 +8,7 @@ import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier. import 'package:zhiying_base_widget/widgets/home/home_goods/bloc/home_goods_bloc.dart'; import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_creater.dart'; import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_item.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_item_single.dart'; import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_style_model.dart'; import 'package:zhiying_base_widget/widgets/home/home_goods/skeleton/home_goods_sk.dart'; @@ -92,16 +93,35 @@ class _HomeGoodsContainerState extends State<_HomeGoodsContainer> { } List goods = snapshot.data; + int column = int.tryParse(_style.listColumn); + column = column <= 0 ? 1: column; + int count = (goods.length / column).ceil(); return ListView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), - itemCount: goods.length, + itemCount: count, itemBuilder: (context, index) { - return HomeGoodsItem( - goods[index], - _style, - data: widget.data, - ); + if (column == 1) { + return HomeGoodsItemSingle( + goods[index], + _style, + data: widget.data, + ); + } else { + // return Container(color: Colors.red, height: 126,margin: EdgeInsets.all(10),); + return Padding( + padding: const EdgeInsets.only(left: 5, right: 5), + child: Row(children: List.generate(column, (c) { + int i = index * column + c; + return Expanded + (child: i < goods.length ? HomeGoodsItem( + goods[i], + _style, + data: widget.data, + ): Container(),); + }).toList(),), + ); + } }); }, ), diff --git a/lib/widgets/home/home_goods/home_goods_item.dart b/lib/widgets/home/home_goods/home_goods_item.dart index fbacb07..c44e18d 100644 --- a/lib/widgets/home/home_goods/home_goods_item.dart +++ b/lib/widgets/home/home_goods/home_goods_item.dart @@ -33,43 +33,42 @@ class HomeGoodsItem extends StatelessWidget { return GestureDetector( onTap: () => _onJumpGoodsDetails(context, goods), child: Container( - margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), - padding: EdgeInsets.all(7.5), + margin: EdgeInsets.only(top: 4, bottom: 4, left: 5, right: 5), + decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(7.5))), - child: Row( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - width: 126, - height: 126, - margin: EdgeInsets.only(right: 10), + width: double.infinity, + margin: EdgeInsets.only(right: 0), child: ClipRRect( - borderRadius: BorderRadius.circular(7.5), + borderRadius: BorderRadius.only(topLeft: Radius.circular(7.5), topRight: Radius.circular(7.5)), child: CachedNetworkImage( imageUrl: goods.goodImage, - fit: BoxFit.fitHeight, + fit: BoxFit.fitWidth, ), ), ), - Expanded( - child: Container( - height: 126, - width: double.infinity, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: double.infinity, - child: _createTitle(), - ), - _createShop(), - _createCupone(), - Expanded(child: Container()), - _createBottom(), - ], - ), + Container( + margin: EdgeInsets.all(7.5), + height: 120, + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + child: _createTitle(), + ), + _createShop(), + Expanded(child: Container()), + _createBottom(), + + _createCupone(), + ], ), ) ], @@ -131,6 +130,7 @@ class HomeGoodsItem extends StatelessWidget { Expanded( child: Text( goods.shopName, + maxLines: 1, style: TextStyle( color: HexColor.fromHex(style.shopNameColor), fontSize: 11, @@ -200,8 +200,6 @@ class HomeGoodsItem extends StatelessWidget { children: [ _createPrice(), _createOriginPrice(), - Expanded(child: Container()), - _createSale(), ], ), ); diff --git a/lib/widgets/home/home_goods/home_goods_item_single.dart b/lib/widgets/home/home_goods/home_goods_item_single.dart index e69de29..9d128a6 100644 --- a/lib/widgets/home/home_goods/home_goods_item_single.dart +++ b/lib/widgets/home/home_goods/home_goods_item_single.dart @@ -0,0 +1,263 @@ +import 'dart:convert'; + +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/pages/goods_details_page/goods_details_page.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_style_model.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +// ignore: must_be_immutable +class HomeGoodsItemSingle extends StatelessWidget { + final HomeGoodsModel goods; + final HomeGoodsStyleModel style; + Map data; + + HomeGoodsItemSingle(this.goods, this.style, {Key key, this.data}) + : super(key: key) { + if (this.data != null && this.data.containsKey('data')) { + String data = this.data['data']; + Map json = Map.from(jsonDecode(data)); + this.data = json; + } + } + + /// 跳到商品详情 + void _onJumpGoodsDetails(BuildContext context, HomeGoodsModel goods) { + Navigator.push(context, + MaterialPageRoute(builder: (_) => GoodsDetailsPage(goods.toJson()))); + } + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () => _onJumpGoodsDetails(context, goods), + child: Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), + padding: EdgeInsets.all(7.5), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(7.5))), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 126, + height: 126, + margin: EdgeInsets.only(right: 10), + child: ClipRRect( + borderRadius: BorderRadius.circular(7.5), + child: CachedNetworkImage( + imageUrl: goods.goodImage, + fit: BoxFit.fitHeight, + ), + ), + ), + Expanded( + child: Container( + height: 126, + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + child: _createTitle(), + ), + _createShop(), + _createCupone(), + Expanded(child: Container()), + _createBottom(), + ], + ), + ), + ) + ], + ), + ), + ); + } + + Widget _createTitle() { + List list = List(); + if (goods.providerName != null && goods.providerName != '') { + list.add(WidgetSpan( + child: Container( + padding: EdgeInsets.only(left: 2, right: 2, top: 3, bottom: 3), + margin: EdgeInsets.only(right: 4), + child: Text( + goods.providerName, + style: TextStyle( + fontSize: 9, + height: 1, + color: HexColor.fromHex(style.providerNameColor), + ), + ), + decoration: BoxDecoration( + color: HexColor.fromHex(style.providerNameBackgroundColor), + borderRadius: BorderRadius.circular(2.5)), + ), + )); + } + list.add(TextSpan( + text: goods.goodTitle, + style: TextStyle( + fontSize: 15, + color: HexColor.fromHex('#333333'), + fontWeight: FontWeight.bold), + )); + return RichText( + maxLines: 2, + overflow: TextOverflow.ellipsis, + text: TextSpan(children: list), + ); + } + + Widget _createShop() { + return Container( + margin: EdgeInsets.only(top: 5), + width: double.infinity, + child: Row( + children: [ + Container( + width: 15, + height: 15, + margin: EdgeInsets.only(right: 2), + child: CachedNetworkImage( + imageUrl: style.shopIcon, + fit: BoxFit.fitHeight, + ), + ), + Expanded( + child: Text( + goods.shopName, + maxLines: 1, + style: TextStyle( + color: HexColor.fromHex(style.shopNameColor), + fontSize: 11, + fontWeight: FontWeight.w400), + )) + ], + ), + ); + } + + Widget _createCupone() { + List widgets = List(); + if (goods.coupon != null && goods.coupon != '') { + widgets.add(Container( + margin: EdgeInsets.only(right: 5), + padding: EdgeInsets.only(left: 10, right: 10, top: 3, bottom: 3), + decoration: BoxDecoration( + color: HexColor.fromHex(style.couponBgColor), + borderRadius: BorderRadius.circular(2.5), + ), + child: Text( + goods.coupon, + textAlign: TextAlign.center, + maxLines: 1, + style: TextStyle( + height: 1, + fontSize: 11, + color: HexColor.fromHex(style.couponFontColor), + ), + ), + )); + } + + if (goods.commission != null || goods.commission != '') { + widgets.add(Container( + margin: EdgeInsets.only(right: 5), + padding: EdgeInsets.only(left: 10, right: 10, top: 3, bottom: 3), + decoration: BoxDecoration( + color: HexColor.fromHex(style.commissionBgColor), + borderRadius: BorderRadius.circular(2.5), + ), + child: Text( + goods.commission, + textAlign: TextAlign.center, + maxLines: 1, + style: TextStyle( + height: 1, + fontSize: 11, + color: HexColor.fromHex(style.commissionFontColor), + ), + ), + )); + } + + return Container( + margin: EdgeInsets.only(top: 6), + child: Row( + children: widgets, + ), + ); + } + + Widget _createBottom() { + return Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + _createPrice(), + _createOriginPrice(), + Expanded(child: Container()), + _createSale(), + ], + ), + ); + } + + Widget _createPrice() { + return RichText( + maxLines: 1, + overflow: TextOverflow.ellipsis, + text: TextSpan(children: [ + TextSpan( + text: '¥', + style: TextStyle( + fontSize: 10, + color: HexColor.fromHex(style.currentPriceColor), + fontWeight: FontWeight.bold, + fontFamily: 'Din', + package: 'zhiying_base_widget', + ), + ), + TextSpan( + text: goods.currentPrice, + style: TextStyle( + fontSize: 20, + color: HexColor.fromHex(style.currentPriceColor), + fontWeight: FontWeight.bold, + fontFamily: 'Din', + package: 'zhiying_base_widget', + ), + ) + ]), + ); + } + + Widget _createOriginPrice() { + return Padding( + padding: EdgeInsets.only(bottom: 2), + child: Text( + '¥${goods.marketPrice}', + style: TextStyle( + fontSize: 11, + height: 1, + color: HexColor.fromHex(style.marketPriceColor), + fontWeight: FontWeight.normal, + fontFamily: 'Din', + package: 'zhiying_base_widget', + decoration: TextDecoration.lineThrough, + ), + )); + } + + Widget _createSale() { + return Text( + '${goods.inorderCount}', + style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')), + ); + } +} diff --git a/lib/widgets/home/home_goods/models/home_goods_header_model.dart b/lib/widgets/home/home_goods/models/home_goods_header_model.dart index ef0917e..4388441 100644 --- a/lib/widgets/home/home_goods/models/home_goods_header_model.dart +++ b/lib/widgets/home/home_goods/models/home_goods_header_model.dart @@ -1,38 +1,37 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'home_goods_header_model.g.dart'; - -@JsonSerializable() -class HomeGoodsHeaderModel extends Object { - @JsonKey(name: 'type') +class HomeGoodsHeaderModel { String type; - - @JsonKey(name: 'title') String title; - - @JsonKey(name: 'subtitle') String subtitle; - - @JsonKey(name: 'tilte_text_color') String tilteTextColor; - - @JsonKey(name: 'subtitle_bg_color') String subtitleBgColor; - - @JsonKey(name: 'subtitle_text_color') String subtitleTextColor; HomeGoodsHeaderModel( - this.type, - this.title, - this.subtitle, - this.tilteTextColor, - this.subtitleBgColor, - this.subtitleTextColor, - ); - - factory HomeGoodsHeaderModel.fromJson(Map srcJson) => - _$HomeGoodsHeaderModelFromJson(srcJson); - - Map toJson() => _$HomeGoodsHeaderModelToJson(this); + {this.type, + this.title, + this.subtitle, + this.tilteTextColor, + this.subtitleBgColor, + this.subtitleTextColor}); + + HomeGoodsHeaderModel.fromJson(Map json) { + type = json['type']; + title = json['title']; + subtitle = json['subtitle']; + tilteTextColor = json['tilte_text_color']; + subtitleBgColor = json['subtitle_bg_color']; + subtitleTextColor = json['subtitle_text_color']; + } + + Map toJson() { + final Map data = new Map(); + data['type'] = this.type; + data['title'] = this.title; + data['subtitle'] = this.subtitle; + data['tilte_text_color'] = this.tilteTextColor; + data['subtitle_bg_color'] = this.subtitleBgColor; + data['subtitle_text_color'] = this.subtitleTextColor; + return data; + } } + diff --git a/lib/widgets/home/home_goods/models/home_goods_model.dart b/lib/widgets/home/home_goods/models/home_goods_model.dart index 16c6dda..acdf9c6 100644 --- a/lib/widgets/home/home_goods/models/home_goods_model.dart +++ b/lib/widgets/home/home_goods/models/home_goods_model.dart @@ -1,58 +1,57 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'home_goods_model.g.dart'; - -@JsonSerializable() -class HomeGoodsModel extends Object { - @JsonKey(name: 'provider') +class HomeGoodsModel { String provider; - - @JsonKey(name: 'provider_name') String providerName; - - @JsonKey(name: 'good_id') String goodId; - - @JsonKey(name: 'good_image') String goodImage; - - @JsonKey(name: 'good_title') String goodTitle; - - @JsonKey(name: 'shop_name') String shopName; - - @JsonKey(name: 'coupon') String coupon; - - @JsonKey(name: 'commission') String commission; - - @JsonKey(name: 'market_price') String marketPrice; - - @JsonKey(name: 'current_price') String currentPrice; - - @JsonKey(name: 'inorder_count') String inorderCount; HomeGoodsModel( - this.provider, - this.providerName, - this.goodId, - this.goodImage, - this.goodTitle, - this.shopName, - this.coupon, - this.commission, - this.marketPrice, - this.currentPrice, - this.inorderCount, - ); - - factory HomeGoodsModel.fromJson(Map srcJson) => - _$HomeGoodsModelFromJson(srcJson); - - Map toJson() => _$HomeGoodsModelToJson(this); + {this.provider, + this.providerName, + this.goodId, + this.goodImage, + this.goodTitle, + this.shopName, + this.coupon, + this.commission, + this.marketPrice, + this.currentPrice, + this.inorderCount}); + + HomeGoodsModel.fromJson(Map 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']; + commission = json['commission']; + marketPrice = json['market_price']; + currentPrice = json['current_price']; + inorderCount = json['inorder_count']; + } + + Map toJson() { + final Map data = new Map(); + 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['commission'] = this.commission; + data['market_price'] = this.marketPrice; + data['current_price'] = this.currentPrice; + data['inorder_count'] = this.inorderCount; + return data; + } } + diff --git a/lib/widgets/home/home_goods/models/home_goods_style_model.dart b/lib/widgets/home/home_goods/models/home_goods_style_model.dart index 3173fd6..bc3d98d 100644 --- a/lib/widgets/home/home_goods/models/home_goods_style_model.dart +++ b/lib/widgets/home/home_goods/models/home_goods_style_model.dart @@ -1,62 +1,69 @@ -import 'package:json_annotation/json_annotation.dart'; import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_header_model.dart'; - -part 'home_goods_style_model.g.dart'; - -@JsonSerializable() -class HomeGoodsStyleModel extends Object { - @JsonKey(name: 'list_column') - String column; - - @JsonKey(name: 'recommend_list') +class HomeGoodsStyleModel { + String listColumn; List recommendList; - - @JsonKey(name: 'provider_name_color') String providerNameColor; - - @JsonKey(name: 'provider_name_background_color') String providerNameBackgroundColor; - - @JsonKey(name: 'shop_name_color') String shopNameColor; - - @JsonKey(name: 'shop_icon') String shopIcon; - - @JsonKey(name: 'coupon_font_color') String couponFontColor; - - @JsonKey(name: 'coupon_bg_color') String couponBgColor; - - @JsonKey(name: 'commission_font_color') String commissionFontColor; - - @JsonKey(name: 'commission_bg_color') String commissionBgColor; - - @JsonKey(name: 'market_price_color') String marketPriceColor; - - @JsonKey(name: 'current_price_color') String currentPriceColor; HomeGoodsStyleModel( - this.recommendList, - this.providerNameColor, - this.providerNameBackgroundColor, - this.shopNameColor, - this.shopIcon, - this.couponFontColor, - this.couponBgColor, - this.commissionFontColor, - this.commissionBgColor, - this.marketPriceColor, - this.currentPriceColor, - ); - - factory HomeGoodsStyleModel.fromJson(Map srcJson) => - _$HomeGoodsStyleModelFromJson(srcJson); - - Map toJson() => _$HomeGoodsStyleModelToJson(this); -} + {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 json) { + listColumn = json['list_column']; + if (json['recommend_list'] != null) { + recommendList = new List(); + json['recommend_list'].forEach((v) { + recommendList.add(new HomeGoodsHeaderModel.fromJson(v)); + }); + } + providerNameColor = json['provider_name_color']; + providerNameBackgroundColor = json['provider_name_background_color']; + shopNameColor = json['shop_name_color']; + shopIcon = json['shop_icon']; + couponFontColor = json['coupon_font_color']; + couponBgColor = json['coupon_bg_color']; + commissionFontColor = json['commission_font_color']; + commissionBgColor = json['commission_bg_color']; + marketPriceColor = json['market_price_color']; + currentPriceColor = json['current_price_color']; + } + + Map toJson() { + final Map data = new Map(); + 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; + } +} \ No newline at end of file diff --git a/lib/widgets/home/home_notice/home_notice_widget.dart b/lib/widgets/home/home_notice/home_notice_widget.dart index 7a93f70..8b894ed 100644 --- a/lib/widgets/home/home_notice/home_notice_widget.dart +++ b/lib/widgets/home/home_notice/home_notice_widget.dart @@ -46,7 +46,7 @@ class _HomeNoticeWidgetContianerState extends State { /// 子item跳转 void _itemJump(HomeNoticeNoticesModel model){ print('${model?.skip_identifier}'); - RouterUtil.route(model.toJson(), context); + // RouterUtil.route(model, model.toJson(), context); } @override diff --git a/lib/widgets/home/home_notice/model/home_notice_model.dart b/lib/widgets/home/home_notice/model/home_notice_model.dart index 1ce3866..80a758a 100644 --- a/lib/widgets/home/home_notice/model/home_notice_model.dart +++ b/lib/widgets/home/home_notice/model/home_notice_model.dart @@ -1,3 +1,5 @@ +import 'package:zhiying_comm/zhiying_comm.dart'; + class HomeNoticeModel { String logo_img; String jump_img; @@ -36,7 +38,7 @@ class HomeNoticeModel { } } -class HomeNoticeNoticesModel { +class HomeNoticeNoticesModel{ String notice_text; String skip_identifier; diff --git a/lib/widgets/home/home_quick_entry/home_quick_entry.dart b/lib/widgets/home/home_quick_entry/home_quick_entry.dart index 8689a25..3975c09 100644 --- a/lib/widgets/home/home_quick_entry/home_quick_entry.dart +++ b/lib/widgets/home/home_quick_entry/home_quick_entry.dart @@ -34,7 +34,7 @@ class _HomeQuickEntryContianerState extends State { /// Icon点击事件 void _itemIconClick(TypeNormal model){ print("item type = ${model.skip_identifier}"); - RouterUtil.route(model.toJson(), context); + // RouterUtil.route(model, model.toJson(), context); } @override diff --git a/lib/widgets/home/home_slide_banner/home_slide_banner.dart b/lib/widgets/home/home_slide_banner/home_slide_banner.dart index 56f073c..c959382 100644 --- a/lib/widgets/home/home_slide_banner/home_slide_banner.dart +++ b/lib/widgets/home/home_slide_banner/home_slide_banner.dart @@ -44,7 +44,7 @@ class _HomeSlideBannerContainerState extends State { /// 子元素点击事件 void _itemOnClick(IndexCarousel model) { print('点击了 $model'); - RouterUtil.route(model.toJson(), context); + // RouterUtil.route(model, model.toJson(), context); // Navigator.push(context, MaterialPageRoute( // builder: (_) => PageFactory.create('goods_details', null) // )); diff --git a/lib/widgets/home/home_sreach/home_sreach_creater.dart b/lib/widgets/home/home_sreach/home_sreach_creater.dart index 6102cbd..cd63df2 100644 --- a/lib/widgets/home/home_sreach/home_sreach_creater.dart +++ b/lib/widgets/home/home_sreach/home_sreach_creater.dart @@ -8,9 +8,9 @@ class HomeSreachCreater extends WidgetCreater { List createWidgets(Map model) { return [ SliverPersistentHeader( - pinned: false, + pinned: true, floating: false, - delegate: HomeSreachDeleagater(), + delegate: HomeSreachDeleagater(model), ), ]; } diff --git a/lib/widgets/home/home_sreach/home_sreach_widget.dart b/lib/widgets/home/home_sreach/home_sreach_widget.dart index c99d7d8..2882038 100644 --- a/lib/widgets/home/home_sreach/home_sreach_widget.dart +++ b/lib/widgets/home/home_sreach/home_sreach_widget.dart @@ -1,13 +1,20 @@ + import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:flutter/material.dart'; import 'dart:ui'; +import 'package:cached_network_image/cached_network_image.dart'; + class HomeSreachDeleagater extends SliverPersistentHeaderDelegate{ + final Map model; + HomeSreachWidget _searchWidget; + double _height; - HomeSreachDeleagater() : super() { + HomeSreachDeleagater(this.model) : super() { _height = MediaQueryData.fromWindow(window).padding.top + 44; + _searchWidget = HomeSreachWidget(model); } @override @@ -15,7 +22,7 @@ class HomeSreachDeleagater extends SliverPersistentHeaderDelegate{ print('${shrinkOffset.toString()}'); double percent = shrinkOffset / _height; print('${percent.toString()}'); - return HomeSreachWidget(null); + return _searchWidget; } @override @@ -63,7 +70,7 @@ class _HomeSreachContainerState extends State { color: Colors.transparent, height: 30, width: double.infinity, - margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 10, top: MediaQueryData.fromWindow(window).padding.top + 10), + margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 7, top: MediaQueryData.fromWindow(window).padding.top + 7), child: Row( children: [ /// 搜索框 @@ -95,10 +102,7 @@ class _HomeSreachContainerState extends State { fontSize: 14, ), contentPadding: EdgeInsets.zero, - prefixIcon: Icon( - Icons.search, - color: Colors.white, - ), + prefixIcon: Icon(Icons.search, color: Colors.white,), filled: true, fillColor: Color(0x50cccccc), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Color(0x00000000)), borderRadius: BorderRadius.all(Radius.circular(30))), diff --git a/lib/widgets/mine/mine_data/mine_data.dart b/lib/widgets/mine/mine_data/mine_data.dart index 5917327..4303733 100644 --- a/lib/widgets/mine/mine_data/mine_data.dart +++ b/lib/widgets/mine/mine_data/mine_data.dart @@ -47,16 +47,18 @@ class _MineDataState extends State { Map json = convert.jsonDecode(d); MineDataModel style = MineDataModel.fromJson(Map.from(json)); + + List list = style.gridView.map((item) { + return MineProfileDataModel(name: item.name, value: '¥0'); + }).toList(); MineProfileModel profile = MineProfileModel( - '', - '', - '', - '', - '', - '¥0', - style.datas.map((item) { - return MineProfileDataModel(item.name, '¥0'); - }).toList(), + username:'', + avatar:'', + inviteCode:'', + userLvName:'', + userLvIcon:'', + total:'', + gridViews:list, ); return MineDataWidget(profile, widget.data); } diff --git a/lib/widgets/mine/mine_data/mine_data_widget.dart b/lib/widgets/mine/mine_data/mine_data_widget.dart index 799f3e0..7cdab60 100644 --- a/lib/widgets/mine/mine_data/mine_data_widget.dart +++ b/lib/widgets/mine/mine_data/mine_data_widget.dart @@ -121,7 +121,7 @@ class MineDataWidget extends StatelessWidget { ), ), onTap: () { - RouterUtil.route(_json, context); + // RouterUtil.route(_json, context); }, ) ], @@ -133,7 +133,7 @@ class MineDataWidget extends StatelessWidget { } Widget _createCenter() { - List datas = profile.datas; + List datas = profile.gridViews; int maxColumn = 2; int row = (datas.length / 2).ceil(); if (row % 3 == 0) { diff --git a/lib/widgets/mine/mine_data/model/mine_data_model.dart b/lib/widgets/mine/mine_data/model/mine_data_model.dart index 6db6567..93cc50b 100644 --- a/lib/widgets/mine/mine_data/model/mine_data_model.dart +++ b/lib/widgets/mine/mine_data/model/mine_data_model.dart @@ -1,67 +1,73 @@ -import 'package:json_annotation/json_annotation.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart'; -part 'mine_data_model.g.dart'; - -@JsonSerializable() -class MineDataModel extends Object { - @JsonKey(name: 'accumulated_earnings_name_color') +class MineDataModel { String accumulatedEarningsNameColor; - - @JsonKey(name: 'accumulated_earnings_color') String accumulatedEarningsColor; - - @JsonKey(name: 'accumulated_earnings_bg_img') String accumulatedEarningsBgImg; - - @JsonKey(name: 'btn_text') String btnText; - - @JsonKey(name: 'btn_text_color') String btnTextColor; - - @JsonKey(name: 'btn_img') String btnImg; - - @JsonKey(name: 'required_login') String requiredLogin; - - @JsonKey(name: 'required_taobao_auth') String requiredTaobaoAuth; - - @JsonKey(name: 'skip_identifier') String skipIdentifier; - - @JsonKey(name: 'grid_view_bg_color') String gridViewBgColor; - - @JsonKey(name: 'grid_view_name_color') String gridViewNameColor; - - @JsonKey(name: 'grid_view_value_color') String gridViewValueColor; - - @JsonKey(name: 'grid_view') - List datas; + List gridView; MineDataModel( - this.accumulatedEarningsNameColor, - this.accumulatedEarningsColor, - this.accumulatedEarningsBgImg, - this.btnText, - this.btnTextColor, - this.btnImg, - this.requiredLogin, - this.requiredTaobaoAuth, - this.skipIdentifier, - this.gridViewBgColor, - this.gridViewNameColor, - this.gridViewValueColor, - this.datas, - ); - - factory MineDataModel.fromJson(Map srcJson) => - _$MineDataModelFromJson(srcJson); - - Map toJson() => _$MineDataModelToJson(this); + {this.accumulatedEarningsNameColor, + this.accumulatedEarningsColor, + this.accumulatedEarningsBgImg, + this.btnText, + this.btnTextColor, + this.btnImg, + this.requiredLogin, + this.requiredTaobaoAuth, + this.skipIdentifier, + this.gridViewBgColor, + this.gridViewNameColor, + this.gridViewValueColor, + this.gridView}); + + MineDataModel.fromJson(Map json) { + accumulatedEarningsNameColor = json['accumulated_earnings_name_color']; + accumulatedEarningsColor = json['accumulated_earnings_color']; + accumulatedEarningsBgImg = json['accumulated_earnings_bg_img']; + btnText = json['btn_text']; + btnTextColor = json['btn_text_color']; + btnImg = json['btn_img']; + requiredLogin = json['required_login']; + requiredTaobaoAuth = json['required_taobao_auth']; + skipIdentifier = json['skip_identifier']; + gridViewBgColor = json['grid_view_bg_color']; + gridViewNameColor = json['grid_view_name_color']; + gridViewValueColor = json['grid_view_value_color']; + if (json['grid_view'] != null) { + gridView = new List(); + json['grid_view'].forEach((v) { + gridView.add(new MineProfileDataModel.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['accumulated_earnings_name_color'] = this.accumulatedEarningsNameColor; + data['accumulated_earnings_color'] = this.accumulatedEarningsColor; + data['accumulated_earnings_bg_img'] = this.accumulatedEarningsBgImg; + data['btn_text'] = this.btnText; + data['btn_text_color'] = this.btnTextColor; + data['btn_img'] = this.btnImg; + data['required_login'] = this.requiredLogin; + data['required_taobao_auth'] = this.requiredTaobaoAuth; + data['skip_identifier'] = this.skipIdentifier; + data['grid_view_bg_color'] = this.gridViewBgColor; + data['grid_view_name_color'] = this.gridViewNameColor; + data['grid_view_value_color'] = this.gridViewValueColor; + if (this.gridView != null) { + data['grid_view'] = this.gridView.map((v) => v.toJson()).toList(); + } + return data; + } } diff --git a/lib/widgets/mine/mine_header/mine_header_container.dart b/lib/widgets/mine/mine_header/mine_header_container.dart index b6323b7..14cfc71 100644 --- a/lib/widgets/mine/mine_header/mine_header_container.dart +++ b/lib/widgets/mine/mine_header/mine_header_container.dart @@ -64,7 +64,7 @@ class _MineHeaderContainerState extends State { ), ), onTap: () async { - await RouterUtil.route(widget.json, context); + await RouterUtil.route(SkipModel.fromJson(widget.json), widget.json, context); _bloc.loadData(); }, ), diff --git a/lib/widgets/mine/mine_header/mine_header_static_container.dart b/lib/widgets/mine/mine_header/mine_header_static_container.dart index ab68694..900d726 100644 --- a/lib/widgets/mine/mine_header/mine_header_static_container.dart +++ b/lib/widgets/mine/mine_header/mine_header_static_container.dart @@ -35,11 +35,11 @@ class _MineStaticContainerState extends State { child: ClipRRect( borderRadius: BorderRadius.circular(28), child: CachedNetworkImage( - imageUrl: widget.staticModel.defaultAvatar, + imageUrl: widget.staticModel.nonLoginAvatar, fit: BoxFit.cover)), ), onTap: () { - RouterUtil.route(widget.json, context); + // RouterUtil.route(SkipModel.fromJson(widget.json), widget.json, context); }, ), Expanded( diff --git a/lib/widgets/mine/mine_header/model/mine_header_model.dart b/lib/widgets/mine/mine_header/model/mine_header_model.dart index abe240b..b87c436 100644 --- a/lib/widgets/mine/mine_header/model/mine_header_model.dart +++ b/lib/widgets/mine/mine_header/model/mine_header_model.dart @@ -1,64 +1,65 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'mine_header_model.g.dart'; - -@JsonSerializable() -class MineHeaderModel extends Object { - @JsonKey(name: 'lv_bg_color') +class MineHeaderModel { String lvBgColor; - - @JsonKey(name: 'lv_name_color') String lvNameColor; - - @JsonKey(name: 'non_login_avatar') - String defaultAvatar; - - @JsonKey(name: 'user_name_color') + String nonLoginAvatar; String userNameColor; - - @JsonKey(name: 'invited_code_text') String invitedCodeText; - - @JsonKey(name: 'invited_code_color') String invitedCodeColor; - - @JsonKey(name: 'login_color') String loginColor; - - @JsonKey(name: 'login_name') String loginName; - - @JsonKey(name: 'login_name_help_text') String loginNameHelpText; - - @JsonKey(name: 'coype_icon') String coypeIcon; - - @JsonKey(name: 'required_login') String requiredLogin; - - @JsonKey(name: 'required_taobao_auth') String requiredTaobaoAuth; - - @JsonKey(name: 'skip_identifier') String skipIdentifier; MineHeaderModel( - this.defaultAvatar, - this.userNameColor, - this.invitedCodeText, - this.invitedCodeColor, - this.loginColor, - this.loginName, - this.loginNameHelpText, - this.coypeIcon, - this.requiredLogin, - this.requiredTaobaoAuth, - this.skipIdentifier, - ); - - factory MineHeaderModel.fromJson(Map srcJson) => - _$MineHeaderModelFromJson(srcJson); - - Map toJson() => _$MineHeaderModelToJson(this); + {this.lvBgColor, + this.lvNameColor, + this.nonLoginAvatar, + this.userNameColor, + this.invitedCodeText, + this.invitedCodeColor, + this.loginColor, + this.loginName, + this.loginNameHelpText, + this.coypeIcon, + this.requiredLogin, + this.requiredTaobaoAuth, + this.skipIdentifier}); + + MineHeaderModel.fromJson(Map json) { + lvBgColor = json['lv_bg_color']; + lvNameColor = json['lv_name_color']; + nonLoginAvatar = json['non_login_avatar']; + userNameColor = json['user_name_color']; + invitedCodeText = json['invited_code_text']; + invitedCodeColor = json['invited_code_color']; + loginColor = json['login_color']; + loginName = json['login_name']; + loginNameHelpText = json['login_name_help_text']; + coypeIcon = json['coype_icon']; + requiredLogin = json['required_login']; + requiredTaobaoAuth = json['required_taobao_auth']; + skipIdentifier = json['skip_identifier']; + } + + Map toJson() { + final Map data = new Map(); + data['lv_bg_color'] = this.lvBgColor; + data['lv_name_color'] = this.lvNameColor; + data['non_login_avatar'] = this.nonLoginAvatar; + data['user_name_color'] = this.userNameColor; + data['invited_code_text'] = this.invitedCodeText; + data['invited_code_color'] = this.invitedCodeColor; + data['login_color'] = this.loginColor; + data['login_name'] = this.loginName; + data['login_name_help_text'] = this.loginNameHelpText; + data['coype_icon'] = this.coypeIcon; + data['required_login'] = this.requiredLogin; + data['required_taobao_auth'] = this.requiredTaobaoAuth; + data['skip_identifier'] = this.skipIdentifier; + return data; + } } + diff --git a/lib/widgets/mine/mine_header/model/mine_profile_model.dart b/lib/widgets/mine/mine_header/model/mine_profile_model.dart index 0f06e1e..c07bd2d 100644 --- a/lib/widgets/mine/mine_header/model/mine_profile_model.dart +++ b/lib/widgets/mine/mine_header/model/mine_profile_model.dart @@ -1,57 +1,68 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'mine_profile_model.g.dart'; - -@JsonSerializable() -class MineProfileModel extends Object { - @JsonKey(name: 'username') +class MineProfileModel { String username; - - @JsonKey(name: 'avatar') String avatar; - - @JsonKey(name: 'InviteCode') String inviteCode; - - @JsonKey(name: 'user_lv_name') String userLvName; - - @JsonKey(name: 'user_lv_icon') String userLvIcon; - - @JsonKey(name: 'total') String total; - - @JsonKey(name: 'grid_views') - List datas; - - MineProfileModel(this.username, - this.avatar, - this.inviteCode, - this.userLvName, - this.userLvIcon, - this.total, - this.datas,); - - factory MineProfileModel.fromJson(Map srcJson) => - _$MineProfileModelFromJson(srcJson); - - Map toJson() => _$MineProfileModelToJson(this); + List gridViews; + + MineProfileModel( + {this.username, + this.avatar, + this.inviteCode, + this.userLvName, + this.userLvIcon, + this.total, + this.gridViews}); + + MineProfileModel.fromJson(Map json) { + username = json['username']; + avatar = json['avatar']; + inviteCode = json['InviteCode']; + userLvName = json['user_lv_name']; + userLvIcon = json['user_lv_icon']; + total = json['total']; + if (json['grid_views'] != null) { + gridViews = new List(); + json['grid_views'].forEach((v) { + gridViews.add(new MineProfileDataModel.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['username'] = this.username; + data['avatar'] = this.avatar; + data['InviteCode'] = this.inviteCode; + data['user_lv_name'] = this.userLvName; + data['user_lv_icon'] = this.userLvIcon; + data['total'] = this.total; + if (this.gridViews != null) { + data['grid_views'] = this.gridViews.map((v) => v.toJson()).toList(); + } + return data; + } } -@JsonSerializable() -class MineProfileDataModel extends Object { - @JsonKey(name: 'name') - String name; - @JsonKey(name: 'value') +class MineProfileDataModel { + String name; String value; - MineProfileDataModel(this.name, - this.value,); + MineProfileDataModel({this.name, this.value}); - factory MineProfileDataModel.fromJson(Map srcJson) => - _$MineProfileDataModelFromJson(srcJson); + MineProfileDataModel.fromJson(Map json) { + name = json['name']; + value = json['value']; + } - Map toJson() => _$MineProfileDataModelToJson(this); + Map toJson() { + final Map data = new Map(); + data['name'] = this.name; + data['value'] = this.value; + return data; + } } + diff --git a/lib/widgets/mine/mine_nav/mine_nav.dart b/lib/widgets/mine/mine_nav/mine_nav.dart index 10620ff..d8a35b6 100644 --- a/lib/widgets/mine/mine_nav/mine_nav.dart +++ b/lib/widgets/mine/mine_nav/mine_nav.dart @@ -26,7 +26,7 @@ class MineNavDelegate extends SliverPersistentHeaderDelegate { List icons = json['app_bar_icons']; _icons = icons.map((icon) { SkipModel model = SkipModel.fromJson(Map.from(icon)); - return MineNavIcon(model, json); + return MineNavIcon(icon['icon'], model); }).toList(); } } @@ -78,26 +78,24 @@ class MineNav extends StatelessWidget { } class MineNavIcon extends StatelessWidget { - final SkipModel model; - final Map data; +final String imgUrl; +final SkipModel skipModel; - const MineNavIcon(this.model, this.data, {Key key}) : super(key: key); + const MineNavIcon(this.imgUrl, this.skipModel, {Key key}) : super(key: key); @override Widget build(BuildContext context) { - return GestureDetector( - child: Container( - width: 24, - height: 24, - margin: EdgeInsets.only(left: 6), - child: CachedNetworkImage( - imageUrl: model.icon, - ), + return GestureDetector(child: Container( + width: 24, + height: 24, + margin: EdgeInsets.only(left: 6), + child: CachedNetworkImage( + imageUrl: imgUrl, ), - onTap: () { - print('页面跳转 ${model.skipIdentifier}'); - RouterUtil.route(model.toJson(), context); - }, - ); + + ), + onTap:() { + RouterUtil.route(skipModel, null, context); + }); } } diff --git a/lib/widgets/mine/mine_quick_entry/mine_quick_entry.dart b/lib/widgets/mine/mine_quick_entry/mine_quick_entry.dart index ea6f0fe..4bb79c5 100644 --- a/lib/widgets/mine/mine_quick_entry/mine_quick_entry.dart +++ b/lib/widgets/mine/mine_quick_entry/mine_quick_entry.dart @@ -20,7 +20,7 @@ class MineQuickEntry extends StatelessWidget { Widget build(BuildContext context) { int column = int.tryParse(model.layout) ?? 4; - return (model?.items?.length ?? 0) <= 0 + return (model?.functionsList?.length ?? 0) <= 0 ? Container() : Container( margin: EdgeInsets.only( @@ -32,17 +32,17 @@ class MineQuickEntry extends StatelessWidget { width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(7.5), - color: HexColor.fromHex(model.myFunctionsBgColor)), + color: HexColor.fromHex(model.functionsBgColor)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - (model?.title ?? '') == '' + (model?.myFunctionsText ?? '') == '' ? Container() : Container( margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 12.5), child: Text( - model.title, + model.myFunctionsText, style: TextStyle( fontSize: 15, fontWeight: FontWeight.w500), ), @@ -56,7 +56,7 @@ class MineQuickEntry extends StatelessWidget { mainAxisSpacing: 1, childAspectRatio: 1, ), - itemCount: model?.items?.length ?? 0, + itemCount: model?.functionsList?.length ?? 0, itemBuilder: (BuildContext context, int index) { return GestureDetector( child: Container( @@ -69,12 +69,12 @@ class MineQuickEntry extends StatelessWidget { height: 36, margin: EdgeInsets.only(bottom: 4), child: CachedNetworkImage( - imageUrl: model.items[index].icon, + imageUrl: model.functionsList[index].icon, fit: BoxFit.cover, ), ), Text( - model.items[index].name, + model.functionsList[index].name, style: TextStyle( color: HexColor.fromHex('#333333'), fontSize: 11), @@ -84,7 +84,7 @@ class MineQuickEntry extends StatelessWidget { ), ), onTap: () { - RouterUtil.route(model.items[index].toJson(), context); + // RouterUtil.route(model.items[index].toJson(), context); }, ); }, diff --git a/lib/widgets/mine/mine_quick_entry/model/mine_quick_model.dart b/lib/widgets/mine/mine_quick_entry/model/mine_quick_model.dart index 9073953..c4eb482 100644 --- a/lib/widgets/mine/mine_quick_entry/model/mine_quick_model.dart +++ b/lib/widgets/mine/mine_quick_entry/model/mine_quick_model.dart @@ -1,68 +1,78 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'mine_quick_model.g.dart'; - -@JsonSerializable() -class MineQuickModel extends Object { - @JsonKey(name: 'my_functions_text') - String title; - - @JsonKey(name: 'my_functions_text_color') - String titleColor; - - @JsonKey(name: 'layout') +class MineQuickModel { + String myFunctionsText; + String myFunctionsTextColor; String layout; - - @JsonKey(name: 'functions_bg_color') - String myFunctionsBgColor; - - @JsonKey(name: 'functions_list') - List items; + String functionsBgColor; + List functionsList; MineQuickModel( - this.title, - this.titleColor, - this.layout, - this.myFunctionsBgColor, - this.items, - ); - - factory MineQuickModel.fromJson(Map srcJson) => - _$MineQuickModelFromJson(srcJson); - - Map toJson() => _$MineQuickModelToJson(this); + {this.myFunctionsText, + this.myFunctionsTextColor, + this.layout, + this.functionsBgColor, + this.functionsList}); + + MineQuickModel.fromJson(Map json) { + myFunctionsText = json['my_functions_text']; + myFunctionsTextColor = json['my_functions_text_color']; + layout = json['layout']; + functionsBgColor = json['functions_bg_color']; + if (json['functions_list'] != null) { + functionsList = new List(); + json['functions_list'].forEach((v) { + functionsList.add(new MineQuickItemModel.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['my_functions_text'] = this.myFunctionsText; + data['my_functions_text_color'] = this.myFunctionsTextColor; + data['layout'] = this.layout; + data['functions_bg_color'] = this.functionsBgColor; + if (this.functionsList != null) { + data['functions_list'] = + this.functionsList.map((v) => v.toJson()).toList(); + } + return data; + } } -@JsonSerializable() -class MineQuickItemModel extends Object { - @JsonKey(name: 'name') - String name; - - @JsonKey(name: 'name_color') - String nameColor; - @JsonKey(name: 'icon') +class MineQuickItemModel { String icon; - - @JsonKey(name: 'required_login') + String name; + String nameColor; String requiredLogin; - - @JsonKey(name: 'required_taobao_auth') String requiredTaobaoAuth; - - @JsonKey(name: 'skip_identifier') String skipIdentifier; MineQuickItemModel( - this.name, - this.icon, - this.requiredLogin, - this.requiredTaobaoAuth, - this.skipIdentifier, - ); - - factory MineQuickItemModel.fromJson(Map srcJson) => - _$MineQuickItemModelFromJson(srcJson); - - Map toJson() => _$MineQuickItemModelToJson(this); + {this.icon, + this.name, + this.nameColor, + this.requiredLogin, + this.requiredTaobaoAuth, + this.skipIdentifier}); + + MineQuickItemModel.fromJson(Map json) { + icon = json['icon']; + name = json['name']; + nameColor = json['name_color']; + requiredLogin = json['required_login']; + requiredTaobaoAuth = json['required_taobao_auth']; + skipIdentifier = json['skip_identifier']; + } + + Map toJson() { + final Map data = new Map(); + data['icon'] = this.icon; + data['name'] = this.name; + data['name_color'] = this.nameColor; + data['required_login'] = this.requiredLogin; + data['required_taobao_auth'] = this.requiredTaobaoAuth; + data['skip_identifier'] = this.skipIdentifier; + return data; + } } diff --git a/pubspec.yaml b/pubspec.yaml index cb7523d..208c6d2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,10 +29,6 @@ dev_dependencies: zhiying_comm: path: ../zhiying_comm - - json_serializable: ^3.3.0 - build_runner: ^1.10.0 - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec