<template>
  <div class="header-content">
    <!--    <div class="header-return" @click="goBack">-->
    <!--      <VanIcon class="header-icon" name="arrow-left"/>-->
    <!--    </div>-->
    <div class="weather">
      <img
        v-show="outWeather.imgname"
        :src="outWeather.imgname"
        class="weather-icon"
        alt=""
      />
      <div class="weather-text">
        <p>
          <span class="pr5"
            >{{ outWeather.temperature ? outWeather.temperature : "--" }}℃</span
          >
          <span>/</span>
          <span class="pr5">PM2.5</span>
          <span>{{ outWeather.pm25 ? outWeather.pm25 : "--" }}</span>
        </p>
        <p>
          <span class="pr5">{{
            outWeather.text ? outWeather.text : "--"
          }}</span>
          <span>{{ outWeather.quality ? outWeather.quality : "--" }}</span>
        </p>
      </div>
    </div>
    <div class="set-space-btn" @click="setPermanentSpace">设置常驻空间</div>
  </div>
</template>
<script lang="ts">
import { defineComponent, onMounted, reactive, toRefs } from "vue";
import { Icon } from "vant";
import { useRouter } from "vue-router";

export default defineComponent({
  props: {
    outWeather: {
      type: Object,
      default: () => {
        return {};
      },
    }
  },
  components: {
    VanIcon: Icon,
  },
  setup() {
    const router = useRouter();
    const proxyData = reactive({
      goBack() {
        window.history.go(-1);
      },
      /**
       * 设置常驻空间
       */
      setPermanentSpace() {
        router.push({ path: "/mySpace" });
      },
    });
    return {
      ...toRefs(proxyData),
    };
  },
});
</script>

<style lang="scss" scoped>
.header-content {
  position: relative;
  box-sizing: border-box;
  padding: 10px 12px;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0) 100%
  );

  .set-space-btn {
    position: absolute;
    font-size: 12px;
    color: #000;
    //width: 73px;
    cursor: pointer;
    padding: 0 10px;
    height: 28px;
    line-height: 28px;
    background: #ffe823;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.07), 0px 0px 1px rgba(0, 0, 0, 0.15);
    border-radius: 30px;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
  }
}

.header-return {
  display: inline-block;
  width: 32px;
  height: 32px;
  line-height: 32px;
  text-align: center;
  background: rgba(0, 0, 0, 0.15);
  border: 0.5px solid rgba(255, 255, 255, 0.25);
  box-sizing: border-box;
  border-radius: 25px;
  font-size: 24px;
  color: #fff;
  vertical-align: middle;
  .header-icon {
    font-size: 15px;
  }
}

.weather {
  height: 35px;
  padding-top: 5px;
  box-sizing: border-box;
  padding-left: 15px;
  display: inline-block;
  vertical-align: middle;

  .weather-icon {
    width: 24px;
    height: 24px;
    display: inline-block;
    vertical-align: middle;
  }

  .weather-text {
    box-sizing: border-box;
    padding-left: 10px;
    display: inline-block;
    vertical-align: middle;
    font-family: Persagy;
    font-style: normal;
    font-weight: 500;
    color: #fff;
    font-size: 12px;

    .pr5 {
      padding-right: 5px;
    }

    p {
      &:nth-child(2) {
        padding-top: 5px;
      }
    }
  }
}
</style>
