Commit 4f93e67d by 程智春

下载文件

parent 8db45656
......@@ -12,7 +12,8 @@
"pages/tabBar2/main",
"pages/tabBar3/main",
"pages/tabBar4/main",
"pages/changeAdr/main"
"pages/changeAdr/main",
"pages/downFile/main"
],
"usingComponents": {},
"window": {
......
<template>
<div class="container">
<van-loading style="margin-top:20%" v-if="status" size="24px" vertical>下载中...</van-loading>
</div>
</template>
<script>
export default {
data(){
return{
status : true
}
},
created(){
// this.download()
},
methods : {
download(){
let down = wx.downloadFile({
url : 'http://bkzs.hfut.edu.cn/generic/web/viewer.html?file=/userfiles/1/files/files/2019/12/%E5%90%88%E8%82%A5%E5%B7%A5%E4%B8%9A%E5%A4%A7%E5%AD%A62019%E5%B9%B4%E6%8A%A5%E8%80%83%E6%8C%87%E5%8D%971.pdf',
success : (data) => {
console.log('下载成功',data)
console.log(data.tempFilePath)
if(data.statusCode == 200){
wx.openDocument({
filePath: data.tempFilePath,
showMenu:true,
fileType : 'pdf',
success: function (res) {
console.log('打开文档成功',res)
}
})
}
},
fail : (err) => {
console.log('下载失败',err)
}
})
down.onProgressUpdate((res) => {
console.log(res,'res')
if(res.progress == 100){
console.log('下载成功')
this.status = false
}
})
}
}
}
</script>
<style scoped lang="scss">
</style>
\ No newline at end of file
import Vue from 'vue'
import App from './index'
const app = new Vue(App)
app.$mount()
\ No newline at end of file
{
"navigationBarTitleText":"下载",
"usingComponents": {
"van-loading": "/static/vant/loading/index"
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment