设备图纸查看修改
This commit is contained in:
parent
68bd5ff1b5
commit
b783cb87af
@ -10,11 +10,8 @@
|
||||
<u-collapse style="margin-top: 40px;">
|
||||
<u-collapse-item :title="item.fileName" :isLink="isLink" :disabled="disabled"
|
||||
v-for="(item,index) in itemDrawingList">
|
||||
<text v-if="!item.localHave" style="color: #1771f7;" slot="value"
|
||||
class="u-page__item__title__slot-title"
|
||||
@click="downloadDrawing(item.fileName,item.url,index)">下载</text>
|
||||
<text v-if="item.localHave" style="color: #1771f7;" slot="value" @click="openDrawing(item.fileName)"
|
||||
class="u-page__item__title__slot-title">打开</text>
|
||||
<text style="color: #1771f7;" slot="value" class="u-page__item__title__slot-title"
|
||||
@click="lookDrawing(item.fileName,item.url,index)">查看</text>
|
||||
</u-collapse-item>
|
||||
</u-collapse>
|
||||
</u-popup>
|
||||
@ -132,60 +129,27 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
//打开文件
|
||||
openDrawing(fileName) {
|
||||
// 判断当前环境是否为App环境
|
||||
if (this.$scope.$mp && this.$scope.$mp.runtime && this.$scope.$mp.runtime === 'app-plus') {
|
||||
// 在App环境中调用plus.io.getRoot()获取根目录
|
||||
plus.io.getRoot((root) => {
|
||||
console.log('App根目录:' + root);
|
||||
lookDrawing(fileName,url,index){
|
||||
uni.showLoading({
|
||||
title: '正在加载……'
|
||||
});
|
||||
} else {
|
||||
console.log('当前不是App环境,无法获取根目录');
|
||||
}
|
||||
console.log(fileName)
|
||||
let fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||
console.log(fileType)
|
||||
uni.openDocument({
|
||||
showMenu: true,
|
||||
fileType: fileType,
|
||||
filePath: 'file://storage/emulated/0/Android/data/com.inspur.ipcApp/apps/__UNI__B298C37/downloads/storage/ipcApp/' +
|
||||
fileName,
|
||||
success: function(res) {
|
||||
console.log(res, "打开文件成功");
|
||||
},
|
||||
fail: function(res) {
|
||||
console.log(res)
|
||||
uni.showToast({
|
||||
title: "打开文件失败请重试",
|
||||
icon: "none",
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
//本地无文件--下载并打开文件
|
||||
downloadDrawing(name, url, index) {
|
||||
let progressVal = 0;
|
||||
let that = this
|
||||
uni.showLoading({
|
||||
title: '正在下载……'
|
||||
});
|
||||
let dtask = plus.downloader.createDownload(url, {
|
||||
// filename: 'file://storage/ipcApp/' + name
|
||||
filename: 'file://storage/ipcApp/' + name
|
||||
}, function(d, status) {
|
||||
uni.downloadFile({
|
||||
url: url,
|
||||
success: function (res) {
|
||||
uni.hideLoading();
|
||||
if (status == 200) {
|
||||
uni.$u.toast('下载成功')
|
||||
let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
|
||||
console.log(fileSaveUrl)
|
||||
that.itemDrawingList[index].localHave = true;
|
||||
} else {
|
||||
uni.$u.toast('下载失败')
|
||||
plus.downloader.clear();
|
||||
var filePath = res.tempFilePath;
|
||||
uni.openDocument({
|
||||
filePath: filePath,
|
||||
fileType: fileType,
|
||||
showMenu: true,
|
||||
success: function (res) {
|
||||
console.log('打开文档成功');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
dtask.start();
|
||||
},
|
||||
clickDownload(paths) {
|
||||
this.itemDrawingList = [];
|
||||
@ -193,52 +157,11 @@
|
||||
let list = paths.split(",");
|
||||
list.forEach((item, index) => {
|
||||
let fileName = item.substring(item.lastIndexOf("/") + 1)
|
||||
const self = this;
|
||||
// // 假设你想检查的文件路径是_local://hello.txt_
|
||||
// let filePath = 'file://storage/ipcApp/' + fileName;
|
||||
// // 使用plus.io的resolveLocalFileSystemURL方法
|
||||
// plus.io.resolveLocalFileSystemURL(filePath,
|
||||
// function(entry) {
|
||||
// // 文件存在的回调
|
||||
// console.log("文件存在: " + entry.fullPath);
|
||||
// let drawing = {
|
||||
// url: baseUrl + item,
|
||||
// fileName: fileName,
|
||||
// localHave: true
|
||||
// }
|
||||
// self.itemDrawingList.push(drawing)
|
||||
// },
|
||||
// function(error) {
|
||||
// // 文件不存在的回调
|
||||
// console.log("文件不存在: " + filePath);
|
||||
// let drawing = {
|
||||
// url: baseUrl + item,
|
||||
// fileName: fileName,
|
||||
// localHave: false
|
||||
// }
|
||||
// self.itemDrawingList.push(drawing)
|
||||
// }
|
||||
// );
|
||||
uni.getFileInfo({
|
||||
filePath: 'file://storage/emulated/0/Android/data/com.inspur.ipcApp/apps/__UNI__B298C37/downloads/storage/ipcApp/' +
|
||||
fileName,
|
||||
success(res) {
|
||||
let drawing = {
|
||||
url: baseUrl + item,
|
||||
fileName: fileName,
|
||||
localHave: true
|
||||
fileName: fileName
|
||||
}
|
||||
self.itemDrawingList.push(drawing)
|
||||
},
|
||||
fail(err) {
|
||||
let drawing = {
|
||||
url: baseUrl + item,
|
||||
fileName: fileName,
|
||||
localHave: false
|
||||
}
|
||||
self.itemDrawingList.push(drawing)
|
||||
}
|
||||
})
|
||||
this.itemDrawingList.push(drawing)
|
||||
})
|
||||
}
|
||||
this.showDrawing = true;
|
||||
|
Loading…
Reference in New Issue
Block a user