|
@@ -112,6 +112,10 @@ if (!window.utilsEnv) {
|
|
|
}
|
|
|
return agent
|
|
|
},
|
|
|
+ getIsH5HostName: function () {
|
|
|
+ var hostname = location.hostname.toLowerCase()
|
|
|
+ return hostname.indexOf('h5') !== -1
|
|
|
+ },
|
|
|
// 是否是在app里面运行
|
|
|
getIsInTheAppContainer: function () {
|
|
|
// 判断是否在app环境下
|
|
@@ -139,7 +143,19 @@ if (!window.utilsEnv) {
|
|
|
var inWX = navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
|
|
|
var inApp = this.getIsInTheAppContainer()
|
|
|
var platformOS = this.androidOrIOS()
|
|
|
- var platform = inApp ? 'app' : (inWX ? 'wx' : 'h5')
|
|
|
+ var getPlatform = function () {
|
|
|
+ var h5host = this.getIsH5HostName()
|
|
|
+ if (inApp) {
|
|
|
+ return 'app'
|
|
|
+ } else if (h5host) {
|
|
|
+ return 'h5'
|
|
|
+ } else if (inWX) {
|
|
|
+ return 'wx'
|
|
|
+ } else {
|
|
|
+ return 'h5'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var platform = getPlatform()
|
|
|
return {
|
|
|
platformOS: platformOS,
|
|
|
platform: platform,
|
|
@@ -160,7 +176,7 @@ var utils = {
|
|
|
platform: window.utilsEnv.platformEnvs.platform, // wx/app/h5
|
|
|
},
|
|
|
$envs: {
|
|
|
- inWX: window.utilsEnv.platformEnvs.inWX, // 是否在微信中
|
|
|
+ inWX: window.utilsEnv.platformEnvs.platform === 'wx', // 是否在微信中
|
|
|
inH5: window.utilsEnv.platformEnvs.platform === 'h5', // 是否在h5中
|
|
|
inApp: window.utilsEnv.platformEnvs.inApp, // 是否在app中
|
|
|
inAndroid: window.utilsEnv.platformEnvs.platformOS === 'android', // 是否在android中
|