const app = getApp() Page({ data: { popupShow: false, popupType: 'argument', // popupType: 'selectIdentity', // 选择您的身份 // popupType: 'bindDoctorReject', // 绑定失败 // popupType: 'bindDoctor', // 绑定成功 // popupType: 'bindDoctorQuestion', // 为什么绑定医生 // popupType: 'conformBindDoctorQuestion', // 确认绑定曾经扫码医生 // popupType: 'conformBindDoctorConform', // 注册后绑定医生码 popupParams: { position: 'bottom', } as any, userInfo: {}, bannerList: [], knowledgeList: [] as any, questionList: [] as any, pageTop: '', background: 'transparent', guide: 0, guideShow: false, guideList: ['2-1', '2-2', '2-3'], }, onLoad() { app.waitLogin({ type: 0 }).then(() => { app.getUserInfo().then((userInfo) => { this.setData({ userInfo, popupShow: !userInfo.guestPrivacyAgree, popupParams: { position: 'bottom', }, }) const waitBindDoctorId = app.globalData.waitBindDoctorId if (!userInfo.guestPrivacyAgree) { app.mpBehavior({ PageName: 'PG_PATIENTLOGIN' }) } else if (waitBindDoctorId) { this.handleBindDoctor(waitBindDoctorId) } }) this.getBanner() this.getKnowledgeList() this.getQuestionList() }) }, handleBindDoctor(id: string) { app.getDoctorInfo(id).then((res) => { this.setData({ popupShow: true, popupType: 'conformBindDoctorConform', popupParams: { name: res.doctorName, avatar: res.doctorAvatar, hostipal: res.hospitalName, className: res.hospitalClassificationName, levelName: res.hospitalLevelName, }, }) }) }, getBanner() { wx.ajax({ method: 'GET', url: '?r=wtx/common/banner-config', data: {}, }).then((res) => { this.setData({ bannerList: res, }) }) }, getKnowledgeList() { wx.ajax({ method: 'GET', url: '?r=wtx/knowledge/index-list', data: {}, }).then((res) => { this.setData({ knowledgeList: res.list, }) }) }, getQuestionList() { wx.ajax({ method: 'GET', url: '?r=wtx/common-question/index-list', data: {}, }).then((res) => { this.setData({ questionList: res.list, }) }) }, onBannerItemTap(e: any) { app.mpBehavior({ PageName: 'BTN_HOMEBANNER' }) const { path } = e.currentTarget.dataset wx.navigateTo({ url: path, }) }, handleKnowledge() { app.mpBehavior({ PageName: 'BTN_HOMEEDUCATIONALL' }) wx.switchTab({ url: '/pages/knowledge/index', }) }, handleKnowledgeDetail(e: any) { app.mpBehavior({ PageName: 'BTN_HOMEEDUCATIONCARD' }) const { index } = e.currentTarget.dataset const params = this.data.knowledgeList[index] if (params.Type == 1) { wx.navigateTo({ url: `/pages/knowledgeDetail/index?id=${params.Id}`, }) return } wx.navigateTo({ url: `/pages/knowledgeDetailVideo/index?id=${params.Id}`, }) }, handleAskItem(e) { app.mpBehavior({ PageName: 'BTN_HOMEFAQENTRY' }) const { id } = e.currentTarget.dataset wx.navigateTo({ url: `/pages/ask/index?id=${id}`, }) wx.ajax({ method: 'POST', url: '?r=wtx/common-question/click', data: { Id: id }, }) }, routerTo(e) { const { url } = e.currentTarget.dataset const PageName = { '/pages/applyFrom/index': 'BTN_HOMEPREAPPLYCARD', '/pages/ask/index': 'BTN_HOMEFAQENTRY', }[url] if (PageName) { app.mpBehavior({ PageName }) } wx.navigateTo({ url, }) }, touchmovePreview() { return false }, handleTapPreview() { if (this.data.guide == this.data.guideList.length - 1) { this.setData({ guideShow: false, }) } this.setData({ guide: Number(this.data.guide) + 1, }) }, handlePopupOk() { const { popupType } = this.data if (popupType === 'argument') { app.mpBehavior({ PageName: 'BTN_PATIENTLOG' }) 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 = '' }) } }, }) export {}