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.
73 lines
2.0 KiB
73 lines
2.0 KiB
Page({ |
|
data: { |
|
imageField: '', |
|
patientId: '', |
|
list: [] as { visitDate: string; images: string[] }[], |
|
pagination: { count: 0, page: 1, pages: 1 }, |
|
}, |
|
|
|
onLoad(options: any) { |
|
if (options.name) { |
|
wx.setNavigationBarTitle({ title: options.name }) |
|
} |
|
if (options.imageField) { |
|
this.setData({ imageField: options.imageField, patientId: options.patientId || '' }) |
|
this.getImageHistory(true) |
|
} |
|
}, |
|
|
|
onReachBottom() { |
|
const { page, pages } = this.data.pagination |
|
if (page < pages) { |
|
this.setData({ 'pagination.page': page + 1 }) |
|
this.getImageHistory() |
|
} |
|
}, |
|
|
|
getImageHistory(reset = false) { |
|
const page = reset ? 1 : this.data.pagination.page |
|
const data: Record<string, any> = { imageField: this.data.imageField, page, pageSize: 10 } |
|
data.patientId = this.data.patientId |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=igg4/doctor/medical-visit/image-history', |
|
data, |
|
}).then((res: any) => { |
|
if (!res || !res.list) return |
|
// 按就诊日期分组 |
|
const groupMap: Record<string, string[]> = {} |
|
for (const item of res.list) { |
|
if (!groupMap[item.visitDate]) { |
|
groupMap[item.visitDate] = [] |
|
} |
|
groupMap[item.visitDate].push(item.imageUrl) |
|
} |
|
const newList = Object.keys(groupMap) |
|
.sort((a, b) => b.localeCompare(a)) |
|
.map((visitDate) => ({ |
|
visitDate, |
|
images: groupMap[visitDate], |
|
})) |
|
this.setData({ |
|
list: reset ? newList : [...this.data.list, ...newList], |
|
pagination: { |
|
count: res.totalCount || 0, |
|
page: res.page || 1, |
|
pages: res.pages || 1, |
|
}, |
|
}) |
|
}) |
|
}, |
|
|
|
handlePreviewImage(e: WechatMiniprogram.CustomEvent) { |
|
const { url, date } = e.currentTarget.dataset |
|
const group = this.data.list.find((item) => item.visitDate === date) |
|
if (!group) return |
|
wx.previewImage({ |
|
current: url, |
|
urls: group.images, |
|
}) |
|
}, |
|
}) |
|
|
|
export {}
|
|
|