<template>
<!-- 下载页面 -->
  <view class="progress-box">
    <progress :percent="progress" show-info stroke-width="3" />
  </view>
</template>

<script>
export default {
  data() {
    return {
      progress: 0,
    };
  },
  methods: {},
  onLoad(option) {
    const downloadTask = uni.downloadFile({
      url: option.url,
      success: (res) => {
        if (res.statusCode === 200) {
          uni.openDocument({
            filePath: res.tempFilePath,
            showMenu: true, //是否显示右上角菜单
          });
        }
      },
    });
    downloadTask.onProgressUpdate((res) => {
      this.progress = res.progress;
    });
  },
  onShow() {
    if (this.progress == 100) {
      uni.navigateBack();
    }
  },
};
</script>

<style></style>
