index.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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="http://api.map.baidu.com/api?v=2.0&ak=fdc489725992ba738397be65dc657d9e"></script> -->
  13. <script src="./static/clipper.js"></script>
  14. <script>
  15. ; /(iPhone|iPad|iPhone OS|Phone|iPod|iOS|Android)/i.test(navigator.userAgent) &&
  16. ((head = document.getElementsByTagName('head')),
  17. (viewport = document.createElement('meta')),
  18. (viewport.name = 'viewport'),
  19. (viewport.content =
  20. 'target-densitydpi=device-dpi, width=375px, user-scalable=no'),
  21. head.length > 0 && head[head.length - 1].appendChild(viewport))
  22. </script>
  23. <script>
  24. function showToast(msg, duration) {
  25. duration = isNaN(duration) ? 3000 : duration;
  26. var m = document.createElement('div');
  27. m.innerHTML = msg;
  28. 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;";
  29. document.body.appendChild(m);
  30. setTimeout(function () {
  31. var d = 0.5;
  32. m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
  33. m.style.opacity = '0';
  34. setTimeout(function () { document.body.removeChild(m) }, d * 1000);
  35. }, duration);
  36. }
  37. document.addEventListener('plusready', function () {
  38. var webview = plus.webview.currentWebview();
  39. plus.navigator.setStatusBarBackground('#65d1a3');//设置顶部颜色
  40. plus.key.addEventListener('backbutton', function () {
  41. webview.canBack(function (e) {
  42. if (e.canBack) {
  43. webview.back(-1);
  44. } else {
  45. //webview.close(); //hide,quit
  46. //plus.runtime.quit();
  47. //首页返回键处理
  48. //处理逻辑:1秒内,连续两次按返回键,则退出应用;
  49. var first = null;
  50. plus.key.addEventListener('backbutton', function () {
  51. //首次按键,提示‘再按一次退出应用’
  52. if (!first) {
  53. first = new Date().getTime();
  54. // console.log('再按一次退出应用');
  55. showToast("再点击一次,退出程序", 1500);
  56. setTimeout(function () {
  57. first = null;
  58. }, 1000);
  59. } else {
  60. if (new Date().getTime() - first < 1500) {
  61. plus.runtime.quit();
  62. }
  63. }
  64. }, false);
  65. }
  66. })
  67. });
  68. console.log(plus.display.resolutionHeight)
  69. });
  70. //定时器 异步运行
  71. function hello() {
  72. console.log("hello");
  73. }
  74. //使用方法名字执行方法
  75. var t1 = window.setTimeout(hello, 1000);
  76. var t2 = window.setTimeout("hello()", 3000);//使用字符串执行方法
  77. window.clearTimeout(t1);//去掉定时器
  78. </script>
  79. </body>
  80. </html>