main
parent
60b6f780d2
commit
b920194baa
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, dynamic>? data, resultDialogConfig, bool isCancelWhiteList = false]) async {
|
||||
Future post(String url, [Map<String, dynamic>? data,Map<String,String>? 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) {
|
||||
|
|
10
pubspec.lock
10
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"
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue