"use strict";
|
const common_vendor = require("../../common/vendor.js");
|
const _sfc_main = {
|
__name: "search",
|
setup(__props) {
|
const searchKey = common_vendor.ref("");
|
const showResults = common_vendor.ref(false);
|
const searchHistory = common_vendor.ref([
|
"心内科",
|
"发烧",
|
"骨科",
|
"儿科"
|
]);
|
const hotSearches = [
|
"心内科",
|
"儿科",
|
"发烧",
|
"骨科",
|
"高血压",
|
"糖尿病",
|
"感冒",
|
"头痛"
|
];
|
const suggestions = common_vendor.computed(() => {
|
if (!searchKey.value)
|
return [];
|
return [
|
searchKey.value + "科",
|
"儿童" + searchKey.value,
|
searchKey.value + "专科",
|
searchKey.value + "疾病"
|
];
|
});
|
const resultTabs = [
|
{ value: "department", count: 5 },
|
{ value: "doctor", count: 8 },
|
{ value: "disease", count: 3 }
|
];
|
const currentTab = common_vendor.ref("department");
|
const departmentResults = common_vendor.ref([
|
{
|
id: 1,
|
name: "心内科",
|
icon: "/static/department/cardiology.png",
|
description: "心血管疾病诊治",
|
rating: 4.9,
|
doctorCount: 8,
|
hospitalId: 1,
|
hospitalName: "青岛镜湖医院",
|
hospitalLogo: "/static/hospital/kiang-wu.jpg",
|
distance: 2.5
|
},
|
{
|
id: 2,
|
name: "心内科",
|
icon: "/static/department/cardiology.png",
|
description: "心血管疾病诊治",
|
rating: 4.8,
|
doctorCount: 6,
|
hospitalId: 2,
|
hospitalName: "青岛科大医院",
|
hospitalLogo: "/static/hospital/must.jpg",
|
distance: 5.8
|
}
|
]);
|
const doctorResults = common_vendor.ref([
|
{
|
id: 1,
|
name: "张医生",
|
title: "主任医师",
|
avatar: "/static/doctor/doctor1.jpg",
|
department: "心内科",
|
specialty: "冠心病、心律失常",
|
rating: 4.9,
|
ratingCount: 1280
|
}
|
]);
|
const diseaseResults = common_vendor.ref([
|
{
|
id: 1,
|
name: "冠心病",
|
description: "心脏冠状动脉血管发生动脉粥样硬化病变而引起的心脏病",
|
departments: ["心内科", "心外科"]
|
}
|
]);
|
const clearSearch = () => {
|
searchKey.value = "";
|
showResults.value = false;
|
};
|
const goBack = () => {
|
common_vendor.index.navigateBack();
|
};
|
const clearHistory = () => {
|
common_vendor.index.showModal({
|
title: "提示",
|
content: "确定要清空搜索历史吗?",
|
success: (res) => {
|
if (res.confirm) {
|
searchHistory.value = [];
|
}
|
}
|
});
|
};
|
const deleteHistory = (index) => {
|
searchHistory.value.splice(index, 1);
|
};
|
const useHistory = (keyword) => {
|
searchKey.value = keyword;
|
handleSearch();
|
};
|
const useHotSearch = (keyword) => {
|
searchKey.value = keyword;
|
handleSearch();
|
};
|
const useSuggestion = (keyword) => {
|
searchKey.value = keyword;
|
handleSearch();
|
};
|
const handleSearch = () => {
|
if (!searchKey.value.trim())
|
return;
|
if (!searchHistory.value.includes(searchKey.value)) {
|
searchHistory.value.unshift(searchKey.value);
|
if (searchHistory.value.length > 10) {
|
searchHistory.value.pop();
|
}
|
}
|
showResults.value = true;
|
};
|
const switchTab = (tab) => {
|
currentTab.value = tab;
|
};
|
const navigateToDepartment = (dept) => {
|
common_vendor.index.navigateTo({
|
url: `/pages/department/detail?id=${dept.id}&hospitalId=${dept.hospitalId}`
|
});
|
};
|
const navigateToDoctor = (doctor) => {
|
common_vendor.index.navigateTo({
|
url: `/pages/appointment/doctor?doctorId=${doctor.id}`
|
});
|
};
|
const navigateToDisease = (disease) => {
|
common_vendor.index.navigateTo({
|
url: `/pages/disease/detail?id=${disease.id}`
|
});
|
};
|
return (_ctx, _cache) => {
|
return common_vendor.e({
|
a: _ctx.$t("common.search.placeholder"),
|
b: common_vendor.o(handleSearch),
|
c: searchKey.value,
|
d: common_vendor.o(($event) => searchKey.value = $event.detail.value),
|
e: searchKey.value
|
}, searchKey.value ? {
|
f: common_vendor.o(clearSearch)
|
} : {}, {
|
g: common_vendor.t(_ctx.$t("common.search.cancel")),
|
h: common_vendor.o(goBack),
|
i: !searchKey.value && searchHistory.value.length
|
}, !searchKey.value && searchHistory.value.length ? {
|
j: common_vendor.t(_ctx.$t("common.search.history")),
|
k: common_vendor.t(_ctx.$t("common.search.clear")),
|
l: common_vendor.o(clearHistory),
|
m: common_vendor.f(searchHistory.value, (item, index, i0) => {
|
return {
|
a: common_vendor.t(item),
|
b: common_vendor.o(($event) => deleteHistory(index), index),
|
c: index,
|
d: common_vendor.o(($event) => useHistory(item), index)
|
};
|
})
|
} : {}, {
|
n: !searchKey.value
|
}, !searchKey.value ? {
|
o: common_vendor.t(_ctx.$t("common.search.hot")),
|
p: common_vendor.f(hotSearches, (tag, index, i0) => {
|
return {
|
a: common_vendor.t(tag),
|
b: index,
|
c: common_vendor.o(($event) => useHotSearch(tag), index),
|
d: index < 3 ? 1 : ""
|
};
|
})
|
} : {}, {
|
q: searchKey.value && !showResults.value
|
}, searchKey.value && !showResults.value ? {
|
r: common_vendor.f(suggestions.value, (item, index, i0) => {
|
return {
|
a: common_vendor.t(item),
|
b: index,
|
c: common_vendor.o(($event) => useSuggestion(item), index)
|
};
|
})
|
} : {}, {
|
s: showResults.value
|
}, showResults.value ? common_vendor.e({
|
t: common_vendor.f(resultTabs, (tab, index, i0) => {
|
return {
|
a: common_vendor.t(_ctx.$t(`department.search.tabs.${tab.value}`)),
|
b: common_vendor.t(tab.count),
|
c: index,
|
d: currentTab.value === tab.value ? 1 : "",
|
e: common_vendor.o(($event) => switchTab(tab.value), index)
|
};
|
}),
|
v: currentTab.value === "department"
|
}, currentTab.value === "department" ? {
|
w: common_vendor.f(departmentResults.value, (dept, index, i0) => {
|
return {
|
a: dept.hospitalLogo,
|
b: common_vendor.t(dept.hospitalName),
|
c: dept.icon,
|
d: common_vendor.t(dept.name),
|
e: common_vendor.t(dept.description),
|
f: common_vendor.t(dept.distance),
|
g: common_vendor.t(dept.rating),
|
h: common_vendor.t(dept.doctorCount),
|
i: index,
|
j: common_vendor.o(($event) => navigateToDepartment(dept), index)
|
};
|
})
|
} : {}, {
|
x: currentTab.value === "doctor"
|
}, currentTab.value === "doctor" ? {
|
y: common_vendor.f(doctorResults.value, (doctor, index, i0) => {
|
return {
|
a: doctor.avatar,
|
b: common_vendor.t(doctor.name),
|
c: common_vendor.t(doctor.title),
|
d: common_vendor.t(doctor.department),
|
e: common_vendor.t(doctor.specialty),
|
f: common_vendor.t(doctor.rating),
|
g: common_vendor.t(doctor.ratingCount),
|
h: index,
|
i: common_vendor.o(($event) => navigateToDoctor(doctor), index)
|
};
|
})
|
} : {}, {
|
z: currentTab.value === "disease"
|
}, currentTab.value === "disease" ? {
|
A: common_vendor.f(diseaseResults.value, (disease, index, i0) => {
|
return {
|
a: common_vendor.t(disease.name),
|
b: common_vendor.t(disease.description),
|
c: common_vendor.f(disease.departments, (dept, idx, i1) => {
|
return {
|
a: common_vendor.t(dept),
|
b: idx
|
};
|
}),
|
d: index,
|
e: common_vendor.o(($event) => navigateToDisease(disease), index)
|
};
|
})
|
} : {}) : {}, {
|
B: common_vendor.gei(_ctx, "")
|
});
|
};
|
}
|
};
|
wx.createPage(_sfc_main);
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/department/search.js.map
|