const app = getApp() Page({ data: { popupShow: false, // popupType:'selectHostipal', popupType: 'selectHostipalComplete', popupParams: {} as any, selectId: '', list: [] as any[], total: 0, pagination: { page: 1, pages: 1, count: 1, }, search: '', provinceId: '', provinceName: '', cityId: '', cityName: '', }, onLoad() { app.waitLogin({ type: 1 }).then(() => { this.getHospitalList() }) }, handleSearch() { this.getHospitalList(1) }, handleAreaChange(e) { const value = e.detail this.setData({ provinceId: value[0].value, cityId: value[1] ? value[1].value : '', provinceName: value[0].label, cityName: value[1] ? value[1].label : '', }) this.getHospitalList(1) }, getHospitalList(newPage = 1) { const { search, provinceId, cityId } = this.data wx.ajax({ method: 'GET', url: '?r=wtx/common/get-hospital-list', data: { search, provinceId, cityId, page: newPage, }, }).then((res) => { const list = res.page === 1 ? res.list : [...this.data.list, ...res.list] this.setData({ total: res.count, list, pagination: { page: res.page, pages: res.pages, count: res.count, }, }) }) }, onReachBottom() { const { page, pages } = this.data.pagination if (pages > page) { this.getHospitalList(page + 1) } }, handleSelect(e) { const { index } = e.currentTarget.dataset const item = this.data.list[index] this.setData({ selectId: item.hospitalId, popupShow: true, popupType: 'selectHostipal', popupParams: { ...item, }, }) }, handlePopupOk() { const { popupType } = this.data if (popupType === 'selectHostipal') { this.setData({ popupShow: false, }) wx.ajax({ method: 'POST', url: '?r=wtx/treatment/save-d-hospital', data: { hospitalId: this.data.selectId, }, }).then(() => { this.setData({ popupShow: true, popupType: 'selectHostipalComplete', popupParams: { close: true, }, }) }) } }, handlePopupCancel() { const { popupType } = this.data if (popupType === 'selectHostipalComplete') { wx.navigateBack() } this.setData({ popupShow: false, }) }, handleBindDoctor() { wx.navigateTo({ url: '/patient/pages/selectDoctorList/index', }) }, handleBack() { wx.navigateBack() }, }) export {}