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

126 lines
3.1 KiB

2 months ago
import dayjs from 'dayjs'
3 months ago
2 months ago
const app = getApp<IAppOption>()
4 months ago
Page({
data: {
list: [] as any[],
pagination: {
page: 1,
pages: 1,
count: 1,
},
3 months ago
fileLabelIcon: {
pdf: 'file-label1',
doc: 'file-label2',
docx: 'file-label3',
pptx: 'file-label4',
xls: 'file-label5',
xlsx: 'file-label6',
ppt: 'file-label7',
},
4 months ago
},
3 months ago
onShow() {
2 months ago
app.waitLogin({ type: [2] }).then(() => {
app.mpBehavior({ doctor:true, PageName: 'PG_LibraryList' })
2 months ago
this.getList()
})
3 months ago
},
4 months ago
getList(newPage = 1) {
wx.ajax({
method: 'GET',
3 months ago
url: '?r=xd/doctor/index/get-material-list',
4 months ago
data: {
page: newPage,
ContentType: '3,5',
4 months ago
},
}).then((res) => {
3 months ago
res.list.forEach((item) => {
2 months ago
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]
4 months ago
this.setData({
total: res.count,
list,
pagination: {
page: res.page,
pages: res.pages,
count: res.count,
},
2 months ago
})
})
4 months ago
},
onReachBottom() {
2 months ago
const { page, pages } = this.data.pagination
4 months ago
if (pages > page) {
2 months ago
this.getList(page + 1)
4 months ago
}
},
3 months ago
handleDetail(e) {
app.mpBehavior({ doctor:true, PageName: 'BTN_LibraryListContent' })
2 months ago
const { id, index } = e.currentTarget.dataset
const params = this.data.list[index]
if (params.ContentType === '5' && params.FileList[0]) {
2 months ago
app.oldMpBehavior({ PositionId: '1', OperateType: '1', OperateId: id as string })
this.handleFile(params.FileList[0])
} else {
wx.navigateTo({
url: `/pages/informationDetail/index?id=${id}`,
2 months ago
})
}
},
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: () => {
2 months ago
wx.hideLoading()
},
fail: () => {
wx.showToast({
title: '下载文件失败',
icon: 'none',
2 months ago
})
wx.hideLoading()
},
2 months ago
})
} else {
2 months ago
wx.hideLoading()
wx.showToast({
title: '下载文件失败',
icon: 'none',
2 months ago
})
}
},
fail() {
2 months ago
wx.hideLoading()
wx.showToast({
title: '下载文件失败',
icon: 'none',
2 months ago
})
},
2 months ago
})
4 months ago
},
3 months ago
onShareAppMessage(e) {
if (e.from === 'button') {
app.mpBehavior({ doctor:true, PageName: 'BTN_LibraryListShare' })
2 months ago
const { Title, CoverImgUrl, Id } = e.target.dataset.params
app.oldMpBehavior({ PositionId: '2', OperateType: '3', OperateId: Id })
3 months ago
return {
title: Title,
path: `/pages/informationDetail/index?id=${Id}`,
imageUrl: CoverImgUrl,
2 months ago
}
3 months ago
}
2 months ago
return {}
3 months ago
},
2 months ago
})
4 months ago
2 months ago
export {}