/** * 应用全局配置 * 环境自动检测(基于微信小程序官方 API) */ let API_BASE_URL = 'http://localhost:9083' try { const accountInfo = uni.getAccountInfoSync() const env = accountInfo && accountInfo.miniProgram && accountInfo.miniProgram.envVersion if (env) { switch (env) { case 'develop': API_BASE_URL = 'http://localhost:9083' break case 'trial': API_BASE_URL = 'https://cmai.etotem.com.cn' break case 'release': API_BASE_URL = 'https://cmai.etotem.com.cn' break } } } catch (e) { // 非小程序环境(H5/dev),使用默认地址 } export default { API_BASE_URL, api(path) { return API_BASE_URL + path } }