const app = getApp(); Page({ data: { showDetail: false, popupDoctorDetail: {}, Search: "", list: [], pagination: { page: 1, pages: 1, count: 1, }, DoctorId: "", DoctorName: "", }, onLoad() { app.waitLogin(true).then(() => { this.getList(); this.getHostipalDict() this.getDoctorDict() }); }, getDoctorDict() { wx.ajax({ method: "GET", url: "?r=takeda/reg/doctor-dict", data: {}, }).then((res) => { const SpecialtyList: any = []; res.DoctorSpecialtyLabel.forEach((item: any) => { SpecialtyList.push(...item.options); }); this.setData({ DoctorTitleType: res.DoctorTitleType, }); }); }, getHostipalDict() { wx.ajax({ method: "GET", url: "?r=takeda/reg/hospital-dict", data: {}, }).then((res) => { this.setData({ hospitalClassification: res.hospitalClassification, hospitalLevel: res.hospitalLevel, }); }); }, handleSearch() { this.setData({ list: [], }); this.getList(); }, handleReset() { this.setData({ Search: "", }); this.handleSearch(); }, getList(newPage = 1) { const { Search } = this.data; wx.ajax({ method: "GET", url: "?r=takeda/reg/second-doctor-list", data: { Search, page: newPage, }, }).then((res) => { const list = res.page === 1 ? res.list : [...this.data.list, ...res.list]; this.setData({ list, pagination: { page: res.page, pages: res.pages, count: res.count, }, }); }); }, onReachBottom() { const { page, pages } = this.data.pagination; if (pages > page) { this.getList(page + 1); } }, handlePopupClose() { this.setData({ showDetail: false, }); }, handleRadio(e: any) { const { index } = e.currentTarget.dataset; const { list } = this.data; this.setData({ DoctorId: (list as any)[index].DoctorId, DoctorName: (list as any)[index].DoctorName, }); }, handleResolve() { const { DoctorId, DoctorName } = this.data; if (!DoctorId) { wx.showToast({ title: "请选择医生", icon: "none", }); return; } const eventChannel = this.getOpenerEventChannel(); eventChannel.emit("acceptDataFromOpenedPage", { DoctorId, DoctorName }); this.handleBack(); }, handleBack() { wx.navigateBack(); }, }); export {};