更新样式
This commit is contained in:
46
lib/controller/home/Dio.dart
Normal file
46
lib/controller/home/Dio.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/controller/login/login_controller.dart';
|
||||
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
|
||||
class ApiService {
|
||||
static Dio dio = Dio();
|
||||
|
||||
static Dio request = Dio();
|
||||
static Dio requestNoInfo = Dio();
|
||||
static Dio requestNoError = Dio(); //不处理错误的请求,用于设备操作上报
|
||||
|
||||
static Dio reservation = Dio();
|
||||
|
||||
static void init() {
|
||||
|
||||
reservationInit();
|
||||
}
|
||||
|
||||
static void reservationInit() {
|
||||
reservation.options.baseUrl = "https://crm-api.swes.com.cn";
|
||||
reservation.options.connectTimeout = const Duration(seconds: 15);
|
||||
reservation.options.receiveTimeout = const Duration(seconds: 10);
|
||||
reservation.options.sendTimeout = const Duration(seconds: 10);
|
||||
reservation.interceptors.add(InterceptorsWrapper(
|
||||
onRequest: (options, handler) {
|
||||
print("---> ${options.method}, ${options.path}, ${options.data}");
|
||||
options.headers['token'] =
|
||||
"bMAQVR1x48t66u8EDYSftAJGo17r0rIB3z15JgyyoGz1rAEZHs1htHOCorYFJ2RT";
|
||||
return handler.next(options);
|
||||
},
|
||||
onResponse: (response, ResponseInterceptorHandler handler) {
|
||||
print("<--- ${response.statusCode} ${response.data}");
|
||||
return handler.next(response);
|
||||
},
|
||||
onError: (e, handler) {
|
||||
// 错误处理,例如打印错误信息
|
||||
showToast("网络异常或服务连接异常,请稍候再试", color: color_error);
|
||||
print("DioError: $e");
|
||||
return handler.reject(e);
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user