<template>
  <view class="">
    <!-- <web-view src="https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/1.pdf" /> -->
    <!-- #ifdef APP-PLUS -->
    <web-view :src="pdfUrl" />
    <!-- #endif -->
    <!-- #ifdef H5 -->
    <web-view :src="pdfUrl" />
    <!-- #endif -->
  </view>
</template>

<script>
  export default {
    data() {
      return {
        pdfUrl: '' // PDF 文件的 URL
      }
    },
    onLoad(options) {
      // this.pdfUrl = options.url; // 从参数中获取 PDF 文件的 URL
      // this.pdfUrl = uni.downloadFile('https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/1.pdf')
      let that = this;
      // 从参数中获取 PDF 文件的 URL
      // #ifdef APP-PLUS
      that.pdfUrl = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(options.url); 
      // #endif
      // #ifdef H5
      that.pdfUrl = options.url
      // uni.downloadFile({
      //   url: options.url,
      //   success: function(res) {
      //     var filePath = res.tempFilePath;
      //     uni.openDocument({
      //       filePath: filePath,
      //       showMenu: true,
      //       success: function (res) {
      //         console.log('打开文档成功');
      //       }
      //     });
      //   }
      // });
      // #endif
      
    },
    onShow() {},
    methods: {},
    onPullDownRefresh() {
      uni.stopPullDownRefresh()
    }
  }
</script>

<style lang="scss">

</style>