<template>
  <div class="home">
    <van-nav-bar title="首页" fixed placeholder />

    <div class="content">
      <van-cell-group inset>
        <van-cell title="欢迎使用" value="H5移动端" />
      </van-cell-group>

      <van-grid :column-num="2" class="grid">
        <van-grid-item icon="photo-o" text="功能1" @click="showToast('功能1')" />
        <van-grid-item icon="chat-o" text="功能2" @click="showToast('功能2')" />
        <van-grid-item icon="setting-o" text="功能3" @click="showToast('功能3')" />
        <van-grid-item icon="star-o" text="功能4" @click="showToast('功能4')" />
      </van-grid>

      <van-button type="primary" block class="btn" @click="goToUser">
        进入个人中心
      </van-button>
    </div>

    <van-tabbar v-model="active" route>
      <van-tabbar-item icon="home-o" to="/">首页</van-tabbar-item>
      <van-tabbar-item icon="user-o" to="/user">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { showToast } from 'vant'

const router = useRouter()
const active = ref(0)

const goToUser = () => {
  router.push('/user')
}
</script>

<style scoped>
.home {
  padding-bottom: 50px;
}

.content {
  padding: 16px;
}

.grid {
  margin-top: 16px;
}

.btn {
  margin-top: 24px;
}
</style>
