<template>
  <div class="container">
    <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="getList">
      <div class="message" v-for="(item, index) in list" :key="index">
        <div class="title">诉求办理进展</div>
        <van-divider />
        <div class="content">
          <div class="label">诉求描述：</div>
          <div class="value">{{ item.content }}</div>
        </div>
        <div class="content">
          <div class="label">办理状态：</div>
          <div class="value">{{ item.actionCode }}</div>
        </div>
        <div class="content">
          <div class="label">办理时间：</div>
          <div class="value">{{ item.operateTime }}</div>
        </div>
      </div>
    </van-list>
  </div>
</template>

<script>
import { getWxmpEventAndDemandMessageList } from '@/api/user'

export default {
  name: 'message',
  data() {
    return {
      list: [],
      total: 0,
      loading: false,
      finished: false,
      pageNo: 1,
      pageSize: 5
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      getWxmpEventAndDemandMessageList({
        phone: this.$store.state.app.userInfo.phone,
        pageNo: this.pageNo++,
        pageSize: this.pageSize
      }).then(res => {
        this.list.push(...res.data.list)
        this.total = res.data.total
        // 加载状态结束
        this.loading = false
        // 数据全部加载完成
        if (!res.data || this.list.length >= this.total) {
          this.finished = true
        } else {
          this.pageNo++
        }
      })
    }
  }
}
</script>

<style scoped lang="less">
@import './index';
</style>
