<template>
  <div class="page">
    <div class="list" v-if="files.length">
      <div class="item" v-for="(item, index) in files" :key="index">
        <div class="top">
          <img :src="item.imageUrl" alt="" @click="previewImage(index)">
        </div>
        <div class="bottom">
          <h3 v-if="item.certificateName">{{item.certificateName}}</h3>
          <p>获取时间：{{item.createTime.substring(0, 10)}}</p>
        </div>
      </div>
    </div>
    <AiEmpty :description="`暂无数据`" class="emptyWrap" v-else/>
  </div>
</template>
<script>
import {mapState} from 'vuex'

export default {
  name: "myCertificate",
  appName: "我的证书",
  data() {
    return {
      files: [],
    }
  },
  computed: {
    ...mapState(['user', 'token']),
  },
  onLoad() {
    uni.setNavigationBarTitle({ 
      title: '我的证书'
    })
    uni.setNavigationBarColor({
      frontColor: "#000000",
      backgroundColor: "#F4F6FA",
    })
    this.getFile()
  },
  methods: {
    getFile() {
      this.$instance.post(`/app/appcertificateinfo/queryCertificateByApplet`).then(res => {
        if (res.code == 0) {
          this.files = res.data
        }
      })
    },
    previewImage(index) {
      var tempList = []
      for (var i in this.files) {
        tempList.push(this.files[i].imageUrl)
      }

      uni.previewImage({
        current: tempList[index],
        urls: tempList
      });
    },
  },
}
</script>
<style scoped lang="scss">
@import "~dvcp-wui/common";

.page {
  width: 100%;
  background-color: #F4F5FA;
  .list {
    padding: 50px 0 0 32px;
    .item {
      display: inline-block;
      width: calc(50% - 28px);
      margin: 0 26px 24px 0;
      box-sizing: border-box;
      background-color: #fff;
      .top {
        padding: 24px;
        border-bottom: 1px solid #eee;
      }
      .bottom {
        padding: 24px;
      }
      img {
        width: 100%;
        height: 308px;
      }
      h3 {
        font-family: PingFangSC-Regular;
        font-weight: 400;
        font-size: 32px;
        color: #333;
        margin-bottom: 8px;
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      p {
        font-family: PingFangSC-Regular;
        font-size: 24px;
        color: #999;
      }
    }
    .item:nth-of-type(2n) {
      margin-right: 0;
    }
    
  }
}
</style>
