index.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover">
  6. <title>功道云</title>
  7. <script src="html5plus://ready"></script>
  8. <script src="static/js/polyfill.min.js"></script>
  9. <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
  10. <script type="text/javascript" src="//open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script>
  11. <script>
  12. //某些情况下安卓没有提前注入plus对象,导致异常,有这种情况出现直接reload,直到plus存在
  13. if (window.navigator.userAgent.toLowerCase().match(/html5plus/i) == 'html5plus') {
  14. if (!window.plus) {
  15. window.location.reload()
  16. }
  17. }
  18. if (window.plus) {
  19. function set_item(key, val) {
  20. if (window.plus) {
  21. return plus.storage.setItem(key, val)
  22. } else {
  23. return localStorage.setItem(key, val)
  24. }
  25. }
  26. function get_item(key) {
  27. if (window.plus) {
  28. return plus.storage.getItem(key)
  29. } else {
  30. return localStorage.getItem(key)
  31. }
  32. }
  33. if (!get_item('first_init') && plus.webview.currentWebview().id == plus.runtime.appid) {
  34. set_item('first_init', '1');
  35. plus.io.requestFileSystem(plus.io.PRIVATE_WWW, function(fs) {
  36. var full_url = 'file://' + fs.root.fullPath + 'init.html'
  37. var init_w = plus.webview.create(full_url, full_url);
  38. init_w.show()
  39. }, function(e) {
  40. console.log(e)
  41. });
  42. }
  43. plus.navigator.setStatusBarStyle('light');
  44. document.documentElement.style.backgroundColor = '#26A2FF';
  45. plus.navigator.setStatusBarBackground('#26A2FF');
  46. function setBadgeNumber(newNum) {
  47. plus.runtime.setBadgeNumber(newNum);
  48. if (plus.os.name != 'Android') {
  49. var GeTuiSdk = plus.ios.importClass('GeTuiSdk');
  50. GeTuiSdk.setBadge(newNum);
  51. }
  52. }
  53. if (plus.webview.currentWebview().id == plus.runtime.appid) {
  54. plus.push.addEventListener('receive', function(msg) {
  55. console.log(msg)
  56. }, false);
  57. }
  58. if (plus.navigator.isImmersedStatusbar()) {
  59. var bar_height = plus.navigator.getStatusbarHeight();
  60. document.documentElement.style.marginTop = bar_height + 'px';
  61. document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
  62. document.documentElement.classList.add('app_view_html')
  63. var myEvent = new Event('resize');
  64. window.dispatchEvent(myEvent);
  65. plus.webview.currentWebview().setStyle({
  66. softinputMode: "adjustResize",
  67. })
  68. }
  69. var first = null
  70. var wv_current = plus.webview.currentWebview().nativeInstanceObject()
  71. if (plus.os.name != 'Android') {
  72. wv_current.plusCallMethod({
  73. 'setKeyboardDisplayRequiresUserAction': false
  74. })
  75. }
  76. var wgtVer = null;
  77. plus.runtime.getProperty(plus.runtime.appid, function(inf) {
  78. wgtVer = inf.version
  79. });
  80. }
  81. window.onload = function() {
  82. if (window.plus) {
  83. document.body.classList.add('on_app')
  84. }
  85. (function(window) {
  86. window.addEventListener('focusout', function() {
  87. //软键盘收起的事件处理
  88. window.setTimeout(function() {
  89. if (!(document.activeElement && (document.activeElement.type == 'textarea' || document.activeElement
  90. .type == 'text' || document.activeElement.type == 'password' || document.activeElement.type ==
  91. 'search'))) {
  92. let ua = window.navigator.userAgent.toLowerCase();
  93. if (ua.match(/MicroMessenger/i) == 'micromessenger') {
  94. window.scroll(0, 0)
  95. }
  96. }
  97. }, 300)
  98. });
  99. var winW = document.documentElement.clientWidth || window.innerWidth
  100. if (winW > 750) {
  101. winW = 750
  102. }
  103. var fontSize = Math.round(winW / 7.5)
  104. if (fontSize % 2 > 0) {
  105. fontSize += 1
  106. }
  107. setInterval(function() {
  108. document.body.style.height = '100%'
  109. }, 100)
  110. document.documentElement.style.fontSize = fontSize + 'px'
  111. window.onresize = function() {
  112. if (window.plus) {
  113. setTimeout(function() {
  114. var bar_height = plus.navigator.getStatusbarHeight();
  115. document.documentElement.style.marginTop = bar_height + 'px';
  116. document.documentElement.style.backgroundColor = '#26A2FF';
  117. document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
  118. }, 100)
  119. }
  120. var winW = document.documentElement.clientWidth || window.innerWidth
  121. document.body.clientWidth
  122. if (winW > 750) {
  123. winW = 750
  124. }
  125. fontSize = Math.round(winW / 7.5)
  126. if (fontSize % 2 > 0) {
  127. fontSize += 1
  128. }
  129. document.documentElement.style.fontSize = fontSize + 'px'
  130. }
  131. setTimeout(function() {
  132. document.body.style.opacity = 1;
  133. document.documentElement.style.opacity = 1;
  134. if (window.plus && plus.webview.currentWebview().id == plus.runtime.appid) {
  135. localStorage.setItem('window_height', plus.screen.resolutionHeight + 1)
  136. }
  137. }, 100)
  138. }(window))
  139. }
  140. </script>
  141. </head>
  142. <body style="opacity: 0">
  143. <div id="app"></div>
  144. <!-- built files will be auto injected -->
  145. </body>
  146. <!-- <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=a3b5fef4a3a2984284387ae5e2c340ed&plugin=AMap.Geocoder"></script>
  147. <script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script> -->
  148. </html>