wwf
17 小时以前 4e6f18dfa08e2f2f4f02aaa1b8e8e51852b7a9a1
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
const ua = window.navigator.userAgent
const mobileAgents = ['Android', 'iPhone', 'qxyiOSApp', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod', 'OpenHarmony']
 
const isWeixin = ua.match(/MicroMessenger/i) == 'MicroMessenger'
const isWeixinWork = ua.match(/wxwork/i) == 'wxwork'
const isTBSX5 = ua.match(/MQQBrowser/i) == 'MQQBrowser' || ua.match(/TBS/i) == 'TBS'
 
const isHarmony = ua.indexOf('OpenHarmony') > -1
const isHarmonyApp = ua.indexOf('qxyHarmony') > -1
const isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1
const isAndroidApp = ua.indexOf('qxyAndroidApp') > -1
const isiOSApp = ua.indexOf('qxyiOSApp') > -1
const isiOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) || isiOSApp
const isApp = isAndroidApp || isiOSApp
const isOldVerApp = (isApp) && ua.indexOf('qxyEcpt') < 0
 
let isMobile = false
for (let v = 0; v < mobileAgents.length; v++) {
  if (ua.includes(mobileAgents[v])) {
    isMobile = true
    break
  }
}
 
let iosInputBlur = function () { // 兼容ios输入框
  if(isiOS) { // 判断是否为IOS系统
    setTimeout(() => {
      const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
      window.scrollTo(0, Math.max(scrollHeight - 1, 0))
    }, 100)
  }
}
 
let wxWorkIosScrollToTop = function() {
  if (isWeixinWork && isiOS) {
    setTimeout(() => {
      window.scrollTo(1, 0)
    }, 1000)
  }
}
 
export {
  isWeixin,
  isWeixinWork,
  isMobile,
  isTBSX5,
  isiOS,
  isiOSApp,
  isAndroid,
  isAndroidApp,
  isApp,
  isOldVerApp,
  iosInputBlur,
  wxWorkIosScrollToTop,
  isHarmony,
  isHarmonyApp
}