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

347 lines
7.8 KiB

import dayjs from 'dayjs'
2 months ago
const app = getApp<IAppOption>()
2 months ago
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,
3 weeks ago
stat: {},
notice: [],
2 months ago
bannerList: [],
briefingList: [],
sopList: [],
2 months ago
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',
},
2 months ago
},
onShow() {
4 weeks ago
app.waitLogin({ type: [2] }).then(() => {
this.getNotice()
this.getBanner()
this.getBriefingList()
this.getSopList()
this.getList()
3 weeks ago
this.getStat()
2 months ago
app.getUserInfo(2).then((userInfo) => {
this.setData({
userInfo,
})
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
}
})
2 months ago
},
3 weeks ago
getStat() {
wx.ajax({
method: 'GET',
url: '?r=zd/doctor/index/get-latest-static',
data: {},
}).then((res) => {
this.setData({
stat: res,
})
})
},
2 months ago
handleWebview() {
2 months ago
// wx.showToast({
// title: '访问路径:公众号“TED关爱中心”底部菜单栏',
// icon: 'none',
// });
const encodeUrl = encodeURIComponent('https://dct.meddb.cn')
2 months ago
wx.navigateTo({
url: `/pages/webview/index?url=${encodeUrl}`,
})
2 months ago
},
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.oldMpBehavior({ PositionId: '4', OperateType: '4', OperateId: res.list[0].Id })
2 months ago
}
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',
})
2 months ago
},
handleNoticeDetail(e) {
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,
})
},
})
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] || {}
2 months ago
if (Id) {
app.oldMpBehavior({ PositionId: '4', OperateType: '4', OperateId: Id })
2 months ago
}
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,
})
})
2 months ago
},
handleBanner(e) {
const { index } = e.currentTarget.dataset
const { LinkUrl } = this.data.bannerList[index]
if (!LinkUrl) return
2 months ago
wx.navigateTo({
url: LinkUrl,
fail() {
wx.switchTab({
url: LinkUrl,
})
2 months ago
},
})
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')
item.FileType = item.FileList[0]?.FileType || ''
})
2 months ago
this.setData({
list: res.list,
})
})
2 months ago
},
handleBriefingDetail(e: any) {
const { id } = e.currentTarget.dataset
2 months ago
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]
1 month ago
if (!params) {
return
1 month ago
}
wx.showLoading({
title: '加载中',
mask: true,
})
app.oldMpBehavior({ PositionId: '1', OperateType: '2', OperateId: Id as string })
this.handleFile(params)
},
handleDetail(e: any) {
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 }) {
1 month ago
wx.downloadFile({
url: FileUrl,
filePath: `${wx.env.USER_DATA_PATH}/${FileName}`,
1 month ago
success: (res) => {
if (res.statusCode === 200) {
wx.openDocument({
showMenu: false,
filePath: res.filePath,
success: () => {
wx.hideLoading()
1 month ago
},
fail: () => {
wx.showToast({
title: '下载文件失败',
icon: 'none',
})
wx.hideLoading()
1 month ago
},
})
1 month ago
} else {
wx.hideLoading()
1 month ago
wx.showToast({
title: '下载文件失败',
icon: 'none',
})
1 month ago
}
},
fail() {
wx.hideLoading()
1 month ago
wx.showToast({
title: '下载文件失败',
icon: 'none',
})
1 month ago
},
})
1 month ago
},
2 months ago
handleMore() {
wx.switchTab({
url: '/pages/information/index',
})
},
handlePatient() {
wx.navigateTo({
url: '/pages/d_patient/index',
})
2 months ago
},
2 months ago
handlePopupOk() {
const { popupType } = this.data
2 months ago
},
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
}
2 months ago
this.setData({
popupShow: false,
})
2 months ago
},
2 months ago
onShareAppMessage(e) {
if (e.from === 'button') {
const { Title, CoverImgUrl, Id } = e.target.dataset.params
app.oldMpBehavior({ PositionId: '1', OperateType: '3', OperateId: Id })
2 months ago
return {
title: Title,
path: `/pages/informationDetail/index?id=${Id}`,
imageUrl: CoverImgUrl,
}
2 months ago
}
2 months ago
return {
imageUrl: `${app.globalData.imageUrl}share.png?t=${this.data.Timestamp}`,
}
2 months ago
},
})
2 months ago
export {}