You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
203 lines
4.5 KiB
203 lines
4.5 KiB
const app = getApp<IAppOption>(); |
|
|
|
Page({ |
|
data: { |
|
show1: false, |
|
isOpen: 2, |
|
|
|
caseId: "", |
|
images: [] as any, |
|
info: "", |
|
audios: [] as any, |
|
files: [] as any, |
|
|
|
DoctorLevel: 1, |
|
}, |
|
onLoad(options) { |
|
this.setData({ |
|
caseId: options.id, |
|
}); |
|
app.waitLogin().then(() => { |
|
app.getUserInfo(this, (res) => { |
|
this.setData({ |
|
DoctorLevel: res.DoctorLevel, |
|
}); |
|
}); |
|
}); |
|
}, |
|
handlePhoto(e) { |
|
const detail = e.detail; |
|
const images = this.data.images; |
|
this.setData({ |
|
images: [ |
|
...images, |
|
{ |
|
name: detail.name, |
|
url: detail.fileUrl, |
|
isRepeat: 2, |
|
}, |
|
], |
|
}); |
|
}, |
|
handleDelPhoto(e) { |
|
const { index } = e.currentTarget.dataset; |
|
this.setData({ |
|
images: this.data.images.filter((_, i) => i !== Number(index)), |
|
}); |
|
}, |
|
handleAudio(e) { |
|
this.setData({ |
|
audios: [ |
|
...this.data.audios, |
|
{ |
|
name: e.detail.name, |
|
url: e.detail.fileUrl, |
|
duration: e.detail.duration, |
|
isRepeat: 2, |
|
}, |
|
], |
|
}); |
|
}, |
|
handleDelAudio(e) { |
|
const { index } = e.currentTarget.dataset; |
|
this.setData({ |
|
audios: this.data.audios.filter((_, i) => i !== Number(index)), |
|
}); |
|
}, |
|
handleFile(e) { |
|
this.setData({ |
|
files: [ |
|
...this.data.files, |
|
{ |
|
fileType: e.detail.fileType, |
|
name: e.detail.name, |
|
url: e.detail.fileUrl, |
|
size: e.detail.size, |
|
isRepeat: 2, |
|
videoUrl: e.detail.videoUrl, |
|
duration: e.detail.duration, |
|
}, |
|
], |
|
}); |
|
}, |
|
handleDelFile(e) { |
|
const { index } = e.currentTarget.dataset; |
|
this.setData({ |
|
files: this.data.files.filter((_, i) => i !== Number(index)), |
|
}); |
|
}, |
|
handlePreviewFile(e) { |
|
const { index } = e.currentTarget.dataset; |
|
const item = this.data.files[index]; |
|
wx.downloadFile({ |
|
url: item.url, |
|
success(res) { |
|
wx.openDocument({ |
|
filePath: res.tempFilePath, |
|
fail() { |
|
wx.showToast({ |
|
title: "该文件无法预览", |
|
icon: "none", |
|
}); |
|
}, |
|
}); |
|
}, |
|
}); |
|
}, |
|
handleDownloadFile(e) { |
|
const { index } = e.currentTarget.dataset; |
|
const item = this.data.files[index]; |
|
wx.downloadFile({ |
|
url: item.url, |
|
success(res) { |
|
if (res.statusCode === 200) { |
|
wx.hideLoading(); |
|
const tempFilePath = res.tempFilePath; |
|
const FileSystemManager = wx.getFileSystemManager(); |
|
FileSystemManager.saveFile({ |
|
tempFilePath, |
|
success() { |
|
wx.showToast({ |
|
title: "下载成功", |
|
icon: "none", |
|
mask: true, |
|
}); |
|
}, |
|
fail() { |
|
wx.showToast({ |
|
title: "下载失败,请重新尝试", |
|
icon: "none", |
|
mask: true, |
|
}); |
|
}, |
|
}); |
|
} |
|
}, |
|
}); |
|
}, |
|
formatParams() { |
|
const { images, info, audios, files } = this.data; |
|
return { images: JSON.stringify(images), info, audios: JSON.stringify(audios), files: JSON.stringify(files) }; |
|
}, |
|
onClose() { |
|
this.setData({ |
|
show1: false, |
|
}); |
|
}, |
|
handleTogleOpen() { |
|
this.setData({ |
|
isOpen: this.data.isOpen === 1 ? 2 : 1, |
|
}); |
|
}, |
|
handleSave() { |
|
const { images, audios, files, info } = this.data; |
|
if (images.length === 0 && audios.length === 0 && files.length === 0 && !info) { |
|
wx.showToast({ |
|
title: "请填写或上传反馈信息", |
|
icon: "none", |
|
}); |
|
return; |
|
} |
|
this.setData({ |
|
show1: true, |
|
}); |
|
}, |
|
handleBack() { |
|
wx.navigateBack(); |
|
}, |
|
|
|
handleSubmit() { |
|
const { caseId, isOpen } = this.data; |
|
const params = this.formatParams(); |
|
wx.ajax({ |
|
method: "POST", |
|
url: "?r=takeda/case/add-feedback", |
|
data: { |
|
...params, |
|
caseId, |
|
isOpen, |
|
}, |
|
}).then(() => { |
|
wx.navigateBack(); |
|
}); |
|
}, |
|
handleInvite() { |
|
const { caseId, isOpen } = this.data; |
|
const params = this.formatParams(); |
|
wx.navigateTo({ |
|
url: `/module1/pages/setCaseDoctor/index`, |
|
success: (res) => { |
|
res.eventChannel.emit("acceptDataFromOpenerPage", { |
|
params: { |
|
...params, |
|
isOpen, |
|
}, |
|
caseId, |
|
feedBackInvite: true, |
|
}); |
|
}, |
|
}); |
|
}, |
|
}); |
|
|
|
export {};
|
|
|