|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
|
|
const app = getApp<IAppOption>();
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
list: [] as any[],
|
|
|
|
|
pagination: {
|
|
|
|
|
page: 1,
|
|
|
|
|
pages: 1,
|
|
|
|
|
count: 1,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
app.waitLogin({ type: 2 }).then(() => {
|
|
|
|
|
this.getList();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
getList(newPage = 1) {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=xd/doctor/index/get-material-list',
|
|
|
|
|
data: {
|
|
|
|
|
page: newPage,
|
|
|
|
|
ContentType: '3,5',
|
|
|
|
|
},
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
res.list.forEach((item) => {
|
|
|
|
|
item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD');
|
|
|
|
|
item.FileType = item.FileList[0]?.FileType || '';
|
|
|
|
|
});
|
|
|
|
|
const list = res.page === 1 ? res.list : [...this.data.list, ...res.list];
|
|
|
|
|
this.setData({
|
|
|
|
|
total: res.count,
|
|
|
|
|
list,
|
|
|
|
|
pagination: {
|
|
|
|
|
page: res.page,
|
|
|
|
|
pages: res.pages,
|
|
|
|
|
count: res.count,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
const { page, pages } = this.data.pagination;
|
|
|
|
|
if (pages > page) {
|
|
|
|
|
this.getList(page + 1);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleDetail(e) {
|
|
|
|
|
const { id, index } = e.currentTarget.dataset;
|
|
|
|
|
const params = this.data.list[index];
|
|
|
|
|
if (params.ContentType === '5' && params.FileList[0]) {
|
|
|
|
|
this.handleFile(params.FileList[0]);
|
|
|
|
|
} else {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: `/pages/informationDetail/index?id=${id}`,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleFile({ FileUrl, FileName }) {
|
|
|
|
|
wx.downloadFile({
|
|
|
|
|
url: FileUrl,
|
|
|
|
|
filePath: `${wx.env.USER_DATA_PATH}/${FileName}`,
|
|
|
|
|
success: (res) => {
|
|
|
|
|
if (res.statusCode === 200) {
|
|
|
|
|
wx.openDocument({
|
|
|
|
|
showMenu: false,
|
|
|
|
|
filePath: res.filePath,
|
|
|
|
|
success: () => {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
},
|
|
|
|
|
fail: () => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '下载文件失败',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
});
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '下载文件失败',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail() {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '下载文件失败',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onShareAppMessage(e) {
|
|
|
|
|
if (e.from === 'button') {
|
|
|
|
|
const { Title, CoverImgUrl, Id } = e.target.dataset.params;
|
|
|
|
|
app.mpBehavior({ PositionId: '2', OperateType: '3', OperateId: Id });
|
|
|
|
|
return {
|
|
|
|
|
title: Title,
|
|
|
|
|
path: `/pages/informationDetail/index?id=${Id}`,
|
|
|
|
|
imageUrl: CoverImgUrl,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return {};
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export {};
|