<template>
  <section id="download">
    <v-container fluid>
      <v-row align="center" justify="center">
        <v-col cols="10">
          <v-row align="center" justify="center">
            <v-col sm="4" class="hidden-xs-only">
              <v-img src="@/assets/img/ill2.svg" class="d-block ml-auto mr-auto" max-width="350px"/>
            </v-col>
            <v-col cols="12" sm="8" class="white--text text-left">
              <h1 class="font-weight-light display-2 mb-2">About Company</h1>
              <h1 class="font-weight-light">
                {{ companyData.intro }}
              </h1>
            </v-col>
          </v-row>
        </v-col>
      </v-row>
    </v-container>
  </section>
</template>
<script>
import axios from 'axios';

export default {
  data() {
    return {
      companyData: {
        intro: ""
      }
    }
  },
  created() {
    this.getCompanyData();
  },
  methods: {
    getCompanyData() {
      const websiteCode = this.extractSubstring(window.location.pathname);
      let userWebsiteId = "";
      axios.get("/api/website/template/getWebsiteByWebsiteCode", {
        params: {
          websiteCode: websiteCode,
        }
      }).then(response => {
        if (response.data.code === 200) {
          userWebsiteId = response.data.data.id;
          axios.get("/api/website/template/company", {
            params: {
              userWebsiteId: userWebsiteId,
            }
          }).then(response => {
            if (response.data.data !== null) {
              this.companyData = response.data.data;
            }
          })
        }
      })
          .catch(error => {
            console.error('Error fetching company data:', error);
          });
    },
    extractSubstring(str) {
      const startIndex = str.indexOf('/');
      if (startIndex !== -1) {
        const endIndex = str.indexOf('/', startIndex + 1);
        if (endIndex !== -1) {
          return str.substring(startIndex + 1, endIndex - 1);
        } else {
          return str.substring(startIndex + 1);
        }
      }
      return ''; // 如果没有找到匹配，返回空字符串
    }
  }
}
</script>
<style scoped>
#download {
  background-image: url("~@/assets/img/bgDownload.jpg");
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  height: 500px;
}

#download .container,
#download .row {
  height: 100%;
}
</style>