<template>
  <div class="page-content">
    <photo-album :member-id="memberId" :folder-id="folderId"/>
    <!-- <vue-gic-footer style="padding-bottom:80px"></vue-gic-footer> -->
  </div>
</template>

<script>
import vNav from '@/common/navbar/navbar.vue';
import photoAlbum from './photo-album.vue';
import request from '@/api/request.js';
export default {
  name: 'img-list',
  components: {
    vNav,
    photoAlbum
  },
  data() {
    return {
      api: {
        // 获取用户所有相册
        getOneMemberAlbum: '/api-member/getOneMemberAlbum'
      },
      navpath: [
        {
          name: '首页',
          path: ''
        },
        {
           name: '客户详情',
          path: '/customerDetail?memberId=' + this.$route.query.memberId || '',
        },
        {
          name: "相册",
          path: ''
        }
      ],
      from: '',
      memberId: '',
      folderId: ''
    }
  },
  async created() {
    let from = this.$route.query.from;
    let memberId = this.$route.query.memberId;
    let folderId = this.$route.query.folderId;
    this.memberId = memberId;
    this.folderId = folderId;
    await this.getImgList()
    let folder = this.folderData.filter(item => item.id === folderId);
    this.navpath[2] = {
      name: "相册",
      path: `/photo-album?memberId=${memberId}&from=${from}`
    }
    if (folder.length > 0) {
      this.navpath.push({
        name: folder[0].name,
        path: ''
      })
    }
  },
  methods: {
    getImgList() {
      return request.get(`${this.api.getOneMemberAlbum}/${this.memberId}`).then(res => {
        let { code, message, data } = res.data;
        data = data || [];
        if (code !== 200) {
          this.$message.error(message);
          return;
        }
        this.folderData = data.slice();
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.page-content {
  min-width: 1200px;
}
</style>
