<template>
  <div class="Watermark4" @click="linkTo('./WatermarkConfig')">
    <div class="top">
      <image src="./../../images/fangyishuiyin.png" />
      <h2>日常消杀</h2>
    </div>
    <div class="Watermark4-body">
      <h2>{{ time }}</h2>
      <p>{{ date }} {{ weekCn }}</p>
      <div class="info">
        <div class="info-item">
          <label>地点：</label>
          <span>武汉市·绿地蓝海A座</span>
        </div>
        <div class="info-item">
          <label>人员：</label>
          <span>陶白白</span>
        </div>
        <div class="info-item">
          <label>备注：</label>
          <span>这是一条很长的备注信息</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {mapActions} from 'vuex'
  export default {
    data () {
      return {
        date: '',
        time: '',
        week: '',
        timer: null
      }
    },

    computed: {
      weekCn() {
        if (this.week === 1) {
          return '星期一'
        }
        if (this.week === 2) {
          return '星期二'
        }
        if (this.week === 3) {
          return '星期三'
        }
        if (this.week === 4) {
          return '星期四'
        }
        if (this.week === 5) {
          return '星期五'
        }

        if (this.week === 6) {
          return '星期六'
        }

        return '星期天'
      }
    },

    created () {
      this.date = this.$dayjs(new Date).format('YYYY-MM-DD')
      this.time = this.$dayjs().format('HH:mm')

      this.timer = setInterval(() => {
        this.date = this.$dayjs().format('YYYY-MM-DD')
        this.time = this.$dayjs().format('HH:mm')
        this.week = new Date().getDay()
      }, 1000)
    },

    destroyed () {
      clearInterval(this.timer)
    },

    methods: {
      ...mapActions(['injectJWeixin']),

      linkTo (url) {
        uni.navigateTo({
          url
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .Watermark4 {
    width: 400px;
    line-height: 1;
    border-radius: 4px;

    * {
      box-sizing: border-box;
    }

    .top {
      position: relative;
      width: 400px;
      height: 60px;
      line-height: 60px;
      padding-left: 60px;
      background: linear-gradient(270deg, rgba(67, 60, 255, 0) 0%, rgba(60, 163, 255, 0.8) 50%, #3B92FF 100%);

      image {
        position: absolute;
        left: -32px;
        top: -16px;
        z-index: 1;
        width: 92px;
        height: 112px;
      }

      h2 {
        font-weight: 500;
        font-size: 32px;
        color: #fff;
      }
    }

    .Watermark4-body {
      padding: 24px 20px;
      background: linear-gradient(270deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 50%, rgba(0, 0, 0, 0.5) 100%);

      & > h2 {
        line-height: 56px;
        font-size: 48px;
        font-weight: bold;
        color: #FFFFFF;
      }

      & > p {
        line-height: 36px;
        margin-bottom: 16px;
        font-size: 26px;
        color: #FFFFFF;
      }

      .info {
        .info-item {
          display: flex;
          line-height: 1.4;
          margin-bottom: 8px;

          &:last-child {
            margin-bottom: 0;
          }

          label {
            color: #BADCFF;
            font-size: 28px;
          }

          span {
            flex: 1;
            font-size: 28px;
          }
        }
      }
    }
  }
</style>
