WXL
3 天以前 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7
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
<template>
  <view class="appointment-container">
    <!-- 顶部搜索栏 -->
    <view class="search-bar">
      <view class="search-box">
        <text class="iconfont icon-search"></text>
        <input type="text" :placeholder="$t('appointment.search.placeholder')" v-model="searchKey" />
      </view>
    </view>
    
    <!-- 医院列表 -->
    <view class="hospital-list">
      <view 
        class="hospital-item card"
        v-for="(hospital, index) in hospitals"
        :key="index"
      >
        <image :src="hospital.image" mode="aspectFill" class="hospital-image" />
        <view class="info">
          <text class="name">{{ hospital.name }}</text>
          <text class="address">{{ hospital.address }}</text>
          <view class="tags">
            <text v-for="(tag, idx) in hospital.tags" :key="idx">{{ tag }}</text>
          </view>
          <view class="footer">
            <view class="rating">
              <text class="score">{{ hospital.rating }}</text>
              <text class="label">综合评分</text>
            </view>
            <view class="distance">
              <text class="value">{{ hospital.distance }}km</text>
              <text class="label">距离</text>
            </view>
            <button 
              class="book-btn primary-btn"
              @tap.stop="selectHospital(hospital)"
            >
              立即预约
            </button>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>
 
<script setup>
import { ref } from 'vue'
 
const searchKey = ref('')
 
// 医院列表数据
const hospitals = ref([
  {
    id: 1,
    name: '青岛镜湖医院',
    address: '青岛连胜马路33号',
    image: '/static/hospital/kiang-wu.png',
    tags: ['综合医院', '24小时急诊', '特需门诊'],
    rating: 4.8,
    distance: 2.5
  },
  {
    id: 2,
    name: '青岛科大医院',
    address: '青岛氹仔大学大马路',
    image: '/static/hospital/must.png',
    tags: ['大学医院', '专科门诊', '中医科'],
    rating: 4.7,
    distance: 5.8
  }
])
 
// 选择医院
const selectHospital = (hospital) => {
  // 保存当前选中的医院ID到全局状态
  getApp().globalData.currentHospitalId = hospital.id
  
  uni.navigateTo({
    url: `/pages/department/index?hospitalId=${hospital.id}`,
    fail: (err) => {
      console.error('导航失败:', err)
      // 如果导航失败,尝试使用 redirectTo
      uni.redirectTo({
        url: `/pages/department/index?hospitalId=${hospital.id}`,
        fail: (err2) => {
          console.error('重定向失败:', err2)
        }
      })
    }
  })
}
</script>
 
<style lang="scss">
.appointment-container {
  min-height: 100vh;
  background: $bg-color;
  
  .search-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 20rpx 30rpx;
    background: #fff;
    box-shadow: $shadow-sm;
  }
  
  .hospital-list {
    padding: 20rpx;
    
    .hospital-item {
      margin-bottom: 20rpx;
      
      .hospital-image {
        width: 100%;
        height: 300rpx;
        border-radius: $radius-md;
        margin-bottom: 20rpx;
      }
      
      .info {
        .name {
          font-size: 34rpx;
          color: $text-primary;
          font-weight: bold;
          margin-bottom: 10rpx;
          display: block;
        }
        
        .address {
          font-size: 26rpx;
          color: $text-regular;
          margin-bottom: 16rpx;
          display: block;
        }
        
        .tags {
          margin-bottom: 20rpx;
          
          text {
            display: inline-block;
            font-size: 22rpx;
            color: $primary-color;
            background: $primary-light;
            padding: 4rpx 12rpx;
            border-radius: $radius-sm;
            margin-right: 10rpx;
            margin-bottom: 10rpx;
          }
        }
        
        .footer {
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding-top: 20rpx;
          border-top: 1rpx solid #eee;
          
          .rating, .distance {
            display: flex;
            flex-direction: column;
            align-items: center;
            
            .score, .value {
              font-size: 32rpx;
              color: $primary-color;
              font-weight: bold;
              margin-bottom: 4rpx;
            }
            
            .label {
              font-size: 22rpx;
              color: $text-secondary;
            }
          }
          
          .book-btn {
            width: 160rpx;
            height: 60rpx;
            line-height: 60rpx;
            font-size: 26rpx;
            &:active {
              opacity: 0.8;
              transform: scale(0.95);
            }
          }
        }
      }
    }
  }
}
</style>