Browse Source

1.更新版本、请求头获取方式

tags/0.0.12+5
“yanghuaxuan” 3 years ago
parent
commit
ebd3a34a74
3 changed files with 35 additions and 46 deletions
  1. +7
    -7
      example/ios/Podfile.lock
  2. +27
    -38
      lib/util/net_util.dart
  3. +1
    -1
      pubspec.yaml

+ 7
- 7
example/ios/Podfile.lock View File

@@ -19,6 +19,8 @@ PODS:
- securityGuard (= 5.4.191) - securityGuard (= 5.4.191)
- UTDID (= 1.1.0.16) - UTDID (= 1.1.0.16)
- WindVane (= 8.5.0.46-bc11) - WindVane (= 8.5.0.46-bc11)
- flutter_clipboard_plugin (0.0.1):
- Flutter
- flutter_native_image (0.0.1): - flutter_native_image (0.0.1):
- Flutter - Flutter
- flutter_xupdate (0.0.1): - flutter_xupdate (0.0.1):
@@ -31,8 +33,6 @@ PODS:
- FMDB (2.7.5): - FMDB (2.7.5):
- FMDB/standard (= 2.7.5) - FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5) - FMDB/standard (2.7.5)
- imei_plugin (0.0.1):
- Flutter
- jdsdk (0.0.1): - jdsdk (0.0.1):
- Flutter - Flutter
- mob_linksdk_pro (3.3.7): - mob_linksdk_pro (3.3.7):
@@ -175,11 +175,11 @@ DEPENDENCIES:
- device_info (from `.symlinks/plugins/device_info/ios`) - device_info (from `.symlinks/plugins/device_info/ios`)
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- flutter_alibc (from `.symlinks/plugins/flutter_alibc/ios`) - flutter_alibc (from `.symlinks/plugins/flutter_alibc/ios`)
- flutter_clipboard_plugin (from `.symlinks/plugins/flutter_clipboard_plugin/ios`)
- flutter_native_image (from `.symlinks/plugins/flutter_native_image/ios`) - flutter_native_image (from `.symlinks/plugins/flutter_native_image/ios`)
- flutter_xupdate (from `.symlinks/plugins/flutter_xupdate/ios`) - flutter_xupdate (from `.symlinks/plugins/flutter_xupdate/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- fluwx (from `.symlinks/plugins/fluwx/ios`) - fluwx (from `.symlinks/plugins/fluwx/ios`)
- imei_plugin (from `.symlinks/plugins/imei_plugin/ios`)
- jdsdk (from `.symlinks/plugins/jdsdk/ios`) - jdsdk (from `.symlinks/plugins/jdsdk/ios`)
- moblink (from `.symlinks/plugins/moblink/ios`) - moblink (from `.symlinks/plugins/moblink/ios`)
- mobsms (from `.symlinks/plugins/mobsms/ios`) - mobsms (from `.symlinks/plugins/mobsms/ios`)
@@ -235,6 +235,8 @@ EXTERNAL SOURCES:
:path: Flutter :path: Flutter
flutter_alibc: flutter_alibc:
:path: ".symlinks/plugins/flutter_alibc/ios" :path: ".symlinks/plugins/flutter_alibc/ios"
flutter_clipboard_plugin:
:path: ".symlinks/plugins/flutter_clipboard_plugin/ios"
flutter_native_image: flutter_native_image:
:path: ".symlinks/plugins/flutter_native_image/ios" :path: ".symlinks/plugins/flutter_native_image/ios"
flutter_xupdate: flutter_xupdate:
@@ -243,8 +245,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/fluttertoast/ios" :path: ".symlinks/plugins/fluttertoast/ios"
fluwx: fluwx:
:path: ".symlinks/plugins/fluwx/ios" :path: ".symlinks/plugins/fluwx/ios"
imei_plugin:
:path: ".symlinks/plugins/imei_plugin/ios"
jdsdk: jdsdk:
:path: ".symlinks/plugins/jdsdk/ios" :path: ".symlinks/plugins/jdsdk/ios"
moblink: moblink:
@@ -307,12 +307,12 @@ SPEC CHECKSUMS:
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175 device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_alibc: 0e2a29e7c1de759672d87a260051240d209964b9 flutter_alibc: 0e2a29e7c1de759672d87a260051240d209964b9
flutter_clipboard_plugin: b4f4432820ed598732eb18f6daa68a3ef26f711f
flutter_native_image: 9c0b7451838484458e5b0fae007b86a4c2d4bdfe flutter_native_image: 9c0b7451838484458e5b0fae007b86a4c2d4bdfe
flutter_xupdate: bdb588f0fe4f6c5e45436b8b0de08d505a50c04e flutter_xupdate: bdb588f0fe4f6c5e45436b8b0de08d505a50c04e
fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b
fluwx: 8d47bee15c7fed07b94c2a12fb2381677232431a
fluwx: 07a55ed66bf3a4961e836a2a411b02dcada32902
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
imei_plugin: cb1af7c223ac2d82dcd1457a7137d93d65d2a3cd
jdsdk: 2ca38c7e3a2dfb0f3641425f8fd1e8d20357693f jdsdk: 2ca38c7e3a2dfb0f3641425f8fd1e8d20357693f
mob_linksdk_pro: 9ad768d8da15c410d51056319f43a76c7cc01347 mob_linksdk_pro: 9ad768d8da15c410d51056319f43a76c7cc01347
mob_secverify: 08a42250544a6bbb6cab5e78504494aa0b40200c mob_secverify: 08a42250544a6bbb6cab5e78504494aa0b40200c


+ 27
- 38
lib/util/net_util.dart View File

@@ -105,31 +105,7 @@ class NetUtil {
// post请求的参数 // post请求的参数
Map<String, dynamic> bodyParams = params; Map<String, dynamic> bodyParams = params;


///只拿一次头部数据
if (NetUtil.headParam == null) {
NetUtil.headParam = await _getMustHeadParams();
}

// token 读取SP缓存中的用户token
String token = await SharedPreferencesUtil.getStringValue(GlobalConfig.SHARED_KEY_TOKEN);

if (EmptyUtil.isEmpty(token) && !bool.fromEnvironment("dart.vm.product")) {
try {
Map setting = await NativeUtil.getSetting();
token = setting['token'];
} catch (e, s) {
print(s);
print(e);
}
}
if (!EmptyUtil.isEmpty(token)) {
// params['token'] = token;
NetUtil.headParam['Authorization'] = 'Bearer ' + token;
}

if (NetUtil.headParam['token'] == null) {}
// 请求头参数
Map<String, dynamic> headParam = NetUtil.headParam;
NetUtil.headParam = await _getMustHeadParams();


Response response; Response response;
try { try {
@@ -354,16 +330,29 @@ class NetUtil {
// return params; // return params;
// } // }



static PackageInfo packageInfo;
static Map setting;
static IosDeviceInfo iosInfo;
static AndroidDeviceInfo androidInfo;
static String imei;
/// 获取必须的请求参数(用于请求头部) /// 获取必须的请求参数(用于请求头部)
static Future<Map<String, String>> _getMustHeadParams() async { static Future<Map<String, String>> _getMustHeadParams() async {

Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
// 应用信息 // 应用信息
PackageInfo packageInfo = await PackageInfo.fromPlatform();
if(packageInfo==null){
packageInfo = await PackageInfo.fromPlatform();
}
// 原生传的信息 // 原生传的信息
Map setting = await NativeUtil.getSetting();
if(setting==null){
setting = await NativeUtil.getSetting();
}


if (Platform.isIOS) { if (Platform.isIOS) {
IosDeviceInfo iosInfo = await DeviceInfoPlugin().iosInfo;
if(iosInfo==null){
iosInfo = await DeviceInfoPlugin().iosInfo;
}
// 设备 // 设备
params["platform"] = "ios"; params["platform"] = "ios";
// 设备系统版本 // 设备系统版本
@@ -377,7 +366,9 @@ class NetUtil {
// idfa // idfa
params['idfa'] = iosInfo?.identifierForVendor?.toString(); params['idfa'] = iosInfo?.identifierForVendor?.toString();
} else if (Platform.isAndroid) { } else if (Platform.isAndroid) {
AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
if(androidInfo==null){
androidInfo = await DeviceInfoPlugin().androidInfo;
}
// 设备 // 设备
params["platform"] = "android"; params["platform"] = "android";
// 设备系统版本 // 设备系统版本
@@ -422,6 +413,13 @@ class NetUtil {
// 当前时间戳:秒 // 当前时间戳:秒
params["time"] = TimeUtil.getNowTime(); params["time"] = TimeUtil.getNowTime();


if (imei==null) {
imei = await _getImei();
print("获取到udid"+(imei??""));
}else{
params['imei']=imei;
}

// 过滤空字段,过滤首尾空格 // 过滤空字段,过滤首尾空格
Map<String, String> filters = Map<String, String>(); Map<String, String> filters = Map<String, String>();
params.forEach((key, value) { params.forEach((key, value) {
@@ -561,15 +559,6 @@ class NetUtil {
} }
} }


static void getImei() async {
if (!NetUtil.headParam.containsKey('imei')) {
String imei = await _getImei();
print("获取到udid"+imei??"");
if (imei != null) {
NetUtil.headParam['imei'] = imei;
}
}
}
} }


/** /**


+ 1
- 1
pubspec.yaml View File

@@ -43,7 +43,7 @@ dependencies:
flutter_alibc: flutter_alibc:
# path: ../zhiying_flutter_alibc # path: ../zhiying_flutter_alibc
git: git:
ref: 0.0.11
ref: 0.0.12
url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_flutter_alibc.git url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_flutter_alibc.git
url_launcher: ^5.6.0 url_launcher: ^5.6.0
#图片预览控件 #图片预览控件


Loading…
Cancel
Save