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

146 lines
3.1 KiB

2 weeks ago
import dayjs from 'dayjs';
3 weeks ago
const app = getApp<IAppOption>();
Page({
2 weeks ago
data: {
popupShow: false,
// popupType: 'popup1', // 绑定医生弹窗
// popupType: 'popup2', // 去关注弹窗
// popupType: 'popup3', // 问题反馈弹窗
popupType: 'popup4', // 登录失败弹窗
popupParams: {
close: true,
} as any,
2 weeks ago
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,
});
},
});
2 weeks ago
},
2 weeks ago
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}`,
});
3 weeks ago
},
2 weeks ago
handlePopupOk() {
const { popupType } = this.data;
},
handlePopupCancel() {
const { popupType } = this.data;
this.setData({
popupShow: false,
});
},
2 weeks ago
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 {};
},
3 weeks ago
});
export {};