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

301 lines
6.8 KiB

2 months ago
import dayjs from 'dayjs';
2 months ago
const app = getApp<IAppOption>();
Page({
2 months ago
data: {
2 months ago
Timestamp: '',
2 months ago
popupShow: false,
2 months ago
popupType: 'popup1', // 绑定医生弹窗
2 months ago
// popupType: 'popup2', // 去关注弹窗
// popupType: 'popup3', // 问题反馈弹窗
2 months ago
// popupType: 'popup4', // 登录失败弹窗
2 months ago
popupParams: {
close: true,
} as any,
2 months ago
userInfo: {},
2 months ago
current: 0,
notice: [],
2 months ago
bannerList: [],
briefingList: [],
sopList: [],
2 months ago
list: [] as any[],
},
onShow() {
app.waitLogin({ type: 2 }).then(() => {
this.getNotice();
2 months ago
this.getBanner();
this.getBriefingList();
this.getSopList();
2 months ago
this.getList();
app.getUserInfo(2).then((userInfo) => {
this.setData({
userInfo,
});
2 months ago
this.getTab();
2 months ago
});
});
},
2 months ago
getTab() {
wx.ajax({
method: 'GET',
url: '?r=xd/doctor/index/is-welcome',
data: {},
}).then((res) => {
if (res.IsWelcome === 1) {
this.setData({
popupShow: true,
popupType: 'popup1',
popupParams: {
close: true,
...this.data.userInfo,
},
});
}
});
},
2 months ago
handleWebview() {
2 months ago
// wx.showToast({
// title: '访问路径:公众号“TED关爱中心”底部菜单栏',
// icon: 'none',
// });
2 months ago
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-latest-mini-msg',
2 months ago
data: {},
}).then((res) => {
2 months ago
if (res.list.length) {
app.mpBehavior({ PositionId: '4', OperateType: '4', OperateId: res.list[0].Id });
}
2 months ago
this.setData({
notice: res.list.map((item) => {
item.year = dayjs(item.PublishDate).format('YYYY');
item.month = dayjs(item.PublishDate).format('MM');
item.day = dayjs(item.PublishDate).format('DD');
return item;
}),
2 months ago
});
});
},
handleNotice() {
wx.navigateTo({
url: '/pages/message/index',
});
},
handleNoticeDetail(e) {
const { index } = e.currentTarget.dataset;
const { Id, Url } = this.data.notice[index];
app.mpBehavior({ PositionId: '4', OperateType: '1', OperateId: Id });
if (Url) {
wx.navigateTo({
url: Url,
fail() {
wx.reLaunch({
url: Url,
});
},
});
2 months ago
} else {
this.handleNotice();
}
},
2 months ago
handleSwiperChange(e) {
const current = e.detail.current;
2 months ago
this.setData({
current: e.detail.current,
});
2 months ago
const { Id } = this.data.notice[current] || {};
if (Id) {
app.mpBehavior({ PositionId: '4', OperateType: '4', OperateId: Id });
}
2 months ago
},
2 months ago
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];
2 months ago
if (!LinkUrl) return;
2 months ago
wx.navigateTo({
url: LinkUrl,
fail() {
wx.switchTab({
url: LinkUrl,
});
},
});
2 months ago
},
getBriefingList() {
wx.ajax({
method: 'GET',
url: '?r=xd/doctor/index/get-material-list',
data: {
count: 10,
ContentType: 1,
},
}).then((res) => {
res.list.forEach((item) => {
item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD');
});
this.setData({
briefingList: res.list,
});
});
},
getSopList() {
wx.ajax({
method: 'GET',
url: '?r=xd/doctor/index/get-material-list',
data: {
count: 10,
ContentType: 2,
},
}).then((res) => {
res.list.forEach((item) => {
item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD');
});
this.setData({
sopList: res.list,
});
});
},
2 months ago
getList() {
2 months ago
wx.ajax({
method: 'GET',
2 months ago
url: '?r=xd/doctor/index/get-material-list',
data: {
ContentType: '3,5',
2 months ago
count: 3,
},
2 months ago
}).then((res) => {
res.list.forEach((item) => {
item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD');
});
this.setData({
list: res.list,
2 months ago
});
});
},
handleDetail(e: any) {
const { id } = e.currentTarget.dataset;
wx.navigateTo({
url: `/pages/informationDetail/index?id=${id}`,
});
2 months ago
},
1 month ago
handleSop(e) {
const { index } = e.currentTarget.dataset;
const { Id, FileList } = this.data.sopList[index];
const params: any = FileList[0];
if (!params) {
return;
}
wx.showLoading({
title: '加载中',
mask: true,
});
app.mpBehavior({ PositionId: '1', OperateType: '2', OperateId: Id as string });
wx.downloadFile({
url: params.FileUrl,
filePath: `${wx.env.USER_DATA_PATH}/${params.FileName}`,
success: (res) => {
if (res.statusCode === 200) {
wx.openDocument({
showMenu: false,
filePath: res.filePath,
success: () => {
wx.hideLoading();
},
fail: () => {
wx.showToast({
title: '下载文件失败',
icon: 'none',
});
wx.hideLoading();
},
});
} else {
wx.hideLoading();
wx.showToast({
title: '下载文件失败',
icon: 'none',
});
}
},
fail() {
wx.hideLoading();
wx.showToast({
title: '下载文件失败',
icon: 'none',
});
},
});
},
2 months ago
handleMore() {
wx.switchTab({
url: '/pages/information/index',
});
},
2 months ago
handlePopupOk() {
const { popupType } = this.data;
},
handlePopupCancel() {
const { popupType } = this.data;
2 months ago
if (popupType === 'popup1') {
wx.ajax({
method: 'POST',
url: '?r=xd/doctor/index/cancel-welcome',
data: {},
}).then(() => {
this.setData({
popupShow: false,
popupType: '',
popupParams: {},
});
});
return;
}
2 months ago
this.setData({
popupShow: false,
});
},
2 months 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,
};
}
2 months ago
return {
imageUrl: `${app.globalData.imageUrl}share.png?t=${this.data.Timestamp}`,
};
2 months ago
},
2 months ago
});
export {};