<template>
  <div id="list-4">
    <van-col span="24" class="main">
      <van-col span="24" class="list" v-for="(item, index) in list" :key="index">
        <van-col span="24" class="other">
          <van-col span="24" class="otherInfo">
            <span>{{ item.name || '暂无' }}</span>
          </van-col>
          <van-col span="24" class="otherInfo">
            发送时间：<span>{{ getDate(item.meta) || '暂无' }}</span>
          </van-col>
          <van-col span="24" class="otherInfo">
            缴费截止：<span>{{ item.lose_date || '暂无' }}</span>
          </van-col>
          <!-- <van-col span="24" class="otherInfo">
            预警次数：<span>{{ getNum(item.early_num) }}</span>
          </van-col> -->
          <van-col span="24" class="otherInfo">
            预警信息：<span>{{ item.content }}</span>
          </van-col>
        </van-col>
        <van-col span="24" class="btn">
          <van-button size="small" type="danger" @click="toDel(item)">删除信息</van-button>
        </van-col>
      </van-col>
    </van-col>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
var moment = require('moment');
export default {
  name: 'list-4',
  props: {
    list: { type: Array },
  },
  components: {},
  data: function () {
    return {};
  },
  created() {},
  methods: {
    toDel(data) {
      this.$emit('toDel', data);
    },
    getDate(data) {
      let newDate = moment(data.createdAt).format('YYYY-MM-DD hh:mm:ss');
      if (newDate) return newDate;
    },
    getNum(num) {
      if (num == '1') return '还有三个月到期';
      else if (num == '2') return '还有两个月到期';
      else if (num == '3') return '本月到期';
      else return '暂无';
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  padding: 8px 0 0 0;
  .list {
    background-color: #fff;
    margin: 0 0 8px 0;
    padding: 8px;
    border-radius: 5px;
    .title {
      font-size: 16px;
      font-weight: bold;
      margin: 0 0 5px 0;
    }
    .other {
      margin: 0 0 5px 0;
      .otherInfo {
        font-size: 14px;
        color: #666;
        margin: 0 0 5px 0;
        span {
          color: #000;
          line-height: 20px;
        }
      }
    }
    .btn {
      text-align: center;
      .van-button {
        margin: 0 5px;
      }
    }
  }
}
</style>
