<!--
 * @Author: wjc
 * @Date: 2024-06-05 15:04:50
 * @LastEditors: wjc
 * @LastEditTime: 2024-06-25 15:12:29
 * @Description: 
-->
<template>
  <view class="splash-container">
    <template v-if="isInstall">
      <image :src="splash" class="splash-img"></image>
    </template>
    <up-swiper
      v-else
      :list="list"
      height="100vh"
      :autoplay="false"
      @click="onTapSwiper"
    ></up-swiper>
  </view>
</template>

<script setup lang="ts">
  import { useUserStore } from '@/stores/modules/userStore'

  import guide1 from '@/static/images/guide1.png'
  import guide2 from '@/static/images/guide2.png'
  import guide3 from '@/static/images/guide3.png'
  import splash from '@/static/images/splash.png'

  defineOptions({ name: 'Splash' })

  const userStore = useUserStore()
  const isInstall = computed(() => userStore.isInstall)
  const list = ref([guide1, guide2, guide3])

  const onTapSwiper = (index: number) => {
    if (index === 2) {
      uni.navigateTo({
        url: '/pages/login/index',
      })
    }
  }

  onMounted(() => {
    userStore.getUserInfoAction().then((res) => {
      if (res) {
        if (isInstall.value) {
          setTimeout(() => {
            uni.switchTab({
              url: '/pages/index/index',
            })
          }, 2000)
        } else {
          uni.reLaunch({
            url: '/pages/login/index',
          })
        }
      }
    })
  })
</script>

<style scoped lang="scss">
  .splash-container {
    @apply wh-full;
    .splash-img {
      @apply wh-full;
    }
  }
</style>
