"use strict"; const common_vendor = require("../../common/vendor.js"); const _sfc_main = { __name: "index", setup(__props) { const keyword = common_vendor.ref(""); const searchHistory = common_vendor.ref([ "心内科", "张医生", "感冒发烧", "镜湖医院" ]); const hotSearches = common_vendor.ref([ { keyword: "新冠疫苗", count: 12580 }, { keyword: "心内科", count: 8654 }, { keyword: "儿科", count: 6532 }, { keyword: "镜湖医院", count: 4521 }, { keyword: "发烧咳嗽", count: 3654 } ]); const suggests = common_vendor.ref([]); const tabs = common_vendor.ref([ { name: "医院", count: 0 }, { name: "科室", count: 0 }, { name: "医生", count: 0 }, { name: "疾病", count: 0 } ]); const currentTab = common_vendor.ref(0); const hospitals = common_vendor.ref([]); const departments = common_vendor.ref([]); const doctors = common_vendor.ref([]); const diseases = common_vendor.ref([]); const onSearch = (e) => { const value = e.detail.value.trim(); if (!value) { suggests.value = []; return; } suggests.value = [ { type: "hospital", name: "青岛镜湖医院", desc: "三级甲等综合医院" }, { type: "department", name: "心内科", desc: "心血管疾病诊治" }, { type: "doctor", name: "张医生", desc: "主任医师 心内科" } ]; }; const onConfirm = () => { if (!keyword.value) return; suggests.value = []; if (!searchHistory.value.includes(keyword.value)) { searchHistory.value.unshift(keyword.value); if (searchHistory.value.length > 10) { searchHistory.value.pop(); } } loadSearchResult(); }; const loadSearchResult = () => { hospitals.value = [ { id: 1, name: "青岛镜湖医院", type: "三级甲等综合医院", image: "/static/hospital/kiang-wu.jpg", tags: ["综合医院", "24小时急诊"] } ]; departments.value = [ { id: 1, name: "心内科", desc: "心血管疾病诊治", icon: "/static/department/cardiology.png" } ]; doctors.value = [ { id: 1, name: "张医生", title: "主任医师", avatar: "/static/doctor/avatar1.jpg", hospital: "青岛镜湖医院", specialty: "冠心病、高血压、心律失常" } ]; diseases.value = [ { id: 1, name: "冠心病", department: "心内科" } ]; tabs.value[0].count = hospitals.value.length; tabs.value[1].count = departments.value.length; tabs.value[2].count = doctors.value.length; tabs.value[3].count = diseases.value.length; }; const switchTab = (index) => { currentTab.value = index; }; const loadMore = () => { }; const useHistory = (keyword2) => { keyword2.value = keyword2; onConfirm(); }; const deleteHistory = (index) => { searchHistory.value.splice(index, 1); }; const clearHistory = () => { common_vendor.index.showModal({ title: "提示", content: "确定要清空搜索历史吗?", success: (res) => { if (res.confirm) { searchHistory.value = []; } } }); }; const useHot = (item) => { keyword.value = item.keyword; onConfirm(); }; const selectSuggest = (item) => { keyword.value = item.name; onConfirm(); }; const getTypeIcon = (type) => { const icons = { hospital: "icon-hospital", department: "icon-department", doctor: "icon-doctor", disease: "icon-disease" }; return icons[type]; }; const clearKeyword = () => { keyword.value = ""; suggests.value = []; }; const goBack = () => { common_vendor.index.navigateBack(); }; const viewHospital = (hospital) => { common_vendor.index.navigateTo({ url: `/pages/hospital/detail?id=${hospital.id}` }); }; const viewDepartment = (department) => { common_vendor.index.navigateTo({ url: `/pages/department/detail?id=${department.id}` }); }; const viewDoctor = (doctor) => { common_vendor.index.navigateTo({ url: `/pages/doctor/detail?id=${doctor.id}` }); }; const viewDisease = (disease) => { common_vendor.index.navigateTo({ url: `/pages/disease/detail?id=${disease.id}` }); }; return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.o([($event) => keyword.value = $event.detail.value, onSearch]), b: common_vendor.o(onConfirm), c: keyword.value, d: keyword.value }, keyword.value ? { e: common_vendor.o(clearKeyword) } : {}, { f: common_vendor.o(goBack), g: !keyword.value && searchHistory.value.length }, !keyword.value && searchHistory.value.length ? { h: common_vendor.o(clearHistory), i: 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) }; }) } : {}, { j: !keyword.value }, !keyword.value ? { k: common_vendor.f(hotSearches.value, (item, index, i0) => { return { a: common_vendor.t(index + 1), b: index < 3 ? 1 : "", c: common_vendor.t(item.keyword), d: common_vendor.t(item.count), e: index, f: common_vendor.o(($event) => useHot(item), index) }; }) } : {}, { l: keyword.value && suggests.value.length }, keyword.value && suggests.value.length ? { m: common_vendor.f(suggests.value, (item, index, i0) => { return { a: common_vendor.n(getTypeIcon(item.type)), b: common_vendor.t(item.name), c: common_vendor.t(item.desc), d: index, e: common_vendor.o(($event) => selectSuggest(item), index) }; }) } : {}, { n: keyword.value && !suggests.value.length }, keyword.value && !suggests.value.length ? common_vendor.e({ o: common_vendor.f(tabs.value, (tab, index, i0) => { return common_vendor.e({ a: common_vendor.t(tab.name), b: tab.count }, tab.count ? { c: common_vendor.t(tab.count) } : {}, { d: index, e: currentTab.value === index ? 1 : "", f: common_vendor.o(($event) => switchTab(index), index) }); }), p: currentTab.value === 0 }, currentTab.value === 0 ? { q: common_vendor.f(hospitals.value, (item, index, i0) => { return { a: item.image, b: common_vendor.t(item.name), c: common_vendor.t(item.type), d: common_vendor.f(item.tags, (tag, idx, i1) => { return { a: common_vendor.t(tag), b: idx }; }), e: index, f: common_vendor.o(($event) => viewHospital(item), index) }; }), r: common_vendor.o(loadMore) } : {}, { s: currentTab.value === 1 }, currentTab.value === 1 ? { t: common_vendor.f(departments.value, (item, index, i0) => { return { a: item.icon, b: common_vendor.t(item.name), c: common_vendor.t(item.desc), d: index, e: common_vendor.o(($event) => viewDepartment(item), index) }; }), v: common_vendor.o(loadMore) } : {}, { w: currentTab.value === 2 }, currentTab.value === 2 ? { x: common_vendor.f(doctors.value, (item, index, i0) => { return { a: item.avatar, b: common_vendor.t(item.name), c: common_vendor.t(item.title), d: common_vendor.t(item.hospital), e: common_vendor.t(item.specialty), f: index, g: common_vendor.o(($event) => viewDoctor(item), index) }; }), y: common_vendor.o(loadMore) } : {}, { z: currentTab.value === 3 }, currentTab.value === 3 ? { A: common_vendor.f(diseases.value, (item, index, i0) => { return { a: common_vendor.t(item.name), b: common_vendor.t(item.department), c: index, d: common_vendor.o(($event) => viewDisease(item), index) }; }), B: common_vendor.o(loadMore) } : {}) : {}, { C: common_vendor.gei(_ctx, "") }); }; } }; wx.createPage(_sfc_main); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/search/index.js.map