<template>
  <div class="get-file">
    <loading :active="isLoading" :is-full-page="true" />
  </div>
</template>

<script>
import Loading from "vue-loading-overlay";
import "vue-loading-overlay/dist/vue-loading.css";
import { serchUrlPath } from "../api/registrations";
import { buildPdfUrl } from "../api/client";

export default {
  name: "GetFile",
  components: {
    Loading,
  },
  data() {
    return {
      isLoading: false,
    };
  },
  computed: {
    fileSuffix() {
      return this.$route.params.urlPath;
    },
    fullPath() {
      return this.$route.fullPath;
    },
  },
  mounted() {
    this.isLoading = true;
    serchUrlPath(this.fileSuffix).then((res) => {
      if (res != null && res.length > 1) {
        window.location.href = buildPdfUrl(res);
      } else {
        this.isLoading = false;
        alert("请访问短信提供的链接！");
      }
    }).catch(() => {
      this.isLoading = false;
    });
  },
};
</script>

<style scoped>
.get-file {
  padding: 20px;
}
</style>
