fix: 修复websocket
This commit is contained in:
@@ -21,21 +21,54 @@ const sensitiveData = [
|
||||
|
||||
const isDev = checkDev('dev');
|
||||
|
||||
// 环境URL配置
|
||||
const ENV_URLS = {
|
||||
// 生产环境
|
||||
prod: {
|
||||
main: "https://app.xiaokang88.com/member",
|
||||
xkApi: "https://api.xiaokang88.com/api/mobile",
|
||||
shop: "https://shop.xiaokang88.com/member",
|
||||
im: "https://api.ws.g.xiaokang88.com/api"
|
||||
},
|
||||
// 测试环境
|
||||
test: {
|
||||
main: "https://test.xk.app.nailaoyun.cn/member",
|
||||
xkApi: "https://test.xk.api.nailaoyun.cn/api/mobile",
|
||||
shop: "https://test.xk.shop.nailaoyun.cn/member",
|
||||
im: "https://api.ws.g.nailaoyun.cn/api"
|
||||
},
|
||||
// 本地开发环境
|
||||
local: {
|
||||
main: "http://127.0.0.1:18000/member",
|
||||
xkApi: "http://127.0.0.1:18001/api/mobile",
|
||||
shop: "http://127.0.0.1:18018/member",
|
||||
im: "http://127.0.0.1:12080/api"
|
||||
}
|
||||
};
|
||||
|
||||
// 获取当前环境配置
|
||||
function getEnvUrls() {
|
||||
// 如果是本地开发环境,使用本地配置
|
||||
if (isDev === true) {
|
||||
return ENV_URLS.local;
|
||||
}
|
||||
// 检查是否开启了开发者测试模式
|
||||
const devMode = uni.getStorageSync('dev_mode');
|
||||
return devMode ? ENV_URLS.test : ENV_URLS.prod;
|
||||
}
|
||||
|
||||
function request(url, params, method = 0) {
|
||||
let baseURL = isDev === true? 'http://127.0.0.1:18000/member': "https://app.xiaokang88.com/member"
|
||||
// let baseURL = "http://127.0.0.1:18000/member"
|
||||
const envUrls = getEnvUrls();
|
||||
let baseURL = envUrls.main;
|
||||
|
||||
if (url.split('/').indexOf('imApi') !== -1) {
|
||||
// baseURL = "http://127.0.0.1:12080/api"
|
||||
// baseURL = isDev === true? 'http://127.0.0.1:12080/api': "http://im.xiaokang88.com/api"
|
||||
baseURL = isDev === true? 'http://127.0.0.1:12080/api': "https://api.ws.g.xiaokang88.com/api"
|
||||
// baseURL = "https://api.ws.g.xiaokang88.com/api"
|
||||
baseURL = envUrls.im;
|
||||
}
|
||||
if (url.split('/').indexOf('newApi') !== -1) {
|
||||
baseURL = isDev === true? 'http://127.0.0.1:18018/member': "https://shop.xiaokang88.com/member"
|
||||
baseURL = envUrls.shop;
|
||||
}
|
||||
if (url.split('/').indexOf('xkApi') !== -1) {
|
||||
baseURL = isDev === true? 'http://127.0.0.1:18001/api/mobile': "https://api.xiaokang88.com/api/mobile"
|
||||
// baseURL = "http://127.0.0.1:18001/api/mobile"
|
||||
baseURL = envUrls.xkApi;
|
||||
}
|
||||
url = url.replace('/oldApi', '');
|
||||
url = url.replace('/newApi', '');
|
||||
|
||||
Reference in New Issue
Block a user