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.
367 lines
8.6 KiB
367 lines
8.6 KiB
import dayjs from 'dayjs' |
|
|
|
const app = getApp<IAppOption>() |
|
|
|
Page({ |
|
data: { |
|
Timestamp: '', |
|
|
|
popupShow: false, |
|
popupType: 'popup1', // 绑定医生弹窗 |
|
// popupType: 'popup2', // 去关注弹窗 |
|
// popupType: 'popup3', // 问题反馈弹窗 |
|
// popupType: 'popup4', // 登录失败弹窗 |
|
popupParams: { |
|
close: true, |
|
} as any, |
|
|
|
userInfo: {} as any, |
|
current: 0, |
|
|
|
stat: {}, |
|
|
|
notice: [], |
|
|
|
bannerList: [], |
|
|
|
briefingList: [], |
|
sopList: [], |
|
|
|
list: [] as any[], |
|
|
|
fileLabelIcon: { |
|
pdf: 'file-label1', |
|
doc: 'file-label2', |
|
docx: 'file-label3', |
|
pptx: 'file-label4', |
|
xls: 'file-label5', |
|
xlsx: 'file-label6', |
|
ppt: 'file-label7', |
|
}, |
|
}, |
|
onShow() { |
|
app.waitLogin({ type: [2] }).then(() => { |
|
app.mpBehavior({ PageName: 'PG_DoctorHome' }) |
|
this.getNotice() |
|
this.getBanner() |
|
this.getList() |
|
this.getStat() |
|
app.getUserInfo(2).then((userInfo: any) => { |
|
this.setData({ |
|
userInfo, |
|
}) |
|
this.getTab() |
|
this.getBriefingList() |
|
this.getSopList() |
|
if (userInfo.IsEDC === '1') { |
|
app.mpBehavior({ PageName: 'PG_DoctorHomeNotice' }) |
|
} |
|
}) |
|
}) |
|
}, |
|
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, |
|
}, |
|
}) |
|
} |
|
}) |
|
}, |
|
getStat() { |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=zd/doctor/index/get-latest-static', |
|
data: {}, |
|
}).then((res) => { |
|
this.setData({ |
|
stat: res, |
|
}) |
|
}) |
|
}, |
|
handleWebview() { |
|
// wx.showToast({ |
|
// title: '访问路径:公众号“TED关爱中心”底部菜单栏', |
|
// icon: 'none', |
|
// }); |
|
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', |
|
data: {}, |
|
}).then((res) => { |
|
if (res.list.length) { |
|
app.oldMpBehavior({ PositionId: '4', OperateType: '4', OperateId: res.list[0].Id }) |
|
} |
|
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 |
|
}), |
|
}) |
|
}) |
|
}, |
|
handleNotice() { |
|
wx.navigateTo({ |
|
url: '/pages/message/index', |
|
}) |
|
}, |
|
handleNoticeDetail(e) { |
|
app.mpBehavior({ PageName: 'BTN_DoctorHomeNotice' }) |
|
const { index } = e.currentTarget.dataset |
|
const { Id, Url } = this.data.notice[index] |
|
app.oldMpBehavior({ PositionId: '4', OperateType: '1', OperateId: Id }) |
|
if (Url) { |
|
wx.navigateTo({ |
|
url: Url, |
|
fail() { |
|
wx.reLaunch({ |
|
url: Url, |
|
}) |
|
}, |
|
}) |
|
} else { |
|
this.handleNotice() |
|
} |
|
}, |
|
handleSwiperChange(e) { |
|
const current = e.detail.current |
|
this.setData({ |
|
current: e.detail.current, |
|
}) |
|
|
|
const { Id } = this.data.notice[current] || {} |
|
if (Id) { |
|
app.oldMpBehavior({ PositionId: '4', OperateType: '4', OperateId: Id }) |
|
} |
|
}, |
|
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] |
|
if (!LinkUrl) return |
|
wx.navigateTo({ |
|
url: LinkUrl, |
|
fail() { |
|
wx.switchTab({ |
|
url: LinkUrl, |
|
}) |
|
}, |
|
}) |
|
}, |
|
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, |
|
}) |
|
if (res.list.length && this.data.userInfo.IsEDC === '1') { |
|
app.mpBehavior({ PageName: 'PG_DoctorHomeBrief' }) |
|
} |
|
}) |
|
}, |
|
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, |
|
}) |
|
if (res.list.length && this.data.userInfo.IsEDC === '1') { |
|
app.mpBehavior({ PageName: 'PG_DoctorHomeSop' }) |
|
} |
|
}) |
|
}, |
|
getList() { |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=xd/doctor/index/get-material-list', |
|
data: { |
|
ContentType: '3,5', |
|
count: 3, |
|
}, |
|
}).then((res) => { |
|
res.list.forEach((item) => { |
|
item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD') |
|
item.FileType = item.FileList[0]?.FileType || '' |
|
}) |
|
this.setData({ |
|
list: res.list, |
|
}) |
|
if (res.list.length) { |
|
app.mpBehavior({ PageName: 'PG_DoctorHomeLibrary' }) |
|
} |
|
}) |
|
}, |
|
handleBriefingDetail(e: any) { |
|
app.mpBehavior({ PageName: 'BTN_DoctorHomeBrief' }) |
|
const { id } = e.currentTarget.dataset |
|
wx.navigateTo({ |
|
url: `/pages/informationDetail/index?id=${id}`, |
|
}) |
|
}, |
|
handleSop(e) { |
|
app.mpBehavior({ PageName: 'BTN_DoctorHomeSop' }) |
|
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.oldMpBehavior({ PositionId: '1', OperateType: '2', OperateId: Id as string }) |
|
this.handleFile(params) |
|
}, |
|
handleDetail(e: any) { |
|
app.mpBehavior({ PageName: 'BTN_DoctorHomeLibrary' }) |
|
const { id, index } = e.currentTarget.dataset |
|
const params = this.data.list[index] |
|
if (params.ContentType === '5' && params.FileList[0]) { |
|
app.oldMpBehavior({ PositionId: '1', OperateType: '1', OperateId: id as string }) |
|
this.handleFile(params.FileList[0]) |
|
} else { |
|
wx.navigateTo({ |
|
url: `/pages/informationDetail/index?id=${id}`, |
|
}) |
|
} |
|
}, |
|
handleFile({ FileUrl, FileName }) { |
|
wx.downloadFile({ |
|
url: FileUrl, |
|
filePath: `${wx.env.USER_DATA_PATH}/${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', |
|
}) |
|
}, |
|
}) |
|
}, |
|
handleMore() { |
|
wx.switchTab({ |
|
url: '/pages/information/index', |
|
}) |
|
}, |
|
|
|
handlePatient() { |
|
wx.navigateTo({ |
|
url: '/pages/d_patient/index', |
|
}) |
|
}, |
|
handlePopupOk() { |
|
const { popupType } = this.data |
|
}, |
|
handlePopupCancel() { |
|
const { popupType } = this.data |
|
if (popupType === 'popup1') { |
|
wx.ajax({ |
|
method: 'POST', |
|
url: '?r=xd/doctor/index/cancel-welcome', |
|
data: {}, |
|
}).then(() => { |
|
this.setData({ |
|
popupShow: false, |
|
popupType: '', |
|
popupParams: {}, |
|
}) |
|
}) |
|
return |
|
} |
|
this.setData({ |
|
popupShow: false, |
|
}) |
|
}, |
|
handleMpBehavior(e) { |
|
const { code } = e.currentTarget.dataset |
|
app.mpBehavior({ PageName: code }) |
|
}, |
|
onShareAppMessage(e) { |
|
if (e.from === 'button') { |
|
const { Title, CoverImgUrl, Id } = e.target.dataset.params |
|
app.oldMpBehavior({ PositionId: '1', OperateType: '3', OperateId: Id }) |
|
return { |
|
title: Title, |
|
path: `/pages/informationDetail/index?id=${Id}`, |
|
imageUrl: CoverImgUrl, |
|
} |
|
} |
|
return { |
|
imageUrl: `${app.globalData.imageUrl}share.png?t=${this.data.Timestamp}`, |
|
} |
|
}, |
|
}) |
|
|
|
export {}
|
|
|