微信小程序
微信小程序中根据项目环境,切换域名实现
通过wx.getAccountInfoSync()获取envVersion来判断使用哪个域名
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| let baseUrl:string = ''; let tkbackUrl: string = ''; const { miniProgram: { envVersion } } = wx.getAccountInfoSync(); console.log('envVersion', envVersion) switch (envVersion) { case "develop": baseUrl = "https://cs-web.spritarmath.com"; tkbackUrl = "https://cs-tkback.spritarmath.com"; break; case "trial": baseUrl = "https://web.spritarmath.com"; tkbackUrl = "https://tkback.spritarmath.com"; break; default: baseUrl = "https://web.spritarmath.com"; tkbackUrl = "https://tkback.spritarmath.com"; break; } export default { baseUrl, tkbackUrl, ossUrl: 'https://cqtech.oss-cn-chengdu.aliyuncs.com/', serverImg: 'https://filetech.spritarmath.com/weChat/miniProd/', homeIndex: '/pages/index/index', }
|