|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
const app = getApp<IAppOption>()
|
|
|
|
|
const licia = require('miniprogram-licia')
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
userInfo: {} as any,
|
|
|
|
|
bron: '',
|
|
|
|
|
age: '',
|
|
|
|
|
ageStart: '1930-01-01',
|
|
|
|
|
ageEnd: '',
|
|
|
|
|
|
|
|
|
|
ageRangeList: [
|
|
|
|
|
{ id: 5, value: '18岁以下' },
|
|
|
|
|
{ id: 1, value: '18岁-44岁' },
|
|
|
|
|
{ id: 2, value: '45岁-59岁' },
|
|
|
|
|
{ id: 3, value: '60岁-74岁' },
|
|
|
|
|
{ id: 4, value: '75岁以上' },
|
|
|
|
|
],
|
|
|
|
|
diagnosisTimeRangeList: [
|
|
|
|
|
{ id: 1, value: '6个月以内' },
|
|
|
|
|
{ id: 2, value: '6个月-3年' },
|
|
|
|
|
{ id: 3, value: '3年以上' },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
const ageEnd = licia.dateFormat(new Date(), 'yyyy-mm-dd')
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
ageEnd,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
app.waitLogin().then(() => {
|
|
|
|
|
app.mpBehavior({ PageName: 'PG_PATIENTPERSONALINFO' })
|
|
|
|
|
const that = this
|
|
|
|
|
app.getUserInfo(that, true, that.formatUserInfo.bind(that))
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
formatUserInfo(res) {
|
|
|
|
|
this.formatBorn(res.Birth)
|
|
|
|
|
},
|
|
|
|
|
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,
|
|
|
|
|
'userInfo.Birth': Birth,
|
|
|
|
|
'userInfo.AgeYear': Number(dayjs().format('YYYY')) - Birth.split('-')[0],
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleChaneAge(e) {
|
|
|
|
|
const Birth = e.detail.value
|
|
|
|
|
this.formatBorn(Birth)
|
|
|
|
|
this.updateUserInfo()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleInput(e) {
|
|
|
|
|
const { key } = e.currentTarget.dataset
|
|
|
|
|
this.setData({
|
|
|
|
|
[`userInfo.${key}`]: e.detail.value,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleRadio(e) {
|
|
|
|
|
const { id, key } = e.currentTarget.dataset
|
|
|
|
|
this.setData({
|
|
|
|
|
[`userInfo.${key}`]: id,
|
|
|
|
|
})
|
|
|
|
|
this.updateUserInfo(true)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updateUserInfo(update = true) {
|
|
|
|
|
if (!update) return
|
|
|
|
|
const { PatientName, RelationType, Gender, AgeRange, DiagnosisTimeRange, Birth, DiagnosisTime } = this.data.userInfo
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=igg4/account/update-info',
|
|
|
|
|
data: {
|
|
|
|
|
name: PatientName,
|
|
|
|
|
relationType: RelationType,
|
|
|
|
|
gender: Gender,
|
|
|
|
|
ageRange: AgeRange,
|
|
|
|
|
diagnosisTimeRange: DiagnosisTimeRange,
|
|
|
|
|
birth: Birth,
|
|
|
|
|
diagnosisTime: DiagnosisTime,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.then((_res) => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '修改成功',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
app.getUserInfo(this, true, this.formatUserInfo.bind(this))
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: err.data.msg,
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
app.getUserInfo(this, true, this.formatUserInfo.bind(this))
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleChangeTel() {
|
|
|
|
|
app.mpBehavior({ PageName: 'PG_PATIENTPERSONALINFO_CHANGEPHONECLICK' })
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/changePhone/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleChangeUser() {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/changeUser/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleLogout() {
|
|
|
|
|
app.mpBehavior({ PageName: 'BTN_PATIENTPERSONALINFOLOGOUT' })
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/cancellation/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleBack() {
|
|
|
|
|
wx.navigateBack()
|
|
|
|
|
},
|
|
|
|
|
routerTo(e) {
|
|
|
|
|
const { url } = e.currentTarget.dataset
|
|
|
|
|
if (url.includes('/doctor/pages/d_login/index')) {
|
|
|
|
|
app.mpBehavior({ PageName: 'BTN_PATIENTPERSONALINFOSWITCHDOCTORPORTAL' })
|
|
|
|
|
}
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export {}
|