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

586 lines
14 KiB

10 months ago
import dayjs from 'dayjs'
10 months ago
const app = getApp<IAppOption>()
const licia = require('miniprogram-licia')
10 months ago
Page({
data: {
today: dayjs().format('YYYY年MM月DD日 dddd'),
4 months ago
qolShow: false,
hormoneShow: false,
medicalInsuranceShow: false,
hospitalMapShow: false,
4 months ago
medicalInsuranceJump: false,
hospitalMapJump: false,
10 months ago
configList: [],
infoList: [] as any,
10 months ago
zdUserInfo: {} as any,
10 months ago
anyWhere: false,
regGuide: true,
10 months ago
isLogin: 1,
10 months ago
4 months ago
qolDetail: {} as any,
5 months ago
hormoneDetail: { recordId: '' },
9 months ago
10 months ago
adlList: [],
adlNum: '',
adlNewRecord: {} as any,
liveList: [],
liveStatus: app.globalData.liveStatus,
liveDownList: [],
// toastShow: true,
// toastType: "doubleStandards",
// toastType: "healthCare",
// toastType: "aldAlert",
// toastType:"dedicatedDoctor",
// toastType: 'public-toast',
4 months ago
// toastType: 'medical-guide',
// toastType: 'question-toast',
// toastType: 'guideEnterInfo',
// toastType: 'guideEnterInfoJump',
10 months ago
toastShow: false,
toastType: '',
4 months ago
toastParams: { close: true } as any,
10 months ago
sliderTop: 0,
unreadCount: 0,
options: {} as any,
},
onLoad(options) {
10 months ago
const systemInfo = wx.getSystemInfoSync()
10 months ago
10 months ago
if (options.visitors === '1') {
wx.showToast({
title: '未完成注册,登录失败',
icon: 'none',
})
}
10 months ago
app.zdGetTheme().then((res) => {
10 months ago
this.setData({
theme: res,
10 months ago
})
})
10 months ago
4 months ago
if (options.jump == '1') {
this.setData({
toastShow: true,
toastType: 'guideEnterInfoJump',
})
}
10 months ago
this.setData({
sliderTop: systemInfo.screenHeight - 160,
options,
10 months ago
})
10 months ago
},
onShow() {
10 months ago
app.waitLogin({ type: [0, 1] }).then(() => {
10 months ago
app.mpBehavior({ PageName: 'PG_PatientHome' })
10 months ago
this.setData({
anyWhere: app.globalData.anyWhere,
10 months ago
isLogin: app.globalData.isLogin,
})
10 months ago
if (this.data.options.es === '201501') {
10 months ago
app.globalData.IsAliQiWei = 1
10 months ago
this.setData({
options: {},
10 months ago
})
10 months ago
}
10 months ago
app.getZdUserInfo(this, true, (zdUserInfo) => {
10 months ago
this.setData({
10 months ago
zdUserInfo,
10 months ago
})
10 months ago
if (zdUserInfo.ExclusiveDoctorId) {
app.mpBehavior({ PageName: 'PG_PatientHomeDoctorCard' })
}
10 months ago
this.getPopup()
10 months ago
this.getConfig(zdUserInfo)
this.getSystemConfig()
10 months ago
if (zdUserInfo.ExclusiveDoctorId > 0) {
10 months ago
this.getUnreadCount()
10 months ago
}
10 months ago
})
})
10 months ago
},
10 months ago
async getPopup() {
4 months ago
if (this.data.toastShow)
return
const data1 = await wx.ajax({
10 months ago
method: 'GET',
url: '?r=zd/popup/info',
data: {
Type: 6,
},
})
if (data1.showAlert) {
10 months ago
this.setData({
toastShow: data1.showAlert,
10 months ago
toastType: 'dedicatedDoctor',
toastParams: {},
})
4 months ago
return
10 months ago
}
4 months ago
const data3 = await wx.ajax({
method: 'GET',
url: '?r=zd/popup/get-popup',
data: {
type: 3,
},
})
if (data3.showAlert) {
this.setData({
toastShow: data3.showAlert,
toastType: 'medical-guide',
4 months ago
toastParams: { close: true },
4 months ago
})
}
const data4 = await wx.ajax({
method: 'GET',
url: '?r=zd/popup/get-need-popup',
data: {
type: 1,
},
})
if (data4.showAlert) {
this.setData({
toastShow: data4.showAlert,
toastType: 'guideEnterInfo',
toastParams: {},
})
}
10 months ago
},
10 months ago
getUnreadCount() {
wx.ajax({
method: 'GET',
10 months ago
url: '?r=zd/message-interact/get-unread-count',
10 months ago
data: {},
}).then((res) => {
this.setData({
unreadCount: res,
10 months ago
})
})
10 months ago
},
getSystemConfig() {
wx.ajax({
method: 'GET',
10 months ago
url: '?r=zd/common/get-config',
10 months ago
data: {},
}).then((res) => {
this.setData({
systemConfig: res,
10 months ago
})
})
10 months ago
},
10 months ago
getConfig(zdUserInfo: any) {
4 months ago
// 处理用户类型
const UserType = zdUserInfo.UserType <= 2 ? 1 : Math.min(zdUserInfo.UserType, 3)
10 months ago
wx.ajax({
method: 'GET',
10 months ago
url: `?r=zd/mini-conf/get-config`,
4 months ago
data: { userType: UserType },
10 months ago
}).then((res) => {
4 months ago
// 过滤子列表
const processedRes = res.map((item: any) => {
if (['spread1', 'spread2', 'serviceConf'].includes(item.code)) {
item.subList = item.subList?.filter((subItem: any) => subItem.showStatus == 1) || []
10 months ago
}
10 months ago
return item
})
4 months ago
// 初始化显示状态
const statusMap = {
qolShow: false,
hormoneShow: false,
medicalInsuranceShow: false,
hospitalMapShow: false,
4 months ago
medicalInsuranceJump: false,
hospitalMapJump: false,
4 months ago
}
// 处理配置项
processedRes.forEach((item: any) => {
4 months ago
const { code, showStatus, configId, showNum, openStatus } = item
4 months ago
// 设置显示状态
if (code === 'medicalInsurance' && showStatus == 1) {
statusMap.medicalInsuranceShow = true
4 months ago
if (openStatus == 1)
statusMap.medicalInsuranceJump = true
10 months ago
}
4 months ago
if (code === 'hospitalMap' && showStatus == 1) {
statusMap.hospitalMapShow = true
4 months ago
if (openStatus == 1)
statusMap.hospitalMapJump = true
10 months ago
}
4 months ago
if (code === 'adl' && showStatus == 1) {
statusMap.qolShow = true
5 months ago
}
4 months ago
if (code === 'hormone' && showStatus == 1) {
statusMap.hormoneShow = true
10 months ago
}
4 months ago
// 调用对应方法
switch (code) {
case 'article':
this.getInfoList(configId)
break
case 'adl':
this.getQol()
break
case 'hormone':
this.getHormone()
break
case 'activity2':
this.getActivity(configId, showNum, 'liveList')
break
case 'activity1':
this.getActivity(configId, showNum, 'liveDownList')
break
10 months ago
}
10 months ago
})
4 months ago
this.setData({
configList: processedRes,
...statusMap,
})
10 months ago
})
10 months ago
},
setPopupInfo() {
wx.ajax({
method: 'POST',
10 months ago
url: '?r=zd/popup/update-click-status',
10 months ago
data: {
Type: 1,
Id: this.data.toastParams.Id,
},
10 months ago
}).then((_res) => {})
10 months ago
},
getInfoList(configId: string) {
wx.ajax({
method: 'GET',
10 months ago
url: '?r=zd/pic-text/index-list',
10 months ago
data: {
count: 0,
ConfigId: configId,
},
}).then((res) => {
this.setData({
infoList: licia.chunk(res.list, 3),
10 months ago
})
})
10 months ago
},
9 months ago
getQol() {
10 months ago
wx.ajax({
method: 'GET',
9 months ago
url: '?r=xd/qol/index',
10 months ago
data: {},
}).then((res) => {
this.setData({
9 months ago
qolDetail: {
...res.newRecord,
4 months ago
isTodayRecord: res.isTodayRecord,
CreateDate: dayjs(res.newRecord.CreateTime).format('MM-DD'),
10 months ago
},
10 months ago
})
})
10 months ago
},
5 months ago
getHormone() {
wx.ajax({
method: 'GET',
url: '?r=xd/hormone-dosage/get-last-record',
data: {},
}).then((res) => {
this.setData({
hormoneDetail: {
...res,
4 months ago
createTime: dayjs(res.createTime).format('MM-DD'),
5 months ago
},
})
})
},
10 months ago
getActivity(ConfigId: string, count: number, key: string) {
wx.ajax({
method: 'GET',
10 months ago
url: '?r=zd/activity/index-list',
10 months ago
data: { ConfigId, count },
}).then((res) => {
this.setData({
[key]: res.list.map((item) => {
10 months ago
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
10 months ago
}),
10 months ago
})
})
10 months ago
},
routerTo(e) {
4 months ago
let { url, active, code, status } = e.currentTarget.dataset
if (status === false) {
wx.showToast({
icon: 'none',
title: '功能正在建设中,敬请期待',
})
return
}
if (!url)
return
10 months ago
if (code === 'doctor') {
app.mpBehavior({ PageName: 'BTN_PatientHomeDoctorCard' })
10 months ago
}
10 months ago
if (code === 'activity2' && url.includes('/patient/pages/live/index')) {
app.mpBehavior({ PageName: 'BTN_PatientHomeLiveCard' })
10 months ago
}
10 months ago
if (code === 'activity2' && url.includes('/patient/pages/liveDetail/index')) {
9 months ago
app.mpBehavior({ PageName: 'BTN_PatientHomeLiveCard' })
}
if (code === 'article' && url.includes('/patient/pages/repositoryDetail/index')) {
10 months ago
app.mpBehavior({ PageName: 'BTN_PatientHomeContentCard' })
10 months ago
}
if (url.includes('loginState')) {
10 months ago
url = url + encodeURIComponent(app.globalData.loginState)
9 months ago
wx.navigateTo({
url,
10 months ago
})
return
10 months ago
}
wx.navigateTo({
url,
fail() {
10 months ago
app.globalData.active = active
10 months ago
wx.switchTab({
url,
10 months ago
})
10 months ago
},
10 months ago
})
10 months ago
},
4 months ago
handleAddQol() {
const { qolDetail } = this.data
4 months ago
const url
= qolDetail.Id && qolDetail.isTodayRecord
? `/patient/pages/qolAdd/index?id=${qolDetail.Id}&edit=1`
: `/patient/pages/qol/index`
4 months ago
wx.navigateTo({
url,
success() {
if (qolDetail.isTodayRecord) {
wx.showToast({
icon: 'none',
title: '每日仅录入1次,您可修改选项',
})
}
},
})
},
4 months ago
handleHormone() {
const { hormoneDetail } = this.data
if (hormoneDetail.recordId > 0) {
wx.navigateTo({
url: `/patient/pages/hormones/index?id=${hormoneDetail.recordId}`,
})
}
else {
wx.navigateTo({
url: '/patient/pages/hormonesStart/index',
})
}
},
10 months ago
handleReg() {
10 months ago
app.zdPermissionVerification(3, 0, '')
10 months ago
},
handleToastOk() {
10 months ago
const { toastType } = this.data
if (toastType === 'ndrlAldAlert') {
10 months ago
wx.navigateTo({
10 months ago
url: '/patient/pages/adl/index?nrdl=1',
10 months ago
})
this.handleToastCancel()
}
else if (toastType === 'doubleStandards') {
10 months ago
wx.navigateTo({
10 months ago
url: '/patient/pages/adl/index',
10 months ago
})
this.handleToastCancel()
}
else if (toastType === 'dedicatedDoctor') {
10 months ago
wx.ajax({
method: 'POST',
10 months ago
url: '?r=zd/popup/close-popup',
10 months ago
data: {
Type: 6,
},
}).then((_res) => {
wx.navigateTo({
10 months ago
url: '/patient/pages/interactivePatient/index',
10 months ago
})
})
this.handleToastCancel(null, false)
}
4 months ago
else if (toastType === 'medical-guide') {
wx.ajax({
method: 'POST',
url: '?r=zd/popup/add-record',
data: { type: 3 },
}).then(() => {
wx.navigateTo({
url: '/patient/pages/medical/index',
})
})
this.handleToastCancel(null, false)
}
else if (toastType === 'guideEnterInfo') {
wx.ajax({
method: 'POST',
url: '?r=zd/popup/close-need-popup',
data: { type: 1 },
}).then(() => {
wx.navigateTo({
url: '/patient/pages/personalInformation/index',
})
this.handleToastCancel(null, false)
})
}
else if (toastType === 'guideEnterInfoJump') {
wx.navigateTo({
url: '/patient/pages/personalInformation/index',
})
this.handleToastCancel(null, false)
}
10 months ago
},
handleToastCancel(_e = null, sure = true) {
10 months ago
const { toastType } = this.data
10 months ago
if (toastType === 'doubleStandards' && sure) {
wx.ajax({
method: 'POST',
10 months ago
url: '?r=zd/popup/close-popup',
10 months ago
data: {
Type: 5,
},
10 months ago
})
}
else if (toastType === 'dedicatedDoctor' && sure) {
10 months ago
wx.ajax({
method: 'POST',
10 months ago
url: '?r=zd/popup/close-popup',
10 months ago
data: {
Type: 6,
},
10 months ago
})
}
4 months ago
else if (toastType === 'medical-guide' && sure) {
wx.ajax({
method: 'POST',
url: '?r=zd/popup/add-record',
data: { type: 3 },
})
}
else if (toastType === 'guideEnterInfo' && sure) {
wx.ajax({
method: 'POST',
url: '?r=zd/popup/close-need-popup',
data: { type: 1 },
})
}
10 months ago
this.setData({
toastShow: false,
toastType: '',
toastParams: '',
10 months ago
})
10 months ago
},
handleRegClose() {
this.setData({
regGuide: false,
10 months ago
})
10 months ago
},
handleToggleSave(e) {
const { index, sindex } = e.currentTarget.dataset
const list = this.data.infoList
const { Id, IsCollect } = list[index][sindex]
app.zdPermissionVerification(3, 3, `patient/pages/repository/index`).then(() => {
if (IsCollect == 1) {
wx.ajax({
method: 'POST',
url: '?r=zd/pic-text/cancel-collection',
data: {
ContentId: Id,
},
loading: true,
}).then(() => {
list[index][sindex].IsCollect = 0
list[index][sindex].CollectionPeopleNum = list[index][sindex].CollectionPeopleNum - 1
wx.showToast({
title: '取消收藏',
icon: 'none',
})
this.setData({
infoList: list,
})
})
}
else {
wx.ajax({
method: 'POST',
url: '?r=zd/pic-text/collection',
data: {
ContentId: Id,
},
loading: true,
}).then(() => {
wx.showToast({
title: '收藏成功',
icon: 'none',
})
list[index][sindex].IsCollect = 1
list[index][sindex].CollectionPeopleNum = Number(list[index][sindex].CollectionPeopleNum) + 1
this.setData({
timeToastType: '10',
saveLock: true,
})
this.setData({
infoList: list,
})
})
}
})
},
4 months ago
handleQuestionToast(e) {
const { type } = e.currentTarget.dataset
this.setData({
toastShow: true,
toastType: 'question-toast',
toastParams: {
4 months ago
title: {
1: '生活质量自评',
2: '激素记录',
}[type],
4 months ago
type,
4 months ago
close: true,
},
})
},
10 months ago
})