信达小程序
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.

147 lines
3.2 KiB

2 months ago
import dayjs from 'dayjs';
const app = getApp<IAppOption>();
2 months ago
Page({
data: {
2 months ago
popupShow: false,
popupType: 'popup5', // 绑定医生弹窗
popupParams: {
position: 'bottom',
} as any,
2 months ago
Timestamp: '',
2 months ago
doc: '1',
2 months ago
2 months ago
id: '',
detail: {} as any,
showShare: false,
2 months ago
2 months ago
fileIcon: {
pdf: 'file-icon1',
doc: 'file-icon2',
docx: 'file-icon3',
pptx: 'file-icon4',
xls: 'file-icon5',
xlsx: 'file-icon6',
ppt: 'file-icon7',
none: 'file-icon8',
},
2 months ago
},
2 months ago
onLoad(options) {
this.setData({
id: options.id,
});
app.waitLogin({ type: 2 }).then(() => {
app.mpBehavior({ PositionId: '1', OperateType: '1', OperateId: options.id as string });
this.getDetail();
});
},
getDetail() {
wx.ajax({
method: 'GET',
url: '?r=xd/doctor/index/get-material-detail',
data: {
Id: this.data.id,
},
}).then((res) => {
if (res.ContentType == '4') {
wx.hideShareMenu();
wx.offCopyUrl();
wx.setNavigationBarTitle({
title: '通知详情',
});
}
2 months ago
this.setData({
detail: {
...res,
PublishTime: dayjs(res.PublishTime).format('YYYY-MM-DD'),
},
showShare: res.ContentType !== '4',
2 months ago
});
});
},
1 month ago
handlePopup(e) {
const { index } = e.currentTarget.dataset;
2 months ago
this.setData({
popupShow: true,
popupType: 'popup5',
popupParams: {
position: 'bottom',
1 month ago
index,
2 months ago
},
});
},
handlePopupOk() {
const { popupType } = this.data;
if (popupType === 'popup5') {
this.handleDownload();
this.handlePopupCancel();
}
},
handlePopupCancel() {
this.setData({
popupShow: false,
});
},
2 months ago
handleDownload() {
1 month ago
const {
detail,
popupParams: { index },
} = this.data;
const params = detail.FileList[index];
2 months ago
wx.showLoading({
title: '加载中',
mask: true,
});
2 months ago
app.mpBehavior({ PositionId: '1', OperateType: '2', OperateId: detail.Id as string });
2 months ago
wx.downloadFile({
1 month ago
url: params.FileUrl,
filePath: `${wx.env.USER_DATA_PATH}/${params.FileName}`,
2 months ago
success: (res) => {
if (res.statusCode === 200) {
wx.openDocument({
2 months ago
showMenu: true,
filePath: res.filePath,
2 months ago
success: () => {
2 months ago
wx.hideLoading();
2 months ago
},
fail: (err) => {
2 months ago
wx.showToast({
title: '下载文件失败',
icon: 'none',
});
wx.hideLoading();
2 months ago
},
});
} else {
2 months ago
wx.hideLoading();
wx.showToast({
title: '下载文件失败',
icon: 'none',
});
2 months ago
}
},
2 months ago
fail(err) {
2 months ago
wx.hideLoading();
wx.showToast({
title: '下载文件失败',
icon: 'none',
});
},
2 months ago
});
},
2 months ago
onShareAppMessage() {
const { Title, CoverImgUrl, Id } = this.data.detail;
app.mpBehavior({ PositionId: '1', OperateType: '3', OperateId: Id as string });
return {
title: Title,
path: `/pages/informationDetail/index?id=${Id}`,
imageUrl: CoverImgUrl,
};
2 months ago
},
2 months ago
});
export {};