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

544 lines
13 KiB

import dayjs from 'dayjs'
const app = getApp<IAppOption>()
const licia = require('miniprogram-licia')
1 month ago
Page({
data: {
today: dayjs().format('YYYY年MM月DD日 dddd'),
configList: [],
infoList: [],
storyList: [],
4 weeks ago
zdUserInfo: {} as any,
1 month ago
anyWhere: false,
regGuide: true,
isLogin: 1,
1 month ago
adlList: [],
adlNum: '',
adlNewRecord: {} as any,
liveList: [],
liveStatus: app.globalData.liveStatus,
liveDownList: [],
detail: {},
referralFromShow: false,
publicCard: false,
// toastShow: true,
// toastType: "doubleStandards",
// toastType: "vipScan",
// toastType: "healthCare",
// toastType: "aldAlert",
// toastType:"dedicatedDoctor",
// toastType: 'referral-toast',
// toastType: 'public-toast',
toastShow: false,
toastType: '',
toastParams: {} as any,
sliderTop: 0,
unreadCount: 0,
options: {} as any,
},
onLoad(options) {
const systemInfo = wx.getSystemInfoSync()
1 month ago
2 weeks ago
if (options.visitors === '1') {
wx.showToast({
title: '未完成注册,登录失败',
icon: 'none',
})
}
4 weeks ago
app.zdGetTheme().then((res) => {
1 month ago
this.setData({
theme: res,
})
})
1 month ago
this.setData({
sliderTop: systemInfo.screenHeight - 160,
options,
})
1 month ago
},
onShow() {
4 weeks ago
app.waitLogin({ type: [0, 1] }).then(() => {
1 month ago
this.setData({
anyWhere: app.globalData.anyWhere,
isLogin: app.globalData.isLogin,
})
1 month ago
if (this.data.options.es === '201501') {
app.globalData.IsAliQiWei = 1
1 month ago
this.setData({
options: {},
})
1 month ago
}
4 weeks ago
app.getZdUserInfo(this, true, (zdUserInfo) => {
1 month ago
this.setData({
4 weeks ago
zdUserInfo,
publicCard: zdUserInfo.isShowFollowGuide == 1,
})
this.getPopup()
this.getConfig(zdUserInfo)
this.getSystemConfig()
4 weeks ago
if (zdUserInfo.ExclusiveDoctorId > 0) {
this.getUnreadCount()
1 month ago
}
4 weeks ago
if (zdUserInfo.UserType == 4) {
this.getLastRecord()
1 month ago
}
})
})
1 month ago
},
async getPopup() {
const data3 = await wx.ajax({
method: 'GET',
url: '?r=zd/popup/info',
data: {
Type: 6,
},
})
if (data3.showAlert) {
this.setData({
toastShow: data3.showAlert,
toastType: 'dedicatedDoctor',
toastParams: {},
})
}
},
1 month ago
getUnreadCount() {
wx.ajax({
method: 'GET',
4 weeks ago
url: '?r=zd/message-interact/get-unread-count',
1 month ago
data: {},
}).then((res) => {
this.setData({
unreadCount: res,
})
})
1 month ago
},
getSystemConfig() {
wx.ajax({
method: 'GET',
4 weeks ago
url: '?r=zd/common/get-config',
1 month ago
data: {},
}).then((res) => {
this.setData({
systemConfig: res,
})
})
1 month ago
},
getLastRecord() {
wx.ajax({
method: 'GET',
4 weeks ago
url: '?r=zd/medication/last-record',
1 month ago
}).then((res) => {
this.setData({
detail: {
weekName: dayjs(res.InjectionDate).format('ddd'),
days: dayjs().diff(res.InjectionDate, 'day'),
...res,
},
})
})
1 month ago
},
4 weeks ago
getConfig(zdUserInfo: any) {
let UserType = zdUserInfo.UserType
1 month ago
if (UserType <= 2) {
UserType = 1
1 month ago
}
wx.ajax({
method: 'GET',
4 weeks ago
url: `?r=zd/mini-conf/get-config`,
1 month ago
data: { userType: UserType },
}).then((res) => {
res = res.map((item: any) => {
if (item.code == 'spread1' || item.code == 'spread2' || item.code == 'serviceConf') {
item.subList = item.subList.filter((subItem) => {
return subItem.showStatus == 1
})
1 month ago
}
// if (item.name === 'BANNER-MINIDOVTOR') {
// item.subList = item.subList
// .filter((subItem: any) => {
4 weeks ago
// return subItem.linkUrl !== 'MINIDOCTOR' || zdUserInfo.EntryThreePeriod === 1
1 month ago
// })
// .filter((subItem: any) => {
4 weeks ago
// return subItem.linkUrl !== 'MINIDOCTOR-1.0' || zdUserInfo.EntryTwoPeriod === 1
1 month ago
// })
// }
return item
})
1 month ago
this.setData({
configList: res,
})
1 month ago
res.forEach((item) => {
if (item.code == 'article') {
this.getInfoList(item.configId)
1 month ago
}
if (item.code == 'story') {
this.getStoryList(item.configId)
1 month ago
}
if (item.code == 'adl') {
this.getAdl()
1 month ago
}
if (item.code == 'activity2') {
this.getActivity(item.configId, item.showNum, 'liveList')
1 month ago
}
if (item.code == 'activity1') {
this.getActivity(item.configId, item.showNum, 'liveDownList')
1 month ago
}
})
})
1 month ago
},
setPopupInfo() {
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/popup/update-click-status',
1 month ago
data: {
Type: 1,
Id: this.data.toastParams.Id,
},
}).then((_res) => {})
1 month ago
},
setBannerClick() {
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/nrdl/add-banner-click-record',
1 month ago
data: {},
})
1 month ago
},
getInfoList(configId: string) {
wx.ajax({
method: 'GET',
4 weeks ago
url: '?r=zd/pic-text/index-list',
1 month ago
data: {
count: 0,
ConfigId: configId,
},
}).then((res) => {
this.setData({
infoList: licia.chunk(res.list, 3),
})
})
1 month ago
},
getStoryList(configId: string) {
wx.ajax({
method: 'GET',
4 weeks ago
url: '?r=zd/story/index-list',
1 month ago
data: {
count: 0,
ConfigId: configId,
},
}).then((res) => {
this.setData({
storyList: res.list,
})
})
1 month ago
},
getAdl() {
wx.ajax({
method: 'GET',
4 weeks ago
url: '?r=zd/adl/index',
1 month ago
data: {},
}).then((res) => {
const newRecord = res.newRecord
1 month ago
this.setData({
adlList: res.list,
adlNum: res.count,
adlNewRecord: {
days: dayjs().diff(newRecord.CreateTime, 'day'),
...newRecord,
newCreateTime: dayjs(newRecord.CreateTime).format('YYYY-MM-DD'),
},
})
})
1 month ago
},
getActivity(ConfigId: string, count: number, key: string) {
wx.ajax({
method: 'GET',
4 weeks ago
url: '?r=zd/activity/index-list',
1 month ago
data: { ConfigId, count },
}).then((res) => {
this.setData({
[key]: res.list.map((item) => {
item.EndTimeValue = dayjs(item.EndTime).valueOf()
item.BeginTimeValue = dayjs(item.BeginTime).valueOf()
item.SignUpDeadlineValue = dayjs(item.SignUpDeadline).valueOf()
item.BeginDate = dayjs(item.BeginTime).format('YYYY-MM-DD')
item.EndDate = dayjs(item.EndTime).format('YYYY-MM-DD')
item.isDay = item.BeginDate == item.EndDate
item.BeginHm = dayjs(item.BeginTime).format('HH:mm')
item.EndHm = dayjs(item.EndTime).format('HH:mm')
item.BeginTime = dayjs(item.BeginTime).format('YYYY-MM-DD HH:mm')
item.EndTime = dayjs(item.EndTime).format('YYYY-MM-DD HH:mm')
return item
1 month ago
}),
})
})
1 month ago
},
routerTo(e) {
let { url, active, code } = e.currentTarget.dataset
if (!url) return
1 month ago
if (code === 'adl') {
1 month ago
}
if (code === 'drugs') {
1 month ago
}
4 weeks ago
if (code === 'story' && url === '/patient/pages/story/index') {
1 month ago
}
4 weeks ago
if (code === 'story' && url.includes('/patient/pages/publishStoryDetail/index')) {
1 month ago
}
4 weeks ago
if (code === 'activity2' && url === '/patient/pages/live/index') {
1 month ago
}
4 weeks ago
if (code === 'activity2' && url === '/patient/pages/live/index?index=0') {
1 month ago
}
4 weeks ago
if (code === 'activity2' && url.includes('/patient/pages/liveDetail/index')) {
1 month ago
}
4 weeks ago
if (code === 'activity1' && url === '/patient/pages/live/index') {
1 month ago
}
4 weeks ago
if (code === 'activity1' && url.includes('/patient/pages/liveDetail/index')) {
1 month ago
}
4 weeks ago
if (code === 'article' && url === '/patient/pages/repository/index') {
1 month ago
}
4 weeks ago
if (code === 'article' && url.includes('/patient/pages/repositoryDetail/index')) {
1 month ago
}
if (code === 'serviceConf') {
1 month ago
}
4 weeks ago
if (url === '/patient/pages/interactivePatient/index') {
1 month ago
}
if (url === 'NRDL') {
this.setBannerClick()
this.handleNRDL()
return
1 month ago
}
if (url.includes('loginState')) {
url = url + encodeURIComponent(app.globalData.loginState)
4 weeks ago
app.zdPermissionVerification(2, 11, `/patient/pages/repository/index`).then(() => {
1 month ago
wx.navigateTo({
url,
})
})
return
1 month ago
}
wx.navigateTo({
url,
fail() {
app.globalData.active = active
1 month ago
wx.switchTab({
url,
})
1 month ago
},
})
1 month ago
},
handleReg() {
app.zdPermissionVerification(3, 0, '')
1 month ago
},
handleMiniDoctor(e) {
const { link } = e.currentTarget.dataset
let period = ''
1 month ago
if (link === 'MINIDOCTOR-1.0') {
period = '2'
1 month ago
}
wx.navigateTo({
4 weeks ago
url: `/patient/pages/webview/index?period=${period}`,
})
1 month ago
},
handleQuestion() {
4 weeks ago
app.zdPermissionVerification(2, 11, `/patient/pages/repository/index`).then(() => {
1 month ago
const webviewUrl = encodeURIComponent(
`${app.globalData.url}/zdcare/#/info?loginState=${app.globalData.loginState}`,
)
1 month ago
wx.navigateTo({
4 weeks ago
url: `/patient/pages/webview/index?url=${webviewUrl}`,
})
})
1 month ago
},
handleSlider() {
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/nrdl/add-slide-click-record',
1 month ago
data: {},
})
this.handleNRDL()
1 month ago
},
handleNRDL() {
4 weeks ago
app.zdPermissionVerification(3, 12, `/patient/pages/index/index`).then(() => {
1 month ago
wx.navigateTo({
4 weeks ago
url: `/patient/pages/nrdl/index`,
})
4 weeks ago
// if (this.data.zdUserInfo.has7DayAdl === 1) {
1 month ago
// wx.navigateTo({
4 weeks ago
// url: `/patient/pages/nrdl/index`,
1 month ago
// });
// } else {
// this.setData({
// toastShow: true,
// toastType: "ndrlAldAlert",
// });
// }
})
1 month ago
},
routerVipTo() {
const { MedicineAuditSwitch, UseDrugsAuditStatus, isFollow } = this.data.zdUserInfo
1 month ago
if (MedicineAuditSwitch === '0') {
wx.navigateTo({
4 weeks ago
url: '/patient/pages/vipLogin/index',
})
1 month ago
} else if (MedicineAuditSwitch === '1') {
const pendPath = {
0: '/patient/pages/vipPending/index',
1: '/patient/pages/vipStartPending/index',
}[isFollow]
1 month ago
const url = {
1: pendPath,
2: '/patient/pages/vipReject/index',
}[UseDrugsAuditStatus]
1 month ago
wx.navigateTo({
url: url || '/patient/pages/vipCert/index',
})
1 month ago
} else {
wx.showToast({
icon: 'none',
title: '工程师正在努力建设中,敬请期待!',
})
1 month ago
}
},
handleToastOk() {
const { toastType } = this.data
1 month ago
if (toastType === 'vipScan') {
this.routerVipTo()
this.handleToastCancel()
1 month ago
} else if (toastType === 'aldAlert') {
wx.navigateTo({
4 weeks ago
url: '/patient/pages/adl/index',
})
this.handleToastCancel()
1 month ago
} else if (toastType === 'healthCare') {
this.setPopupInfo()
this.handleNRDL()
this.handleToastCancel()
1 month ago
} else if (toastType === 'ndrlAldAlert') {
wx.navigateTo({
4 weeks ago
url: '/patient/pages/adl/index?nrdl=1',
})
this.handleToastCancel()
1 month ago
} else if (toastType === 'doubleStandards') {
wx.navigateTo({
4 weeks ago
url: '/patient/pages/adl/index',
})
this.handleToastCancel()
1 month ago
} else if (toastType === 'dedicatedDoctor') {
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/popup/close-popup',
1 month ago
data: {
Type: 6,
},
}).then((_res) => {
wx.navigateTo({
4 weeks ago
url: '/patient/pages/interactivePatient/index',
})
})
this.handleToastCancel(null, false)
1 month ago
} else if (toastType === 'referral-toast') {
this.setData({
referralFromShow: true,
})
1 month ago
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/re-visit/update-popup-show-status',
1 month ago
data: {},
})
this.handleToastCancel(null, false)
1 month ago
}
},
handleToastCancel(_e = null, sure = true) {
const { toastType } = this.data
1 month ago
if (toastType === 'doubleStandards' && sure) {
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/popup/close-popup',
1 month ago
data: {
Type: 5,
},
})
1 month ago
} else if (toastType === 'dedicatedDoctor' && sure) {
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/popup/close-popup',
1 month ago
data: {
Type: 6,
},
})
1 month ago
} else if (toastType === 'referral-toast') {
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/re-visit/update-popup-show-status',
1 month ago
data: {},
})
1 month ago
}
this.setData({
toastShow: false,
toastType: '',
toastParams: '',
})
1 month ago
},
handlePublic() {
this.setData({
toastShow: true,
toastType: 'public-toast',
toastParams: {},
})
this.handlePublicClose()
1 month ago
},
handlePublicClose() {
this.setData({
publicCard: false,
})
1 month ago
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/account/add-user-subscribe-guide-record',
1 month ago
data: {},
})
1 month ago
},
handleMp(e: any) {
const { code } = e.currentTarget.dataset
1 month ago
const PageName = {
spread1: 'BTN_PATIENTHOMEBANNER1',
spread2: 'BTN_PATIENTHOMEBANNER2',
}[code]
1 month ago
},
handleRegClose() {
this.setData({
regGuide: false,
})
1 month ago
},
})