|
@@ -1,8 +1,11 @@
|
|
|
import { login } from "../logic";
|
|
import { login } from "../logic";
|
|
|
import { request as _request } from "../wx/network";
|
|
import { request as _request } from "../wx/network";
|
|
|
|
|
+import { getAccountInfoSync } from "../wx/open-api";
|
|
|
|
|
|
|
|
const shareRequestCache = new Map<string, IRequestData<any>>();
|
|
const shareRequestCache = new Map<string, IRequestData<any>>();
|
|
|
|
|
|
|
|
|
|
+const miniProgram = getAccountInfoSync();
|
|
|
|
|
+
|
|
|
export function createRequest(option: IRequestCreateConfig) {
|
|
export function createRequest(option: IRequestCreateConfig) {
|
|
|
const { baseURL } = option;
|
|
const { baseURL } = option;
|
|
|
|
|
|
|
@@ -25,6 +28,9 @@ export function createRequest(option: IRequestCreateConfig) {
|
|
|
header['Authorization'] = meta?.ignoreToken ? '' : await option.token?.() ?? '';
|
|
header['Authorization'] = meta?.ignoreToken ? '' : await option.token?.() ?? '';
|
|
|
header['patientId'] = wx.getStorageSync('patientId') ?? '';
|
|
header['patientId'] = wx.getStorageSync('patientId') ?? '';
|
|
|
header['doctorId'] = wx.getStorageSync('doctorId') ?? '';
|
|
header['doctorId'] = wx.getStorageSync('doctorId') ?? '';
|
|
|
|
|
+ header['appId'] = miniProgram.appId ?? '';
|
|
|
|
|
+ header['version'] = miniProgram.version ?? '';
|
|
|
|
|
+ header['env'] = miniProgram.envVersion ?? '';
|
|
|
|
|
|
|
|
const promise = _request<IRequestData<T>>({
|
|
const promise = _request<IRequestData<T>>({
|
|
|
url: /https?\:\/\//.test(url) ? url : `${baseURL}${url}`,
|
|
url: /https?\:\/\//.test(url) ? url : `${baseURL}${url}`,
|