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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
"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