Commit 75f4af3b authored by 潘永坪's avatar 潘永坪

登录请求优化

parent 5060c547
......@@ -5,11 +5,21 @@
<script>
export default {
data() {
return {}
return {
timer:null,
}
},
onLoad() {
this.login()
},
// 一般页面用onUnload
// tabbar页面用onHide
onUnload() {
if(this.timer) {
clearTimeout(this.timer)
this.timer = null
}
},
methods:{
//---登录
login(){
......@@ -65,7 +75,7 @@ export default {
}
} else {
uni.showToast({
title: res.message + '请退出并重新登录',
title: res.message,
icon: 'none'
})
}
......@@ -75,16 +85,13 @@ export default {
title: '登录失败,请退出并重新登录',
icon: 'none'
})
let timer = setTimeout(() => {
_this.timer = setTimeout(() => {
_this.login()
}, 2000)
_this.$once('hook:beforeDestroy', () => {
clearTimeout(timer)
})
})
} else {
uni.showToast({
title: res.message + '请退出并重新登录',
title: res.message,
icon: 'none'
})
}
......@@ -94,12 +101,9 @@ export default {
title: '登录失败,请退出并重新登录',
icon: 'none'
})
let timer = setTimeout(() => {
_this.timer = setTimeout(() => {
_this.login()
}, 2000)
this.$once('hook:beforeDestroy', () => {
clearTimeout(timer)
})
})
}
}
......
......@@ -160,12 +160,6 @@ export default {
title: '登录失败',
icon: 'none'
})
let timer=setTimeout(()=>{
_this.login()
},2000)
_this.$once('hook:beforeDestroy', () => {
clearTimeout(timer)
})
})
}
}
......
......@@ -255,9 +255,6 @@
title:"登录失败",
icon:"none"
})
setTimeout(()=>{
_this.login()
},1000)
})
}
}
......
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