|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
const app = getApp<IAppOption>()
|
|
|
|
|
const licia = require('miniprogram-licia')
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
scrollBottom: '',
|
|
|
|
|
isEdit: false,
|
|
|
|
|
area: [] as string[][],
|
|
|
|
|
city: [] as string[][],
|
|
|
|
|
zdUserInfo: {} as any,
|
|
|
|
|
areaValue: '',
|
|
|
|
|
bron: '',
|
|
|
|
|
age: '',
|
|
|
|
|
ageStart: '1930-01-01',
|
|
|
|
|
ageEnd: '',
|
|
|
|
|
|
|
|
|
|
rtValue: '0',
|
|
|
|
|
RTList: [
|
|
|
|
|
{ id: 1, value: '本人' },
|
|
|
|
|
{ id: 2, value: '亲友' },
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
genderValue: '0',
|
|
|
|
|
GenderList: [
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
value: '男',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 2,
|
|
|
|
|
value: '女',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
bolList: {
|
|
|
|
|
1: '是',
|
|
|
|
|
2: '否',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ageRangeValue: '0',
|
|
|
|
|
|
|
|
|
|
dict: {} as any,
|
|
|
|
|
|
|
|
|
|
DiagnosisTime: '',
|
|
|
|
|
|
|
|
|
|
HasTedSurgery: '',
|
|
|
|
|
IsGraves: '',
|
|
|
|
|
|
|
|
|
|
selectDiagnoseTypeIndex: '0',
|
|
|
|
|
diagnoseTypeShow: false,
|
|
|
|
|
diagnoseTypeValue: '0',
|
|
|
|
|
DTList: app.globalData.DiagnoseType.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
id: item.id,
|
|
|
|
|
value: item.name,
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
popupShow: false,
|
|
|
|
|
popupType: 'popup7',
|
|
|
|
|
popupParams: {} as any,
|
|
|
|
|
},
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
if (options.bottom) {
|
|
|
|
|
this.setData({
|
|
|
|
|
scrollBottom: options.bottom,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
const SystemInfo = app.globalSystemInfo
|
|
|
|
|
if (SystemInfo) {
|
|
|
|
|
const { bottom } = SystemInfo.capsulePosition
|
|
|
|
|
this.setData({
|
|
|
|
|
bottom,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const ageEnd = licia.dateFormat(new Date(), 'yyyy-mm-dd')
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
ageEnd,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
app.waitLogin({ type: [1] }).then(() => {
|
|
|
|
|
app.mpBehavior({ PageName: 'PG_PatientPersonalInfo' })
|
|
|
|
|
const that = this
|
|
|
|
|
app.getZdUserInfo(that, true, that.formatUserInfo.bind(that))
|
|
|
|
|
this.getDict()
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getDict() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=xd/user/get-dict',
|
|
|
|
|
data: {},
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
this.setData({
|
|
|
|
|
dict: res,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
formatUserInfo(res) {
|
|
|
|
|
this.formatBorn(res.Birth)
|
|
|
|
|
this.handleChaneDiagnosisTime({ detail: { value: res.DiagnosisTime } }, false)
|
|
|
|
|
const diagnoseTypeValue = this.data.DTList.findIndex((item) => item.id == res.DiagnoseType)
|
|
|
|
|
this.handleChangeDiagnoseType({ detail: { value: [diagnoseTypeValue] } })
|
|
|
|
|
this.handleDiagnoseTypeSave(false)
|
|
|
|
|
// this.handleTapRT();
|
|
|
|
|
|
|
|
|
|
if (this.data.scrollBottom) {
|
|
|
|
|
wx.pageScrollTo({
|
|
|
|
|
scrollTop: 100000,
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
scrollBottom: '',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
formatBorn(Birth) {
|
|
|
|
|
let bron = ''
|
|
|
|
|
let age = ''
|
|
|
|
|
const date = new Date()
|
|
|
|
|
const year = date.getFullYear()
|
|
|
|
|
const month = date.getMonth() + 1
|
|
|
|
|
if (!Birth) {
|
|
|
|
|
bron = `${Birth}年`
|
|
|
|
|
age = '岁'
|
|
|
|
|
} else if (Birth && Birth.split('-').length > 1) {
|
|
|
|
|
bron = `${Birth.split('-')[0]}年${Birth.split('-')[1]}月`
|
|
|
|
|
age =
|
|
|
|
|
month - Birth.split('-')[1] >= 0
|
|
|
|
|
? `${year - Birth.split('-')[0]}岁${month - Birth.split('-')[1]}个月`
|
|
|
|
|
: `${year - Birth.split('-')[0] - 1}岁${12 - Birth.split('-')[1] + month}个月`
|
|
|
|
|
} else {
|
|
|
|
|
bron = `${Birth}年`
|
|
|
|
|
age = `${year - Birth}岁`
|
|
|
|
|
}
|
|
|
|
|
age = age.replace('岁0个月', '岁')
|
|
|
|
|
this.setData({
|
|
|
|
|
bron,
|
|
|
|
|
age,
|
|
|
|
|
'zdUserInfo.Birth': Birth,
|
|
|
|
|
'zdUserInfo.AgeYear': Number(dayjs().format('YYYY')) - Birth.split('-')[0],
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleChaneAge(e) {
|
|
|
|
|
const Birth = e.detail.value
|
|
|
|
|
this.formatBorn(Birth)
|
|
|
|
|
this.updateUserInfo()
|
|
|
|
|
},
|
|
|
|
|
handleChaneDiagnosisTime(e, update = true) {
|
|
|
|
|
const DiagnosisTime = e.detail.value
|
|
|
|
|
this.setData({
|
|
|
|
|
DiagnosisTime: dayjs(DiagnosisTime).format('YYYY年MM月'),
|
|
|
|
|
'zdUserInfo.DiagnosisTime': DiagnosisTime,
|
|
|
|
|
})
|
|
|
|
|
this.updateUserInfo(update)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleInput(e) {
|
|
|
|
|
const { key } = e.currentTarget.dataset
|
|
|
|
|
this.setData({
|
|
|
|
|
[`zdUserInfo.${key}`]: e.detail.value,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleChangeRT(e, update = true) {
|
|
|
|
|
const value = e.detail.value
|
|
|
|
|
const id = this.data.RTList.filter((_item, index) => index == value)[0]?.id
|
|
|
|
|
this.setData({
|
|
|
|
|
rtValue: value,
|
|
|
|
|
'zdUserInfo.RelationType': id,
|
|
|
|
|
})
|
|
|
|
|
this.updateUserInfo(update)
|
|
|
|
|
},
|
|
|
|
|
handleChangeGender(e, update = true) {
|
|
|
|
|
const value = e.detail.value
|
|
|
|
|
const id = this.data.GenderList.filter((_item, index) => index == value)[0]?.id
|
|
|
|
|
this.setData({
|
|
|
|
|
genderValue: value,
|
|
|
|
|
'zdUserInfo.Gender': id,
|
|
|
|
|
})
|
|
|
|
|
this.updateUserInfo(update)
|
|
|
|
|
},
|
|
|
|
|
handleChangeAgeRange(e, update = true) {
|
|
|
|
|
const value = e.detail.value
|
|
|
|
|
const id = this.data.dict.AgeRange.filter((_item, index) => index == value)[0]?.id
|
|
|
|
|
this.setData({
|
|
|
|
|
ageRangeValue: value,
|
|
|
|
|
'zdUserInfo.AgeRange': id,
|
|
|
|
|
})
|
|
|
|
|
this.updateUserInfo(update)
|
|
|
|
|
},
|
|
|
|
|
handleDiagnoseTypeSave(update = true) {
|
|
|
|
|
const rangeIndex = this.data.selectDiagnoseTypeIndex
|
|
|
|
|
const id = this.data.DTList.filter((_item, index) => index == rangeIndex)[0]?.id
|
|
|
|
|
this.setData({
|
|
|
|
|
diagnoseTypeValue: rangeIndex,
|
|
|
|
|
'zdUserInfo.DiagnoseType': id,
|
|
|
|
|
})
|
|
|
|
|
if (update) {
|
|
|
|
|
this.handleDiagnoseTypeShow()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.updateUserInfo(update)
|
|
|
|
|
},
|
|
|
|
|
handleRadio(e) {
|
|
|
|
|
const { id, key } = e.currentTarget.dataset
|
|
|
|
|
this.setData({
|
|
|
|
|
[`zdUserInfo.${key}`]: id,
|
|
|
|
|
})
|
|
|
|
|
this.updateUserInfo(true)
|
|
|
|
|
},
|
|
|
|
|
handleDiagnoseTypeShow() {
|
|
|
|
|
this.setData({
|
|
|
|
|
diagnoseTypeShow: !this.data.diagnoseTypeShow,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleChangeDiagnoseType(e) {
|
|
|
|
|
const value = e.detail.value[0]
|
|
|
|
|
this.setData({
|
|
|
|
|
selectDiagnoseTypeIndex: value,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleRedioSelect(e) {
|
|
|
|
|
const { key, id } = e.currentTarget.dataset
|
|
|
|
|
this.setData({
|
|
|
|
|
[`zdUserInfo.${key}`]: id,
|
|
|
|
|
})
|
|
|
|
|
this.updateUserInfo()
|
|
|
|
|
},
|
|
|
|
|
updateUserInfo(update = true) {
|
|
|
|
|
if (!update) return
|
|
|
|
|
const { PatientName, RelationType, Gender, Birth, DiagnosisTime, DiagnoseType, ...zdUserInfo } =
|
|
|
|
|
this.data.zdUserInfo
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=zd/account/update-info',
|
|
|
|
|
data: {
|
|
|
|
|
name: PatientName,
|
|
|
|
|
relationType: RelationType,
|
|
|
|
|
gender: Gender,
|
|
|
|
|
birth: Birth,
|
|
|
|
|
diagnosisTime: DiagnosisTime,
|
|
|
|
|
diagnoseType: DiagnoseType,
|
|
|
|
|
ageRange: zdUserInfo.AgeRange,
|
|
|
|
|
patientCanFollowUp: zdUserInfo.PatientCanFollowUp,
|
|
|
|
|
antibodyType: zdUserInfo.AntibodyType,
|
|
|
|
|
thyroidAbnormal: zdUserInfo.ThyroidAbnormal,
|
|
|
|
|
previousConvulsion: zdUserInfo.PreviousConvulsion,
|
|
|
|
|
traditionalImmunosuppressant: zdUserInfo.TraditionalImmunosuppressant,
|
|
|
|
|
medicalInsuranceType: zdUserInfo.MedicalInsuranceType,
|
|
|
|
|
isKnowTituyo: zdUserInfo.IsKnowTituyo,
|
|
|
|
|
isUseTituyo: zdUserInfo.IsUseTituyo,
|
|
|
|
|
...zdUserInfo,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.then((_res) => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '修改成功',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
app.getZdUserInfo(this, true, this.formatUserInfo.bind(this))
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: err.data.msg,
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
app.getZdUserInfo(this, true, this.formatUserInfo.bind(this))
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleNoUpload() {
|
|
|
|
|
return false
|
|
|
|
|
},
|
|
|
|
|
handleSetData(e) {
|
|
|
|
|
this.setData({
|
|
|
|
|
'zdUserInfo.prescriptionImg': e.detail.imgUrl,
|
|
|
|
|
})
|
|
|
|
|
this.updateUserInfo()
|
|
|
|
|
},
|
|
|
|
|
handleDelData() {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: true,
|
|
|
|
|
popupType: 'popup7',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handlePopupOk() {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: false,
|
|
|
|
|
popupType: '',
|
|
|
|
|
'zdUserInfo.prescriptionImg': '',
|
|
|
|
|
})
|
|
|
|
|
this.updateUserInfo()
|
|
|
|
|
},
|
|
|
|
|
handlePopupCancel() {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: false,
|
|
|
|
|
popupType: '',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleChangeTel() {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/patient/pages/changePhone/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleChangeUser() {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/patient/pages/changeUser/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleLogout() {
|
|
|
|
|
app.mpBehavior({ PageName: 'BTN_PatientPersonalInfoCancel' })
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/patient/pages/cancellation/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleBack() {
|
|
|
|
|
wx.navigateBack()
|
|
|
|
|
},
|
|
|
|
|
routerTo(e) {
|
|
|
|
|
const { url } = e.currentTarget.dataset
|
|
|
|
|
if (url.includes('/pages/login/index')) {
|
|
|
|
|
app.mpBehavior({ PageName: 'BTN_PatientPersonalInfoChangeDoctor' })
|
|
|
|
|
}
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
redirectTo(e) {
|
|
|
|
|
const { url } = e.currentTarget.dataset
|
|
|
|
|
wx.redirectTo({
|
|
|
|
|
url,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handlePreview() {
|
|
|
|
|
wx.previewImage({
|
|
|
|
|
urls: [this.data.zdUserInfo.PrescriptionImg],
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
})
|