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.
 
 
 

149 lines
3.8 KiB

import dayjs from 'dayjs'
const app = getApp<IAppOption>()
Page({
data: {
relationType: '1',
name: '',
gender: '',
birth: '',
ageRange: '',
diagnosisTime: '',
diagnoseType: '',
diagnoseTypeShow: false,
DiagnoseType: app.globalData.DiagnoseType,
diagnoseTypeIndex: '',
diagnoseTypeName: '',
selectDiagnoseTypeIndex: '0',
currentDate: dayjs().format('YYYY-MM'),
submiting: false,
proces: '0',
},
onLoad(options) {
this.setData({
pagePath: options.page,
proces: options.proces,
})
app.waitLogin({ isReg: false, loginPage: true }).then(() => {
app.getUserInfo(this, true, (userInfo) => {
this.setData({
relationType: userInfo.RelationType || '1',
name: userInfo.PatientName,
gender: userInfo.Gender,
ageRange: userInfo.AgeRange,
})
})
})
},
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,
})
},
bindChangeDate(e: WechatMiniprogram.CustomEvent) {
const { key } = e.currentTarget.dataset
this.setData({
[key]: e.detail.value,
})
},
handleDiagnoseTypeSave() {
const rangeIndex = this.data.selectDiagnoseTypeIndex
const { DiagnoseType } = this.data
const { id, name } = DiagnoseType[rangeIndex]
this.setData({
diagnoseTypeIndex: rangeIndex,
diagnoseTypeName: name,
diagnoseType: id,
})
this.handleDiagnoseTypeShow()
},
handleDiagnoseTypeShow() {
this.setData({
diagnoseTypeShow: !this.data.diagnoseTypeShow,
})
},
bindChange(e: WechatMiniprogram.CustomEvent) {
const rangeIndex = e.detail.value[0]
this.setData({
selectDiagnoseTypeIndex: rangeIndex,
})
},
handleSubmit() {
if (this.data.submiting) return
const { name, gender, ageRange, relationType } = this.data
const { registrationSource, registChannel, regBusinessId, WorkerId } = app.globalData
const { doctorId, inviteChan, recDoctorId: recommendDoctorId } = app.globalData.scene
let 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 : '/pages/index/index'
this.setData({
submiting: true,
})
wx.ajax({
method: 'POST',
url: '?r=igg4/account/reg',
data: {
name,
gender,
ageRange,
relationType,
registrationSource,
registChannel,
regBusinessId,
WorkerId,
inviteChannel: inviteChan,
inviteDoctorId: recommendDoctorId ? '' : doctorId,
recommendDoctorId: recommendDoctorId ? doctorId : '',
beRecommendDoctorId: recommendDoctorId,
},
loading: true,
})
.then((_res) => {
app.globalData.scene.doctorId = ''
app.globalData.scene.recDoctorId = ''
app.getUserInfo(this, true, () => {
wx.reLaunch({
url: `/pages/qaForm/index?backPage=${encodeURIComponent(navUrl)}`,
})
this.setData({
submiting: false,
})
})
})
.catch(() => {
this.setData({
submiting: false,
})
})
},
handleBack() {
wx.navigateBack()
},
})
export {}