diff --git a/lib/api/login_api.dart b/lib/api/login_api.dart index b33f913..b06e241 100644 --- a/lib/api/login_api.dart +++ b/lib/api/login_api.dart @@ -14,8 +14,8 @@ class LoginApi { "wx_openid": openid, "wx_unionid": unionid }; - var headers = {'Content-Type': 'x-www-form-urlencoded'}; - var post = await xHttp.post("/v2/auth/get-access-token", data); + var headers = {'Content-Type': 'application/x-www-form-urlencoded'}; + var post = await xHttp.post("/v2/auth/get-access-token", data, headers); // print(post); } } diff --git a/lib/util/xhttp.dart b/lib/util/xhttp.dart index a3e8dd7..8022aca 100644 --- a/lib/util/xhttp.dart +++ b/lib/util/xhttp.dart @@ -1,4 +1,7 @@ import 'dart:convert'; +import 'package:autosos_flutter/config/constant.dart'; +import 'package:autosos_flutter/util/device_id_utils.dart'; +import 'package:basic_utils/basic_utils.dart'; import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; @@ -51,6 +54,8 @@ class XHttp { // responseType: , headers: { 'Content-Type': 'application/json', + 'deviceid':DeviceIdUtils.getDeviceId(), + 'appver':Constant.newVersion }, connectTimeout: const Duration(milliseconds: CONNECT_TIMEOUT), receiveTimeout: const Duration(milliseconds: RECEIVE_TIMEOUT), @@ -370,7 +375,7 @@ class XHttp { } /// post 请求 - Future post(String url, [Map? data, resultDialogConfig, bool isCancelWhiteList = false]) async { + Future post(String url, [Map? data,Map? headers, resultDialogConfig, bool isCancelWhiteList = false]) async { // 可转为使用 request 代替,简化代码。 Response response; CancelToken requestToken = CancelToken(); @@ -382,6 +387,11 @@ class XHttp { } } try { + if(headers!=null) { + headers.forEach((key, value) { + dio.options.headers[key]=value; + }); + } response = await dio.post(url, data: data, cancelToken: requestToken); return response.data; } catch (e) { diff --git a/pubspec.lock b/pubspec.lock index 2d21620..fba33f5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -200,6 +200,14 @@ packages: description: flutter source: sdk version: "0.0.0" + getuiflut: + dependency: "direct main" + description: + name: getuiflut + sha256: "6bf5ac61fd92ef908455a23bc84e50946dd7316846706493b6638988b9d36d9e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.25" http: dependency: transitive description: @@ -510,5 +518,5 @@ packages: source: hosted version: "1.0.4" sdks: - dart: ">=3.2.6 <4.0.0" + dart: ">=3.2.0 <=3.2.3" flutter: ">=3.16.0" diff --git a/pubspec.yaml b/pubspec.yaml index f5459d9..7c1f9b0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.2.6 <4.0.0' + sdk: '>=3.0.0 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -39,6 +39,7 @@ dependencies: basic_utils: ^5.7.0 uuid: ^4.3.3 device_info_plus: ^9.1.2 + getuiflut: ^0.2.25 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.