Ver código fonte

添加公共方法

tags/0.0.1
Weller 4 anos atrás
pai
commit
7fe9b39e84
3 arquivos alterados com 40 adições e 13 exclusões
  1. +14
    -0
      example/ios/Runner/Info.plist
  2. +20
    -4
      lib/util/router_util.dart
  3. +6
    -9
      lib/util/taobao/taobao_auth.dart

+ 14
- 0
example/ios/Runner/Info.plist Ver arquivo

@@ -211,5 +211,19 @@
<false/>
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
<key>NSCameraUsageDescription</key>
<string>获取相机权限更换头像或者扫码</string>
<key>NSContactsUsageDescription</key>
<string>获取访问通信录权限添加联系人信息</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>获取定位权限用于搜索附近的网点和查找附近的油站信息</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>获取定位权限用于搜索附近的网点和查找附近的油站信息</string>
<key>NSMicrophoneUsageDescription</key>
<string>获取访问麦克风权限录制语音或视频</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>获取访问相册权限更换头像</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>获取访问相册权限更换头像</string>
</dict>
</plist>

+ 20
- 4
lib/util/router_util.dart Ver arquivo

@@ -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);
}
}

+ 6
- 9
lib/util/taobao/taobao_auth.dart Ver arquivo

@@ -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<String, dynamic> data = Map<String, dynamic>.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} ');
}
}


Carregando…
Cancelar
Salvar