<template>
  <div class="page" v-loading.body.fullscreen="fullscreenLoading" element-loading-background="rgba(255, 255, 255, 0)">
    <div class="header">
      <div class="back">
        <backIcon/>
      </div>
      {{ title[id] }}
    </div>
    <iframe v-if="iframeUrl" class="iframe" :src="iframeUrl" frameborder="0"></iframe>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
  data () {
    return {
      content: '',
      id: '',
      title: {
        // '5': '用户协议',
        // '3': '隐私条款',
        // '25': '声明',
        // '1': 'AML/KYC 政策',
        // '7': '法律声明',
        // '9': '风险披露',
        '5': this.$t('auth.l28'),
        '3': this.$t('common.l56'),
        '25': this.$t('share.l11'),
        '1': this.$t('auth.l35'),
        '7': this.$t('auth.l25'),
        '9': this.$t('auth.l26'),
      }
    }
  },
  computed: {
    ...mapGetters(['iframeUrlObj']),
    iframeUrl() {
      var url = {
        '5': 'user',
        '3': 'privacy',
        '25': 'coupon',
        '1': 'kyc',
        '7': 'legal',
        '9': 'risk',
      }
      return (this.iframeUrlObj && this.iframeUrlObj[url[this.id]][this.language])
    }
  },
  created () {
    if (this.$route.params.id) {
      this.id = this.$route.params.id
      if (!this.iframeUrlObj) {
        this.$store.dispatch('getIframeUrl')
      }
    }
  },
  methods: {
  }
}
</script>
<style lang="less" scoped>
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  text-align: center;
  padding-top: 15px;
  padding-bottom: 17px;
  font-size: 18px;
  font-weight: 600;
  background-color: var(--bg-);
  .back {
    position: absolute;
    left: 9px;
    top: 11px;
  }
}
.iframe {
  position: fixed;
  top: 50px;
  left: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  height: calc(100% - 50px);
}
.container {
  padding: 10px 18px 27px;
  background-color: #fff;
}
::v-deep .content {
  word-break: break-all;
  P {
    font-size: 14px;
    color: #3D3C3C;
    line-height: 24px;
    margin-bottom: 10px;
    border-radius: 8px;
    border: 1px solid #F1F1F1;
    padding: 17px 14px;
  }
  img {
    max-width: 100%;
    height: auto !important;
  }
  h1 {
    padding: 10px 0;
    line-height: 1.2em;
  }
}
</style>