index.js
1.72 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { preReleaseAppId } from '~/config'
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
let envIndex = 2
/**
*
0本地
1开发
2测试
3生产
4预发布
*/
const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo);
// console.log(accountInfo.miniProgram.envVersion)
//手动控制体验版环境的请求 true就依据下面envIndex false就默认为2
const manual = false
const release = false
// 判断小程序环境
// develop:开发版(正常开发工具,测试时)
// trial:体验版
// release:正式版
// console.log( systemInfo.platform);
// console.log(accountInfo.miniProgram.envVersion);
// 对比一下appkey
// console.log();
if (systemInfo.platform != 'devtools') {
// 判断预发布的appid 是强制锁定为4(预发布的地址)
if (accountInfo.miniProgram.appId == preReleaseAppId) {
envIndex = 4
} else {
switch (accountInfo.miniProgram.envVersion) {
case 'develop':
// this.globalData.url = 'http://192.168.0.252:3000/api'; //
break
case 'trial':
envIndex = manual ? envIndex : 2
break
case 'release':
envIndex = release ? envIndex : 3
break
default:
envIndex = 3
break
}
}
}
const domain = {
ip: 'http://192.168.1.125:6906',
dev: 'http://192.168.1.125:6906',
uat: 'https://aus-lot.test.glsx.com.cn',
preRelease: 'https://aus-lot.beta.glsx.com.cn',
prod: 'https://aus-lot.glsx.com.cn'
}[target[envIndex]]
const pathEnum = {
vr: '/vr-api'
}
const CONFIG_ENV_MAP={
'1':'develop',
'2':'test',
'3':'production',
'4':'beta'
}
module.exports = {
envIndex,
domain,
pathEnum,
// secretKey,
env:CONFIG_ENV_MAP[envIndex]
}