|
@@ -173,50 +173,125 @@ export default {
|
|
|
},
|
|
|
set_keep_alive_update_data (key, value) {
|
|
|
this.keep_alive_update_data[key] = value
|
|
|
- }
|
|
|
- },
|
|
|
- mounted () {
|
|
|
- if (window.plus) {
|
|
|
- this.user_info = JSON.parse(plus.storage.getItem('user_info'))
|
|
|
- } else {
|
|
|
- this.user_info = JSON.parse(localStorage.getItem('user_info'))
|
|
|
- }
|
|
|
- let self = this
|
|
|
- FastClick.attach(document.body)
|
|
|
- Vue.prototype.$keep_alive_update = (key, value) => {
|
|
|
+ },
|
|
|
+ // 初始化页面
|
|
|
+ init() {
|
|
|
+ let self = this;
|
|
|
+ self.create_web_view(false);
|
|
|
+ self.$router.beforeEach((to, from, next) => {
|
|
|
+ let view_id = ''
|
|
|
if (window.plus) {
|
|
|
- let all_view = plus.webview.all()
|
|
|
- let js = 'window.VueObj.$root.$children[0].set_keep_alive_update_data("' + key + '", ' + JSON.stringify(value) + ');'
|
|
|
- for (let i = 0; i < all_view.length; i++) {
|
|
|
- all_view[i].evalJS(js)
|
|
|
+ view_id = plus.storage.getItem(process.env.APPID)
|
|
|
+ } else {
|
|
|
+ self.parse_com(self.$root.$children)
|
|
|
+ self.keep_alive_update_data = {}
|
|
|
+ }
|
|
|
+ if (window.plus && plus.webview.currentWebview().id != view_id && from.name != 'empty' && to.fullPath.indexOf('replace=1') < 0) {
|
|
|
+ let StatusBarStyle = plus.navigator.getStatusBarStyle()
|
|
|
+ plus.navigator.setStatusBarStyle('light')
|
|
|
+ let div_mark = document.createElement('DIV')
|
|
|
+ div_mark.style.zIndex = 1000
|
|
|
+ div_mark.id = 'div_mark'
|
|
|
+ div_mark.style.top = 0
|
|
|
+ div_mark.style.left = 0
|
|
|
+ div_mark.style.right = 0
|
|
|
+ div_mark.style.bottom = 0
|
|
|
+ div_mark.style.position = 'fixed'
|
|
|
+ document.body.appendChild(div_mark)
|
|
|
+ var plusUrl = plus.webview.currentWebview().getURL()
|
|
|
+ var _empty_webview = plus.webview.getWebviewById(view_id)
|
|
|
+ plusUrl = plusUrl.split('#')[0] + '#' + to.fullPath
|
|
|
+ if (_empty_webview && plus.storage.getItem(view_id + '_loaded')) {
|
|
|
+ _empty_webview.evalJS('window.VueObj.$router.replace({path: "' + to.fullPath + '"});')
|
|
|
+ // self.create_web_view(true)
|
|
|
+ setTimeout(() => {
|
|
|
+ _empty_webview.show('pop-in', 300, function () {
|
|
|
+ // 窗口显示动画完成
|
|
|
+ plus.nativeUI.closeWaiting()
|
|
|
+ self.create_web_view(true)
|
|
|
+ }, {acceleration: 'capture'})
|
|
|
+ document.body.removeChild(div_mark)
|
|
|
+ }, 100)
|
|
|
+ _empty_webview.onclose = function () {
|
|
|
+ let close_setp = localStorage.getItem('close_setp')
|
|
|
+ if (close_setp * 1 < -1) {
|
|
|
+ localStorage.setItem('close_setp', close_setp * 1 + 1)
|
|
|
+ plus.webview.currentWebview().close()
|
|
|
+ }
|
|
|
+ plus.navigator.setStatusBarStyle(StatusBarStyle)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (window.plus) {
|
|
|
+ let webview = plus.webview.create(plusUrl, plusUrl)
|
|
|
+ plus.nativeUI.showWaiting('加载中....')
|
|
|
+ webview.onloaded = function () {
|
|
|
+ document.body.removeChild(div_mark)
|
|
|
+ webview.show('pop-in', 300, function () {
|
|
|
+ // 窗口显示动画完成
|
|
|
+ plus.nativeUI.closeWaiting()
|
|
|
+ }, {acceleration: 'capture'})
|
|
|
+ }
|
|
|
+ webview.onclose = function () {
|
|
|
+ let close_setp = localStorage.getItem('close_setp')
|
|
|
+ if (close_setp * 1 < -1) {
|
|
|
+ localStorage.setItem('close_setp', close_setp * 1 + 1)
|
|
|
+ plus.webview.currentWebview().close()
|
|
|
+ }
|
|
|
+ plus.navigator.setStatusBarStyle(StatusBarStyle)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ let routersArr = sessionStorage.getItem('routers') && sessionStorage.getItem('routers').split(',') || []
|
|
|
+ if (routersArr.length == 0) {
|
|
|
+ routersArr.push(from.path)
|
|
|
+ routersArr.push(to.path)
|
|
|
+ next()
|
|
|
} else {
|
|
|
- self.set_keep_alive_update_data(key, value)
|
|
|
+ // 如果是后退
|
|
|
+ if (routersArr.indexOf(to.path) != -1) {
|
|
|
+ // 从哪里后退的,调用他的状态更新方法,复原状态
|
|
|
+ self.$store.commit('RESET', window.$routes_map[from.name].store_name)
|
|
|
+ routersArr.splice(routersArr.indexOf(to.path) + 1, 100)
|
|
|
+ // 后退时延迟100毫秒执行动画,这样体验会好一些
|
|
|
+ next()
|
|
|
+ self.transitionName = 'slide-right'
|
|
|
+ } else {
|
|
|
+ self.transitionName = 'slide-left'
|
|
|
+ routersArr.push(to.path)
|
|
|
+ next()
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- document.body.addEventListener(
|
|
|
- 'click',
|
|
|
- function (e) {
|
|
|
+ sessionStorage.setItem('routers', routersArr.join(','))
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 初始化APP特性
|
|
|
+ initTx() {
|
|
|
+ let self = this;
|
|
|
+ FastClick.attach(document.body)
|
|
|
+ Vue.prototype.$keep_alive_update = (key, value) => {
|
|
|
+ if (window.plus) {
|
|
|
+ let all_view = plus.webview.all()
|
|
|
+ let js = 'window.VueObj.$root.$children[0].set_keep_alive_update_data("' + key + '", ' + JSON.stringify(value) + ');'
|
|
|
+ for (let i = 0; i < all_view.length; i++) {
|
|
|
+ all_view[i].evalJS(js)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ self.set_keep_alive_update_data(key, value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ document.body.addEventListener('click', function (e) {
|
|
|
let blur_fun = function () {
|
|
|
setTimeout(() => {
|
|
|
- if (
|
|
|
- !(
|
|
|
- document.activeElement &&
|
|
|
- (document.activeElement.type == 'textarea' ||
|
|
|
- document.activeElement.type == 'text' ||
|
|
|
- document.activeElement.type == 'password' ||
|
|
|
- document.activeElement.type == 'search' ||
|
|
|
- document.activeElement.type == 'number')
|
|
|
- ) &&
|
|
|
- window.plus
|
|
|
- ) {
|
|
|
+ if (!(document.activeElement && (document.activeElement.type == 'textarea' || document.activeElement.type == 'text' || document.activeElement.type == 'password' || document.activeElement.type == 'search' || document.activeElement.type == 'number'||document.activeElement.type == 'tel')) && window.plus) {
|
|
|
plus.webview.currentWebview().setStyle({
|
|
|
softinputMode: 'adjustResize',
|
|
|
height: localStorage.getItem('window_height')
|
|
|
})
|
|
|
}
|
|
|
}, 200)
|
|
|
- e.target.classList.remove('cur_focus')
|
|
|
setTimeout(() => {
|
|
|
localStorage.removeItem('has_input_focus')
|
|
|
}, 50)
|
|
@@ -226,19 +301,11 @@ export default {
|
|
|
document.documentElement.style.height = 'calc(100% - ' + bar_height + 'px)'
|
|
|
}
|
|
|
}
|
|
|
- e.target.removeEventListener('blur', blur_fun, false)
|
|
|
- localStorage.setItem('last_click_pos', JSON.stringify({ y: e.offsetY, x: e.offsetX }))
|
|
|
+ e.target.removeEventListener('blur', blur_fun, false);
|
|
|
+ localStorage.setItem('last_click_pos', JSON.stringify({y: e.offsetY, x: e.offsetX}))
|
|
|
self.getParentNodes(e.target, 'van-cell--clickable', 'cell-clicked-bg')
|
|
|
self.getParentNodes(e.target, 'van-grid-item__content', 'col-clicked-bg')
|
|
|
- if (
|
|
|
- e.target.type == 'textarea' ||
|
|
|
- e.target.type == 'text' ||
|
|
|
- e.target.type == 'password' ||
|
|
|
- e.target.type == 'search' ||
|
|
|
- e.target.type == 'number' ||
|
|
|
- e.target.classList.contains('input_label') ||
|
|
|
- e.target.classList.contains('hidden_input')
|
|
|
- ) {
|
|
|
+ if (e.target.type == 'textarea' || e.target.type == 'text' || e.target.type == 'password' || e.target.type == 'search' || e.target.type == 'number' || e.target.classList.contains('input_label') || e.target.classList.contains('hidden_input')||document.activeElement.type == 'tel') {
|
|
|
if (navigator.userAgent.indexOf('Android') > 0 && window.plus) {
|
|
|
setTimeout(() => {
|
|
|
let _target = e.target.cloneNode(true)
|
|
@@ -251,7 +318,6 @@ export default {
|
|
|
setTimeout(() => {
|
|
|
e.target.classList.remove('ad_has_focus')
|
|
|
e.target.parentNode.removeChild(_target)
|
|
|
- e.target.classList.add('cur_focus')
|
|
|
setTimeout(() => {
|
|
|
window.scroll(0, 0)
|
|
|
var myEvent = new Event('resize')
|
|
@@ -260,7 +326,6 @@ export default {
|
|
|
}, 100)
|
|
|
}, 200)
|
|
|
}
|
|
|
-
|
|
|
if (e.target.classList.contains('input_label')) {
|
|
|
if (e.target.children[0].classList.contains('hasfocus')) {
|
|
|
return
|
|
@@ -293,9 +358,17 @@ export default {
|
|
|
document.activeElement.blur()
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
- true
|
|
|
- )
|
|
|
+ }, true)
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ if (window.plus) {
|
|
|
+ this.user_info = JSON.parse(plus.storage.getItem('user_info'))
|
|
|
+ } else {
|
|
|
+ this.user_info = JSON.parse(localStorage.getItem('user_info'))
|
|
|
+ }
|
|
|
+ this.initTx();
|
|
|
},
|
|
|
created () {
|
|
|
localStorage.removeItem('menuCommon')
|
|
@@ -305,105 +378,7 @@ export default {
|
|
|
} else {
|
|
|
this.$setCache('isAndroid', 2)
|
|
|
}
|
|
|
- let self = this
|
|
|
- self.create_web_view(false)
|
|
|
- self.$router.beforeEach((to, from, next) => {
|
|
|
- let view_id = ''
|
|
|
- if (window.plus) {
|
|
|
- view_id = plus.storage.getItem(process.env.APPID)
|
|
|
- } else {
|
|
|
- self.parse_com(self.$root.$children)
|
|
|
- self.keep_alive_update_data = {}
|
|
|
- }
|
|
|
- if (window.plus && plus.webview.currentWebview().id != view_id && from.name != 'empty' && to.fullPath.indexOf('replace=1') < 0) {
|
|
|
- let StatusBarStyle = plus.navigator.getStatusBarStyle()
|
|
|
- plus.navigator.setStatusBarStyle('light')
|
|
|
- let div_mark = document.createElement('DIV')
|
|
|
- div_mark.style.zIndex = 1000
|
|
|
- div_mark.id = 'div_mark'
|
|
|
- div_mark.style.top = 0
|
|
|
- div_mark.style.left = 0
|
|
|
- div_mark.style.right = 0
|
|
|
- div_mark.style.bottom = 0
|
|
|
- div_mark.style.position = 'fixed'
|
|
|
- document.body.appendChild(div_mark)
|
|
|
- var plusUrl = plus.webview.currentWebview().getURL()
|
|
|
- var _empty_webview = plus.webview.getWebviewById(view_id)
|
|
|
- plusUrl = plusUrl.split('#')[0] + '#' + to.fullPath
|
|
|
- if (_empty_webview && plus.storage.getItem(view_id + '_loaded')) {
|
|
|
- _empty_webview.evalJS('window.VueObj.$router.replace({path: "' + to.fullPath + '"});')
|
|
|
- setTimeout(() => {
|
|
|
- _empty_webview.show(
|
|
|
- 'pop-in',
|
|
|
- 300,
|
|
|
- function () {
|
|
|
- // 窗口显示动画完成
|
|
|
- plus.nativeUI.closeWaiting()
|
|
|
- self.create_web_view(true)
|
|
|
- },
|
|
|
- { acceleration: 'capture' }
|
|
|
- )
|
|
|
- document.body.removeChild(div_mark)
|
|
|
- }, 100)
|
|
|
- _empty_webview.onclose = function () {
|
|
|
- let close_setp = localStorage.getItem('close_setp')
|
|
|
- if (close_setp * 1 < -1) {
|
|
|
- localStorage.setItem('close_setp', close_setp * 1 + 1)
|
|
|
- plus.webview.currentWebview().close()
|
|
|
- }
|
|
|
- plus.navigator.setStatusBarStyle(StatusBarStyle)
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (window.plus) {
|
|
|
- let webview = plus.webview.create(plusUrl, plusUrl)
|
|
|
- plus.nativeUI.showWaiting('加载中....')
|
|
|
- webview.onloaded = function () {
|
|
|
- document.body.removeChild(div_mark)
|
|
|
- webview.show(
|
|
|
- 'pop-in',
|
|
|
- 300,
|
|
|
- function () {
|
|
|
- // 窗口显示动画完成
|
|
|
- plus.nativeUI.closeWaiting()
|
|
|
- },
|
|
|
- { acceleration: 'capture' }
|
|
|
- )
|
|
|
- }
|
|
|
- webview.onclose = function () {
|
|
|
- let close_setp = localStorage.getItem('close_setp')
|
|
|
- if (close_setp * 1 < -1) {
|
|
|
- localStorage.setItem('close_setp', close_setp * 1 + 1)
|
|
|
- plus.webview.currentWebview().close()
|
|
|
- }
|
|
|
- plus.navigator.setStatusBarStyle(StatusBarStyle)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
- let routersArr = (sessionStorage.getItem('routers') && sessionStorage.getItem('routers').split(',')) || []
|
|
|
- if (routersArr.length == 0) {
|
|
|
- routersArr.push(from.path)
|
|
|
- routersArr.push(to.path)
|
|
|
- next()
|
|
|
- } else {
|
|
|
- // 如果是后退
|
|
|
- if (routersArr.indexOf(to.path) != -1) {
|
|
|
- // 从哪里后退的,调用他的状态更新方法,复原状态
|
|
|
- self.$store.commit('RESET', window.$routes_map[from.name].store_name)
|
|
|
- routersArr.splice(routersArr.indexOf(to.path) + 1, 100)
|
|
|
- // 后退时延迟100毫秒执行动画,这样体验会好一些
|
|
|
- next()
|
|
|
- self.transitionName = 'slide-right'
|
|
|
- } else {
|
|
|
- self.transitionName = 'slide-left'
|
|
|
- routersArr.push(to.path)
|
|
|
- next()
|
|
|
- }
|
|
|
- }
|
|
|
- sessionStorage.setItem('routers', routersArr.join(','))
|
|
|
- })
|
|
|
+ this.init();
|
|
|
}
|
|
|
}
|
|
|
</script>
|