/*
 * @Author: zhangzc
 * @Email: zhangzc2@guahao.com
 * @Date: 2019-09-10 15:33:37
 * @Last Modified by: hejk
 * @Last Modified time: 2022-01-25 15:40:32
 * @Description: pdf阅读组件
 * @Route: Route
 */
<template>
    <div class="pdf-container">
        <template v-for="i in totalPages">
            <pdf :src="task"
                 :page="i"
                 :key="i"
                 class="pdf-item" />
        </template>
    </div>
</template>
<script>
// import { urlObject } from 'utils/util';
import pdf from './pdf/vuePdfNoSssNoWorker';

export default {
    name: 'BkPdfReader',
    components: {
        pdf
    },
    props: {
        url: {
            type: String,
            default: ''
        }
    },
    data() {
        return {
            task: '',
            totalPages: 0
        };
    },
    created() {
        // const urlReg = /^(https?):\/\//;
        
        // if (!urlReg.test(this.url)) return;
        // const urlObj = urlObject(this.url);
        // const { pathname, search } = urlObj;
        // this.loading = true;
        // const url = `/oss${pathname}${search}`;
        this.task = pdf.createLoadingTask(this.url);
        this.task.then(pdfInfo => {
            this.totalPages = pdfInfo.numPages;
        });
    }
};
</script>
