Browse Source

1.每次请求都更新meui

tags/0.0.12+6
“yanghuaxuan” 3 years ago
parent
commit
daa079e1da
1 changed files with 14 additions and 19 deletions
  1. +14
    -19
      lib/util/net_util.dart

+ 14
- 19
lib/util/net_util.dart View File

@@ -330,27 +330,26 @@ class NetUtil {
// return params;
// }

static PackageInfo packageInfo;
static Map setting;
static IosDeviceInfo iosInfo;
static AndroidDeviceInfo androidInfo;
static String imei;

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

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

if (Platform.isIOS) {
if(iosInfo==null){
if (iosInfo == null) {
iosInfo = await DeviceInfoPlugin().iosInfo;
}
// 设备
@@ -366,7 +365,7 @@ class NetUtil {
// idfa
params['idfa'] = iosInfo?.identifierForVendor?.toString();
} else if (Platform.isAndroid) {
if(androidInfo==null){
if (androidInfo == null) {
androidInfo = await DeviceInfoPlugin().androidInfo;
}
// 设备
@@ -413,12 +412,9 @@ class NetUtil {
// 当前时间戳:秒
params["time"] = TimeUtil.getNowTime();

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

// 过滤空字段,过滤首尾空格
Map<String, String> filters = Map<String, String>();
@@ -440,9 +436,9 @@ class NetUtil {
}

/// 获取Android imei
static Future<String> _getImei() async {
static Future<String> getImei() async {
try {
return await FlutterAlibc.getUdid();
return await FlutterAlibc.getUdid();
} catch (e, s) {
Logger.error(e, s);
}
@@ -558,7 +554,6 @@ class NetUtil {
Logger.error('未知错误: ${e.toString()}');
}
}

}

/**


Loading…
Cancel
Save