index.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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>
  10. //某些情况下安卓没有提前注入plus对象,导致异常,有这种情况出现直接reload,直到plus存在
  11. if (window.navigator.userAgent.toLowerCase().match(/html5plus/i) == 'html5plus') {
  12. if (!window.plus) {
  13. window.location.reload()
  14. }
  15. }
  16. if (window.plus) {
  17. // function set_item(key, val){
  18. // if(window.plus){
  19. // return plus.storage.setItem(key, val)
  20. // }else{
  21. // return localStorage.setItem(key, val)
  22. // }
  23. // }
  24. // function get_item(key){
  25. // if(window.plus){
  26. // return plus.storage.getItem(key)
  27. // }else{
  28. // return localStorage.getItem(key)
  29. // }
  30. // }
  31. // //plus.storage.removeItem('first_init')
  32. // if(!get_item('first_init') && plus.webview.currentWebview().id == plus.runtime.appid){
  33. // set_item('first_init', '1');
  34. // plus.io.requestFileSystem( plus.io.PRIVATE_WWW, function( fs ) {
  35. // var full_url = 'file://'+fs.root.fullPath+'init.html'
  36. // var init_w = plus.webview.create(full_url,full_url);
  37. // init_w.show()
  38. // }, function ( e ) {
  39. // console.log(e)
  40. // } );
  41. // }
  42. plus.navigator.setStatusBarStyle('light');
  43. document.documentElement.style.backgroundColor = '#26A2FF';
  44. plus.navigator.setStatusBarBackground('#26A2FF');
  45. // function setBadgeNumber(newNum) {
  46. // plus.runtime.setBadgeNumber(newNum);
  47. // if (plus.os.name != 'Android') {
  48. // var GeTuiSdk = plus.ios.importClass('GeTuiSdk');
  49. // GeTuiSdk.setBadge(newNum);
  50. // }
  51. // }
  52. if (plus.navigator.isImmersedStatusbar()) {
  53. var bar_height = plus.navigator.getStatusbarHeight();
  54. document.documentElement.style.marginTop = bar_height + 'px';
  55. document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
  56. document.documentElement.classList.add('app_view_html')
  57. var myEvent = new Event('resize');
  58. window.dispatchEvent(myEvent);
  59. plus.webview.currentWebview().setStyle({
  60. softinputMode: "adjustResize",
  61. })
  62. }
  63. var first = null
  64. //解决在hbuilder中ios打包后,获取焦点失效的bug
  65. //setInterval(function () {
  66. var wv_current = plus.webview.currentWebview().nativeInstanceObject()
  67. if (plus.os.name != 'Android') {
  68. wv_current.plusCallMethod({
  69. 'setKeyboardDisplayRequiresUserAction': false
  70. })
  71. }
  72. var webview = plus.webview.all();
  73. webview = webview[webview.length - 1]
  74. //}, 1000)
  75. plus.key.addEventListener('backbutton', function (e) {
  76. if (plus.storage.getItem('qr_scaning')) {
  77. return false;
  78. }
  79. webview.canBack(function (e) {
  80. if (e.canBack) {
  81. webview.back()
  82. } else {
  83. if (webview.id == plus.runtime.appid) {
  84. //首次按键,提示‘再按一次退出应用’
  85. if (!first) {
  86. first = new Date().getTime()
  87. plus.nativeUI.toast("再按一次退出应用");
  88. setTimeout(function () {
  89. first = null
  90. }, 1000)
  91. } else {
  92. if (new Date().getTime() - first < 1500) {
  93. plus.runtime.quit()
  94. }
  95. }
  96. } else {
  97. webview.close();
  98. }
  99. }
  100. })
  101. })
  102. var wgtVer = null;
  103. plus.runtime.getProperty(plus.runtime.appid, function (inf) {
  104. wgtVer = inf.version
  105. });
  106. }
  107. window.onload = function () {
  108. if(window.plus){
  109. document.body.classList.add('on_app')
  110. }
  111. (function (window) {
  112. window.addEventListener('focusout', function () {
  113. //软键盘收起的事件处理
  114. window.setTimeout(function () {
  115. if (!(document.activeElement && (document.activeElement.type == 'textarea' || document.activeElement.type == 'text' || document.activeElement.type == 'password' || document.activeElement.type == 'search'||document.activeElement.type == 'tel'))) {
  116. let ua = window.navigator.userAgent.toLowerCase();
  117. if (ua.match(/MicroMessenger/i) == 'micromessenger') {
  118. window.scroll(0, 0)
  119. }
  120. }
  121. }, 300)
  122. });
  123. var winW = document.documentElement.clientWidth || window.innerWidth
  124. if (winW > 750) {
  125. winW = 750
  126. }
  127. var fontSize = Math.round(winW / 7.5)
  128. if (fontSize % 2 > 0) {
  129. fontSize += 1
  130. }
  131. setInterval(function () {
  132. document.body.style.height = '100%'
  133. }, 100)
  134. document.documentElement.style.fontSize = fontSize + 'px'
  135. window.onresize = function () {
  136. if (window.plus) {
  137. setTimeout(function () {
  138. var bar_height = plus.navigator.getStatusbarHeight();
  139. document.documentElement.style.marginTop = bar_height + 'px';
  140. document.documentElement.style.backgroundColor = '#26A2FF';
  141. document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
  142. }, 100)
  143. }
  144. var winW = document.documentElement.clientWidth || window.innerWidth
  145. document.body.clientWidth
  146. if (winW > 750) {
  147. winW = 750
  148. }
  149. fontSize = Math.round(winW / 7.5)
  150. if (fontSize % 2 > 0) {
  151. fontSize += 1
  152. }
  153. document.documentElement.style.fontSize = fontSize + 'px'
  154. }
  155. setTimeout(function () {
  156. document.body.style.opacity = 1;
  157. document.documentElement.style.opacity = 1;
  158. if (window.plus && plus.webview.currentWebview().id == plus.runtime.appid) {
  159. localStorage.setItem('window_height', plus.screen.resolutionHeight + 1)
  160. }
  161. }, 100)
  162. }(window))
  163. }
  164. </script>
  165. </head>
  166. <body style="opacity: 0">
  167. <div id="app"></div>
  168. <!-- built files will be auto injected -->
  169. </body>
  170. <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.24&key=bc53b742b79c85c83ed94ef921facf93&plugin=AMap.Geocoder"></script>
  171. <script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
  172. <!-- <script type="text/javascript" async>
  173. // 公司的:a3b5fef4a3a2984284387ae5e2c340ed
  174. // 瑞欣的:bc53b742b79c85c83ed94ef921facf93
  175. // 郭家裕:00e4871f053b00afc323b2457ce4688f
  176. </script> -->
  177. </html>