Commit bc0dc184 authored by tongzifang's avatar tongzifang

add business type

parent f3e97fbb
enum BusinessType {
Cy2("新饮食", "66", "catering"),
Bake("新休闲", "18", "baking"),
MealMate("新正餐", "70", "mealmate-apiserver"),
;
const BusinessType(this.prefix, this.type, this.api);
final String prefix;
final String type;
final String api;
}
import 'package:base_data_channel/config/business_type.dart';
import 'package:base_data_channel/http/qmai_host.dart'; import 'package:base_data_channel/http/qmai_host.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:sp_util/sp_util.dart'; import 'package:sp_util/sp_util.dart';
...@@ -10,7 +11,7 @@ class HeaderInterceptor extends Interceptor { ...@@ -10,7 +11,7 @@ class HeaderInterceptor extends Interceptor {
Map<String, dynamic> dictionary = { Map<String, dynamic> dictionary = {
'Accept': '*/*; v=1.0', 'Accept': '*/*; v=1.0',
'Accept-Language': 'Accept-Language':
'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
'QM-STORE-AUTH': 'undefined2', 'QM-STORE-AUTH': 'undefined2',
'X-CSRF-TOKEN': '{{csrf_token()}}', 'X-CSRF-TOKEN': '{{csrf_token()}}',
'Connection': 'close', 'Connection': 'close',
...@@ -25,6 +26,11 @@ class HeaderInterceptor extends Interceptor { ...@@ -25,6 +26,11 @@ class HeaderInterceptor extends Interceptor {
'Qm-From': 'android', 'Qm-From': 'android',
}; };
options.headers.addAll(dictionary); options.headers.addAll(dictionary);
if (SpUtil.getString('businessType') == BusinessType.MealMate.type &&
options.path.contains(BusinessType.Cy2.api)) {
options.path = options.path
.replaceFirst(BusinessType.Cy2.api, BusinessType.MealMate.api);
}
super.onRequest(options, handler); super.onRequest(options, handler);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment