62 lines
1.3 KiB
Vue
62 lines
1.3 KiB
Vue
|
||
|
||
<template>
|
||
TEST
|
||
</template>
|
||
|
||
|
||
<script setup lang="ts">
|
||
import {onTabItemTap} from "@dcloudio/uni-app";
|
||
import {useSwitchTab} from "@/stores/switchTab";
|
||
import {USE_ABS_PATH} from "@/constants/glable";
|
||
|
||
const isLogin = ref<boolean>(false);
|
||
|
||
|
||
|
||
const switchTab = useSwitchTab();
|
||
const originalPagePath = switchTab.lastPage;
|
||
|
||
|
||
onTabItemTap((item)=>{
|
||
console.log("触发切换Tab事件:",item)
|
||
console.log("是否登陆:",isLogin.value)
|
||
const currentPages = getCurrentPages();
|
||
console.log("获取到的页面地址:",currentPages)
|
||
|
||
isLogin.value = true;
|
||
|
||
if(!isLogin.value){
|
||
uni.showModal({
|
||
title: '提示',
|
||
content: '请先登录',
|
||
success: (res) => {
|
||
if (res.confirm) {
|
||
// 用户点击“确定”,跳转到登录页面
|
||
uni.switchTab({
|
||
url: '/pages/login/login',
|
||
});
|
||
} else if (res.cancel) {
|
||
console.log("当前转发地址:",originalPagePath)
|
||
// 用户点击“取消”,返回原始页面
|
||
uni.switchTab({
|
||
url: USE_ABS_PATH + originalPagePath,
|
||
});
|
||
}
|
||
},
|
||
});
|
||
}
|
||
console.log("完成Tab切换事件",item)
|
||
});
|
||
|
||
// 生命周期钩子
|
||
onMounted(() => {
|
||
console.log("内容2已载入")
|
||
});
|
||
|
||
</script>
|
||
|
||
|
||
<style scoped lang="scss">
|
||
|
||
</style> |