修改强制退出登录

This commit is contained in:
haomingming 2025-11-14 13:57:14 +08:00
parent 5d2d8cc9ff
commit 38d13d33ce

54
App.vue
View File

@ -1,4 +1,5 @@
<script>
export default {
globalData: {
plAd: true,
@ -47,30 +48,57 @@ export default {
},
onShow() {
try {
// #ifdef APP
let checkTokenCallBackFlag = false
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', {
msg: 'checkToken'
}, ret => {
checkTokenCallBackFlag = true
console.log('check回调')
console.log(ret)
if (ret.code == 0) {
uni.setStorageSync('AUTH_TOKEN_App','')
uni.showModal({
title: '提示',
content: '您已退出登录!',
success: function (res) {
if (res.confirm) {
uni.sendNativeEvent('goTabbarPage', {
msg: 'home'
}, ret => {
console.log(ret);
})
plus.runtime.quit()
}else{
uni.setStorageSync('AUTH_TOKEN_App',temp_token);
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
})
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("data", data);
@ -89,7 +117,6 @@ export default {
plus.nativeUI.toast = (function(str) {
if (str == '再按一次退出应用') {
main.moveTaskToBack(false);
} else {
uni.showToast({
title: str,
@ -133,24 +160,29 @@ export default {
@import "@/uni_modules/uni-scss/index.scss";
/* #ifndef APP-NVUE */
@import "@/static/customicons.css";
//
page {
background-color: #f5f5f5;
}
.uni-navbar__header-btns-right {
min-width: 120rpx;
width: auto !important;
}
/* #endif */
.uni-nav-bar-text {
font-weight: bold;
font-size: 36rpx !important;
}
.example-info {
font-size: 14px;
color: #333;
padding: 10px;
}
.twoline {
display: -webkit-box;
-webkit-box-orient: vertical;
@ -163,17 +195,21 @@ page {
white-space: nowrap;
text-overflow: ellipsis;
}
.uni-navbar .uniui-left {
font-weight: bold;
font-size: 50rpx !important;
}
::-webkit-scrollbar {
display: none;
}
.status_bar {
height: var(--status-bar-height);
background-color: #eeeeee;
}
.navbox {
position: fixed;
top: 0;