修改附件
parent
5f7f73970a
commit
0364e37009
|
|
@ -38,7 +38,7 @@
|
||||||
<view v-for="(item, i) in ob" :key="i">
|
<view v-for="(item, i) in ob" :key="i">
|
||||||
<view class="flex items-center h-84rpx">
|
<view class="flex items-center h-84rpx">
|
||||||
<view class="w-110rpx text-primary"
|
<view class="w-110rpx text-primary"
|
||||||
>{{ timeFormat(item.month, 'mm') }}月</view
|
>{{ timeFormat(`${item.month}-01`, 'mm') }}月</view
|
||||||
>
|
>
|
||||||
<view class="flex-1"
|
<view class="flex-1"
|
||||||
>{{ item.actual_performance }}/{{
|
>{{ item.actual_performance }}/{{
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,15 @@
|
||||||
<uv-parse :content="info.content"></uv-parse>
|
<uv-parse :content="info.content"></uv-parse>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<uv-modal
|
||||||
|
ref="modalRef"
|
||||||
|
title="下载成功"
|
||||||
|
content="下载成功!是否打开"
|
||||||
|
showCancelButton
|
||||||
|
@confirm="confirm"
|
||||||
|
>
|
||||||
|
</uv-modal>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|
@ -52,8 +61,10 @@ import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { timeFormat } from '@climblee/uv-ui/libs/function'
|
import { timeFormat } from '@climblee/uv-ui/libs/function'
|
||||||
|
|
||||||
|
const modalRef = ref(null)
|
||||||
const id = ref('')
|
const id = ref('')
|
||||||
const info = ref({})
|
const info = ref({})
|
||||||
|
const tempFile = ref(null)
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
id.value = options.id
|
id.value = options.id
|
||||||
http.get(`/train/books/${id.value}`).then((res) => {
|
http.get(`/train/books/${id.value}`).then((res) => {
|
||||||
|
|
@ -62,59 +73,33 @@ onLoad((options) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const downloadFile = (url) => {
|
const downloadFile = (url) => {
|
||||||
// #ifdef H5
|
const filetype = url.substring(url.lastIndexOf('.') + 1)
|
||||||
|
const whiteFile = ['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx']
|
||||||
uni.downloadFile({
|
uni.downloadFile({
|
||||||
url: url, // 文件的URL
|
url: url,
|
||||||
success: function (res) {
|
success: (res) => {
|
||||||
console.log('下载成功', res)
|
if (res.statusCode === 200) {
|
||||||
// 在这里可以处理文件下载后的操作,比如保存到本地、读取文件内容等
|
tempFile.value = res
|
||||||
},
|
|
||||||
fail: function (err) {
|
if (whiteFile.includes(filetype)) {
|
||||||
console.log('下载失败', err)
|
modalRef.value.open()
|
||||||
// 在这里可以处理文件下载失败的情况,比如重新下载、提示用户等
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '下载成功',
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
// #endif
|
|
||||||
// #ifdef APP-PLUS
|
|
||||||
let dtask = plus.downloader.createDownload(
|
|
||||||
url,
|
|
||||||
{
|
|
||||||
filename: 'file://storage/emulated/0/Download/',
|
|
||||||
},
|
|
||||||
(d, status) => {
|
|
||||||
if (status == 200) {
|
|
||||||
let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename)
|
|
||||||
// saveFile(fileSaveUrl)
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载成功',
|
|
||||||
icon: 'none',
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
//下载失败
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载失败',
|
|
||||||
})
|
|
||||||
plus.downloader.clear() //清除下载任务
|
|
||||||
}
|
|
||||||
console.log(d)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
dtask.start()
|
|
||||||
// #endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveFile = (filePath) => {
|
const confirm = () => {
|
||||||
uni.saveFile({
|
var filePath = encodeURI(tempFile.value.tempFilePath)
|
||||||
tempFilePath: filePath,
|
uni.openDocument({
|
||||||
success: (res) => {
|
filePath: encodeURI(filePath),
|
||||||
uni.showToast({
|
// fileType: filetype,
|
||||||
title: '文件保存成功',
|
showMenu: true,
|
||||||
})
|
|
||||||
console.log('文件保存成功,路径为:' + res.savedFilePath)
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
console.log('文件保存失败:' + err)
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue