index.html 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <!-- <meta name="viewport" content="width=device-width,initial-scale=1.0"> -->
  6. <title>discern</title>
  7. </head>
  8. <body>
  9. <div id="app"></div>
  10. <!-- built files will be auto injected -->
  11. <script src="https://unpkg.com/vue-baidu-map"></script>
  12. <script src="./static/clipper.js"></script>
  13. <script>
  14. ; /(iPhone|iPad|iPhone OS|Phone|iPod|iOS|Android)/i.test(navigator.userAgent) &&
  15. ((head = document.getElementsByTagName('head')),
  16. (viewport = document.createElement('meta')),
  17. (viewport.name = 'viewport'),
  18. (viewport.content =
  19. 'target-densitydpi=device-dpi, width=375px, user-scalable=no'),
  20. head.length > 0 && head[head.length - 1].appendChild(viewport))
  21. </script>
  22. <script>
  23. function showToast(msg, duration) {
  24. duration = isNaN(duration) ? 3000 : duration;
  25. var m = document.createElement('div');
  26. m.innerHTML = msg;
  27. m.style.cssText = "width:35%; min-width:180px; background:#000; opacity:0.6; height:auto;min-height: 30px; color:#fff; line-height:30px; text-align:center; border-radius:15px; position:fixed; top:85%; left:25%; z-index:999999;";
  28. document.body.appendChild(m);
  29. setTimeout(function () {
  30. var d = 0.5;
  31. m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
  32. m.style.opacity = '0';
  33. setTimeout(function () { document.body.removeChild(m) }, d * 1000);
  34. }, duration);
  35. }
  36. document.addEventListener('plusready', function () {
  37. var webview = plus.webview.currentWebview();
  38. plus.navigator.setStatusBarBackground('#65d1a3');//设置顶部颜色
  39. plus.key.addEventListener('backbutton', function () {
  40. webview.canBack(function (e) {
  41. if (e.canBack) {
  42. webview.back(-1);
  43. } else {
  44. //webview.close(); //hide,quit
  45. //plus.runtime.quit();
  46. //首页返回键处理
  47. //处理逻辑:1秒内,连续两次按返回键,则退出应用;
  48. var first = null;
  49. plus.key.addEventListener('backbutton', function () {
  50. //首次按键,提示‘再按一次退出应用’
  51. if (!first) {
  52. first = new Date().getTime();
  53. // console.log('再按一次退出应用');
  54. showToast("再点击一次,退出程序", 1500);
  55. setTimeout(function () {
  56. first = null;
  57. }, 1000);
  58. } else {
  59. if (new Date().getTime() - first < 1500) {
  60. plus.runtime.quit();
  61. }
  62. }
  63. }, false);
  64. }
  65. })
  66. });
  67. console.log(plus.display.resolutionHeight)
  68. });
  69. //定时器 异步运行
  70. function hello() {
  71. console.log("hello");
  72. }
  73. //使用方法名字执行方法
  74. var t1 = window.setTimeout(hello, 1000);
  75. var t2 = window.setTimeout("hello()", 3000);//使用字符串执行方法
  76. window.clearTimeout(t1);//去掉定时器
  77. </script>
  78. </body>
  79. </html>