<template>
    <div class="app-container">
      <van-nav-bar
        title="公示公告"
        fixed
        placeholder
      >
        <template #right>
<!--          <van-icon name="wap-nav" color="#000" size="18"/>-->
        </template>
      </van-nav-bar>
      <van-pull-refresh v-model="refreshing" @refresh="getList()">
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="getList('+1')"
        >
          <van-cell v-for="item in list" :key="item.id" is-link url="" style="margin:2%;width:96%;border-radius: 6px;box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16); min-height: 100px;" :to="{name:'proposerLite', query: {id:item.applyProposerId}}">
            <template #title>
              <p style="display:inline-block;background: #EC4B2C;height:20px;width: 20px;border-radius: 2px;margin-right: 10px;float: left"></p><p style="font-weight: bold;font-size: 18px;">{{item.projectName}}</p>
            </template>
            <template #label>
              <p style="font-size: 0.35rem; margin-left: 30px; margin-bottom: 0.1rem;">{{formatDict(options.announce_type, item.announceType)}}</p>
             <p style="font-size: 0.35rem; margin-left: 30px; margin-top: 0.1rem;">{{item.startDate}} 至 {{item.endDate}}</p>
            </template>
          </van-cell>
        </van-list>
      </van-pull-refresh>
      <onlineHomeIndex></onlineHomeIndex>
    </div>
</template>

<script>
import { getList } from "@/api/onlineHome/homestead/information";
  import onlineHomeIndex from "../onlineHomeIndex";
    export default {
      components: {
        onlineHomeIndex
      },
        name: "publicity",
      created() {
        this.initOptions();
        this.getList();
      },
      data() {
        return {
          list: [],
          refreshing: false,
          loading: false,
          finished: false,
          queryParams:{
            pageNum:1,
            pageSize:10,
            orderByColumn:'createTime',
            isAsc:'desc',
            announceStatus: '2',
          },
          options: {
            announce_status: [],
            announce_type: [],
          },
        };
      },
      methods: {
        getList(target) {
          let type = typeof (target);
          console.log(type, target);
          if (type === 'number')
            this.queryParams.pageNum = target;
          else if (type === 'string') {
            this.queryParams.pageNum = eval(this.queryParams.pageNum + target)
          }
          else
          {
            this.refreshing = true;
            this.finished = true;
            this.total = 0;
            this.queryParams.pageNum = 1;
            this.list = []
          }
          getList(this.queryParams).then((response) => {
            console.log(response)
            if (response.rows.length === 0) {
              this.finished = true;
              return;
            }
            response.rows.forEach((e) => {
              this.list.push(e);
            });
            this.total += response.rows.length;
            this.finished = this.total >= response.total;
          }).catch(() => {
            this.finished = true;
          }).finally(() => {
            this.loading = false;
            this.refreshing = false;
          });
        },
        initOptions() {
          for(let k in this.options)
          {
            this.houseGetDicts(k).then((res) => {
              this.options[k] = res.data;
            });
          }
        },
        formatDict(dict, value) {
          return this.selectDictLabel(dict, value);
        },
      },
    }
</script>

<style scoped>
>>>  .my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 150px;
    text-align: center;
    background-color: #39a9ed;
  }
</style>
