main
zhuce 2024-03-09 19:13:10 +08:00
parent 60b6f780d2
commit b920194baa
4 changed files with 24 additions and 5 deletions

View File

@ -14,8 +14,8 @@ class LoginApi {
"wx_openid": openid, "wx_openid": openid,
"wx_unionid": unionid "wx_unionid": unionid
}; };
var headers = {'Content-Type': 'x-www-form-urlencoded'}; var headers = {'Content-Type': 'application/x-www-form-urlencoded'};
var post = await xHttp.post("/v2/auth/get-access-token", data); var post = await xHttp.post("/v2/auth/get-access-token", data, headers);
// print(post); // print(post);
} }
} }

View File

@ -1,4 +1,7 @@
import 'dart:convert'; 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:dio/dio.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
@ -51,6 +54,8 @@ class XHttp {
// responseType: , // responseType: ,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'deviceid':DeviceIdUtils.getDeviceId(),
'appver':Constant.newVersion
}, },
connectTimeout: const Duration(milliseconds: CONNECT_TIMEOUT), connectTimeout: const Duration(milliseconds: CONNECT_TIMEOUT),
receiveTimeout: const Duration(milliseconds: RECEIVE_TIMEOUT), receiveTimeout: const Duration(milliseconds: RECEIVE_TIMEOUT),
@ -370,7 +375,7 @@ class XHttp {
} }
/// post /// 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 // 使 request
Response response; Response response;
CancelToken requestToken = CancelToken(); CancelToken requestToken = CancelToken();
@ -382,6 +387,11 @@ class XHttp {
} }
} }
try { try {
if(headers!=null) {
headers.forEach((key, value) {
dio.options.headers[key]=value;
});
}
response = await dio.post(url, data: data, cancelToken: requestToken); response = await dio.post(url, data: data, cancelToken: requestToken);
return response.data; return response.data;
} catch (e) { } catch (e) {

View File

@ -200,6 +200,14 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" 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: http:
dependency: transitive dependency: transitive
description: description:
@ -510,5 +518,5 @@ packages:
source: hosted source: hosted
version: "1.0.4" version: "1.0.4"
sdks: sdks:
dart: ">=3.2.6 <4.0.0" dart: ">=3.2.0 <=3.2.3"
flutter: ">=3.16.0" flutter: ">=3.16.0"

View File

@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1 version: 1.0.0+1
environment: 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. # Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions # To automatically upgrade your package dependencies to the latest versions
@ -39,6 +39,7 @@ dependencies:
basic_utils: ^5.7.0 basic_utils: ^5.7.0
uuid: ^4.3.3 uuid: ^4.3.3
device_info_plus: ^9.1.2 device_info_plus: ^9.1.2
getuiflut: ^0.2.25
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.