不用环境设置不同域名
This commit is contained in:
24
src/apis.js
24
src/apis.js
@@ -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 = {}) {
|
function request(method, url, data = {}) {
|
||||||
const token = uni.getStorageSync("token");
|
const token = uni.getStorageSync("token");
|
||||||
|
|||||||
Reference in New Issue
Block a user