信达小程序
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.

346 lines
8.2 KiB

import dayjs from 'dayjs'
const app = getApp<IAppOption>()
const licia = require('miniprogram-licia')
4 months ago
Page({
data: {
scrollBottom: '',
4 months ago
isEdit: false,
area: [] as string[][],
city: [] as string[][],
4 months ago
zdUserInfo: {} as any,
4 months ago
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: '否',
},
4 months ago
ageRangeValue: '0',
dict: {} as any,
4 months ago
DiagnosisTime: '',
HasTedSurgery: '',
IsGraves: '',
4 months ago
selectDiagnoseTypeIndex: '0',
diagnoseTypeShow: false,
diagnoseTypeValue: '0',
DTList: app.globalData.DiagnoseType.map((item) => {
return {
id: item.id,
value: item.name,
}
4 months ago
}),
popupShow: false,
popupType: 'popup7',
popupParams: {} as any,
},
onLoad(options) {
if (options.bottom) {
this.setData({
scrollBottom: options.bottom,
})
}
4 months ago
},
onShow() {
const SystemInfo = app.globalSystemInfo
4 months ago
if (SystemInfo) {
const { bottom } = SystemInfo.capsulePosition
4 months ago
this.setData({
bottom,
})
4 months ago
}
const ageEnd = licia.dateFormat(new Date(), 'yyyy-mm-dd')
4 months ago
this.setData({
ageEnd,
})
4 months ago
4 months ago
app.waitLogin({ type: [1] }).then(() => {
4 months ago
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,
})
})
4 months ago
},
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)
4 months ago
// this.handleTapRT();
if (this.data.scrollBottom) {
wx.pageScrollTo({
scrollTop: 100000,
})
this.setData({
scrollBottom: '',
})
}
4 months ago
},
formatBorn(Birth) {
let bron = ''
let age = ''
const date = new Date()
const year = date.getFullYear()
const month = date.getMonth() + 1
4 months ago
if (!Birth) {
bron = `${Birth}`
age = '岁'
4 months ago
} else if (Birth && Birth.split('-').length > 1) {
bron = `${Birth.split('-')[0]}${Birth.split('-')[1]}`
4 months ago
age =
month - Birth.split('-')[1] >= 0
? `${year - Birth.split('-')[0]}${month - Birth.split('-')[1]}个月`
: `${year - Birth.split('-')[0] - 1}${12 - Birth.split('-')[1] + month}个月`
4 months ago
} else {
bron = `${Birth}`
age = `${year - Birth}`
4 months ago
}
age = age.replace('岁0个月', '岁')
4 months ago
this.setData({
bron,
age,
4 months ago
'zdUserInfo.Birth': Birth,
'zdUserInfo.AgeYear': Number(dayjs().format('YYYY')) - Birth.split('-')[0],
})
4 months ago
},
handleChaneAge(e) {
const Birth = e.detail.value
this.formatBorn(Birth)
this.updateUserInfo()
4 months ago
},
handleChaneDiagnosisTime(e, update = true) {
const DiagnosisTime = e.detail.value
4 months ago
this.setData({
DiagnosisTime: dayjs(DiagnosisTime).format('YYYY年MM月'),
4 months ago
'zdUserInfo.DiagnosisTime': DiagnosisTime,
})
this.updateUserInfo(update)
4 months ago
},
handleInput(e) {
const { key } = e.currentTarget.dataset
4 months ago
this.setData({
4 months ago
[`zdUserInfo.${key}`]: e.detail.value,
})
4 months ago
},
handleChangeRT(e, update = true) {
const value = e.detail.value
const id = this.data.RTList.filter((_item, index) => index == value)[0]?.id
4 months ago
this.setData({
rtValue: value,
4 months ago
'zdUserInfo.RelationType': id,
})
this.updateUserInfo(update)
4 months ago
},
handleChangeGender(e, update = true) {
const value = e.detail.value
const id = this.data.GenderList.filter((_item, index) => index == value)[0]?.id
4 months ago
this.setData({
genderValue: value,
4 months ago
'zdUserInfo.Gender': id,
})
this.updateUserInfo(update)
4 months ago
},
handleChangeAgeRange(e, update = true) {
const value = e.detail.value
const id = this.data.dict.AgeRange.filter((_item, index) => index == value)[0]?.id
4 months ago
this.setData({
ageRangeValue: value,
4 months ago
'zdUserInfo.AgeRange': id,
})
this.updateUserInfo(update)
4 months ago
},
handleDiagnoseTypeSave(update = true) {
const rangeIndex = this.data.selectDiagnoseTypeIndex
const id = this.data.DTList.filter((_item, index) => index == rangeIndex)[0]?.id
4 months ago
this.setData({
diagnoseTypeValue: rangeIndex,
4 months ago
'zdUserInfo.DiagnoseType': id,
})
4 months ago
if (update) {
this.handleDiagnoseTypeShow()
4 months ago
}
this.updateUserInfo(update)
4 months ago
},
handleRadio(e) {
const { id, key } = e.currentTarget.dataset
4 months ago
this.setData({
4 months ago
[`zdUserInfo.${key}`]: id,
})
this.updateUserInfo(true)
4 months ago
},
handleDiagnoseTypeShow() {
this.setData({
diagnoseTypeShow: !this.data.diagnoseTypeShow,
})
4 months ago
},
handleChangeDiagnoseType(e) {
const value = e.detail.value[0]
4 months ago
this.setData({
selectDiagnoseTypeIndex: value,
})
4 months ago
},
handleRedioSelect(e) {
const { key, id } = e.currentTarget.dataset
4 months ago
this.setData({
4 months ago
[`zdUserInfo.${key}`]: id,
})
this.updateUserInfo()
4 months ago
},
updateUserInfo(update = true) {
if (!update) return
4 months ago
const { PatientName, RelationType, Gender, Birth, DiagnosisTime, DiagnoseType, ...zdUserInfo } =
this.data.zdUserInfo
4 months ago
wx.ajax({
method: 'POST',
4 months ago
url: '?r=zd/account/update-info',
4 months ago
data: {
name: PatientName,
relationType: RelationType,
gender: Gender,
birth: Birth,
diagnosisTime: DiagnosisTime,
diagnoseType: DiagnoseType,
4 months ago
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,
4 months ago
...zdUserInfo,
4 months ago
},
})
.then((_res) => {
wx.showToast({
title: '修改成功',
icon: 'none',
})
app.getZdUserInfo(this, true, this.formatUserInfo.bind(this))
4 months ago
})
.catch((err) => {
wx.showToast({
title: err.data.msg,
icon: 'none',
})
app.getZdUserInfo(this, true, this.formatUserInfo.bind(this))
})
4 months ago
},
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: '',
})
},
4 months ago
handleChangeTel() {
wx.navigateTo({
4 months ago
url: '/patient/pages/changePhone/index',
})
4 months ago
},
handleChangeUser() {
wx.navigateTo({
4 months ago
url: '/patient/pages/changeUser/index',
})
4 months ago
},
handleLogout() {
4 months ago
app.mpBehavior({ PageName: 'BTN_PatientPersonalInfoCancel' })
4 months ago
wx.navigateTo({
4 months ago
url: '/patient/pages/cancellation/index',
})
4 months ago
},
handleBack() {
wx.navigateBack()
4 months ago
},
routerTo(e) {
const { url } = e.currentTarget.dataset
4 months ago
if (url.includes('/pages/login/index')) {
app.mpBehavior({ PageName: 'BTN_PatientPersonalInfoChangeDoctor' })
4 months ago
}
wx.navigateTo({
url,
})
4 months ago
},
redirectTo(e) {
const { url } = e.currentTarget.dataset
4 months ago
wx.redirectTo({
url,
})
4 months ago
},
handlePreview() {
wx.previewImage({
urls: [this.data.zdUserInfo.PrescriptionImg],
})
},
})