<template>
  <div class="pop" v-loading.body.fullscreen="fullscreenLoading" element-loading-background="rgba(255, 255, 255, 0)">
    <img class="close" @click="cancel" src="/img/home/nav/close.png" alt="极度证券">
    <div class="title">{{ title[id] }}</div>
    <iframe v-if="iframeUrl" class="iframe" :src="`${iframeUrl}?${random}`" frameborder="0"></iframe>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
  props: ['id'],
  data () {
    return {
      content: {},
      random: (Math.random() * 100000).toFixed(0),
      title: {
        // '5': '用户协议',
        // '7': '法律声明',
        // '9': '风险披露',
        '5': this.$t('auth.l28'),
        '7': this.$t('auth.l25'),
        '9': this.$t('auth.l26'),
      },
    }
  },
  computed: {
    ...mapGetters(['iframeUrlObj']),
    iframeUrl() {
      var url = {
        '5': 'user',
        '7': 'legal',
        '9': 'risk',
      }
      return (this.iframeUrlObj && (this.iframeUrlObj[url[this.id]][this.language] || this.iframeUrlObj[url[this.id]]['en']))
    }
  },
  created() {
    if (!this.iframeUrlObj) {
      this.$store.dispatch('getIframeUrl')
    }
  },
  methods: {
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>
<style lang="less" scoped>
.pop {
  line-height: 1;
  padding: 28px 17px 26px;
  position: relative;
  background-color: #fff;
  border-radius: 12px;
  .close {
    position: absolute;
    top: 17px;
    right: 10px;
    width: 15px;
  }
  .title {
    text-align: center;
    font-weight: 500;
    font-size: 20px;
    margin-bottom: 15px;
  }
  .text {
    font-size: 14px;
    color: #686868;
    line-height: 24px;
  }
}
.iframe {
  height: 80vh;
}
</style>