<template>
	<div class="pdfBox">
		<van-sticky>
			<view class="top-bar justify-center bg-white sh">
				<van-icon class="top-left" name="arrow-left" @tap="goBack()" />
				<view>
					<view class="text-m" style="font-size: 16px;color: #333333">{{title}}</view>
				</view>
			</view>
		</van-sticky>
		<div id="previewPdf"></div>
	</div>
</template>
<script>
  import pdfh5 from 'pdfh5';
  import 'pdfh5/css/pdfh5.css'
  export default {
    name: 'pdfh5',
    data () {
      return {
        pdfh5: null,
	  title:'商城平台交易指引'
      }
    },
    mounted(){
      let url = null
	if(this.$route.query.type==1){
        this.title='营业执照'
        url= 'https://edspicserver.oss-cn-hangzhou.aliyuncs.com/ROOT/ETao/resource/business_license.pdf'
	}else if(this.$route.query.type==2) {
        url='https://img.edsmall.com/ROOT/ETao/resource/trading_guidelines.pdf'
        this.title='商城平台交易指引'
	}else {
        url='https://img.edsmall.com/ROOT/ETao/resource/ThePeoplesRepublicofChina.pdf'
        this.title='增值电信业务经营许可证'
	}
      this.openPdf(url)
    },
    methods: {
      goBack(){
        uni.redirectTo({
          url:'/pages/my/technicalSupport?name=contact',
        });
	},
      openPdf(url){     //url：PDF文件地址
        this.pdfh5 = new pdfh5('#previewPdf', {
          pdfurl:url
        });
      }
    }
  }
</script>
<style lang="scss" scoped>
	.pdfBox {
		position: fixed;
		top: 0;
		left: 0;
		width: 100vw;
		height: 100vh;
		background: #000;
		overflow: hidden;
		z-index: 99;
	}
</style>
