1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <script>
- export default {
- data() {
- return {
- timer: null,
- isOpenRfid: false
- }
- },
- onLaunch: function() {
- /* 无操作15分支后自动登出 */
- this.$storage.setStorage('outTime', new Date().getTime())
- setInterval(() => {
- let routes = getCurrentPages()
- if (routes[0]) {
- let curRoute = routes[routes.length - 1].route
- if (curRoute !== 'pages/login/login') {
- let outTime = this.$storage.getStorageSync('outTime')
- if ((new Date().getTime() - outTime) > 900000) {
- this.$http.LoginQuit().then(res => {
- if(res.code === 0) {
- this.$storage.removeStorageSync('token')
- this.$utils.openNew('/pages/login/login')
- }
- })
- }
- }
- }
- }, 60000)
- },
- onShow: function() {
- console.log(plus.runtime.version)
- clearTimeout(this.timer)
- if (!this.isOpenRfid) {
- this.$pda.uhfInit().then(() => {
- this.isOpenRfid = true
- }).catch(() => {
- {
- this.$msg.showToast('RFID初始化失败,请重启应用!')
- }
- })
- }
- uni.getNetworkType({
- success: res => {
- if (res.networkType === 'none') {
- this.$msg.showToast('当前无网络连接')
- }
- }
- })
- uni.onNetworkStatusChange(res => {
- if (!res.isConnected) {
- this.$msg.showToast('网络连接已断开')
- }
- })
- },
- onHide: function() {
- console.log('App Hide')
- // 一分钟未操作关闭rfid扫描 防止耗电量过高
- this.timer = setTimeout(() => {
- this.$pda.uhfDestroy()
- this.isOpenRfid = false
- console.log('rfid colse ------------')
- }, 60000)
- }
- }
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import "uview-ui/index.scss";
- @import "./static/css/global.scss";
- </style>
|