|
@@ -1,6 +1,5 @@
|
|
|
<!DOCTYPE html>
|
|
|
<html>
|
|
|
-
|
|
|
<head>
|
|
|
<meta charset="utf-8">
|
|
|
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover">
|
|
@@ -9,176 +8,179 @@
|
|
|
<script src="static/js/polyfill.min.js"></script>
|
|
|
<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
|
|
|
<script type="text/javascript" src="//open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script>
|
|
|
- <script>
|
|
|
- //某些情况下安卓没有提前注入plus对象,导致异常,有这种情况出现直接reload,直到plus存在
|
|
|
- if (window.navigator.userAgent.toLowerCase().match(/html5plus/i) == 'html5plus') {
|
|
|
- if (!window.plus) {
|
|
|
- window.location.reload()
|
|
|
- }
|
|
|
+ <script>
|
|
|
+
|
|
|
+ //某些情况下安卓没有提前注入plus对象,导致异常,有这种情况出现直接reload,直到plus存在
|
|
|
+ if (window.navigator.userAgent.toLowerCase().match(/html5plus/i) == 'html5plus') {
|
|
|
+ if (!window.plus) {
|
|
|
+ window.location.reload()
|
|
|
}
|
|
|
- if (window.plus) {
|
|
|
- function set_item(key, val) {
|
|
|
- if (window.plus) {
|
|
|
- return plus.storage.setItem(key, val)
|
|
|
- } else {
|
|
|
- return localStorage.setItem(key, val)
|
|
|
- }
|
|
|
- }
|
|
|
- function get_item(key) {
|
|
|
- if (window.plus) {
|
|
|
- return plus.storage.getItem(key)
|
|
|
- } else {
|
|
|
- return localStorage.getItem(key)
|
|
|
- }
|
|
|
- }
|
|
|
- if (!get_item('first_init') && plus.webview.currentWebview().id == plus.runtime.appid) {
|
|
|
- set_item('first_init', '1');
|
|
|
- plus.io.requestFileSystem(plus.io.PRIVATE_WWW, function(fs) {
|
|
|
- var full_url = 'file://' + fs.root.fullPath + 'init.html'
|
|
|
- var init_w = plus.webview.create(full_url, full_url);
|
|
|
- init_w.show()
|
|
|
- }, function(e) {
|
|
|
- console.log(e)
|
|
|
- });
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ if (window.plus) {
|
|
|
+
|
|
|
+ function set_item(key, val){
|
|
|
+ if(window.plus){
|
|
|
+ return plus.storage.setItem(key, val)
|
|
|
+ }else{
|
|
|
+ return localStorage.setItem(key, val)
|
|
|
}
|
|
|
- plus.navigator.setStatusBarStyle('light');
|
|
|
- document.documentElement.style.backgroundColor = '#26A2FF';
|
|
|
- plus.navigator.setStatusBarBackground('#26A2FF');
|
|
|
- function setBadgeNumber(newNum) {
|
|
|
- plus.runtime.setBadgeNumber(newNum);
|
|
|
- if (plus.os.name != 'Android') {
|
|
|
- var GeTuiSdk = plus.ios.importClass('GeTuiSdk');
|
|
|
- GeTuiSdk.setBadge(newNum);
|
|
|
- }
|
|
|
- }
|
|
|
- if (plus.webview.currentWebview().id == plus.runtime.appid) {
|
|
|
- plus.push.addEventListener('receive', function(msg) {
|
|
|
- console.log(msg)
|
|
|
- }, false);
|
|
|
- }
|
|
|
- if (plus.navigator.isImmersedStatusbar()) {
|
|
|
- var bar_height = plus.navigator.getStatusbarHeight();
|
|
|
- document.documentElement.style.marginTop = bar_height + 'px';
|
|
|
- document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
|
|
|
- document.documentElement.classList.add('app_view_html')
|
|
|
- var myEvent = new Event('resize');
|
|
|
- window.dispatchEvent(myEvent);
|
|
|
- plus.webview.currentWebview().setStyle({
|
|
|
- softinputMode: "adjustResize",
|
|
|
- })
|
|
|
+ }
|
|
|
+ function get_item(key){
|
|
|
+ if(window.plus){
|
|
|
+ return plus.storage.getItem(key)
|
|
|
+ }else{
|
|
|
+ return localStorage.getItem(key)
|
|
|
}
|
|
|
- var first = null
|
|
|
- var wv_current = plus.webview.currentWebview().nativeInstanceObject()
|
|
|
+ }
|
|
|
+ //plus.storage.removeItem('first_init')
|
|
|
+ if(!get_item('first_init') && plus.webview.currentWebview().id == plus.runtime.appid){
|
|
|
+ set_item('first_init', '1');
|
|
|
+ plus.io.requestFileSystem( plus.io.PRIVATE_WWW, function( fs ) {
|
|
|
+ var full_url = 'file://'+fs.root.fullPath+'init.html'
|
|
|
+ var init_w = plus.webview.create(full_url,full_url);
|
|
|
+ init_w.show()
|
|
|
+ }, function ( e ) {
|
|
|
+ console.log(e)
|
|
|
+ } );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ plus.navigator.setStatusBarStyle('light');
|
|
|
+ document.documentElement.style.backgroundColor = '#26A2FF';
|
|
|
+ plus.navigator.setStatusBarBackground('#26A2FF');
|
|
|
+
|
|
|
+ function setBadgeNumber(newNum) {
|
|
|
+ plus.runtime.setBadgeNumber(newNum);
|
|
|
if (plus.os.name != 'Android') {
|
|
|
- wv_current.plusCallMethod({
|
|
|
- 'setKeyboardDisplayRequiresUserAction': false
|
|
|
- })
|
|
|
+ var GeTuiSdk = plus.ios.importClass('GeTuiSdk');
|
|
|
+ GeTuiSdk.setBadge(newNum);
|
|
|
}
|
|
|
- var webview = plus.webview.all();
|
|
|
- webview = webview[webview.length - 1]
|
|
|
- plus.key.addEventListener('backbutton', function(e) {
|
|
|
- if (plus.storage.getItem('qr_scaning')) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- webview.canBack(function(e) {
|
|
|
- if (e.canBack) {
|
|
|
- webview.back()
|
|
|
- } else {
|
|
|
- if (webview.id == plus.runtime.appid) {
|
|
|
- //首次按键,提示‘再按一次退出应用’
|
|
|
- if (!first) {
|
|
|
- first = new Date().getTime()
|
|
|
- plus.nativeUI.toast("再按一次退出应用");
|
|
|
- setTimeout(function() {
|
|
|
- first = null
|
|
|
- }, 1000)
|
|
|
- } else {
|
|
|
- if (new Date().getTime() - first < 1500) {
|
|
|
- plus.runtime.quit()
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ if (plus.navigator.isImmersedStatusbar()) {
|
|
|
+ var bar_height = plus.navigator.getStatusbarHeight();
|
|
|
+ document.documentElement.style.marginTop = bar_height + 'px';
|
|
|
+ document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
|
|
|
+ document.documentElement.classList.add('app_view_html')
|
|
|
+ var myEvent = new Event('resize');
|
|
|
+ window.dispatchEvent(myEvent);
|
|
|
+ plus.webview.currentWebview().setStyle({
|
|
|
+ softinputMode: "adjustResize",
|
|
|
+ })
|
|
|
+ }
|
|
|
+ var first = null
|
|
|
+ //解决在hbuilder中ios打包后,获取焦点失效的bug
|
|
|
+ //setInterval(function () {
|
|
|
+ var wv_current = plus.webview.currentWebview().nativeInstanceObject()
|
|
|
+ if (plus.os.name != 'Android') {
|
|
|
+ wv_current.plusCallMethod({
|
|
|
+ 'setKeyboardDisplayRequiresUserAction': false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ var webview = plus.webview.all();
|
|
|
+ webview = webview[webview.length - 1]
|
|
|
+ //}, 1000)
|
|
|
|
|
|
+ plus.key.addEventListener('backbutton', function (e) {
|
|
|
+ if (plus.storage.getItem('qr_scaning')) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ webview.canBack(function (e) {
|
|
|
+ if (e.canBack) {
|
|
|
+ webview.back()
|
|
|
+ } else {
|
|
|
+ if (webview.id == plus.runtime.appid) {
|
|
|
+ //首次按键,提示‘再按一次退出应用’
|
|
|
+ if (!first) {
|
|
|
+ first = new Date().getTime()
|
|
|
+ plus.nativeUI.toast("再按一次退出应用");
|
|
|
+ setTimeout(function () {
|
|
|
+ first = null
|
|
|
+ }, 1000)
|
|
|
} else {
|
|
|
- webview.close();
|
|
|
+ if (new Date().getTime() - first < 1500) {
|
|
|
+ plus.runtime.quit()
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+ } else {
|
|
|
+ webview.close();
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
})
|
|
|
-
|
|
|
- var wgtVer = null;
|
|
|
- plus.runtime.getProperty(plus.runtime.appid, function(inf) {
|
|
|
- wgtVer = inf.version
|
|
|
- });
|
|
|
+ })
|
|
|
+ var wgtVer = null;
|
|
|
+ plus.runtime.getProperty(plus.runtime.appid, function (inf) {
|
|
|
+ wgtVer = inf.version
|
|
|
+ });
|
|
|
+ }
|
|
|
+ window.onload = function () {
|
|
|
+ if(window.plus){
|
|
|
+ document.body.classList.add('on_app')
|
|
|
}
|
|
|
- window.onload = function() {
|
|
|
- if (window.plus) {
|
|
|
- document.body.classList.add('on_app')
|
|
|
- }
|
|
|
- (function(window) {
|
|
|
- window.addEventListener('focusout', function() {
|
|
|
- //软键盘收起的事件处理
|
|
|
- window.setTimeout(function() {
|
|
|
- if (!(document.activeElement && (document.activeElement.type == 'textarea' || document.activeElement
|
|
|
- .type == 'text' || document.activeElement.type == 'password' || document.activeElement.type ==
|
|
|
- 'search'))) {
|
|
|
- let ua = window.navigator.userAgent.toLowerCase();
|
|
|
- if (ua.match(/MicroMessenger/i) == 'micromessenger') {
|
|
|
- window.scroll(0, 0)
|
|
|
- }
|
|
|
+ (function (window) {
|
|
|
+ window.addEventListener('focusout', function () {
|
|
|
+ //软键盘收起的事件处理
|
|
|
+ window.setTimeout(function () {
|
|
|
+ if (!(document.activeElement && (document.activeElement.type == 'textarea' || document.activeElement.type == 'text' || document.activeElement.type == 'password' || document.activeElement.type == 'search'||document.activeElement.type == 'tel'))) {
|
|
|
+ let ua = window.navigator.userAgent.toLowerCase();
|
|
|
+ if (ua.match(/MicroMessenger/i) == 'micromessenger') {
|
|
|
+ window.scroll(0, 0)
|
|
|
}
|
|
|
- }, 300)
|
|
|
- });
|
|
|
+ }
|
|
|
+ }, 300)
|
|
|
+ });
|
|
|
+ var winW = document.documentElement.clientWidth || window.innerWidth
|
|
|
+ if (winW > 750) {
|
|
|
+ winW = 750
|
|
|
+ }
|
|
|
+ var fontSize = Math.round(winW / 7.5)
|
|
|
+ if (fontSize % 2 > 0) {
|
|
|
+ fontSize += 1
|
|
|
+ }
|
|
|
+
|
|
|
+ setInterval(function () {
|
|
|
+ document.body.style.height = '100%'
|
|
|
+ }, 100)
|
|
|
+ document.documentElement.style.fontSize = fontSize + 'px'
|
|
|
+ window.onresize = function () {
|
|
|
+ if (window.plus) {
|
|
|
+ setTimeout(function () {
|
|
|
+ var bar_height = plus.navigator.getStatusbarHeight();
|
|
|
+ document.documentElement.style.marginTop = bar_height + 'px';
|
|
|
+ document.documentElement.style.backgroundColor = '#26A2FF';
|
|
|
+ document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
|
|
|
+ }, 100)
|
|
|
+ }
|
|
|
+
|
|
|
var winW = document.documentElement.clientWidth || window.innerWidth
|
|
|
+ document.body.clientWidth
|
|
|
if (winW > 750) {
|
|
|
winW = 750
|
|
|
}
|
|
|
- var fontSize = Math.round(winW / 7.5)
|
|
|
+ fontSize = Math.round(winW / 7.5)
|
|
|
if (fontSize % 2 > 0) {
|
|
|
fontSize += 1
|
|
|
}
|
|
|
- setInterval(function() {
|
|
|
- document.body.style.height = '100%'
|
|
|
- }, 100)
|
|
|
document.documentElement.style.fontSize = fontSize + 'px'
|
|
|
- window.onresize = function() {
|
|
|
- if (window.plus) {
|
|
|
- setTimeout(function() {
|
|
|
- var bar_height = plus.navigator.getStatusbarHeight();
|
|
|
- document.documentElement.style.marginTop = bar_height + 'px';
|
|
|
- document.documentElement.style.backgroundColor = '#26A2FF';
|
|
|
- document.documentElement.style.height = 'calc(100vh - ' + bar_height + 'px)'
|
|
|
- }, 100)
|
|
|
- }
|
|
|
- var winW = document.documentElement.clientWidth || window.innerWidth
|
|
|
- document.body.clientWidth
|
|
|
- if (winW > 750) {
|
|
|
- winW = 750
|
|
|
- }
|
|
|
- fontSize = Math.round(winW / 7.5)
|
|
|
- if (fontSize % 2 > 0) {
|
|
|
- fontSize += 1
|
|
|
- }
|
|
|
- document.documentElement.style.fontSize = fontSize + 'px'
|
|
|
+ }
|
|
|
+ setTimeout(function () {
|
|
|
+ document.body.style.opacity = 1;
|
|
|
+ document.documentElement.style.opacity = 1;
|
|
|
+ if (window.plus && plus.webview.currentWebview().id == plus.runtime.appid) {
|
|
|
+ localStorage.setItem('window_height', plus.screen.resolutionHeight + 1)
|
|
|
}
|
|
|
- setTimeout(function() {
|
|
|
- document.body.style.opacity = 1;
|
|
|
- document.documentElement.style.opacity = 1;
|
|
|
- if (window.plus && plus.webview.currentWebview().id == plus.runtime.appid) {
|
|
|
- localStorage.setItem('window_height', plus.screen.resolutionHeight + 1)
|
|
|
- }
|
|
|
- }, 100)
|
|
|
+ }, 100)
|
|
|
|
|
|
- }(window))
|
|
|
- }
|
|
|
- </script>
|
|
|
+ }(window))
|
|
|
+ }
|
|
|
+ </script>
|
|
|
</head>
|
|
|
|
|
|
<body style="opacity: 0">
|
|
|
<div id="app"></div>
|
|
|
<!-- built files will be auto injected -->
|
|
|
</body>
|
|
|
- <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=a3b5fef4a3a2984284387ae5e2c340ed&plugin=AMap.Geocoder"></script>
|
|
|
- <script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
|
|
|
+<!-- <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=a3b5fef4a3a2984284387ae5e2c340ed&plugin=AMap.Geocoder"></script>
|
|
|
+ <script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script> -->
|
|
|
</html>
|