fix:文件阅览
This commit is contained in:
parent
8d356e43e6
commit
9b0d21f66a
4
app.js
4
app.js
|
|
@ -52,8 +52,8 @@ App({
|
|||
userInfo: {},
|
||||
// headerUrl: "http://42.193.40.239:8017/" //线上
|
||||
// headerUrl: "http://192.168.110.10:8017/" //线下
|
||||
headerUrl: "http://192.168.110.186:8017/"
|
||||
// headerUrl: "https://city.sczysoft.com/df/"
|
||||
// headerUrl: "http://192.168.110.186:8017/"
|
||||
headerUrl: "https://city.sczysoft.com/df/"
|
||||
},
|
||||
// https://city.sczysoft.com/df/doc.html //接口
|
||||
// https://city.sczysoft.com/dffile //查看拼接
|
||||
|
|
|
|||
|
|
@ -63,7 +63,43 @@ Page({
|
|||
const name = e.currentTarget.dataset.name;
|
||||
this.data.postData[name] = e.detail.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* 阅览文件
|
||||
*/
|
||||
openread: function (e) {
|
||||
const item = e.currentTarget.dataset.item;
|
||||
const extension = item.filepath.split('.').pop().toLowerCase();
|
||||
if(extension == 'jpg' || extension == 'png' ){
|
||||
wx.previewImage({
|
||||
urls: [app.FILE_SERVER_URL + item.filepath] // 需要预览的图片http链接列表
|
||||
})
|
||||
return
|
||||
}
|
||||
if(extension == 'mp4'){
|
||||
this.setData({
|
||||
videoSrc:app.FILE_SERVER_URL + item.filepath,
|
||||
video: true
|
||||
});
|
||||
return
|
||||
}
|
||||
wx.downloadFile({
|
||||
url: app.FILE_SERVER_URL + item.filepath, //仅为示例,并非真实的资源
|
||||
success(res) {
|
||||
if (res.statusCode === 200) {
|
||||
wx.openDocument({
|
||||
filePath: res.tempFilePath,
|
||||
fail: function (res) {
|
||||
wx.showToast({
|
||||
title: '不支持此格式',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 选择文件
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -59,12 +59,21 @@
|
|||
|
||||
<text wx:if="{{!readonly}}" catchtap="chooseMessageFile" class="title cuIcon-roundadd" style="font-weight: normal;color: #5DA6F4;margin-left: 20rpx;">文件上传</text>
|
||||
</view>
|
||||
<view class="grid">
|
||||
<view style="width: 100%;">
|
||||
<view style="display: flex;margin: 10px 0;align-items: center;" wx:for="{{ files }}">
|
||||
<text style="width: 90%;Word-break:break-all" catchtap="openread" data-item="{{item}}">
|
||||
<text>{{ index + 1 }}</text>
|
||||
<text>{{ item.realfilename }}</text>
|
||||
</text>
|
||||
<text catchtap="deleteFile" data-id="{{item.sysdocumentid}}" class="cuIcon-delete del" style="color:red;"></text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="grid">
|
||||
<view class="img" wx:for="{{files}}" style="position: relative;">
|
||||
<text wx:if="{{!readonly}}" catchtap="deleteFile" data-id="{{item.sysdocumentid}}" class="cuIcon-delete del" style="color:red;"></text>
|
||||
<image class="img" src="{{baseUrl+item.filepath}}" catchtap="filePre" data-url="{{item.filepath}}" />
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="space"></view>
|
||||
</scroll-view>
|
||||
|
|
|
|||
|
|
@ -109,7 +109,43 @@ Page({
|
|||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 阅览文件
|
||||
*/
|
||||
openread: function (e) {
|
||||
const item = e.currentTarget.dataset.item;
|
||||
const extension = item.filepath.split('.').pop().toLowerCase();
|
||||
if(extension == 'jpg' || extension == 'png' ){
|
||||
wx.previewImage({
|
||||
urls: [app.FILE_SERVER_URL + item.filepath] // 需要预览的图片http链接列表
|
||||
})
|
||||
return
|
||||
}
|
||||
if(extension == 'mp4'){
|
||||
this.setData({
|
||||
videoSrc:app.FILE_SERVER_URL + item.filepath,
|
||||
video: true
|
||||
});
|
||||
return
|
||||
}
|
||||
wx.downloadFile({
|
||||
url: app.FILE_SERVER_URL + item.filepath, //仅为示例,并非真实的资源
|
||||
success(res) {
|
||||
if (res.statusCode === 200) {
|
||||
wx.openDocument({
|
||||
filePath: res.tempFilePath,
|
||||
fail: function (res) {
|
||||
wx.showToast({
|
||||
title: '不支持此格式',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取工作类型
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -44,12 +44,21 @@
|
|||
<text catchtap="chooseFile" class="title cuIcon-roundadd" style="font-weight: normal;color: #5DA6F4;">添加图片</text>
|
||||
<text catchtap="chooseMessageFile" class="title cuIcon-roundadd" style="font-weight: normal;color: #5DA6F4;margin-left: 20rpx;">文件上传</text>
|
||||
</view>
|
||||
<view class="grid">
|
||||
<view style="width: 100%;">
|
||||
<view style="display: flex;margin: 10px 0;align-items: center;" wx:for="{{ files}}">
|
||||
<text style="width: 90%;Word-break:break-all" catchtap="openread" data-item="{{item}}">
|
||||
<text>{{ index + 1 }}</text>
|
||||
<text>{{ item.realfilename }}</text>
|
||||
</text>
|
||||
<text catchtap="deleteFile" data-id="{{item.sysdocumentid}}" class="cuIcon-delete del" style="color:red;"></text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="grid">
|
||||
<view class="img" wx:for="{{files}}" style="position: relative;">
|
||||
<text catchtap="deleteFile" data-id="{{item.sysdocumentid}}" class="cuIcon-delete del" style="color:red;"></text>
|
||||
<image class="img" src="{{baseUrl+item.filepath}}" catchtap="filePre" data-url="{{item.filepath}}" />
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="space"></view>
|
||||
</scroll-view>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user