import dayjs from "dayjs"; const app = getApp(); Page({ data: { fold: true, show1: false, show2: false, show3: false, show4: false, show5: false, showArea: false, fieldNames: { text: "label" }, area: [], caseStatusList: {}, roomTypeList: {}, pagination: { page: 1, pages: 1, count: 1, }, list: [], hostilatSearch: "", hostipalList: [], hospitalClassification: {}, hospitalLevel: {}, hostipalPagination: { page: 1, pages: 1, count: 1, }, deptList: [] as any, labelList: [] as any, caseStatusName: "全部", hospitalName: "全部", deptName: "全部", labelName: "全部", provinceName: "", cityName: "", countyName: "", typeName: "全部", search: "", caseStatus: [] as any, hospitalId: [] as any, createRoomTimeBegin: "", createRoomTimeEnd: "", createCaseTimeBegin: "", createCaseTimeEnd: "", deptId: [] as any, labelId: [] as any, provinceId: "", cityId: "", countyId: "", type: "", readStatus: "", userInfo: {}, noReadCount: 0, }, onLoad() { this.getTabBar().setData({ active: 3, }); }, onShow() { app.waitLogin().then(() => { this.getBaseInfo(); this.getList(); this.getHospitalsList(); this.getHostipalDict(); this.getDoctorDict(); this.getArea(); app.getUserInfo(this, (userInfo) => { this.getTabBar().setData({ userInfo, }); }); this.getNotice(); }); }, getNotice() { wx.ajax({ method: "GET", url: "?r=takeda/doctor/todo", data: {}, }).then((res) => { this.getTabBar().setData({ notice: res.notReadChatRoomCount > 0, }); }); }, getBaseInfo() { wx.ajax({ method: "GET", url: "?r=takeda/chat/get-base-info", data: {}, }).then((res) => { this.setData({ caseStatusList: res.caseStatusList, roomTypeList: res.roomTypeList, }); }); }, getArea() { wx.ajax({ method: "GET", url: "/js/area.json", isJSON: true, }).then((res) => { this.setData({ area: res, }); }); }, handleNav(e) { const { nav } = e.currentTarget.dataset; this.setData({ nav, isOpen: nav === "1" ? "1" : "", isHighQuality: nav === "2" ? "1" : "", }); this.handleSearch(); }, getList(newPage = 1) { wx.ajax({ method: "POST", url: `?r=takeda/chat/get-list&page=${newPage}`, data: { search: this.data.search, caseStatus: this.data.caseStatus, createRoomTimeBegin: this.data.createRoomTimeBegin, createRoomTimeEnd: this.data.createRoomTimeEnd, createCaseTimeBegin: this.data.createCaseTimeBegin, createCaseTimeEnd: this.data.createCaseTimeEnd, deptId: this.data.deptId, labelId: this.data.labelId, type: this.data.type, provinceId: this.data.provinceId, cityId: this.data.cityId, countyId: this.data.countyId, hospitalId: this.data.hospitalId, readStatus: this.data.readStatus, }, }).then((res) => { res.list.forEach((item) => { item.roomDoctors = item.roomDoctors.slice(0, 4); item.createTime = dayjs(item.createTime).format("YYYY-MM-DD HH:mm"); }); const list = res.page === 1 ? res.list : [...this.data.list, ...res.list]; this.setData({ list, noReadCount: res.noReadCount, pagination: { page: res.page, pages: res.pages, count: res.count, }, }); }); }, onReachBottom() { const { page, pages } = this.data.pagination; if (pages > page) { this.getList(page + 1); } }, handleSearch() { this.getList(); }, handleCaseShow() { this.setData({ show1: true, }); }, handleCase(e) { const { value } = e.currentTarget.dataset; const { caseStatus, caseStatusList } = this.data; if (!value) { this.setData({ caseStatus: [], caseStatusName: "全部", }); return; } if (caseStatus.includes(value)) { this.setData({ caseStatus: caseStatus.filter((item) => item !== value), caseStatusName: caseStatus .filter((item) => item !== value) .map((item) => caseStatusList[item]) .join(",") || "全部", }); } else { this.setData({ caseStatus: [...caseStatus, value], caseStatusName: [...caseStatus, value].map((item) => caseStatusList[item]).join(",") || "全部", }); } }, handleCaseSubmit() { this.setData({ show1: false, }); this.handleSearch(); }, handleTypeShow() { this.setData({ show5: true, }); }, handleType(e) { const { value } = e.currentTarget.dataset; const { type, roomTypeList } = this.data; if (!value) { this.setData({ type: "", typeName: "全部", }); return; } if (value === type) { this.setData({ type: "", typeName: "全部", }); } else { this.setData({ type: value, typeName: roomTypeList[value], }); } }, handleTypeSubmit() { this.setData({ show5: false, }); this.handleSearch(); }, onClose() { const { show2, show3, showArea } = this.data; this.setData({ show1: false, show2: false, show3: false, show4: false, show5: false, showArea: false, }); if (show2) { this.setData({ hospitalId: "", hospitalName: "全部", }); this.handleSearch(); } if (showArea) { this.setData({ provinceId: "", cityId: "", countyId: "", provinceName: "", cityName: "", countyName: "", }); this.handleSearch(); } if (show3) { this.setData({ deptId: [], labelId: [], deptName: "全部", labelName: "全部", }); this.handleSearch(); } }, handleDetail(e) { const { params } = e.currentTarget.dataset; wx.navigateTo({ url: `/module1/pages/casesDetail/index?id=${params.caseId}`, }); }, // 医院选择弹窗 handleHostipalShow() { this.setData({ show2: true, }); }, getHostipalDict() { wx.ajax({ method: "GET", url: "?r=takeda/reg/hospital-dict", data: {}, }).then((res) => { this.setData({ hospitalClassification: res.hospitalClassification, hospitalLevel: res.hospitalLevel, }); }); }, handleSearchHostipal() { this.getHospitalsList(); }, getHospitalsList(newPage = 1) { wx.ajax({ method: "GET", url: "?r=takeda/reg/hospitals", data: { page: newPage, Search: this.data.hostilatSearch, }, }).then((res) => { const hostipalList = res.page === 1 ? res.list : [...this.data.hostipalList, ...res.list]; this.setData({ hostipalList, hostipalPagination: { page: res.page, pages: res.pages, count: res.count, }, }); }); }, handleHostipalBottom(e) { const hostipalPagination = this.data.hostipalPagination; if (e.detail.direction === "botttom" && hostipalPagination.page < hostipalPagination.pages) { this.getHospitalsList(Number(hostipalPagination.page) + 1); } }, handleHostipal(e) { const { params } = e.currentTarget.dataset; this.setData({ show2: false, hospitalId: this.data.hospitalId.includes(params.HospitalId) ? [] : [params.HospitalId], hospitalName: this.data.hospitalId.includes(params.HospitalId) ? "全部" : params.Name, }); this.handleSearch(); }, getDoctorDict() { wx.ajax({ method: "GET", url: "?r=takeda/reg/doctor-dict", data: {}, }).then((res) => { this.setData({ deptList: res.DoctorSpecialtyLabel, }); }); }, handleTagShow() { this.setData({ show3: true, }); }, handleDept(e) { const { params } = e.currentTarget.dataset; const deptId = this.data.deptId; const newDeptId: any = deptId.includes(params.value) ? deptId.filter((item) => item !== params.value) : [...deptId, params.value]; const newDeptName = this.data.deptList .filter((item) => newDeptId.includes(item.value)) .map((item) => item.label) .join(","); const labelList = this.data.deptList .filter((item) => newDeptId.includes(item.value)) .reduce((pre, cur) => { return [...pre, ...cur.options]; }, []); this.setData({ deptId: newDeptId, deptName: newDeptName || "全部", labelList, labelId: [], labelName: "全部", }); }, handleLabel(e) { const { params } = e.currentTarget.dataset; const { labelId, labelList } = this.data; const newLabelId = labelId.includes(params.value) ? labelId.filter((item) => item !== params.value) : [...labelId, params.value]; let labelName = ""; labelList.forEach((item) => { if (newLabelId.includes(item.value)) { labelName = `${labelName}${labelName ? "," : ""}${item.label}`; } }); this.setData({ labelId: newLabelId, labelName: labelName || "全部", }); }, handleTagSubmit() { this.setData({ show3: false, }); this.handleSearch(); }, handleRead(e) { const { value } = e.currentTarget.dataset; this.setData({ readStatus: value, }); this.handleSearch(); }, handleArea() { this.setData({ showArea: true, }); }, onFinish(e: any) { this.setData({ provinceId: e.detail.code[0], provinceName: e.detail.value[0], cityId: e.detail.code[1], cityName: e.detail.value[1], countyId: e.detail.code[2], countyName: e.detail.value[2], showArea: false, }); this.handleSearch(); }, handleCancel(e) { const { key } = e.currentTarget.dataset; this.setData({ [key]: "", }); this.handleSearch() }, handleFold() { this.setData({ fold: !this.data.fold, }); }, handleCatch() { return false; }, handleRoom(e) { const { params } = e.currentTarget.dataset; wx.navigateTo({ url: `/module1/pages/chatRoom/index?id=${params.roomId}`, }); }, handleReadAll() { wx.showModal({ title: "确认全部标为已读", confirmColor: "#00B4C5", cancelColor: "#141515", success: (res) => { if (res.confirm) { wx.ajax({ method: "POST", url: "?r=takeda/chat/read-history", data: {}, }).then(() => { this.handleSearch(); this.getNotice(); }); } }, }); }, handleNoRead() { wx.showToast({ icon: "none", title: "暂无未读消息", }); }, }); export {};