From 8591e5e99f0b18702268fa4fd5719ba16a0a0d37 Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 21 Sep 2026 15:26:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E9=80=9A=E8=BF=87=E7=8E=AF=E5=A2=83=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=88=A4=E6=96=AD=E8=87=AA=E5=8A=A8=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/miniapp/config/api.js | 24 ++++++++++++++++++++++-- frontend/miniapp/project.config.json | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) 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": {},