台桌列表页面
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import 'package:cashier_reserve/common/push/push.dart';
|
||||
import 'package:cashier_reserve/datas/login/login_result.dart';
|
||||
import 'package:cashier_reserve/data_model/login/login_result.dart';
|
||||
import 'package:cashier_reserve/login/login_view.dart';
|
||||
|
||||
import '../base/ui.dart';
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:cashier_reserve/common/manager/app_manager.dart';
|
||||
import 'package:cashier_reserve/common/manager/hive_manager.dart';
|
||||
import 'package:cashier_reserve/common/print/print.dart';
|
||||
@@ -10,22 +12,30 @@ const String kBaseUrl = 'https://admintestpapi.sxczgkj.cn';
|
||||
const kSuccessCode = 200;
|
||||
const kNeedLoginCode = 401;
|
||||
|
||||
class RequestManager {
|
||||
const Map<String, dynamic> _emptyMap = {};
|
||||
|
||||
class RequestManager {
|
||||
/// HttpClient
|
||||
static final Dio _c = Dio(BaseOptions(
|
||||
baseUrl: kBaseUrl,
|
||||
baseUrl: kBaseUrl,
|
||||
connectTimeout: const Duration(milliseconds: 5000),
|
||||
receiveTimeout: const Duration(milliseconds: 5000)
|
||||
));
|
||||
receiveTimeout: const Duration(milliseconds: 5000)));
|
||||
|
||||
/// GET
|
||||
static Future<dynamic> get(String url, {bool catchError = true}) {
|
||||
static Future<dynamic> get(String url,
|
||||
{Map<String, dynamic> params = _emptyMap, bool catchError = true}) {
|
||||
if (url.contains("?")) {
|
||||
url += "&shopId=${HiveManager.getShopId()}";
|
||||
} else {
|
||||
url += "?shopId=${HiveManager.getShopId()}";
|
||||
}
|
||||
|
||||
// 处理传入的其他参数
|
||||
if (params.isNotEmpty) {
|
||||
String paramString = Uri(queryParameters: params).query;
|
||||
url += "&$paramString";
|
||||
}
|
||||
|
||||
return _doRequest("GET", url, catchError: catchError);
|
||||
}
|
||||
|
||||
@@ -63,11 +73,11 @@ class RequestManager {
|
||||
try {
|
||||
final resp = await _c.request(url,
|
||||
data: body,
|
||||
options: Options(
|
||||
method: method,
|
||||
headers: {"authorization": "Bearer ${AppManager.getUserToken()}"}
|
||||
));
|
||||
options: Options(method: method, headers: {
|
||||
"authorization": "Bearer ${AppManager.getUserToken()}"
|
||||
}));
|
||||
yjPrint("[RequestManager resp]: $method 【$url】body === $resp");
|
||||
|
||||
if (catchError) {
|
||||
if (resp.statusCode == kNeedLoginCode) {
|
||||
AppManager.gotoLogin();
|
||||
@@ -100,4 +110,4 @@ class RequestManager {
|
||||
static _alertError(String title, String errorText) {
|
||||
Utils.alert(AppManager.globalContext!, errorText, title: title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user