From 82b326198a0e56a75a60fd048c415857ae549277 Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Fri, 23 Oct 2020 17:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dart_tool/package_config.json | 2 +- example/lib/main.dart | 26 +++++++++---------- lib/models/user/user_info_model_notifier.dart | 16 +++++++++--- lib/util/taobao/taobao_auth.dart | 3 +-- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index b1c50c6..7e95283 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -482,7 +482,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-10-15T08:13:11.544762Z", + "generated": "2020-10-17T07:39:42.872292Z", "generator": "pub", "generatorVersion": "2.8.2" } diff --git a/example/lib/main.dart b/example/lib/main.dart index a0df0ec..1d3f2b9 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -158,19 +158,19 @@ class HomePage extends StatelessWidget { ), RaisedButton( onPressed: () async { - String detailUrl = 'http://www.hairuyi.com/?mod=appapi&act=gotojingdong&gid=60291609161&yhq_url=http%3A%2F%2Fcoupon.m.jd.com%2Fcoupons%2Fshow.action%3Fkey%3Dd97e1472a8a24c39a9463dbe72b3fa32%26roleId%3D38088450%26to%3Ditem.jd.com%2F60291609161.html'; - String baseUrl = detailUrl.getBaseUrl(); - if (!baseUrl.contains('jd.com')) { - Dio dio = Dio(); - var responds = await dio.get(detailUrl); - detailUrl = responds.realUri.toString(); - } - Logger.debug(detailUrl); - Jdsdk.openUrl( - url - : - detailUrl - ); + // String detailUrl = 'http://www.hairuyi.com/?mod=appapi&act=gotojingdong&gid=60291609161&yhq_url=http%3A%2F%2Fcoupon.m.jd.com%2Fcoupons%2Fshow.action%3Fkey%3Dd97e1472a8a24c39a9463dbe72b3fa32%26roleId%3D38088450%26to%3Ditem.jd.com%2F60291609161.html'; + // String baseUrl = detailUrl.getBaseUrl(); + // if (!baseUrl.contains('jd.com')) { + // Dio dio = Dio(); + // var responds = await dio.get(detailUrl); + // detailUrl = responds.realUri.toString(); + // } + // Logger.debug(detailUrl); + // Jdsdk.openUrl( + // url + // : + // detailUrl + // ); }, child: Text('嗨如意转链打开京东'), ), diff --git a/lib/models/user/user_info_model_notifier.dart b/lib/models/user/user_info_model_notifier.dart index f0cffef..0d4dabe 100644 --- a/lib/models/user/user_info_model_notifier.dart +++ b/lib/models/user/user_info_model_notifier.dart @@ -11,7 +11,11 @@ import 'package:zhiying_comm/util/shared_prefe_util.dart'; /// class UserInfoNotifier with ChangeNotifier { /// 用户信息 - UserInfoModel _userInfo; + static UserInfoModel _userInfo; + + static UserInfoModel get staitcUserInfo { + return _userInfo; + } UserInfoModel get userInfo { if (null == _userInfo) { @@ -28,7 +32,7 @@ class UserInfoNotifier with ChangeNotifier { /// 更新用户数据 void setUserInfo(UserInfoModel loginUser) async { print('${loginUser.toString()}'); - this._userInfo = loginUser; + _userInfo = loginUser; // 缓存数据 await SharedPreferencesUtil.setStringValue( GlobalConfig.SHARED_KEY_TOKEN, loginUser.token); @@ -41,7 +45,7 @@ class UserInfoNotifier with ChangeNotifier { /// 退出登陆 void unLogin() async { - this._userInfo = null; + _userInfo = null; // 清除缓存数据 await SharedPreferencesUtil.setStringValue( GlobalConfig.SHARED_KEY_TOKEN, ''); @@ -60,7 +64,11 @@ class UserInfoNotifier with ChangeNotifier { try { String userInfoJson = await SharedPreferencesUtil.getStringValue( GlobalConfig.SHARED_KEY_USER_INFO); - _userInfo = UserInfoModel.fromJson(jsonDecode(userInfoJson)); + if (userInfoJson == null || userInfoJson == '') { + _userInfo = UserInfoModel(); + } else { + _userInfo = UserInfoModel.fromJson(jsonDecode(userInfoJson)); + } } catch (e) { Logger.log(e); } diff --git a/lib/util/taobao/taobao_auth.dart b/lib/util/taobao/taobao_auth.dart index 429f515..72f8751 100644 --- a/lib/util/taobao/taobao_auth.dart +++ b/lib/util/taobao/taobao_auth.dart @@ -40,8 +40,7 @@ class TaobaoAuth { // TradeResult result = await FlutterAlibc.openByUrl(url: ''); Logger.debug('${result.errorCode} ${result.errorMessage} '); } else if (Platform.isIOS) { - TradeResult result = - await FlutterAlibc.openByUrl(url: url, backUrl: "alisdk://"); + TradeResult result = await FlutterAlibc.openByUrl(url: url); // TradeResult result = await FlutterAlibc.openByUrl(url: ''); Logger.debug('${result.errorCode} ${result.errorMessage} '); }