<template>
  
  <div class="app-container2">

    <div class="box-card" @click="goTo('/yys_sos_alarm')">
      SOS告警 <van-badge :content="countData.press" max="99"  />
    </div>

    <div class="box-card" @click="goTo('/yys_fence_alarm')">
      围栏告警 <van-badge :content="countData.fence" max="99"/>
    </div>

  </div>
  
</template>

<script>
import Vue from "vue";
import { Badge } from "vant";

Vue.use(Badge);

export default {
  data() {
    return {
      openid: '',
      userid: '',
      countData: {},
    }
  },
  created() {
    this.userid = localStorage.getItem('yysUserid');
    this.openid = localStorage.getItem('openid');

    this.getWaitHandleCount();
  },
  methods: {
    // 获取待处理数量
    getWaitHandleCount() {
      this.$http.get('getWaitHandleAlarmCounts&openid='+this.openid+'&userid='+this.userid)
          .then(resp => {
            if (resp.data.success) {
              this.countData = resp.data.data || {}

              this.countData.fence_in = this.countData.fence_in || 0;
              this.countData.fence_out = this.countData.fence_out || 0;

              this.countData.fence = parseInt(this.countData.fence_in) + parseInt(this.countData.fence_out);
            }
          })
          .catch(resp => {})
    },
    // 跳转
    goTo(path) {
      this.$router.push(path);
    },
  },
};
</script>
<style scoped="less">
.van-cell__title {
  text-align: left !important;
}

.box-card {
  line-height: 24px;
  margin: 15px 16px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: #323233;
  box-sizing: border-box;
  background-color: #ffffff;
}
</style>