Commit 1ddce051 authored by xioln's avatar xioln

app返回退出问题修改

parent 6d618a4d
This diff is collapsed.
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
"uglifyjs-webpack-plugin": "^2.2.0", "uglifyjs-webpack-plugin": "^2.2.0",
"vant": "^2.12.10", "vant": "^2.12.10",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-awesome-mui": "^1.7.3",
"vue-giant-tree": "^0.1.4", "vue-giant-tree": "^0.1.4",
"vue-router": "^3.0.7", "vue-router": "^3.0.7",
"vue-touch": "^2.0.0-beta.4", "vue-touch": "^2.0.0-beta.4",
......
...@@ -20,6 +20,38 @@ ...@@ -20,6 +20,38 @@
<div id="app"></div> <div id="app"></div>
<script src="apiUrl.js"></script> <script src="apiUrl.js"></script>
<!-- built files will be auto injected --> <!-- built files will be auto injected -->
<script type="text/javascript">
mui.init({
keyEventBind: {
backbutton: true, //关闭back按键监听
},
});
//首页返回键处理
// 处理逻辑: 1s内,连续两次按返回键,则退出应用;
var first = null;
mui.back = function() {
console.log(sessionStorage.getItem("quit"))
if (sessionStorage.getItem("quit") == 1) {
// 首次按键, 提示 再按一次退出应用
if (!first) {
first = new Date().getTime(); //记录第一次按下回退键的时间
mui.toast("再按一次退出应用");
setTimeout(function() {
//1s 后清除
first = null;
}, 1000);
} else {
if (new Date().getTime() - first < 1000) {
//如果两次按下的时间小于1s
plus.runtime.quit(); //那么就退出app
}
}
} else {
history.go(-1); // 回退到上一页
}
};
</script>
</body> </body>
</html> </html>
...@@ -10,6 +10,8 @@ import VueTouch from 'vue-touch' ...@@ -10,6 +10,8 @@ import VueTouch from 'vue-touch'
import Loading from './components/loading/loading' import Loading from './components/loading/loading'
import { Tree } from 'element-ui' import { Tree } from 'element-ui'
import './styles/index.scss' import './styles/index.scss'
import Mui from 'vue-awesome-mui'
import api from '@/api' import api from '@/api'
Vue.config.productionTip = false Vue.config.productionTip = false
...@@ -17,6 +19,7 @@ Vue.prototype.$utils = utils ...@@ -17,6 +19,7 @@ Vue.prototype.$utils = utils
Vue.prototype.$bus = new Vue() Vue.prototype.$bus = new Vue()
Vue.prototype.$api = api // eslint-disable-line Vue.prototype.$api = api // eslint-disable-line
Vue.use(Vant) Vue.use(Vant)
Vue.use(Mui)
Vue.use(Lazyload, { Vue.use(Lazyload, {
lazyComponent: true lazyComponent: true
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment