删除部分代码
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { BASE_URL, appId } from "../env";
|
||||
import { base64Encode } from "./crypto";
|
||||
import { BASE_URL } from "../env";
|
||||
type RequestProps = {
|
||||
options: WechatMiniprogram.RequestOption;
|
||||
loadingTitle?: string;
|
||||
@@ -21,19 +20,12 @@ const generateFingerprint = (): string => {
|
||||
|
||||
|
||||
export const request = <T = any>(
|
||||
{ options, loadingTitle = "加载中", isLoading = true, needLogin = true }: RequestProps
|
||||
{ options, loadingTitle = "加载中", isLoading = true }: RequestProps
|
||||
): Promise<T> => {
|
||||
const app = getApp<IAppOption>();
|
||||
|
||||
const header: any = {
|
||||
"X-Fingerprint": generateFingerprint(),
|
||||
};
|
||||
if (needLogin) {
|
||||
if (!app.checkLoginState()) {
|
||||
return Promise.reject(new Error('请先登录'));
|
||||
}
|
||||
const openId = wx.getStorageSync("openId") || "";
|
||||
header.Authorization = `Basic ${base64Encode(`${openId}:${appId}`)}`
|
||||
}
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
Reference in New Issue
Block a user