downloadFile.vue 770 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <!-- 下载页面 -->
  3. <view class="progress-box">
  4. <progress :percent="progress" show-info stroke-width="3" />
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. progress: 0,
  12. };
  13. },
  14. methods: {},
  15. onLoad(option) {
  16. const downloadTask = uni.downloadFile({
  17. url: option.url,
  18. success: (res) => {
  19. if (res.statusCode === 200) {
  20. uni.openDocument({
  21. filePath: res.tempFilePath,
  22. showMenu: true, //是否显示右上角菜单
  23. });
  24. }
  25. },
  26. });
  27. downloadTask.onProgressUpdate((res) => {
  28. this.progress = res.progress;
  29. });
  30. },
  31. onShow() {
  32. if (this.progress == 100) {
  33. uni.navigateBack();
  34. }
  35. },
  36. };
  37. </script>
  38. <style></style>