<template>
   <div class="container">
    <Header title="通知公告" />
    <div class="main">
      <div v-for="(item, index) in list" :key="index" class="item">
        <div class="left">
          <van-tag type="primary">通知</van-tag>
           <p style="color: #969799;">{{ item.createTime }}</p>
        </div>

        <div class="right">
          <p>{{ item.noticeTitle }}</p>
          <span>{{ item.noticeContent }}</span>
        </div>

      </div>
      <p v-if="type" class="clicks" @click="getList">点击加载更多</p>
      <p v-else class="clicks">已经到底啦</p>
    </div>
  </div>
</template>

<script>
import { list } from '@/api/new'
export default {
  name: 'VueSkInform',

  data () {
    return {
      list: [],
      type: true,
      pageSize: 10,
      pageNum: 1
    }
  },

  mounted () {
    this.getList()
  },

  methods: {
    getList () {
      list({ pageSize: this.pageSize, pageNum: this.pageNum }).then(({ data }) => {
        if (data.code === 200) {
          this.pageNum++
          this.list.push(...data.rows)
          if (this.list.length >= data.total) {
            this.type = false
          }
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.item{
  border: 1px solid #ccc;
  border-radius: 5px;
  min-height: 80px;
  margin-top: 10px;
  .left{
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
  }
  .right{
    text-align: left;
    padding: 5px 10px;
    span{
      font-size: 12px;
      color: #969799;
      display: inline-block;
      margin-top: 10px;
    }
  }
}
.clicks{
  color: #969799;
  margin-top: 10px;
}
</style>
