<template>
  <div class="deviceCardAir" :style="{backgroundColor: color}" @click="click">

    <div class="deviceCardAir-top">
      <span>#{{ item.id }}</span>
      <span @click="toggle(item)" class="anticon" style="float: right;border-radius: 15px;cursor: pointer;padding: 6px 8px 7px;margin-right: 15px">
        <a-icon type="poweroff"  />
      </span>
    </div>

    <div class="deviceCardAir-content">
      <div style="font-size: 18px;width: 20px;margin-left: 20px;margin-top: 12px;display: inline-block">
        <span v-if="item.online && item.mode=='hot'">制热</span>
        <span v-if="item.online && item.mode=='cold'">制冷</span>
        <span v-if="!item.online">-</span>
      </div>
      <div style="display: inline-block;font-size: 25px;vertical-align: top;padding-top: 20px;margin-left: 10%">
        <span>{{ item.tm }}ºC</span>
      </div>
    </div>

    <div class="deviceCardAir-bottom">
      <span class="anticon" >
        <a-icon type="setting" />
      </span>
      <span style="margin-left: 15px">
        风速：{{ item.wind }}
      </span>
    </div>

  </div>
</template>

<script>
export default {
  data() {
    return {
      color: '',
    }
  },
  props: {
    item: Object,
    toggle: Function,
    click: Function,
  },
  watch: {
    "item.online": function (val) {
      if (this.item.online && this.item.mode=='hot') {
        this.color='#f09b68'
      } else if (this.item.online && this.item.mode=='cold') {
        this.color='#2ea8e5';
      } else {
        this.color='#bebebe'
      }
    },
  },
  mounted() {
    if (this.item.online && this.item.mode=='hot') {
      this.color='#f09b68'
    } else if (this.item.online && this.item.mode=='cold') {
      this.color='#2ea8e5';
    } else {
      this.color='#bebebe'
    }
  },
  methods: {
  }
}
</script>

<style lang="less" scoped>
.deviceCardAir {
  width: 100%;
  height: 10rem;
  background-color: #2ea8e5;
  border-radius: 4px;
  color: white;
  .deviceCardAir-top {
    padding-top: 14px;
    padding-left: 20px;
    font-size: 16px;
    .anticon:hover {
      background-color: rgba(182, 182, 182, 0.7);
    }
  }
  .deviceCardAir-bottom {
    margin-top: 12px;
    margin-left: 18px;
    font-size: 18px;
  }
  .anticon {
    //padding: 6px;
  }

}
</style>