<template>
  <com-dialog
    title="预览"
    :show="show"
    hideFloor
    @update:show="val => $emit('update:show', val)">

    <div class="share-layer" v-if="items.length">
      <previewItem v-for="item in items" :item="normalize(item)" :key="item.id" />
    </div>

    <p v-else style="text-align:center;margin-top: 50px">
      暂无预览链接，请先设置初始场景。
    </p>
  </com-dialog>
</template>

<script>
import comDialog from "@/components/dialog";
import previewItem from "@/components/previewItem";
import { EXAMINE_ADOPT_STATUS } from '@/constant'

export default {
  props: ['show', 'items'],
  methods: {
    normalize(item) {
      return {
        ...item,
        QrCode: item.QrCode + '?m=' + Date.now(),
        link: (item.status === EXAMINE_ADOPT_STATUS && item.online) ? item.vrLink : item.innerVrLink,
        title: (item.type === 'house' && item.byType === 'garden') ? item.houseTitle : item.type === 'house' ? item.roomName : item.houseTitle,
      }
    }
  },
  components: {
    "com-dialog": comDialog,
    previewItem
  }  
}
</script>

<style lang="scss" scoped>
.share-layer {
  margin: 0 16px 0 75px;
  padding-right: 55px;
  overflow-y: auto;
  max-height: 448px;
}

</style>
