|
|
|
|
const app = getApp<IAppOption>()
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
popupShow: false,
|
|
|
|
|
popupType: '',
|
|
|
|
|
popupParams: {
|
|
|
|
|
position: 'bottom',
|
|
|
|
|
} as any,
|
|
|
|
|
userInfo: {} as any,
|
|
|
|
|
days: 0,
|
|
|
|
|
cateList: [] as Array<{ CateId: string; CateName: string }>,
|
|
|
|
|
activeCateId: '',
|
|
|
|
|
picTextList: [] as Array<any>,
|
|
|
|
|
pagination: {
|
|
|
|
|
page: 1,
|
|
|
|
|
pages: 1,
|
|
|
|
|
count: 0,
|
|
|
|
|
},
|
|
|
|
|
videoList: [] as Array<any>,
|
|
|
|
|
configList: [] as Array<any>,
|
|
|
|
|
sectionList: [] as Array<{ code: string; visible: boolean; subList: any[] }>,
|
|
|
|
|
moduleVisible: {
|
|
|
|
|
health: true,
|
|
|
|
|
spread1: true,
|
|
|
|
|
'video-big': true,
|
|
|
|
|
spread2: true,
|
|
|
|
|
'qiye-wx': true,
|
|
|
|
|
education: true,
|
|
|
|
|
} as Record<string, boolean>,
|
|
|
|
|
|
|
|
|
|
healthSummary: {
|
|
|
|
|
heartRate: 0,
|
|
|
|
|
heartRateDate: '',
|
|
|
|
|
revisitDays: 0,
|
|
|
|
|
revisitDate: '',
|
|
|
|
|
} as any,
|
|
|
|
|
},
|
|
|
|
|
onLoad() {
|
|
|
|
|
app.waitLogin({ type: 'any' }).then(() => {
|
|
|
|
|
this.getMyInfo()
|
|
|
|
|
this.getCateList()
|
|
|
|
|
this.getList()
|
|
|
|
|
this.getVideoList()
|
|
|
|
|
this.getConfig()
|
|
|
|
|
this.getHealthSummary()
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
if (app.globalData.loginState) {
|
|
|
|
|
this.getMyInfo()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getHealthSummary() {
|
|
|
|
|
const summary: any = {
|
|
|
|
|
heartRate: 0,
|
|
|
|
|
heartRateDate: '',
|
|
|
|
|
revisitDays: 0,
|
|
|
|
|
revisitDate: '',
|
|
|
|
|
}
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=psvt/heart-rate-record/last-heart-rate',
|
|
|
|
|
}).then((res: any) => {
|
|
|
|
|
if (res) {
|
|
|
|
|
summary.heartRate = res.heartRate || 0
|
|
|
|
|
const date = res.recordDate || ''
|
|
|
|
|
summary.heartRateDate = date ? date.substring(5) : ''
|
|
|
|
|
}
|
|
|
|
|
this.setData({ healthSummary: { ...this.data.healthSummary, ...summary } })
|
|
|
|
|
})
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=psvt/revisit-record/last-revisit',
|
|
|
|
|
}).then((res: any) => {
|
|
|
|
|
summary.revisitDays = res?.daysSinceLastRevisit ?? 0
|
|
|
|
|
const visitDate = res?.visitDate || ''
|
|
|
|
|
summary.revisitDate = visitDate ? visitDate.substring(5) : ''
|
|
|
|
|
this.setData({ healthSummary: { ...this.data.healthSummary, ...summary } })
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getConfig() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: `?r=psvt/mini-conf/get-config`,
|
|
|
|
|
data: {},
|
|
|
|
|
}).then((res: any) => {
|
|
|
|
|
const list = res || []
|
|
|
|
|
list.forEach((item: any) => {
|
|
|
|
|
if ((item.code === 'spread1' || item.code === 'spread2' || item.code === 'serviceConf') && item.subList) {
|
|
|
|
|
item.subList = item.subList.filter((subItem: any) => subItem.showStatus == 1)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const moduleVisible: Record<string, boolean> = {} as any
|
|
|
|
|
list.forEach((item: any) => {
|
|
|
|
|
moduleVisible[item.code] = item.showStatus == 1
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const sectionCodes = ['health', 'spread1', 'video-big', 'spread2']
|
|
|
|
|
const sectionList = sectionCodes
|
|
|
|
|
.map((code) => {
|
|
|
|
|
const conf = list.find((item: any) => item.code === code)
|
|
|
|
|
return {
|
|
|
|
|
code,
|
|
|
|
|
subList: conf?.subList || [],
|
|
|
|
|
visible: conf ? (conf.showStatus == 1 && (code === 'spread1' || code === 'spread2' ? (conf.subList || []).length > 0 : true)) : false,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
const aSeq = list.find((item: any) => item.code === a.code)?.sequence || 0
|
|
|
|
|
const bSeq = list.find((item: any) => item.code === b.code)?.sequence || 0
|
|
|
|
|
return Number(aSeq) - Number(bSeq)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.setData({ configList: list, moduleVisible, sectionList })
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getMyInfo() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=psvt/patient/my-info',
|
|
|
|
|
}).then((res: any) => {
|
|
|
|
|
let days = 0
|
|
|
|
|
if (res.firstOpenTime) {
|
|
|
|
|
const first = new Date(res.firstOpenTime.replace(/-/g, '/'))
|
|
|
|
|
const now = new Date()
|
|
|
|
|
days = Math.max(1, Math.ceil((now.getTime() - first.getTime()) / (1000 * 60 * 60 * 24)))
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
userInfo: res,
|
|
|
|
|
days,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getCateList() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=psvt/pic-text/cate-list',
|
|
|
|
|
}).then((res: any) => {
|
|
|
|
|
this.setData({
|
|
|
|
|
cateList: res || [],
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getList(page = 1, cateId = '', append = false) {
|
|
|
|
|
const params: any = {
|
|
|
|
|
page,
|
|
|
|
|
count: 10,
|
|
|
|
|
}
|
|
|
|
|
if (cateId) {
|
|
|
|
|
params.CateId = cateId
|
|
|
|
|
}
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=psvt/pic-text/list',
|
|
|
|
|
data: params,
|
|
|
|
|
}).then((res: any) => {
|
|
|
|
|
const list = res.list || []
|
|
|
|
|
this.setData({
|
|
|
|
|
picTextList: append ? this.data.picTextList.concat(list) : list,
|
|
|
|
|
pagination: {
|
|
|
|
|
page: res.page || 1,
|
|
|
|
|
pages: res.pages || 1,
|
|
|
|
|
count: Number(res.count) || 0,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getVideoList() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=psvt/video/list',
|
|
|
|
|
data: { page: 1, count: 10 },
|
|
|
|
|
}).then((res: any) => {
|
|
|
|
|
this.setData({
|
|
|
|
|
videoList: res.list || [],
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleCateTap(e: any) {
|
|
|
|
|
const { cateid } = e.currentTarget.dataset
|
|
|
|
|
this.setData({
|
|
|
|
|
activeCateId: cateid || '',
|
|
|
|
|
})
|
|
|
|
|
this.getList(1, cateid || '')
|
|
|
|
|
},
|
|
|
|
|
handleLoadMore() {
|
|
|
|
|
const { pagination, activeCateId } = this.data
|
|
|
|
|
if (pagination.page < pagination.pages) {
|
|
|
|
|
this.getList(pagination.page + 1, activeCateId, true)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handlePopupOk() {
|
|
|
|
|
const { popupType } = this.data
|
|
|
|
|
if (popupType === 'argument') {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=wtx/user/agree-guest-privacy',
|
|
|
|
|
data: {
|
|
|
|
|
WorkerId: app.globalData.scene?.workerId || '',
|
|
|
|
|
},
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: false,
|
|
|
|
|
popupType: '',
|
|
|
|
|
popupParams: {},
|
|
|
|
|
})
|
|
|
|
|
const waitBindDoctorId = app.globalData.waitBindDoctorId
|
|
|
|
|
if (waitBindDoctorId) {
|
|
|
|
|
this.handleBindDoctor(waitBindDoctorId)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (popupType === 'conformBindDoctorConform') {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: false,
|
|
|
|
|
})
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=wtx/account/wait-bind-doctor',
|
|
|
|
|
data: {
|
|
|
|
|
doctorId: app.globalData.waitBindDoctorId,
|
|
|
|
|
},
|
|
|
|
|
}).then(() => {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: `/patient/pages/login/index`,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handlePopupCancel() {
|
|
|
|
|
const { popupType } = this.data
|
|
|
|
|
if (popupType === 'argument') {
|
|
|
|
|
wx.exitMiniProgram()
|
|
|
|
|
}
|
|
|
|
|
if (popupType === 'conformBindDoctorConform') {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: false,
|
|
|
|
|
})
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=wtx/account/wait-bind-doctor',
|
|
|
|
|
data: {
|
|
|
|
|
doctorId: app.globalData.waitBindDoctorId,
|
|
|
|
|
},
|
|
|
|
|
}).then(() => {
|
|
|
|
|
app.globalData.waitBindDoctorId = ''
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleHealthHeartTap() {
|
|
|
|
|
const tabBarParams = app.globalData.tabBarParams || {}
|
|
|
|
|
tabBarParams['pages/health/index'] = 'tab=1'
|
|
|
|
|
app.globalData.tabBarParams = tabBarParams
|
|
|
|
|
wx.switchTab({ url: '/pages/health/index' })
|
|
|
|
|
},
|
|
|
|
|
handleHealthRevisitTap() {
|
|
|
|
|
const tabBarParams = app.globalData.tabBarParams || {}
|
|
|
|
|
tabBarParams['pages/health/index'] = 'tab=2'
|
|
|
|
|
app.globalData.tabBarParams = tabBarParams
|
|
|
|
|
wx.switchTab({ url: '/pages/health/index' })
|
|
|
|
|
},
|
|
|
|
|
handleWechatWork() {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/wechatWork/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
this.handleLoadMore()
|
|
|
|
|
},
|
|
|
|
|
handleBackTop() {
|
|
|
|
|
wx.pageScrollTo({ scrollTop: 0 })
|
|
|
|
|
},
|
|
|
|
|
handleVideoMore() {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/videoList/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleVideoDetail(e) {
|
|
|
|
|
const { index } = e.currentTarget.dataset
|
|
|
|
|
const { videoList } = this.data
|
|
|
|
|
const { Id } = videoList[index]
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: `/pages/videoDetail/index?id=${Id}&index=${index}`,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleBannerTap(e) {
|
|
|
|
|
const { linkurl } = e.currentTarget.dataset
|
|
|
|
|
if (!linkurl) return
|
|
|
|
|
const tabBarPages = ['pages/index/index', 'pages/wall/index', 'pages/health/index', 'pages/my/index']
|
|
|
|
|
const [path, query] = linkurl.split('?')
|
|
|
|
|
if (tabBarPages.some((p) => path === p || path === `/${p}`)) {
|
|
|
|
|
// tabBar 页面:通过 globalData 传参,switchTab 不支持 query
|
|
|
|
|
if (query) {
|
|
|
|
|
app.globalData.tabBarParams = app.globalData.tabBarParams || {}
|
|
|
|
|
app.globalData.tabBarParams[path.replace(/^\//, '')] = query
|
|
|
|
|
}
|
|
|
|
|
wx.switchTab({ url: path.startsWith('/') ? path : `/${path}` })
|
|
|
|
|
} else {
|
|
|
|
|
wx.navigateTo({ url: linkurl })
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handlePicTextDetail(e) {
|
|
|
|
|
const { index } = e.currentTarget.dataset
|
|
|
|
|
const { picTextList } = this.data
|
|
|
|
|
const { Id, Type } = picTextList[index]
|
|
|
|
|
if (Type == 1) {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: `/pages/articleDetail/index?id=${Id}`,
|
|
|
|
|
})
|
|
|
|
|
} else if (Type == 2) {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: `/pages/articleVideoDetail/index?id=${Id}`,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export {}
|