<template>
  <div class="headview">
    <div class="dierjibie">
      <img :src="[img0, img1, img2][swindex]" alt="" srcset="" />
      <div class="asleft">
        <div class="jajajaj" v-if="tianqi">
          {{
            tianqi.result.city
              ? `${tianqi.result.city} ：${tianqi.result.weather || ''} ${tianqi.result.templow || ''}℃ ~${
                  tianqi.result.temphigh || ''
                }℃`
              : ''
          }}
        </div>
      </div>
      <div class="aszhongjian">
        {{ userInfo.companyWechatId ? userInfo.companyName : '广佛格力家用工单系统' }}
      </div>
      <div class="asright">{{ timeStr }}</div>
    </div>
  </div>
</template>

<script>
import { dateFormat2 } from '@/utils/util.js'
import img0 from '@/assets/head8.png'
import img1 from '@/assets/head1.png'
import img2 from '@/assets/head2.png'
import { bigWaterGet } from '@/api/common.js'
export default {
  props: {
    swindex: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      img0,
      img1,
      img2,
      timeStr: '',
      timeId: null,
      info: {},
      tianqi: null
    }
  },
  computed: {
    // 用户信息
    userInfo() {
      return JSON.parse(localStorage.getItem('greemall_user'))
    }
  },
  watch: {
    $IpAdd: {
      handler(newVal, oldVal) {
        if (newVal?.city) {
          bigWaterGet({
            city: newVal.city
          }).then(res => {
            this.tianqi = res.data
            console.log(res.data)
          })
        }
      },
      deep: true,
      immediate: true
    }
  },
  mounted() {
    this.jishikaishi()
  },
  beforeUnmount() {
    this.timeId && clearInterval(this.timeId)
  },
  methods: {
    jishikaishi() {
      let date = new Date()
      this.timeStr = dateFormat2('YYYY-mm-dd HH:MM:SS WWW', date)
      this.timeId = setTimeout(this.jishikaishi, 1000)
    }
  }
}
</script>

<style scoped lang="scss">
.jajajaj {
  height: 24px;
  line-height: 24px;
  font-size: 20px;
  font-family: Source Han Sans CN, Source Han Sans CN-Regular;
  font-weight: 400;
  text-align: left;
  color: #34c7ff;
}

::v-deep .dv-scroll-board {
  background: none !important;

  .row,
  .row-item {
    background: none !important;
    height: 24px !important;
  }
}

.headview {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;

  .dierjibie {
    width: 100%;
    min-width: 1600px;
    height: 100%;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  img {
    position: absolute;
    bottom: 0;
    width: 100%;
    min-width: 1600px;
    height: 58px;
  }

  .aszhongjian {
    font-family: Source Han Sans CN;
    font-weight: 500;
    font-size: 30px;
    color: #ffffff;
    line-height: 35px;
    background: linear-gradient(0deg, #ffffff 0%, #b0d7ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
  }

  .asleft {
    height: 24px;
    overflow: hidden;
    position: absolute;
    bottom: 12px;
    left: 160px;
  }

  .asright {
    font-size: 20px;
    font-family: Source Han Sans CN, Source Han Sans CN-Regular;
    font-weight: 400;
    text-align: left;
    color: #34c7ff;
    position: absolute;
    bottom: 12px;
    right: 160px;
  }
}
</style>
