<script setup>
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import { checkPhone } from "@/manager/LoginManager";
import { goLogin } from "@/hooks/useGoLogin";
import { goHome } from "@/hooks/useGoHome";

onLaunch(async () => {
  console.log("App Launch");

  const token = uni.getStorageSync("token");

  // 检测是否绑定手机号和token
  if (!token) {
    goLogin();

    return;
  }

  if (token) {
    const res = await checkPhone();

    if (res.data) {
      goHome();
    }
  }
});

onShow(() => {
  console.log("App Show");
});

onHide(() => {
  console.log("App Hide");
});
</script>

<style lang="scss">
@import "@/static/fonts/iconfont.css";

/* 添加全局样式 */
page,
body,
#app {
  font-family: PingFang SC, PingFang SC;
  background-color: #e9f3f7;
  height: 100vh;
  width: 100vw;
}

.mb12 {
  margin-bottom: 12px;
}
</style>
