不用环境设置不同域名

This commit is contained in:
kron
2025-08-06 11:56:28 +08:00
parent b286a236ee
commit 8c63ec487a

View File

@@ -1,4 +1,26 @@
const BASE_URL = "https://api.shelingxingqiu.com/api/shoot";
let BASE_URL = "https://api.shelingxingqiu.com/api/shoot"; // 默认正式版
try {
const accountInfo = uni.getAccountInfoSync();
const envVersion = accountInfo.miniProgram.envVersion;
switch (envVersion) {
case "develop": // 开发版
BASE_URL = "https://api.shelingxingqiu.com/api/shoot";
break;
case "trial": // 体验版
BASE_URL = "https://api.shelingxingqiu.com/api/shoot";
break;
case "release": // 正式版
BASE_URL = "https://api.shelingxingqiu.com/api/shoot";
break;
default:
// 保持默认值
break;
}
} catch (e) {
console.error("获取环境信息失败,使用默认正式环境", e);
}
function request(method, url, data = {}) {
const token = uni.getStorageSync("token");