web
This commit is contained in:
@@ -5,11 +5,26 @@ const ENV = {
|
||||
apiBase: 'http://localhost:8081/api/v1',
|
||||
useMock: false,
|
||||
},
|
||||
// 生产环境 - 线上后端
|
||||
// 生产环境 - 线上后端(中国区)
|
||||
production: {
|
||||
apiBase: 'https://tral.cc/api/v1', // 替换为你的线上域名
|
||||
useMock: false,
|
||||
},
|
||||
// 生产环境 - 中国区
|
||||
'production-cn': {
|
||||
apiBase: 'https://api-cn.your-domain.com/api/v1', // 中国区API地址
|
||||
useMock: false,
|
||||
},
|
||||
// 生产环境 - 美国区
|
||||
'production-us': {
|
||||
apiBase: 'https://api-us.your-domain.com/api/v1', // 美国区API地址
|
||||
useMock: false,
|
||||
},
|
||||
// 生产环境 - 欧洲区
|
||||
'production-eu': {
|
||||
apiBase: 'https://api-eu.your-domain.com/api/v1', // 欧洲区API地址
|
||||
useMock: false,
|
||||
},
|
||||
// 测试环境
|
||||
test: {
|
||||
apiBase: 'https://test-api.your-domain.com/api/v1', // 替换为你的测试环境域名
|
||||
@@ -23,7 +38,7 @@ const ENV = {
|
||||
};
|
||||
|
||||
// 当前环境设置 - 修改这里来切换环境
|
||||
const CURRENT_ENV = 'development'; // 可选值: 'development', 'production', 'test', 'mock'
|
||||
const CURRENT_ENV = 'development'; // 可选值: 'development', 'production', 'production-cn', 'production-us', 'production-eu', 'test', 'mock'
|
||||
|
||||
// 导出当前环境的配置
|
||||
const config = {
|
||||
|
||||
@@ -55,6 +55,9 @@ export function getCategoryList() {
|
||||
wx.request({
|
||||
url: `${config.apiBase}/products/categories`,
|
||||
method: 'GET',
|
||||
data: {
|
||||
platform: 'miniprogram' // 指定平台为小程序
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
console.log('原始分类数据:', res.data.data);
|
||||
|
||||
@@ -14,11 +14,32 @@ const ENV_CONFIG = {
|
||||
},
|
||||
production: {
|
||||
name: '生产环境',
|
||||
description: '线上正式服务器',
|
||||
description: '线上正式服务器(中国区)',
|
||||
apiBase: 'https://tral.cc/api/v1',
|
||||
useMock: false,
|
||||
color: '#f5222d'
|
||||
},
|
||||
'production-cn': {
|
||||
name: '生产环境-中国区',
|
||||
description: '中国区生产服务器',
|
||||
apiBase: 'https://api-cn.your-domain.com/api/v1',
|
||||
useMock: false,
|
||||
color: '#f5222d'
|
||||
},
|
||||
'production-us': {
|
||||
name: '生产环境-美国区',
|
||||
description: '美国区生产服务器',
|
||||
apiBase: 'https://api-us.your-domain.com/api/v1',
|
||||
useMock: false,
|
||||
color: '#fa8c16'
|
||||
},
|
||||
'production-eu': {
|
||||
name: '生产环境-欧洲区',
|
||||
description: '欧洲区生产服务器',
|
||||
apiBase: 'https://api-eu.your-domain.com/api/v1',
|
||||
useMock: false,
|
||||
color: '#13c2c2'
|
||||
},
|
||||
test: {
|
||||
name: '测试环境',
|
||||
description: '测试服务器',
|
||||
@@ -101,7 +122,13 @@ export function checkNetworkConnection() {
|
||||
console.error('❌ 后端服务连接失败:', error);
|
||||
wx.showModal({
|
||||
title: '连接失败',
|
||||
content: `无法连接到后端服务\n${envInfo.apiBase}\n\n请检查:\n1. 后端服务是否启动\n2. 网络连接是否正常\n3. 环境配置是否正确`,
|
||||
content: `无法连接到后端服务
|
||||
${envInfo.apiBase}
|
||||
|
||||
请检查:
|
||||
1. 后端服务是否启动
|
||||
2. 网络连接是否正常
|
||||
3. 环境配置是否正确`,
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user