Compare commits

..

No commits in common. "fd226c260bfcb5321759eaaa568ca63d3e25ae22" and "3abe54740ef0be11a63842752e36c3db3dd28f1d" have entirely different histories.

2 changed files with 49 additions and 34 deletions

View File

@ -38,7 +38,7 @@
<view v-for="(item, i) in ob" :key="i">
<view class="flex items-center h-84rpx">
<view class="w-110rpx text-primary"
>{{ timeFormat(`${item.month}-01`, 'mm') }}</view
>{{ timeFormat(item.month, 'mm') }}</view
>
<view class="flex-1"
>{{ item.actual_performance }}/{{

View File

@ -43,15 +43,6 @@
<uv-parse :content="info.content"></uv-parse>
</view>
</template>
<uv-modal
ref="modalRef"
title="下载成功"
content="下载成功!是否打开"
showCancelButton
@confirm="confirm"
>
</uv-modal>
</view>
</template>
<script setup>
@ -61,10 +52,8 @@ import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { timeFormat } from '@climblee/uv-ui/libs/function'
const modalRef = ref(null)
const id = ref('')
const info = ref({})
const tempFile = ref(null)
onLoad((options) => {
id.value = options.id
http.get(`/train/books/${id.value}`).then((res) => {
@ -73,33 +62,59 @@ onLoad((options) => {
})
const downloadFile = (url) => {
const filetype = url.substring(url.lastIndexOf('.') + 1)
const whiteFile = ['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx']
// #ifdef H5
uni.downloadFile({
url: url,
success: (res) => {
if (res.statusCode === 200) {
tempFile.value = res
if (whiteFile.includes(filetype)) {
modalRef.value.open()
} else {
uni.showToast({
title: '下载成功',
icon: 'none',
})
}
}
url: url, // URL
success: function (res) {
console.log('下载成功', res)
//
},
fail: function (err) {
console.log('下载失败', err)
//
},
})
// #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 confirm = () => {
var filePath = encodeURI(tempFile.value.tempFilePath)
uni.openDocument({
filePath: encodeURI(filePath),
// fileType: filetype,
showMenu: true,
const saveFile = (filePath) => {
uni.saveFile({
tempFilePath: filePath,
success: (res) => {
uni.showToast({
title: '文件保存成功',
})
console.log('文件保存成功,路径为:' + res.savedFilePath)
},
fail: (err) => {
console.log('文件保存失败:' + err)
},
})
}
</script>