WXL
11 小时以前 05c363fdd7ab04e3bd9a753e2c5d5bfff04d681c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
"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