修改强制退出登录
This commit is contained in:
parent
5d2d8cc9ff
commit
38d13d33ce
142
App.vue
142
App.vue
@ -1,8 +1,9 @@
|
|||||||
<script >
|
<script>
|
||||||
export default {
|
|
||||||
|
export default {
|
||||||
globalData: {
|
globalData: {
|
||||||
plAd: true,
|
plAd: true,
|
||||||
dotNumber:{
|
dotNumber: {
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -10,11 +11,11 @@ export default {
|
|||||||
|
|
||||||
console.log('打印options');
|
console.log('打印options');
|
||||||
console.log(options);
|
console.log(options);
|
||||||
if(options && options.referrerInfo.extraData && options.referrerInfo.extraData.token){
|
if (options && options.referrerInfo.extraData && options.referrerInfo.extraData.token) {
|
||||||
uni.setStorageSync("AUTH_TOKEN_App", options.referrerInfo.extraData.token);
|
uni.setStorageSync("AUTH_TOKEN_App", options.referrerInfo.extraData.token);
|
||||||
uni.setStorageSync("userInfo", options.referrerInfo.extraData.userInfo);
|
uni.setStorageSync("userInfo", options.referrerInfo.extraData.userInfo);
|
||||||
};
|
};
|
||||||
if(options && options.referrerInfo.extraData && options.referrerInfo.extraData.targetPath){
|
if (options && options.referrerInfo.extraData && options.referrerInfo.extraData.targetPath) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: options.referrerInfo.extraData.targetPath
|
url: options.referrerInfo.extraData.targetPath
|
||||||
});
|
});
|
||||||
@ -47,53 +48,79 @@ export default {
|
|||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
// #ifdef APP
|
// #ifdef APP
|
||||||
|
let checkTokenCallBackFlag = false
|
||||||
console.log("执行onshow")
|
console.log("执行onshow")
|
||||||
let temp_token = uni.getStorageSync('AUTH_TOKEN_App');
|
|
||||||
uni.setStorageSync('AUTH_TOKEN_App','');
|
|
||||||
console.log("temp_token", temp_token);
|
|
||||||
uni.sendNativeEvent('checkToken', {
|
uni.sendNativeEvent('checkToken', {
|
||||||
msg: 'checkToken'
|
msg: 'checkToken'
|
||||||
}, ret => {
|
}, ret => {
|
||||||
|
checkTokenCallBackFlag = true
|
||||||
console.log('check回调')
|
console.log('check回调')
|
||||||
console.log(ret)
|
console.log(ret)
|
||||||
if(ret.code==0){
|
if (ret.code == 0) {
|
||||||
uni.setStorageSync('AUTH_TOKEN_App','')
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '您已退出登录!',
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
uni.sendNativeEvent('goTabbarPage', {
|
uni.sendNativeEvent('goTabbarPage', {
|
||||||
msg: 'home'
|
msg: 'home'
|
||||||
},ret => {
|
}, ret => {
|
||||||
console.log(ret);
|
console.log(ret);
|
||||||
})
|
})
|
||||||
plus.runtime.quit()
|
plus.runtime.quit()
|
||||||
}else{
|
} else if (res.cancel) {
|
||||||
uni.setStorageSync('AUTH_TOKEN_App',temp_token);
|
console.log('用户点击取消');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
uni.onNativeEventReceive((event,data)=>{
|
|
||||||
|
setTimeout(function(){
|
||||||
|
console.log("执行 setTimeout")
|
||||||
|
if(!checkTokenCallBackFlag){
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '您已退出登录',
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
uni.sendNativeEvent('goTabbarPage', {
|
||||||
|
msg: 'home'
|
||||||
|
}, ret => {
|
||||||
|
console.log(ret);
|
||||||
|
})
|
||||||
|
} else if (res.cancel) {
|
||||||
|
console.log('用户点击取消');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 200)
|
||||||
|
|
||||||
|
uni.onNativeEventReceive((event, data) => {
|
||||||
console.log("event", event);
|
console.log("event", event);
|
||||||
console.log("data", data);
|
console.log("data", data);
|
||||||
if (event.indexOf("clearToken") > -1){
|
if (event.indexOf("clearToken") > -1) {
|
||||||
uni.setStorageSync('AUTH_TOKEN_App','')
|
uni.setStorageSync('AUTH_TOKEN_App', '')
|
||||||
plus.runtime.quit()
|
plus.runtime.quit()
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let main = plus.android.runtimeMainActivity();
|
let main = plus.android.runtimeMainActivity();
|
||||||
//为了防止快速点按返回键导致程序退出重写quit方法改为隐藏至后台
|
//为了防止快速点按返回键导致程序退出重写quit方法改为隐藏至后台
|
||||||
plus.runtime.quit = function(){
|
plus.runtime.quit = function() {
|
||||||
main.moveTaskToBack(false);
|
main.moveTaskToBack(false);
|
||||||
};
|
};
|
||||||
//重写toast方法如果内容为 ‘再按一次退出应用’ 就隐藏应用,其他正常toast
|
//重写toast方法如果内容为 ‘再按一次退出应用’ 就隐藏应用,其他正常toast
|
||||||
plus.nativeUI.toast = (function(str){
|
plus.nativeUI.toast = (function(str) {
|
||||||
if(str == '再按一次退出应用'){
|
if (str == '再按一次退出应用') {
|
||||||
main.moveTaskToBack(false);
|
main.moveTaskToBack(false);
|
||||||
|
} else {
|
||||||
}else{
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title:str,
|
title: str,
|
||||||
icon:'none',
|
icon: 'none',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -121,7 +148,7 @@ export default {
|
|||||||
},
|
},
|
||||||
onHide() {},
|
onHide() {},
|
||||||
methods: {},
|
methods: {},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -129,57 +156,66 @@ export default {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
/*每个页面公共css */
|
/*每个页面公共css */
|
||||||
@import "@/uni_modules/uni-scss/index.scss";
|
@import "@/uni_modules/uni-scss/index.scss";
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
@import "@/static/customicons.css";
|
@import "@/static/customicons.css";
|
||||||
// 设置整个项目的背景色
|
|
||||||
page {
|
// 设置整个项目的背景色
|
||||||
|
page {
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
}
|
}
|
||||||
.uni-navbar__header-btns-right {
|
|
||||||
|
.uni-navbar__header-btns-right {
|
||||||
min-width: 120rpx;
|
min-width: 120rpx;
|
||||||
width: auto !important;
|
width: auto !important;
|
||||||
}
|
}
|
||||||
/* #endif */
|
|
||||||
.uni-nav-bar-text {
|
/* #endif */
|
||||||
|
.uni-nav-bar-text {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 36rpx !important;
|
font-size: 36rpx !important;
|
||||||
}
|
}
|
||||||
.example-info {
|
|
||||||
|
.example-info {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #333;
|
color: #333;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
.twoline {
|
|
||||||
|
.twoline {
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
-webkit-box-orient: vertical;
|
-webkit-box-orient: vertical;
|
||||||
-webkit-line-clamp: 2;
|
-webkit-line-clamp: 2;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oneline {
|
.oneline {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.uni-navbar .uniui-left {
|
|
||||||
|
.uni-navbar .uniui-left {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 50rpx !important;
|
font-size: 50rpx !important;
|
||||||
}
|
}
|
||||||
::-webkit-scrollbar {
|
|
||||||
|
::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.status_bar {
|
|
||||||
|
.status_bar {
|
||||||
height: var(--status-bar-height);
|
height: var(--status-bar-height);
|
||||||
background-color: #eeeeee;
|
background-color: #eeeeee;
|
||||||
}
|
}
|
||||||
.navbox{
|
|
||||||
|
.navbox {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
height:calc(var(--status-bar-height) + 44px);
|
height: calc(var(--status-bar-height) + 44px);
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Loading…
x
Reference in New Issue
Block a user