Bladeren bron

更新路由跳转,登录状态

tags/0.0.1
Weller 4 jaren geleden
bovenliggende
commit
590f06eeb2
12 gewijzigde bestanden met toevoegingen van 168 en 491 verwijderingen
  1. +1
    -235
      .dart_tool/package_config.json
  2. BIN
     
  3. +22
    -28
      lib/models/base/skip_model.dart
  4. +0
    -25
      lib/models/base/skip_model.g.dart
  5. +88
    -98
      lib/models/base/widget_model.dart
  6. +0
    -61
      lib/models/base/widget_model.g.dart
  7. +23
    -7
      lib/models/user/user_info_model_notifier.dart
  8. +11
    -11
      lib/pages/login_page/login_page.dart
  9. +2
    -2
      lib/util/extension/color.dart
  10. +15
    -16
      lib/util/router_util.dart
  11. +6
    -6
      lib/util/shared_prefe_util.dart
  12. +0
    -2
      pubspec.yaml

+ 1
- 235
.dart_tool/package_config.json Bestand weergeven

@@ -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",
@@ -187,12 +97,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",
@@ -247,36 +151,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",
@@ -295,42 +175,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",
@@ -343,36 +193,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",
@@ -439,12 +265,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",
@@ -463,12 +283,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": "quiver",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/quiver-2.0.5",
@@ -511,18 +325,6 @@
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "shelf",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shelf-0.7.9",
"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",
@@ -535,12 +337,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",
@@ -571,12 +367,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",
@@ -601,12 +391,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": "typed_data",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/typed_data-1.1.6",
@@ -661,18 +445,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.22+1",
@@ -691,12 +463,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": "../",
@@ -704,7 +470,7 @@
"languageVersion": "2.1"
}
],
"generated": "2020-09-21T02:30:27.331807Z",
"generated": "2020-09-23T04:02:45.114883Z",
"generator": "pub",
"generatorVersion": "2.7.2"
}


+ 22
- 28
lib/models/base/skip_model.dart Bestand weergeven

@@ -1,34 +1,28 @@
import 'package:json_annotation/json_annotation.dart';

part 'skip_model.g.dart';

@JsonSerializable()
class SkipModel extends Object {
@JsonKey(name: 'name')
String name;

@JsonKey(name: 'icon')
String icon;

@JsonKey(name: 'required_login')
class SkipModel {
String url;
String requiredLogin;

@JsonKey(name: 'required_taobao_auth')
String requiredTaobaoAuth;

@JsonKey(name: 'skip_identifier')
String skipIdentifier;

SkipModel(
this.name,
this.icon,
this.requiredLogin,
this.requiredTaobaoAuth,
this.skipIdentifier,
);

factory SkipModel.fromJson(Map<String, dynamic> srcJson) =>
_$SkipModelFromJson(srcJson);

Map<String, dynamic> toJson() => _$SkipModelToJson(this);
{this.url,
this.requiredLogin,
this.requiredTaobaoAuth,
this.skipIdentifier});

SkipModel.fromJson(Map<String, dynamic> json) {
url = json['url'];
requiredLogin = json['required_login'];
requiredTaobaoAuth = json['required_taobao_auth'];
skipIdentifier = json['skip_identifier'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['url'] = this.url;
data['required_login'] = this.requiredLogin;
data['required_taobao_auth'] = this.requiredTaobaoAuth;
data['skip_identifier'] = this.skipIdentifier;
return data;
}
}

+ 0
- 25
lib/models/base/skip_model.g.dart Bestand weergeven

@@ -1,25 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'skip_model.dart';

// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

SkipModel _$SkipModelFromJson(Map<String, dynamic> json) {
return SkipModel(
json['name'] as String,
json['icon'] as String,
json['required_login'] as String,
json['required_taobao_auth'] as String,
json['skip_identifier'] as String,
);
}

Map<String, dynamic> _$SkipModelToJson(SkipModel instance) => <String, dynamic>{
'name': instance.name,
'icon': instance.icon,
'required_login': instance.requiredLogin,
'required_taobao_auth': instance.requiredTaobaoAuth,
'skip_identifier': instance.skipIdentifier,
};

+ 88
- 98
lib/models/base/widget_model.dart Bestand weergeven

@@ -1,106 +1,96 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';

part 'widget_model.g.dart';

@JsonSerializable()
// ignore: must_be_immutable
class WidgetModel extends Object implements Equatable {
@JsonKey(name: 'aspect_ratio')
String aspectRatio;

@JsonKey(name: 'badge')
String badge;

@JsonKey(name: 'bg_color')
String bgColor;

@JsonKey(name: 'bg_color_t')
String bgColorT;

@JsonKey(name: 'bg_img')
String bgImg;

@JsonKey(name: 'components')
List<WidgetModel> components;

@JsonKey(name: 'data')
String data;

@JsonKey(name: 'font_color')
String fontColor;

@JsonKey(name: 'icon')
String icon;

@JsonKey(name: 'img')
String img;

@JsonKey(name: 'is_global')
int isGlobal;

@JsonKey(name: 'margin')
String margin;

@JsonKey(name: 'mod_id')
class WidgetModel {
int modId;

@JsonKey(name: 'mod_name')
String modName;

@JsonKey(name: 'mod_pid')
int modPid;

@JsonKey(name: 'path')
String path;

@JsonKey(name: 'position')
String modName;
String position;

@JsonKey(name: 'sort')
int sort;

@JsonKey(name: 'subtitle')
String subtitle;

@JsonKey(name: 'title')
String skipIdentifier;
String title;

@JsonKey(name: 'url')
String subtitle;
String url;
String margin;
String aspectRatio;
String icon;
String img;
String fontColor;
String bgImg;
String bgColor;
String bgColorT;
String badge;
String path;
String data;
int sort;
int isGlobal;

WidgetModel(
this.aspectRatio,
this.badge,
this.bgColor,
this.bgColorT,
this.bgImg,
this.components,
this.data,
this.fontColor,
this.icon,
this.img,
this.isGlobal,
this.margin,
this.modId,
this.modName,
this.modPid,
this.path,
this.position,
this.sort,
this.subtitle,
this.title,
this.url,
);

factory WidgetModel.fromJson(Map<String, dynamic> srcJson) =>
_$WidgetModelFromJson(srcJson);

Map<String, dynamic> toJson() => _$WidgetModelToJson(this);

@override
List<Object> get props => [modId];

@override
bool get stringify => null;
{this.modId,
this.modPid,
this.modName,
this.position,
this.skipIdentifier,
this.title,
this.subtitle,
this.url,
this.margin,
this.aspectRatio,
this.icon,
this.img,
this.fontColor,
this.bgImg,
this.bgColor,
this.bgColorT,
this.badge,
this.path,
this.data,
this.sort,
this.isGlobal});

WidgetModel.fromJson(Map<String, dynamic> json) {
modId = json['mod_id'];
modPid = json['mod_pid'];
modName = json['mod_name'];
position = json['position'];
skipIdentifier = json['skip_identifier'];
title = json['title'];
subtitle = json['subtitle'];
url = json['url'];
margin = json['margin'];
aspectRatio = json['aspect_ratio'];
icon = json['icon'];
img = json['img'];
fontColor = json['font_color'];
bgImg = json['bg_img'];
bgColor = json['bg_color'];
bgColorT = json['bg_color_t'];
badge = json['badge'];
path = json['path'];
data = json['data'];
sort = json['sort'];
isGlobal = json['is_global'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['mod_id'] = this.modId;
data['mod_pid'] = this.modPid;
data['mod_name'] = this.modName;
data['position'] = this.position;
data['skip_identifier'] = this.skipIdentifier;
data['title'] = this.title;
data['subtitle'] = this.subtitle;
data['url'] = this.url;
data['margin'] = this.margin;
data['aspect_ratio'] = this.aspectRatio;
data['icon'] = this.icon;
data['img'] = this.img;
data['font_color'] = this.fontColor;
data['bg_img'] = this.bgImg;
data['bg_color'] = this.bgColor;
data['bg_color_t'] = this.bgColorT;
data['badge'] = this.badge;
data['path'] = this.path;
data['data'] = this.data;
data['sort'] = this.sort;
data['is_global'] = this.isGlobal;
return data;
}
}

+ 0
- 61
lib/models/base/widget_model.g.dart Bestand weergeven

@@ -1,61 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'widget_model.dart';

// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

WidgetModel _$WidgetModelFromJson(Map<String, dynamic> json) {
return WidgetModel(
json['aspect_ratio'] as String,
json['badge'] as String,
json['bg_color'] as String,
json['bg_color_t'] as String,
json['bg_img'] as String,
(json['components'] as List)
?.map((e) =>
e == null ? null : WidgetModel.fromJson(e as Map<String, dynamic>))
?.toList(),
json['data'] as String,
json['font_color'] as String,
json['icon'] as String,
json['img'] as String,
json['is_global'] as int,
json['margin'] as String,
json['mod_id'] is int ? json['mod_id'] as int : int.parse(json['mod_id']?.toString()),
json['mod_name'] as String,
json['mod_pid'] as int,
json['path'] as String,
json['position'] as String,
json['sort'] as int,
json['subtitle'] as String,
json['title'] as String,
json['url'] as String,
);
}

Map<String, dynamic> _$WidgetModelToJson(WidgetModel instance) =>
<String, dynamic>{
'aspect_ratio': instance.aspectRatio,
'badge': instance.badge,
'bg_color': instance.bgColor,
'bg_color_t': instance.bgColorT,
'bg_img': instance.bgImg,
'components': instance.components,
'data': instance.data,
'font_color': instance.fontColor,
'icon': instance.icon,
'img': instance.img,
'is_global': instance.isGlobal,
'margin': instance.margin,
'mod_id': instance.modId,
'mod_name': instance.modName,
'mod_pid': instance.modPid,
'path': instance.path,
'position': instance.position,
'sort': instance.sort,
'subtitle': instance.subtitle,
'title': instance.title,
'url': instance.url,
};

+ 23
- 7
lib/models/user/user_info_model_notifier.dart Bestand weergeven

@@ -13,14 +13,26 @@ class UserInfoNotifier with ChangeNotifier {
/// 用户信息
UserInfoModel _userInfo;

UserInfoModel get userInfo {
if (null == _userInfo) {
getUserInfoModel().then((user) {
if (user != null) notifyListeners();
});
}
return _userInfo;
}

/// 更新用户数据
void setUserInfo(UserInfoModel loginUser) async {
print('${loginUser.toString()}');
this._userInfo = loginUser;
// 缓存数据
await SharedPreferencesUtil.setStringValue(GlobalConfig.SHARED_KEY_TOKEN, loginUser.token);
await SharedPreferencesUtil.setStringValue(GlobalConfig.SHARED_KEY_MOBILE, loginUser.mobile);
await SharedPreferencesUtil.setStringValue(GlobalConfig.SHARED_KEY_USER_INFO, jsonEncode(loginUser.toJson()));
await SharedPreferencesUtil.setStringValue(
GlobalConfig.SHARED_KEY_TOKEN, loginUser.token);
await SharedPreferencesUtil.setStringValue(
GlobalConfig.SHARED_KEY_MOBILE, loginUser.mobile);
await SharedPreferencesUtil.setStringValue(
GlobalConfig.SHARED_KEY_USER_INFO, jsonEncode(loginUser.toJson()));
notifyListeners();
}

@@ -28,9 +40,12 @@ class UserInfoNotifier with ChangeNotifier {
void unLogin() async {
this._userInfo = null;
// 清除缓存数据
await SharedPreferencesUtil.setStringValue(GlobalConfig.SHARED_KEY_TOKEN, '');
await SharedPreferencesUtil.setStringValue(GlobalConfig.SHARED_KEY_MOBILE, '');
await SharedPreferencesUtil.setStringValue(GlobalConfig.SHARED_KEY_USER_INFO, '');
await SharedPreferencesUtil.setStringValue(
GlobalConfig.SHARED_KEY_TOKEN, '');
await SharedPreferencesUtil.setStringValue(
GlobalConfig.SHARED_KEY_MOBILE, '');
await SharedPreferencesUtil.setStringValue(
GlobalConfig.SHARED_KEY_USER_INFO, '');
notifyListeners();
}

@@ -40,7 +55,8 @@ class UserInfoNotifier with ChangeNotifier {
return _userInfo;
}
try {
String userInfoJson = await SharedPreferencesUtil.getStringValue(GlobalConfig.SHARED_KEY_USER_INFO);
String userInfoJson = await SharedPreferencesUtil.getStringValue(
GlobalConfig.SHARED_KEY_USER_INFO);
_userInfo = UserInfoModel.fromJson(jsonDecode(userInfoJson));
} catch (e) {
Logger.log(e);


+ 11
- 11
lib/pages/login_page/login_page.dart Bestand weergeven

@@ -1,3 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
@@ -5,7 +6,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:zhiying_comm/pages/login_page/account/login_account_page.dart';
import 'package:zhiying_comm/util/empty_util.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:cached_network_image/cached_network_image.dart';

import 'bloc/bloc.dart';
import 'bloc/login_repository.dart';
@@ -16,9 +16,8 @@ import 'model/login_model.dart';
/// 登陆页面
///
class LoginPage extends StatelessWidget {
final Map<String, dynamic> data;

const LoginPage(this.data, {Key key}) : super(key: key);
const LoginPage({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
@@ -44,7 +43,7 @@ class _LoginPageContainerState extends State<LoginPageContainer> {
print('登陆$type');
if(type == 'mobile'){
Navigator.push(context, MaterialPageRoute(
builder: (_) => LoginAccountPage(null)
builder: (_) => LoginAccountPage(null)
));
}
}
@@ -109,6 +108,7 @@ class _LoginPageContainerState extends State<LoginPageContainer> {
Widget _getMainWidget(LoginModel model) {
return Column(
children: <Widget>[

/// 头部
_headWidget(model),
_sizedHeight50,
@@ -206,13 +206,13 @@ class _LoginPageContainerState extends State<LoginPageContainer> {

/// 协议
Widget _protocolWidget(LoginModel model) {
return RichText(
text: TextSpan(text: '', children: model.main.agreements.map((item){
return TextSpan(text: item?.text, style: TextStyle(color: HexColor.fromHex(item?.textColor), fontSize: 10),recognizer: TapGestureRecognizer()..onTap = (){
_jumpUserAgreement(item?.url);
});
}).toList()),
);
return RichText(
text: TextSpan(text: '', children: model.main.agreements.map((item){
return TextSpan(text: item?.text, style: TextStyle(color: HexColor.fromHex(item?.textColor), fontSize: 10),recognizer: TapGestureRecognizer()..onTap = (){
_jumpUserAgreement(item?.url);
});
}).toList()),
);
}

/// 其它登陆方式


+ 2
- 2
lib/util/extension/color.dart Bestand weergeven

@@ -7,8 +7,8 @@
* @FilePath: /hairuyi_flutter_yunfadan/lib/utils/color.dart
*/

import 'dart:ui';
import 'dart:math';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:zhiying_comm/util/log/let_log.dart';
@@ -20,7 +20,7 @@ extension HexColor on Color {
final buffer = StringBuffer();
if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
buffer.write(hexString.replaceFirst('#', ''));
return Color(int.parse(buffer.toString(), radix: 16));
return Color(int.tryParse(buffer.toString(), radix: 16));
}catch(e){
Logger.log(e);
}


+ 15
- 16
lib/util/router_util.dart Bestand weergeven

@@ -1,24 +1,22 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:zhiying_comm/pages/login_page/login_page.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:provider/provider.dart';

class RouterUtil {
static Future route(Map<String, dynamic> model, BuildContext context) async {
// 唯一跳转标识
String skipIdentifier = model['skip_identifier']?.toString();
// 需要登录
String requiredLogin = model['required_login']?.toString();
// 需要淘宝授权
String requiredTaobaoAuth = model['required_taobao_auth']?.toString();

if (skipIdentifier == null || skipIdentifier == '') {
/*公共跳转
* skipModel 跳转参数
* data 额外参数
* */
static Future route(SkipModel skipModel, Map<String, dynamic> data,
BuildContext context) async {
if (skipModel.skipIdentifier == null || skipModel.skipIdentifier == '') {
print('skipIdentifier 参数不存在,无法跳转页面');
return Future.error('skipIdentifier 参数不存在,无法跳转页面');
}
print('skipIdentifier: ${skipIdentifier}');
print('skipIdentifier: ${skipModel.skipIdentifier}');

if (requiredLogin == '1') {
if (skipModel?.requiredLogin == '1') {
UserInfoModel user =
await Provider.of<UserInfoNotifier>(context, listen: false)
.getUserInfoModel();
@@ -27,18 +25,19 @@ class RouterUtil {
print('need login...');
return Navigator.of(context)
.push(MaterialPageRoute(builder: (BuildContext context) {
return LoginPage(model);
return LoginPage();
}));
}
}

Widget page = EmptyPage();
if (PageFactory.hasRegisted(skipIdentifier)) {
page = PageFactory.create(skipIdentifier, model);
if (PageFactory.hasRegisted(skipModel.skipIdentifier)) {
page = PageFactory.create(skipModel.skipIdentifier, data);
} else {
Api api = Api('/api/v1/mod/${skipIdentifier.toString()}',
Api api = Api('/api/v1/mod/${skipModel.skipIdentifier.toString()}',
method: NetMethod.GET);
var result = await api.onRequest();
Logger.debug(result);
page = PageFactory.create('index', Map<String, dynamic>.from(result));
}
return Navigator.of(context)


+ 6
- 6
lib/util/shared_prefe_util.dart Bestand weergeven

@@ -30,13 +30,13 @@ class SharedPreferencesUtil {
}

static Future<bool> setStringValue(String key, String value) async {
if (!EmptyUtil.isEmpty(key) && !EmptyUtil.isEmpty(value)) {
Logger.log('key = ${key}, value = $value');
SharedPreferences prefs = await SharedPreferences.getInstance();
if (null != prefs) {
return prefs.setString(key, value);
}
// if (!EmptyUtil.isEmpty(key) && !EmptyUtil.isEmpty(value)) {
Logger.log('key = ${key}, value = $value');
SharedPreferences prefs = await SharedPreferences.getInstance();
if (null != prefs) {
return prefs.setString(key, value);
}
// }
return false;
}



+ 0
- 2
pubspec.yaml Bestand weergeven

@@ -21,8 +21,6 @@ dependencies:
# 图片缓存
cached_network_image: ^2.2.0+1
equatable: ^1.2.0
json_serializable: ^3.3.0
build_runner: ^1.10.0
# 屏幕适配
flutter_screenutil: ^1.1.0
# 缓存


||||||
x
 
000:0
Laden…
Annuleren
Opslaan