index_1.vue
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<template>
<view class="ncc-file">
<view @click='downLoad(item)' v-for='(item,index) in list' :key="index"
class="ncc-file-item u-type-primary u-line-1">
{{item.name}}
</view>
</view>
</template>
<script>
import {
getDownloadUrl
} from '@/api/common'
export default {
props: {
list: {
type: Array,
default: () => ([])
},
},
methods: {
downLoad(item) {
// #ifdef MP
uni.navigateTo({
url: `/pages/workFlow/filePreview/index??fileId=${item.fileId}&name=${item.name}`
})
// #endif
// #ifndef MP
getDownloadUrl('workFlow', item.fileId).then(res => {
const fileUrl = this.define.baseURL + res.data.url;
// #ifdef H5
window.location.href = fileUrl;
// #endif
// #ifdef APP-PLUS
this.downloadFile(res.data.url);
// #endif
})
// #endif
},
downloadFile(url) {
uni.downloadFile({
url: baseUrl + url,
success: res => {
const filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
success: res => {
}
});
}
});
},
}
}
</script>
<style lang="scss" scoped>
.ncc-file {
.ncc-file-item {
width: 500rpx;
line-height: 60rpx;
}
}
</style>