| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /**
- * 应用全局配置
- *
- * 环境自动检测(基于微信小程序官方 API):
- * uni.getAccountInfoSync().miniProgram.envVersion
- * 'develop' → 开发版(工具内预览)
- * 'trial' → 体验版(上传到体验版)
- * 'release' → 正式版(线上发布)
- *
- * 无需手动修改任何变量,发布到对应环境自动生效。
- */
- // 默认值(兜底)
- let API_BASE_URL = 'http://localhost:9082'
- let DANSHOP_BASE_URL = 'http://localhost:8081'
- try {
- const accountInfo = uni.getAccountInfoSync()
- const env = accountInfo && accountInfo.miniProgram && accountInfo.miniProgram.envVersion
- if (env) {
- switch (env) {
- case 'develop':
- // 开发版 - 本地开发
- API_BASE_URL = 'http://localhost:9082'
- DANSHOP_BASE_URL = 'http://localhost:9081'
- break
- case 'trial':
- // 体验版
- API_BASE_URL = 'https://cfc.iwintrue.com'
- DANSHOP_BASE_URL = 'https://dev.iwintrue.com/danshop'
- break
- case 'release':
- // 正式版
- API_BASE_URL = 'https://cfc.etotem.com.cn'
- DANSHOP_BASE_URL = 'https://danshop.etotem.com.cn'
- break
- }
- }
- } catch (e) {
- // uni.getAccountInfoSync() 不可用(非小程序环境),使用默认值
- }
- export default {
- API_BASE_URL,
- DANSHOP_BASE_URL,
- /** 构建 API 完整 URL */
- api(path) {
- return API_BASE_URL + path
- },
- /** 构建 DAN 测评 API URL */
- danshop(path) {
- return DANSHOP_BASE_URL + path
- }
- }
|