武田小程序
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.

440 lines
9.9 KiB

6 months ago
const app = getApp<IAppOption>();
Page({
data: {
6 months ago
fold: false,
show1: false,
6 months ago
show2: false,
show3: false,
show4: false,
show5: false,
showArea: false,
fieldNames: { text: "label", value: "value", children: "children" },
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: "全部",
6 months ago
labelName: "全部",
6 months ago
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: {},
},
6 months ago
onLoad() {
this.getTabBar().setData({
active: 3,
6 months ago
});
6 months ago
},
onShow() {
6 months ago
app.waitLogin().then(() => {
6 months ago
this.getBaseInfo();
this.getList();
this.getHospitalsList();
this.getHostipalDict();
this.getDoctorDict();
this.getArea();
6 months ago
app.getUserInfo(this, (userInfo) => {
this.getTabBar().setData({
userInfo,
});
});
});
6 months ago
},
6 months ago
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",
data: {
page: newPage,
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);
});
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);
}
},
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),
5 months ago
caseStatusName:
caseStatus
.filter((item) => item !== value)
.map((item) => caseStatusList[item])
.join(",") || "全部",
6 months ago
});
} else {
this.setData({
caseStatus: [...caseStatus, value],
5 months ago
caseStatusName: [...caseStatus, value].map((item) => caseStatusList[item]).join(",") || "全部",
6 months ago
});
}
},
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, 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();
}
},
handleDetail(e) {
const { params } = e.currentTarget.dataset;
wx.navigateTo({
6 months ago
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: [],
});
},
handleLabel(e) {
const { params } = e.currentTarget.dataset;
6 months ago
const { labelId, labelList } = this.data;
6 months ago
const newLabelId = labelId.includes(params.value)
? labelId.filter((item) => item !== params.value)
: [...labelId, params.value];
6 months ago
let labelName = "";
labelList.forEach((item) => {
if (newLabelId.includes(item.value)) {
labelName = `${labelName}${labelName ? "," : ""}${item.label}`;
}
});
6 months ago
this.setData({
labelId: newLabelId,
6 months ago
labelName: labelName || "全部",
6 months ago
});
},
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.selectedOptions[0].value,
provinceName: e.detail.selectedOptions[0].label,
cityId: e.detail.selectedOptions[1].value,
cityName: e.detail.selectedOptions[1].label,
countyId: e.detail.selectedOptions[2].value,
countyName: e.detail.selectedOptions[2].label,
showArea: false,
});
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.ajax({
method: "POST",
url: "?r=takeda/chat/read-history",
data: {},
}).then(() => {
this.handleSearch();
6 months ago
});
},
6 months ago
});
export {};