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.
139 lines
3.4 KiB
139 lines
3.4 KiB
const app = getApp<IAppOption>() |
|
|
|
Page({ |
|
data: { |
|
active: 0, |
|
list: [] as any, |
|
pagination: { |
|
page: 1, |
|
pages: 1, |
|
count: 0, |
|
}, |
|
config: {} as any, |
|
}, |
|
onLoad() { |
|
app.waitLogin().then(() => { |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=igg4/common/get-config', |
|
}).then((res) => { |
|
this.setData({ |
|
config: res, |
|
}) |
|
this.getList() |
|
}) |
|
}) |
|
}, |
|
getList() { |
|
this.getInfoList() |
|
app.mpBehavior({ PageName: 'PG_PATIENTMYFAVORITES_KNOWLEDGEBASE' }) |
|
}, |
|
getInfoList(newPage = 1) { |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=igg4/pic-text/collection-list', |
|
data: { |
|
page: newPage, |
|
count: 10, |
|
}, |
|
loading: true, |
|
}).then((res: any) => { |
|
const list = res.page == 1 ? res.list : [...this.data.list, ...res.list] |
|
this.setData({ |
|
list, |
|
pagination: { |
|
page: res.page, |
|
pages: res.pages, |
|
count: res.count, |
|
}, |
|
}) |
|
}) |
|
}, |
|
handleDetail(e: WechatMiniprogram.CustomEvent) { |
|
const { id } = e.currentTarget.dataset |
|
if (this.data.config.picTextEbookStatus == 1) { |
|
const webviewUrl = encodeURIComponent( |
|
`${app.globalData.url}/zdcare/#/book?loginState=${app.globalData.loginState}&Id=${id}`, |
|
) |
|
wx.navigateTo({ |
|
url: `/pages/webview/index?url=${webviewUrl}`, |
|
}) |
|
} else { |
|
wx.navigateTo({ |
|
url: `/pages/repositoryDetail/index?id=${id}`, |
|
}) |
|
} |
|
}, |
|
handleToggleSave(e: WechatMiniprogram.CustomEvent) { |
|
const { id, collect, index } = e.currentTarget.dataset |
|
if (collect == 1) { |
|
wx.ajax({ |
|
method: 'POST', |
|
url: '?r=igg4/pic-text/cancel-collection', |
|
data: { |
|
ContentId: id, |
|
}, |
|
loading: true, |
|
}).then(() => { |
|
wx.showToast({ |
|
title: '取消收藏', |
|
icon: 'none', |
|
}) |
|
this.setData({ |
|
[`list[${index}].IsCollect`]: 0, |
|
[`list[${index}].CollectionPeopleNum`]: Number(this.data.list[index].CollectionPeopleNum) - 1, |
|
}) |
|
}) |
|
} else { |
|
wx.ajax({ |
|
method: 'POST', |
|
url: '?r=igg4/pic-text/collection', |
|
data: { |
|
ContentId: id, |
|
}, |
|
loading: true, |
|
}).then(() => { |
|
wx.showToast({ |
|
title: '收藏成功', |
|
icon: 'none', |
|
}) |
|
this.setData({ |
|
[`list[${index}].IsCollect`]: 1, |
|
[`list[${index}].CollectionPeopleNum`]: Number(this.data.list[index].CollectionPeopleNum) + 1, |
|
}) |
|
}) |
|
} |
|
}, |
|
onReachBottom() { |
|
const { page, pages } = this.data.pagination |
|
if (pages > page) { |
|
this.getInfoList(page + 1) |
|
} |
|
}, |
|
onShareAppMessage(e: any) { |
|
if (e.from === 'button') { |
|
const { id, index } = e.target.dataset |
|
const { list } = this.data |
|
const { Title, TitlePicLink } = list[index] |
|
wx.ajax({ |
|
method: 'POST', |
|
url: '?r=igg4/pic-text/share', |
|
data: { ContentId: id }, |
|
}).then(() => { |
|
this.setData({ |
|
[`list[${index}].ShareNum`]: Number(this.data.list[index].ShareNum) + 1, |
|
}) |
|
}) |
|
return { |
|
title: Title, |
|
path: `/pages/repositoryDetail/index?id=${id}`, |
|
imageUrl: TitlePicLink, |
|
} |
|
} else { |
|
return { |
|
title: '知识库', |
|
path: '/pages/repository/index', |
|
} |
|
} |
|
}, |
|
})
|
|
|