From 7fe9b39e84afee718b266c0f7e48a8e3913d243c Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Wed, 30 Sep 2020 14:01:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=AC=E5=85=B1=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/ios/Runner/Info.plist | 14 ++++++++++++++ lib/util/router_util.dart | 24 ++++++++++++++++++++---- lib/util/taobao/taobao_auth.dart | 15 ++++++--------- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 53fab93..bb21462 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -211,5 +211,19 @@ io.flutter.embedded_views_preview YES + NSCameraUsageDescription + 获取相机权限更换头像或者扫码 + NSContactsUsageDescription + 获取访问通信录权限添加联系人信息 + NSLocationAlwaysUsageDescription + 获取定位权限用于搜索附近的网点和查找附近的油站信息 + NSLocationWhenInUseUsageDescription + 获取定位权限用于搜索附近的网点和查找附近的油站信息 + NSMicrophoneUsageDescription + 获取访问麦克风权限录制语音或视频 + NSPhotoLibraryAddUsageDescription + 获取访问相册权限更换头像 + NSPhotoLibraryUsageDescription + 获取访问相册权限更换头像 diff --git a/lib/util/router_util.dart b/lib/util/router_util.dart index 546cad2..22cd41e 100644 --- a/lib/util/router_util.dart +++ b/lib/util/router_util.dart @@ -23,10 +23,7 @@ class RouterUtil { print(user.toString()); if (user?.token == null || user.token == '') { print('need login...'); - return Navigator.of(context) - .push(MaterialPageRoute(builder: (BuildContext context) { - return LoginPage(); - })); + RouterUtil.goLogin(context); } } @@ -45,4 +42,23 @@ class RouterUtil { return page; })); } + + // 跳转登录 + static Future goLogin(BuildContext context) { + return Navigator.of(context) + .push(MaterialPageRoute(builder: (BuildContext context) { + return LoginPage(); + })); + } + + static Future openWebview(String url, BuildContext context) { + if (url == null || url == '') { + Logger.error('跳转链接不能为空'); + return Future.error('跳转链接不能为空'); + } + SkipModel model = SkipModel(); + model.skipIdentifier = 'pub.flutter.url'; + model.url = url; + RouterUtil.route(model, null, context); + } } diff --git a/lib/util/taobao/taobao_auth.dart b/lib/util/taobao/taobao_auth.dart index a06ad54..5eeed23 100644 --- a/lib/util/taobao/taobao_auth.dart +++ b/lib/util/taobao/taobao_auth.dart @@ -13,15 +13,12 @@ class TaobaoAuth { return TaobaoAuthAlert(); }); if (isConfirm != null && isConfirm == true) { - Map data = - await NetUtil.post('/api/v1/taobao/auth', method: NetMethod.GET); - - TradeResult result = await FlutterAlibc.openByUrl( - url: - 'https://uland.taobao.com/coupon/edetail?e=3HzI2W1Beb8GQASttHIRqXnNjWpDy9mhXwL7S63FIwYKZE0HebgG45okpD6aY36atPRANf7tQQAMfuX5VbbjJDEhJpUUrcnYl02IO45oPAVVa4HVocdYY3Y9x3IctcCWLspxGy3zBjY8IeN8lvhRA2lzrR4%2BfrcbCbBkjRdlgvJ932VMXbyLuXFtBQJOD%2BAi1xjdOwSZLqE%3D&traceId=0bb623e116004208111058861eea6c&relationId=528397833&union_lens=lensId:TAPI@1600420811@0b8fdc87_0dbb_174a0839173_b4fc@01&relationId=528397833'); -// TradeResult result = await FlutterAlibc.openByUrl( -// url: -// 'http://www.izhim.com/comm/tb_callback.php?_ctrl=domain&domain_return_url=aHR0cDovL3d3dy5oYWlydXlpLmNvbS9jb21tL3RicmVkaXJlY3QucGhwP3RyYWNrX2lkPQ%3D%3D&domain_state=r_NTEwMw'); + Map data = Map.from( + await NetUtil.post('/api/v1/taobao/auth', method: NetMethod.GET)); + Logger.debug(data); + String url = data['data']['redirect_url']; + TradeResult result = await FlutterAlibc.openByUrl(url: url); + // TradeResult result = await FlutterAlibc.openByUrl(url: ''); Logger.debug('${result.errorCode} ${result.errorMessage} '); } }