<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
							   })
			        }
			    },
				// fail:(res)=>{
				// 	console.log('fail',option.url,res);
				// },
				// complete:(res)=>{
				// 	console.log('complete',option.url,res);
				// }
			})
			downloadTask.onProgressUpdate((res) => {
				this.progress=res.progress
			});
		},
		onShow() {
			if(this.progress==100){
				uni.navigateBack()
			}		
		}
	}
</script>

<style>

</style>
