import dayjs from 'dayjs' const app = getApp() Page({ data: { relationType: '1', name: '', gender: '', birth: '', ageRange: '', diagnosisTime: '', diagnoseType: '', IsGraves: '', HasTedSurgery: '', isKnowTituyo: '', isUseTituyo: '', prescriptionImg: '', diagnoseTypeShow: false, DiagnoseType: app.globalData.DiagnoseType, diagnoseTypeIndex: '', diagnoseTypeName: '', selectDiagnoseTypeIndex: '0', currentDate: dayjs().format('YYYY-MM'), submiting: false, proces: '0', dict: {}, bolList: { 1: '是', 2: '否', }, popupShow: false, popupType: 'popup7', popupParams: {} as any, }, onLoad(options) { this.setData({ pagePath: options.page, proces: options.proces, }) app.waitLogin().then(() => { app.mpBehavior({ PageName: 'PG_PatientInfo' }) this.getDict() app.getZdUserInfo(this, true, (zdUserInfo) => { this.setData({ relationType: zdUserInfo.RelationType || '1', name: zdUserInfo.PatientName, gender: zdUserInfo.Gender, ageRange: zdUserInfo.AgeRange, }) }) }) }, getDict() { wx.ajax({ method: 'GET', url: '?r=xd/user/get-dict', data: {}, }).then((res) => { this.setData({ dict: res, }) }) }, handleRelationType(e: WechatMiniprogram.CustomEvent) { const { id } = e.currentTarget.dataset this.setData({ relationType: id, }) }, handleGender(e: WechatMiniprogram.CustomEvent) { const { id } = e.currentTarget.dataset this.setData({ gender: id, }) }, handleSelectAge(e: WechatMiniprogram.CustomEvent) { const { id } = e.currentTarget.dataset this.setData({ ageRange: id, }) }, handleSelectIsGraves(e: WechatMiniprogram.CustomEvent) { const { id } = e.currentTarget.dataset this.setData({ IsGraves: id, }) }, handleSelectHasTedSurgery(e: WechatMiniprogram.CustomEvent) { const { id } = e.currentTarget.dataset this.setData({ HasTedSurgery: id, }) }, handleSelectKnowTituyo(e) { const { id } = e.currentTarget.dataset this.setData({ isKnowTituyo: id, }) }, handleSelectUseTituyo(e) { const { id } = e.currentTarget.dataset this.setData({ isUseTituyo: id, }) wx.pageScrollTo({ scrollTop: 10000, }) }, handleSubmit() { app.mpBehavior({ PageName: 'BTN_PatientInfoComfirm' }) if (this.data.submiting) return const { name, gender, ageRange, relationType, IsGraves, HasTedSurgery } = this.data const { registrationSource, registChannel, regBusinessId, WorkerId, IsAliQiWei } = app.globalData const { doctorId, inviteChan, proMethodId } = app.globalData.scene let toast = '' // if (!diagnosisTime) toast = "确诊时间不能为空"; // if (!birth) toast = "出生日期不能为空"; if (!gender) toast = '请选择性别' if (!ageRange) toast = '请选择年龄范围' if (!name) toast = '姓名不能为空' if (toast) { wx.showToast({ title: toast, icon: 'none' }) return } const backPage = app.globalData.backPage const navUrl = typeof backPage === 'string' && backPage.includes('liveResult') ? backPage : '/patient/pages/certReslove/index' this.setData({ submiting: true, }) wx.ajax({ method: 'POST', url: '?r=zd/account/reg', data: { name, gender, ageRange, // birth, // diagnoseType, // diagnosisTime, relationType, registrationSource, registChannel, regBusinessId, IsGraves, HasTedSurgery, WorkerId, inviteDoctorId: doctorId, inviteChannel: inviteChan, IsAliQiWei, promotionMethodId: proMethodId, }, }) .then((_res) => { app.updateLoginInfo(() => { wx.reLaunch({ url: navUrl, }) this.setData({ submiting: false, }) }) }) .catch(() => { this.setData({ submiting: false, }) }) }, handleVisitors() { app.mpBehavior({ PageName: 'BTN_PatientInfoSkip' }) wx.ajax({ method: 'POST', url: '?r=zd/login/reg-logout', data: {}, showMsg: false, }).then(() => { app.startLogin(() => { wx.reLaunch({ url: '/patient/pages/index/index?visitors=1', }) }) }) }, handleSetData(e) { this.setData({ prescriptionImg: e.detail.imgUrl, }) }, handleDelData() { this.setData({ popupShow: true, popupType: 'popup7', }) }, handlePopupOk() { this.setData({ popupShow: false, popupType: '', prescriptionImg: '', }) }, handlePopupCancel() { this.setData({ popupShow: false, popupType: '', }) }, handleBack() { wx.navigateBack({ fail() { wx.reLaunch({ url: '/patient/pages/login/index', }) }, }) }, }) export {}