index.html 6.6 KB

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