diff --git a/frontend/miniapp/config/api.js b/frontend/miniapp/config/api.js index 9a490f2..66a07c1 100644 --- a/frontend/miniapp/config/api.js +++ b/frontend/miniapp/config/api.js @@ -1,9 +1,29 @@ -const ApiRoot = 'http://softmt.cn'; -// const ApiRoot = 'https://soft.szcti.com'; +// 接口环境:按小程序运行版本自动切换,无需注释切换域名 +// develop: 开发者工具运行/真机预览调试 | trial: 上传后的体验版 | release: 审核发布的正式版 +const API_ROOTS = { + develop: 'http://codebg.cn', // 本地开发(phpStudy,hosts 需将 codebg.cn 指向 127.0.0.1) + trial: 'https://codebg.cn', // 体验版(线上,需 https + 备案域名) + release: 'https://codebg.cn', // 正式版(线上,需 https + 备案域名) +}; + +// 当前运行环境,供调试确认(可在 app.js onLaunch 中打印) +let envVersion = 'release'; + +function getApiRoot() { + try { + envVersion = wx.getAccountInfoSync().miniProgram.envVersion || 'release'; + } catch (e) { + // 基础库过低等异常情况,按正式版处理 + } + return API_ROOTS[envVersion] || API_ROOTS.release; +} + +const ApiRoot = getApiRoot(); const ApiRootUrl = ApiRoot + '/api/' module.exports = { ApiRoot: ApiRoot, + envVersion: envVersion, // 登录 AuthLoginByWeixin: ApiRootUrl + 'auth/wxLogin', //微信登录 // 需求 diff --git a/frontend/miniapp/project.config.json b/frontend/miniapp/project.config.json index f3a7b97..60f947b 100644 --- a/frontend/miniapp/project.config.json +++ b/frontend/miniapp/project.config.json @@ -52,7 +52,7 @@ }, "compileType": "miniprogram", "libVersion": "3.8.7", - "appid": "wxa3d241d5017bd962", + "appid": "wx51cf161b113d9c07", "projectname": "tdesign-miniprogram-starter-retail", "simulatorType": "wechat", "simulatorPluginLibVersion": {},