<template>
  <div class="todo-page" >
    <div class="title" >
      <div class="desc" >代办事项</div>
      <div class="reload" @click="reload" >
        <van-icon name="replay" :class="[loading? 'ratota-ani': '']" />
        刷新
      </div>
    </div>
    <div class="todo-card" @click="goPageDetail" >
      <div  class="card-tile" >
        待审核订单
      </div>
      <div class="todo-count" >
        {{count}}
      </div>
    </div>
  </div>
</template>
<script  setup >
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { crmMessagNumAPI } from '@/api/order'
import { useSchedulerOnce } from 'flicker-vue-hooks'

const router = useRouter()

const count = ref(0)

const loading = ref(false)

const reload =  () => {
  loading.value = true
  useSchedulerOnce( async () => {
    await getCrmMessagNumAPI()
    loading.value = false
  }, 100)

}

const getCrmMessagNumAPI = async () => {
  const { data } = await crmMessagNumAPI()
  count.value = data.checkOrder
}

const goPageDetail = () => {
  router.push({
    path: '/todoDetail'
  })
}

onMounted(() => {
  getCrmMessagNumAPI()
})
</script>
<style lang='less' scoped >
.todo-page {
  width: 100vw;
  height: 100vh;
  background-color: #f9f8f8;
  padding: 24px;
  box-sizing: border-box;
  .title {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 48px;
    font-size: 32px;
    .desc {
      font-size: 60px;
      font-weight: 600;
    }
    .reload {
      width: 160px;
      height: 60px;
      background-color: #0643A2;
      border-radius: 8px;
      display: flex;
      justify-content: center;
      align-items: center;
      color: #fff;
    }
  }
  .todo-card {
    width: 700px;
    height: 280px;
    background-color: #fff;
    border-radius: 24px;
    margin: 0 auto;
    margin-top: 48px;
    padding: 24px;
    box-sizing: border-box;
    .card-tile {
      width: 200px;
      height: 40px;
      font-size: 32px;
      border-left: 8px solid #0643A2;
    }
    .todo-count {
      width: 100%;
      text-align: left;
      margin-top: 48px;
      font-size: 80px;
      font-weight: 600;
      color: red;
      padding-left: 48px;
    }
  }

  .ratota-ani {
    animation: ratota-keyframes 1s linear infinite;
  }

  @keyframes ratota-keyframes {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
</style>
