<template>
  <view class="content">
    <u-list @scrolltolower="scrolltolower" v-if="list.length > 0">
      <u-list-item v-for="(item, index) in list" :key="index">
        <view style="display: flex;align-items: center;justify-content: space-between;">
          <view>
            <u-image width="200rpx" height="200rpx" :src="$filePath + item.FILEPATH"></u-image>
          </view>
          <view class="ml-10" style="flex: 1;">
            <view class="flex-between main-title">
              <text>{{ item.CERTIFICATE }}</text>
            </view>
            <view class="flex-between mt-10 subtitle">
              <text>证书编号:{{ item.SPECIAL_NUMBER }}</text>
            </view>
            <view class="flex-between mt-10 subtitle">
              <text>复审时间:{{ item.REVIEW_TIME }}</text>
            </view>
            <view class="flex-between mt-10 subtitle">
              <view></view>
              <view class="flex-between">
                <u-button type="primary" text="编辑" size="mini"
                          @click="fnEdit(item.SPECIAL_USER_ID)"></u-button>
                <view class="ml-10">
                  <u-button type="primary" text="查看" size="mini"
                            @click="fnView(item.SPECIAL_USER_ID)"></u-button>
                </view>
              </view>
            </view>
          </view>
        </view>
      </u-list-item>
    </u-list>
    <empty v-else></empty>
    <fab-button @click="fnEdit"/>
  </view>
</template>

<script>
import {getCertificateInformationList, getCertificateInformationView} from "../../api";
import FabButton from '@/components/fab_button/index.vue'

export default {
  components: {
    FabButton,
  },
  data() {
    return {
      SPECIAL_USER_ID: '',
      info: {},
      pageSize: 10,
      currentPage: 1,
      totalPage: 0,
      list: []
    }
  },
  /*onLoad(query) {
    this.SPECIAL_USER_ID = query.SPECIAL_USER_ID
    this.fnGetData()
  },*/
  onShow() {
    this.resetList()
  },
  methods: {
    async getData() {
      let resData = await getCertificateInformationList({
        showCount: this.pageSize,
        currentPage: this.currentPage,
      });
      this.list = [...this.list, ...resData.varList];
      this.totalPage = resData.page.totalPage;
    },
    resetList() {
      this.pageSize = 10
      this.currentPage = 1
      this.list = []
      this.getData()
    },
    scrolltolower() {
      this.currentPage++;
      if (this.totalPage >= this.currentPage) this.getData();
    },
    fnView(SPECIAL_USER_ID) {
      uni.$u.route({
        url: '/pages/certificate_information/view',
        params: {
          SPECIAL_USER_ID
        }
      })
    },
    fnEdit(SPECIAL_USER_ID) {
      uni.$u.route({
        url: '/pages/certificate_information/add',
        params: {
          SPECIAL_USER_ID
        }
      })
    },
  },
}


</script>

<style scoped>

</style>