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.
231 lines
5.6 KiB
231 lines
5.6 KiB
const app = getApp<IAppOption>() |
|
|
|
Page({ |
|
data: { |
|
doctor: {} as any, |
|
hospital: {}, |
|
popupDateShow: false, |
|
popupDateFocus: false, |
|
popupBriefShow: false, |
|
popupBriefFocus: false, |
|
ClinicList: [ |
|
{ |
|
name: '周一', |
|
weekday: 1, |
|
timeTypeActive1: false, |
|
timeTypeActive2: false, |
|
}, |
|
{ |
|
name: '周二', |
|
weekday: 2, |
|
timeTypeActive1: false, |
|
timeTypeActive2: false, |
|
}, |
|
{ |
|
name: '周三', |
|
weekday: 3, |
|
timeTypeActive1: false, |
|
timeTypeActive2: false, |
|
}, |
|
{ |
|
name: '周四', |
|
weekday: 4, |
|
timeTypeActive1: false, |
|
timeTypeActive2: false, |
|
}, |
|
{ |
|
name: '周五', |
|
weekday: 5, |
|
timeTypeActive1: false, |
|
timeTypeActive2: false, |
|
}, |
|
{ |
|
name: '周六', |
|
weekday: 6, |
|
timeTypeActive1: false, |
|
timeTypeActive2: false, |
|
}, |
|
{ |
|
name: '周日', |
|
weekday: 7, |
|
timeTypeActive1: false, |
|
timeTypeActive2: false, |
|
}, |
|
], |
|
PopupClinic: '', |
|
}, |
|
onLoad() {}, |
|
onShow() { |
|
app.waitLogin().then((_res) => { |
|
app.mpBehavior({ doctor: true, PageName: 'PG_DOCTORPERSONALINFO' }) |
|
this.getDetail() |
|
}) |
|
}, |
|
getDetail() { |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=zd/doctor/account/info', |
|
data: {}, |
|
}).then((res) => { |
|
const { ClinicList } = this.data |
|
|
|
let weekName = '' |
|
if (res.doctor.ClinicType == 2) { |
|
weekName = res.doctor.Clinic |
|
} else { |
|
;(res.doctor.Clinic ? res.doctor.Clinic : []).forEach((subItem: any) => { |
|
if (subItem.timeType == 1) { |
|
ClinicList[subItem.weekday - 1].timeTypeActive1 = true |
|
} |
|
if (subItem.timeType == 2) { |
|
ClinicList[subItem.weekday - 1].timeTypeActive2 = true |
|
} |
|
}) |
|
|
|
weekName = (res.doctor.Clinic ? res.doctor.Clinic : []) |
|
.map((subItem: { weekday: string | number; timeType: string | number }) => { |
|
const week = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] |
|
const timeDay = { 1: '上午', 2: '下午' } |
|
return `${week[Number(subItem.weekday) - 1]}${timeDay[subItem.timeType]}` |
|
}) |
|
.join(',') |
|
} |
|
|
|
this.setData({ |
|
doctor: { |
|
weekName, |
|
...res.doctor, |
|
Telephone: res.doctor.Telephone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2'), |
|
}, |
|
hospital: res.hospital, |
|
ClinicList, |
|
}) |
|
}) |
|
}, |
|
handleChangeClinicType(e) { |
|
const value = e.detail.value |
|
if (value) { |
|
this.setData({ |
|
'doctor.ClinicType': 2, |
|
'doctor.Clinic': '', |
|
'doctor.weekName': '', |
|
}) |
|
} else { |
|
this.setData({ |
|
'doctor.ClinicType': 1, |
|
'doctor.Clinic': [], |
|
'doctor.weekName': '', |
|
}) |
|
} |
|
this.handleWeekIntroduceSubmit() |
|
}, |
|
handleChangePhone() { |
|
app.mpBehavior({ doctor: true, PageName: 'BTN_DOCTORPERSONALINFOCHANGEPHONE' }) |
|
wx.navigateTo({ |
|
url: '/doctor/pages/d_changePhone/index', |
|
}) |
|
}, |
|
handleWeek() { |
|
const { doctor } = this.data |
|
this.setData({ |
|
PopupClinic: Array.isArray(doctor.Clinic) ? '' : doctor.Clinic, |
|
popupDateShow: true, |
|
}) |
|
setTimeout(() => { |
|
this.setData({ |
|
popupDateFocus: true, |
|
}) |
|
}, 300) |
|
}, |
|
handleWeekSelect(e) { |
|
const { type, index } = e.currentTarget.dataset |
|
const ClinicList = this.data.ClinicList |
|
ClinicList[index][`timeTypeActive${type}`] = !ClinicList[index][`timeTypeActive${type}`] |
|
this.setData({ |
|
ClinicList, |
|
}) |
|
}, |
|
handleWeekIntroduceSubmit() { |
|
const { doctor, PopupClinic } = this.data |
|
let Clinic = '' |
|
if (doctor.ClinicType == 2) { |
|
Clinic = PopupClinic |
|
} else { |
|
const ClinicList = this.data.ClinicList |
|
Clinic = ClinicList.reduce((pre, cur) => { |
|
if (cur.timeTypeActive1) { |
|
pre.push({ weekday: cur.weekday, timeType: 1 }) |
|
} |
|
if (cur.timeTypeActive2) { |
|
pre.push({ weekday: cur.weekday, timeType: 2 }) |
|
} |
|
return pre |
|
}, [] as any) |
|
} |
|
wx.ajax({ |
|
method: 'POST', |
|
url: '?r=zd/doctor/account/update-info', |
|
data: { |
|
Introduce: this.data.doctor.Introduce, |
|
Clinic, |
|
ClinicType: doctor.ClinicType, |
|
}, |
|
}).then(() => { |
|
this.onClose() |
|
}) |
|
}, |
|
handleBrief() { |
|
this.setData({ |
|
popupBriefShow: true, |
|
}) |
|
setTimeout(() => { |
|
this.setData({ |
|
popupBriefFocus: true, |
|
}) |
|
}, 300) |
|
}, |
|
handleBriefInput(e) { |
|
const doctor = this.data.doctor |
|
doctor.Introduce = e.detail.value |
|
this.setData({ |
|
doctor, |
|
}) |
|
}, |
|
onClose() { |
|
this.setData({ |
|
popupDateShow: false, |
|
popupBriefShow: false, |
|
popupBriefFocus: false, |
|
popupDateFocus: false, |
|
}) |
|
this.getDetail() |
|
}, |
|
handleSwitch() { |
|
app.mpBehavior({ doctor: true, PageName: 'BTN_DOCTORPERSONALINFOSWITCHACCOUNT' }) |
|
wx.navigateTo({ |
|
url: '/doctor/pages/d_changeDoctor/index', |
|
}) |
|
}, |
|
handleLoginOut() { |
|
wx.showModal({ |
|
title: '确认退出?', |
|
confirmColor: 'rgba(22, 121, 203, 1)', |
|
success: (res) => { |
|
if (res.confirm) { |
|
wx.ajax({ |
|
method: 'POST', |
|
url: '?r=zd/doctor/account/reg-logout', |
|
data: {}, |
|
}).then((_res) => { |
|
app.globalData.loginType = 1 |
|
app.globalData.anyWhere = true |
|
app.globalData.first = true |
|
wx.reLaunch({ |
|
url: '/pages/login/index', |
|
}) |
|
}) |
|
} |
|
}, |
|
}) |
|
}, |
|
})
|
|
|