Compare commits
No commits in common. "2f317e296055801194d5b670b147650e2b401091" and "a3313064c0e55f516bddaeba9115da22da7163e8" have entirely different histories.
2f317e2960
...
a3313064c0
@ -6,10 +6,6 @@ export const CORP_API_BASE_URL_MAP = {
|
||||
wwa54dfba0b5441ef1: "https://crm.gykqyy.com/ykt/",
|
||||
};
|
||||
|
||||
export const CORP_ID_ALIAS_MAP = {
|
||||
"wpLgjyawAAeRkCPQMp9-z5q-xEzK64nA": "wwa54dfba0b5441ef1",
|
||||
};
|
||||
|
||||
function normalizeBaseUrl(url) {
|
||||
return String(url || "").replace(/\/+$/, "");
|
||||
}
|
||||
@ -18,11 +14,6 @@ function getDefaultBaseUrl() {
|
||||
return normalizeBaseUrl(env.MP_API_BASE_URL);
|
||||
}
|
||||
|
||||
export function normalizeCorpId(corpId) {
|
||||
const normalizedCorpId = String(corpId || "").trim();
|
||||
return CORP_ID_ALIAS_MAP[normalizedCorpId] || normalizedCorpId;
|
||||
}
|
||||
|
||||
function readCachedContext() {
|
||||
if (typeof uni === "undefined" || typeof uni.getStorageSync !== "function") {
|
||||
return null;
|
||||
@ -84,12 +75,12 @@ function parseQueryString(queryString) {
|
||||
export function getCorpIdFromAppOptions(options = {}) {
|
||||
const query = options.query || options || {};
|
||||
const corpId = query.corpId || query.corpid || query.corp_id;
|
||||
if (corpId) return normalizeCorpId(corpId);
|
||||
if (corpId) return String(corpId).trim();
|
||||
|
||||
if (typeof query.q === "string") {
|
||||
const qParams = parseQueryString(safeDecode(query.q));
|
||||
const qCorpId = qParams.corpId || qParams.corpid || qParams.corp_id;
|
||||
if (qCorpId) return normalizeCorpId(qCorpId);
|
||||
if (qCorpId) return String(qCorpId).trim();
|
||||
}
|
||||
|
||||
return "";
|
||||
@ -102,7 +93,7 @@ export function initApiContextFromAppOptions(options = {}) {
|
||||
}
|
||||
|
||||
export function resolveApiContext(corpId) {
|
||||
const normalizedCorpId = normalizeCorpId(corpId);
|
||||
const normalizedCorpId = String(corpId || "").trim();
|
||||
|
||||
if (normalizedCorpId) {
|
||||
const configuredBaseUrl = CORP_API_BASE_URL_MAP[normalizedCorpId];
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { loading, hideLoading } from "./widget";
|
||||
import { buildApiUrl, getDefaultUploadUrl, normalizeCorpId } from "./api-base-config";
|
||||
import { buildApiUrl, getDefaultUploadUrl } from "./api-base-config";
|
||||
|
||||
const defaultOptions = {
|
||||
header: {
|
||||
@ -96,12 +96,6 @@ async function refreshAccessToken() {
|
||||
const request = async (options = {}, showLoading = true) => {
|
||||
// 合并用户传入的配置和默认配置
|
||||
if (!options.data) options.data = {};
|
||||
if (options.data.corpId) {
|
||||
options.data = {
|
||||
...options.data,
|
||||
corpId: normalizeCorpId(options.data.corpId),
|
||||
};
|
||||
}
|
||||
|
||||
const config = {
|
||||
...defaultOptions,
|
||||
@ -207,13 +201,12 @@ export default request;
|
||||
export const uploadUrl = getDefaultUploadUrl();
|
||||
|
||||
export function getFullPath(path, corpId) {
|
||||
return buildApiUrl(path, normalizeCorpId(corpId));
|
||||
return buildApiUrl(path, corpId);
|
||||
}
|
||||
|
||||
|
||||
export function upload(path, corpId) {
|
||||
const normalizedCorpId = normalizeCorpId(corpId);
|
||||
const currentUploadUrl = buildApiUrl("/upload", normalizedCorpId);
|
||||
const currentUploadUrl = buildApiUrl("/upload", corpId);
|
||||
return new Promise((resolve) => {
|
||||
uni.uploadFile({
|
||||
url: currentUploadUrl,
|
||||
@ -223,7 +216,7 @@ export function upload(path, corpId) {
|
||||
success: (res) => {
|
||||
try {
|
||||
const url = JSON.parse(res.data).filePath;
|
||||
resolve(url ? getFullPath(url, normalizedCorpId) : '')
|
||||
resolve(url ? getFullPath(url, corpId) : '')
|
||||
} catch (e) {
|
||||
resolve()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user