|
@@ -61,54 +61,40 @@ Page({
|
|
|
this.initTemplate()
|
|
|
}
|
|
|
},
|
|
|
- deleteFile(e) {
|
|
|
- let item = e.detail.attachmentid ? e.detail : e.currentTarget.dataset.item,
|
|
|
- that = this;
|
|
|
- if (!e.detail.attachmentid) {
|
|
|
- wx.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '是否确认删除该附件',
|
|
|
- complete: ({
|
|
|
- confirm
|
|
|
- }) => {
|
|
|
- if (confirm) that.handleDelete([item.linksid]).then(res => {
|
|
|
- if (res.msg != '成功') return wx.showToast({
|
|
|
- title: res.data,
|
|
|
- icon: "none"
|
|
|
- })
|
|
|
- let files = that.data.files,
|
|
|
- name = item.fileType == "image" ? "images" : "videos",
|
|
|
- name2 = item.fileType == "image" ? "viewImages" : "viewVideos",
|
|
|
- data = that.data.files[name].find(v => v.url == item.url);
|
|
|
- files[name] = files[name].filter(v => v.url != data.url);
|
|
|
- files[name2] = files[name2].filter(v => v.url != data.url);
|
|
|
- that.setData({
|
|
|
- files
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- that.handleDelete([item.linksid]).then(res => {
|
|
|
- if (res.msg != '成功') return wx.showToast({
|
|
|
- title: res.data,
|
|
|
- icon: "none"
|
|
|
- })
|
|
|
- let files = that.data.files;
|
|
|
- files.files = files.files.filter(v => v.url != item.url);
|
|
|
- that.setData({
|
|
|
- files
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- handleDelete(linksid) {
|
|
|
- return _Http.basic({
|
|
|
+ /* 删除文件 */
|
|
|
+ deleteFile({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ let e = detail,
|
|
|
+ item = e.detail.attachmentid ? e.detail : e.currentTarget.dataset.item;
|
|
|
+ _Http.basic({
|
|
|
"classname": "system.attachment.Attachment",
|
|
|
"method": "deleteFileLink",
|
|
|
"content": {
|
|
|
- "linksids": linksid
|
|
|
+ "linksids": [item.linksid]
|
|
|
}
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ let files = this.data.files;
|
|
|
+ switch (item.fileType) {
|
|
|
+ case "image":
|
|
|
+ files.images = files.images.filter(v => v.url != item.url);
|
|
|
+ files.viewImages = files.viewImages.filter(v => v.url != item.url);
|
|
|
+ break;
|
|
|
+ case "video":
|
|
|
+ files.videos = files.videos.filter(v => v.url != item.url);
|
|
|
+ files.viewVideos = files.viewVideos.filter(v => v.url != item.url);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ files.files = files.files.filter(v => v.attachmentid != item.attachmentid);
|
|
|
+ break;
|
|
|
+ };
|
|
|
+ this.setData({
|
|
|
+ files
|
|
|
+ });
|
|
|
})
|
|
|
},
|
|
|
/* 绑定媒体 */
|
|
@@ -132,7 +118,6 @@ Page({
|
|
|
/* 处理附件 */
|
|
|
handleFiles(list) {
|
|
|
let files = this.data.files;
|
|
|
-
|
|
|
list.forEach(v => {
|
|
|
switch (v.fileType) {
|
|
|
case "video":
|
|
@@ -159,17 +144,6 @@ Page({
|
|
|
files
|
|
|
})
|
|
|
},
|
|
|
- /* 预览媒体 */
|
|
|
- viewMedias(e) {
|
|
|
- const {
|
|
|
- index,
|
|
|
- type
|
|
|
- } = e.currentTarget.dataset;
|
|
|
- wx.previewMedia({
|
|
|
- current: index,
|
|
|
- sources: type == 'image' ? this.data.files.viewImages : this.data.files.viewVideos,
|
|
|
- })
|
|
|
- },
|
|
|
/* 初始化模板 */
|
|
|
initTemplate() {
|
|
|
_Http.basic({
|