index.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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.webview.currentWebview().id == plus.runtime.appid) {
  44. plus.push.addEventListener('receive', function(msg){
  45. console.log(msg)
  46. }, false);
  47. }
  48. if (plus.navigator.isImmersedStatusbar()) {
  49. var bar_height = plus.navigator.getStatusbarHeight();
  50. document.documentElement.style.marginTop = bar_height + 'px';
  51. document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
  52. document.documentElement.classList.add('app_view_html')
  53. var myEvent = new Event('resize');
  54. window.dispatchEvent(myEvent);
  55. plus.webview.currentWebview().setStyle({
  56. softinputMode: "adjustResize",
  57. //softinputNavBar: 'none'
  58. })
  59. }
  60. var first = null
  61. //解决在hbuilder中ios打包后,获取焦点失效的bug
  62. //setInterval(function () {
  63. var wv_current = plus.webview.currentWebview().nativeInstanceObject()
  64. if (plus.os.name != 'Android') {
  65. wv_current.plusCallMethod({
  66. 'setKeyboardDisplayRequiresUserAction': false
  67. })
  68. }
  69. var webview = plus.webview.all();
  70. webview = webview[webview.length - 1]
  71. //}, 1000)
  72. plus.key.addEventListener('backbutton', function (e) {
  73. //console.log(webview)
  74. if (plus.storage.getItem('qr_scaning')) {
  75. return false;
  76. }
  77. webview.canBack(function (e) {
  78. if (e.canBack) {
  79. webview.back()
  80. } else {
  81. if (webview.id == plus.runtime.appid) {
  82. //首次按键,提示‘再按一次退出应用’
  83. if (!first) {
  84. first = new Date().getTime()
  85. plus.nativeUI.toast("再按一次退出应用");
  86. setTimeout(function () {
  87. first = null
  88. }, 1000)
  89. } else {
  90. if (new Date().getTime() - first < 1500) {
  91. plus.runtime.quit()
  92. }
  93. }
  94. } else {
  95. webview.close();
  96. }
  97. }
  98. })
  99. })
  100. var wgtVer = null;
  101. plus.runtime.getProperty(plus.runtime.appid, function (inf) {
  102. wgtVer = inf.version
  103. //checkUpdate()
  104. });
  105. function downWgt(wgtUrl) {
  106. plus.nativeUI.showWaiting("正在下载更新");
  107. plus.downloader.createDownload(wgtUrl, {
  108. filename: "_doc/update/"
  109. }, function (d, status) {
  110. if (status == 200) {
  111. installWgt(d.filename);
  112. } else {
  113. plus.nativeUI.alert("下载wgt失败!");
  114. }
  115. plus.nativeUI.closeWaiting();
  116. }).start();
  117. }
  118. function installWgt(path) {
  119. plus.nativeUI.showWaiting("安装更新...")
  120. plus.runtime.install(path, {
  121. force: true
  122. }, function () {
  123. plus.nativeUI.closeWaiting();
  124. plus.nativeUI.alert("更新完成!", function () {
  125. plus.runtime.restart();
  126. });
  127. }, function (e) {
  128. plus.nativeUI.closeWaiting();
  129. plus.nativeUI.alert("安装失败[" + e.code + "]");
  130. });
  131. }
  132. }
  133. window.onload = function () {
  134. if(window.plus){
  135. document.body.classList.add('on_app')
  136. }
  137. (function (window) {
  138. window.addEventListener('focusout', function () {
  139. //软键盘收起的事件处理
  140. window.setTimeout(function () {
  141. if (!(document.activeElement && (document.activeElement.type == 'textarea' || document.activeElement.type == 'text' || document.activeElement.type == 'password' || document.activeElement.type == 'search'))) {
  142. let ua = window.navigator.userAgent.toLowerCase();
  143. if (ua.match(/MicroMessenger/i) == 'micromessenger') {
  144. window.scroll(0, 0)
  145. }
  146. }
  147. }, 300)
  148. });
  149. var winW = document.documentElement.clientWidth || window.innerWidth
  150. if (winW > 750) {
  151. winW = 750
  152. }
  153. var fontSize = Math.round(winW / 7.5)
  154. if (fontSize % 2 > 0) {
  155. fontSize += 1
  156. }
  157. setInterval(function () {
  158. document.body.style.height = '100%'
  159. }, 100)
  160. document.documentElement.style.fontSize = fontSize + 'px'
  161. window.onresize = function () {
  162. if (window.plus) {
  163. setTimeout(function () {
  164. var bar_height = plus.navigator.getStatusbarHeight();
  165. document.documentElement.style.marginTop = bar_height + 'px';
  166. document.documentElement.style.backgroundColor = '#26A2FF';
  167. document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
  168. }, 100)
  169. }
  170. var winW = document.documentElement.clientWidth || window.innerWidth
  171. document.body.clientWidth
  172. if (winW > 750) {
  173. winW = 750
  174. }
  175. fontSize = Math.round(winW / 7.5)
  176. if (fontSize % 2 > 0) {
  177. fontSize += 1
  178. }
  179. document.documentElement.style.fontSize = fontSize + 'px'
  180. }
  181. setTimeout(function () {
  182. document.body.style.opacity = 1;
  183. document.documentElement.style.opacity = 1;
  184. if (window.plus && plus.webview.currentWebview().id == plus.runtime.appid) {
  185. localStorage.setItem('window_height', plus.screen.resolutionHeight + 1)
  186. }
  187. }, 100)
  188. }(window))
  189. }</script><link href=static/css/app.8076158f4f1dffbae5004bef1de19482.css rel=stylesheet></head><body style="opacity: 0"><div id=app style=""></div><script type=text/javascript src=static/js/manifest.2dd8328ce82475e5cdf5.js></script><script type=text/javascript src=static/js/vendor.509cc4e0c2feb192cb2f.js></script><script type=text/javascript src=static/js/app.4d8c62dbd54814c4426f.js></script></body></html>