index.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 webview = plus.webview.all();
  77. // webview = webview[webview.length - 1]
  78. // plus.key.addEventListener('backbutton', function(e) {
  79. // if (plus.storage.getItem('qr_scaning')) {
  80. // return false;
  81. // }
  82. // webview.canBack(function(e) {
  83. // if (e.canBack) {
  84. // webview.back()
  85. // } else {
  86. // if (webview.id == plus.runtime.appid) {
  87. // //首次按键,提示‘再按一次退出应用’
  88. // if (!first) {
  89. // first = new Date().getTime()
  90. // plus.nativeUI.toast("再按一次退出应用");
  91. // setTimeout(function() {
  92. // first = null
  93. // }, 1000)
  94. // } else {
  95. // if (new Date().getTime() - first < 1500) {
  96. // plus.runtime.quit()
  97. // }
  98. // }
  99. // } else {
  100. // webview.close();
  101. // }
  102. // }
  103. // })
  104. // })
  105. var wgtVer = null;
  106. plus.runtime.getProperty(plus.runtime.appid, function(inf) {
  107. wgtVer = inf.version
  108. });
  109. }
  110. window.onload = function() {
  111. if (window.plus) {
  112. document.body.classList.add('on_app')
  113. }
  114. (function(window) {
  115. window.addEventListener('focusout', function() {
  116. //软键盘收起的事件处理
  117. window.setTimeout(function() {
  118. if (!(document.activeElement && (document.activeElement.type == 'textarea' || document.activeElement
  119. .type == 'text' || document.activeElement.type == 'password' || document.activeElement.type ==
  120. 'search'))) {
  121. let ua = window.navigator.userAgent.toLowerCase();
  122. if (ua.match(/MicroMessenger/i) == 'micromessenger') {
  123. window.scroll(0, 0)
  124. }
  125. }
  126. }, 300)
  127. });
  128. var winW = document.documentElement.clientWidth || window.innerWidth
  129. if (winW > 750) {
  130. winW = 750
  131. }
  132. var fontSize = Math.round(winW / 7.5)
  133. if (fontSize % 2 > 0) {
  134. fontSize += 1
  135. }
  136. setInterval(function() {
  137. document.body.style.height = '100%'
  138. }, 100)
  139. document.documentElement.style.fontSize = fontSize + 'px'
  140. window.onresize = function() {
  141. if (window.plus) {
  142. setTimeout(function() {
  143. var bar_height = plus.navigator.getStatusbarHeight();
  144. document.documentElement.style.marginTop = bar_height + 'px';
  145. document.documentElement.style.backgroundColor = '#26A2FF';
  146. document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
  147. }, 100)
  148. }
  149. var winW = document.documentElement.clientWidth || window.innerWidth
  150. document.body.clientWidth
  151. if (winW > 750) {
  152. winW = 750
  153. }
  154. fontSize = Math.round(winW / 7.5)
  155. if (fontSize % 2 > 0) {
  156. fontSize += 1
  157. }
  158. document.documentElement.style.fontSize = fontSize + 'px'
  159. }
  160. setTimeout(function() {
  161. document.body.style.opacity = 1;
  162. document.documentElement.style.opacity = 1;
  163. if (window.plus && plus.webview.currentWebview().id == plus.runtime.appid) {
  164. localStorage.setItem('window_height', plus.screen.resolutionHeight + 1)
  165. }
  166. }, 100)
  167. }(window))
  168. }
  169. </script>
  170. </head>
  171. <body style="opacity: 0">
  172. <div id="app"></div>
  173. <!-- built files will be auto injected -->
  174. </body>
  175. <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=a3b5fef4a3a2984284387ae5e2c340ed&plugin=AMap.Geocoder"></script>
  176. <script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
  177. </html>