|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
const app = getApp<IAppOption>();
|
|
|
|
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
popupShow: false,
|
|
|
|
// popupType: 'popup1', // 绑定医生弹窗
|
|
|
|
// popupType: 'popup2', // 去关注弹窗
|
|
|
|
// popupType: 'popup3', // 问题反馈弹窗
|
|
|
|
popupType: 'popup4', // 登录失败弹窗
|
|
|
|
popupParams: {
|
|
|
|
close: true,
|
|
|
|
} as any,
|
|
|
|
|
|
|
|
userInfo: {},
|
|
|
|
unReadMsgCount: 0,
|
|
|
|
bannerList: [],
|
|
|
|
|
|
|
|
list: [] as any[],
|
|
|
|
total: 0,
|
|
|
|
pagination: {
|
|
|
|
page: 1,
|
|
|
|
pages: 1,
|
|
|
|
count: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onShow() {
|
|
|
|
app.waitLogin({ type: 2 }).then(() => {
|
|
|
|
// this.getNotice();
|
|
|
|
this.getBanner();
|
|
|
|
this.getList();
|
|
|
|
app.getUserInfo(2).then((userInfo) => {
|
|
|
|
this.setData({
|
|
|
|
userInfo,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleWebview() {
|
|
|
|
const encodeUrl = encodeURIComponent('https://dct.meddb.cn');
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/pages/webview/index?url=${encodeUrl}`,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getNotice() {
|
|
|
|
wx.ajax({
|
|
|
|
method: 'GET',
|
|
|
|
url: '?r=xd/doctor/index/get-unread-msg-count',
|
|
|
|
data: {},
|
|
|
|
}).then((res) => {
|
|
|
|
this.setData({
|
|
|
|
unReadMsgCount: res.unReadMsgCount,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleNotice() {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/message/index',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getBanner() {
|
|
|
|
wx.ajax({
|
|
|
|
method: 'GET',
|
|
|
|
url: '?r=xd/doctor/index/get-banner',
|
|
|
|
data: {
|
|
|
|
count: 0,
|
|
|
|
},
|
|
|
|
}).then((res) => {
|
|
|
|
this.setData({
|
|
|
|
bannerList: res.list,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleBanner(e) {
|
|
|
|
const { index } = e.currentTarget.dataset;
|
|
|
|
const { LinkUrl } = this.data.bannerList[index];
|
|
|
|
wx.navigateTo({
|
|
|
|
url: LinkUrl,
|
|
|
|
fail() {
|
|
|
|
wx.switchTab({
|
|
|
|
url: LinkUrl,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getList(newPage = 1) {
|
|
|
|
wx.ajax({
|
|
|
|
method: 'GET',
|
|
|
|
url: '?r=xd/doctor/index/get-latest-material',
|
|
|
|
data: {
|
|
|
|
page: newPage,
|
|
|
|
},
|
|
|
|
}).then((res) => {
|
|
|
|
res.list.forEach((item) => {
|
|
|
|
item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD');
|
|
|
|
});
|
|
|
|
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: any) {
|
|
|
|
const { id } = e.currentTarget.dataset;
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/pages/informationDetail/index?id=${id}`,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handlePopupOk() {
|
|
|
|
const { popupType } = this.data;
|
|
|
|
},
|
|
|
|
handlePopupCancel() {
|
|
|
|
const { popupType } = this.data;
|
|
|
|
this.setData({
|
|
|
|
popupShow: false,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onShareAppMessage(e) {
|
|
|
|
if (e.from === 'button') {
|
|
|
|
const { Title, CoverImgUrl, Id } = e.target.dataset.params;
|
|
|
|
app.mpBehavior({ PositionId: '1', OperateType: '3', OperateId: Id });
|
|
|
|
return {
|
|
|
|
title: Title,
|
|
|
|
path: `/pages/informationDetail/index?id=${Id}`,
|
|
|
|
imageUrl: CoverImgUrl,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export {};
|