<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>
          <view class="flex-between main-title">
            <text>{{ item.NAME }}</text>
            <u--image :showLoading="true" :src="$store.state.filePath + item.FILEPATH" width="40px" height="40px" @click="previewImage($store.state.filePath + item.FILEPATH)"></u--image>
          </view>
        </view>
      </u-list-item>
    </u-list>
    <empty v-else></empty>
  </view>
</template>

<script>
import {getRiskFourColorMapList} from "../../../api";

export default {
  data() {
    return {
      pageSize: 10,
      currentPage: 1,
      totalPage: 0,
      list: [],
      CORPINFO_ID: '',
    }
  },
  onLoad(event) {
    this.CORPINFO_ID = event.CORPINFO_ID;
    this.resetList()
  },
  methods: {
    async getData() {
      this.popupShow = false
      let resData = await getRiskFourColorMapList({
        CORPINFO_ID: this.CORPINFO_ID,
        showCount: this.pageSize,
        currentPage: this.currentPage,
        TYPE: 1,
      });
      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();
    },
    previewImage(current) {
      uni.previewImage({
        urls: [current],
        current
      });
    },
  }
}
</script>

<style scoped>

</style>
