

<template>
TEST
</template>


<script setup lang="ts">
import {onTabItemTap} from "@dcloudio/uni-app";

const isLogin = ref<boolean>(false);

let originalPagePath = "";

onTabItemTap((item)=>{
  console.log("触发切换Tab事件：",item)
  console.log("是否登陆：",isLogin.value)
  const currentPages = getCurrentPages();
  console.log("获取到的页面地址：",currentPages)



  originalPagePath = item.pagePath;

  if(!isLogin.value){
    console.log("当前还没有登陆",item)
    uni.showModal({
      title: '提示',
      content: '请先登录',
      success: (res) => {
        if (res.confirm) {
          // 用户点击“确定”，跳转到登录页面
          uni.switchTab({
            url: '/pages/login/login',
          });
        } else if (res.cancel) {
          // 用户点击“取消”，返回原始页面
          uni.switchTab({
            url: originalPagePath,
          });
        }
      },
    });
  }
  console.log("完成Tab切换事件",item)
});

// 生命周期钩子
onMounted(() => {
  console.log("内容2已载入")
});

</script>


<style scoped lang="scss">

</style>