<template>
  <div>
    <div class="divBox">
      <el-row :gutter="24" class="baseInfo">
        <router-link :to="{ path: '/order/inquiryOrder' }">
          <el-col :xs="24" :sm="24" :lg="6" class="ivu-mb">
            <el-card :bordered="false" dis-hover :padding="12">
              <div slot="header" class="acea-row row-between-wrapper">
                <span>待接诊</span>
              </div>
              <div class="p-content" v-if="count" style="margin-top: 15px; ">
                <span class="content-number"><count-to :start-val="0" :end-val="count.receiveOrderCount" :duration="3000" class="card-panel-num" /></span>
                <div class="acea-row row-between-wrapper" style="margin-top: 34px;">
                </div>
              </div>
            </el-card>
          </el-col>
        </router-link>
        <el-col :xs="24" :sm="24" :lg="6" class="ivu-mb">
          <el-card :bordered="false" dis-hover :padding="12">
            <div slot="header" class="acea-row row-between-wrapper">
              <span>今日服务次数</span>
            </div>
            <div class="p-content" v-if="count" style="margin-top: 15px;">
              <span class="content-number"><count-to :start-val="0" :end-val="todayCount" :duration="3200" class="card-panel-num" /></span>
              <div class="acea-row row-between-wrapper" style="margin-top: 15px;">
              <span class="content-time">累计服务次数</span>
              <span style="float: right">{{doctor.orderNumber }}</span>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="6" class="ivu-mb">
          <el-card :bordered="false" dis-hover :padding="12">
            <div slot="header" class="acea-row row-between-wrapper" >
              <span>我的评分</span>
            </div>
            <div class="p-content" v-if="count" style="margin-top: 15px;">
              <span class="content-number"><count-to :start-val="0" :end-val="doctor.pingStar" :duration="2600" class="card-panel-num" /></span>
              <div class="acea-row row-between-wrapper" style="margin-top: 34px;">
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="6" class="ivu-mb">
          <el-card :bordered="false" dis-hover :padding="12">
            <div slot="header" class="acea-row row-between-wrapper">
              <span>我的余额</span>
            </div>
            <div class="p-content" v-if="count" style="margin-top: 15px; ">
              <span class="content-number"><count-to :start-val="0" :end-val="doctor.balance" :duration="3000" class="card-panel-num" /></span>
              <div class="acea-row row-between-wrapper" style="margin-top: 34px;">
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
import CountTo from "vue-count-to";
import { getIndexData,todayInquiryCount } from "@/api/index";
export default {
  components: {
    CountTo,
  },
  data() {
    return {
      count: {
      },
      todayCount:0,
    };
  },
  computed: {
    doctor() {
      return this.$store.state.user.doctor;
    }
  },
  created() {
    
  },
  mounted() {
    this.getData(); 
    // 设置定时器，每30秒执行一次getIndexData方法
    this.timer = setInterval(() => {
        this.getData();
    }, 30000); 
  },
  beforeDestroy() {
    clearInterval(this.timer); 
},
methods: {
    getData() {
      getIndexData().then(response => {
          this.count = response.data;
      });
      todayInquiryCount().then(response => {
          this.todayCount= response.data;
      });
    },
},
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);
   
    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3;
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;
      .card-panel-num {
        font-size: 32px;
      }
    }
  }
}

@media (max-width: 550px) {
  .card-panel-description {
    display: none;
  }
  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
.baseInfo {
  ::v-deep .el-card__header {
    padding: 15px 20px !important;
  }
}

.ivu-mb {
  margin-bottom: 10px;
  font-size: 12px!important;
}
.up,
.el-icon-caret-top {
  color: #f5222d;
  font-size: 12px;
  opacity: 1 !important;
}

.down,
.el-icon-caret-bottom {
  color: #39c15b;
  font-size: 12px;
  /*opacity: 100% !important;*/
}

.p-content {
  .content-number{
    font-size:32px;
  }
}
 
</style>
