WXL
5 天以前 871522ed7e06fd9c62a87c178d7f5c88d7853a20
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<template>
  <view class="notification">
    <!-- 通知设置 -->
    <view class="section-card">
      <view class="section-title">通知设置</view>
      <view class="setting-list">
        <view class="setting-item">
          <view class="setting-info">
            <text class="name">系统通知</text>
            <text class="desc">接收系统更新、维护等通知</text>
          </view>
          <switch 
            :checked="settings.system"
            @change="e => toggleSetting('system', e.detail.value)"
            color="#0f95b0"
          />
        </view>
        <view class="setting-item">
          <view class="setting-info">
            <text class="name">预约提醒</text>
            <text class="desc">接收挂号、疫苗等预约提醒</text>
          </view>
          <switch 
            :checked="settings.appointment"
            @change="e => toggleSetting('appointment', e.detail.value)"
            color="#0f95b0"
          />
        </view>
        <view class="setting-item">
          <view class="setting-info">
            <text class="name">就医提醒</text>
            <text class="desc">接收就医、取药等提醒</text>
          </view>
          <switch 
            :checked="settings.medical"
            @change="e => toggleSetting('medical', e.detail.value)"
            color="#0f95b0"
          />
        </view>
        <view class="setting-item">
          <view class="setting-info">
            <text class="name">缴费提醒</text>
            <text class="desc">接收待缴费、退款等提醒</text>
          </view>
          <switch 
            :checked="settings.payment"
            @change="e => toggleSetting('payment', e.detail.value)"
            color="#0f95b0"
          />
        </view>
      </view>
    </view>
    
    <!-- 消息列表 -->
    <view class="section-card">
      <view class="section-header">
        <text class="title">最近消息</text>
        <text class="clear-btn" @tap="clearMessages">清空消息</text>
      </view>
      <view class="message-list">
        <view 
          class="message-item"
          v-for="(message, index) in messages"
          :key="index"
          :class="{ unread: !message.read }"
          @tap="viewMessage(message)"
        >
          <view class="message-icon" :class="message.type">
            <text class="iconfont" :class="getIconClass(message.type)"></text>
          </view>
          <view class="message-content">
            <view class="message-header">
              <text class="title">{{ message.title }}</text>
              <text class="time">{{ message.time }}</text>
            </view>
            <text class="desc">{{ message.content }}</text>
          </view>
          <text class="unread-dot" v-if="!message.read"></text>
        </view>
      </view>
    </view>
    
    <!-- 通知方式设置 -->
    <view class="section-card">
      <view class="section-title">通知方式</view>
      <view class="notify-list">
        <view class="notify-item">
          <view class="notify-info">
            <text class="name">应用内通知</text>
            <text class="desc">在应用内接收消息提醒</text>
          </view>
          <switch 
            :checked="notifyMethods.app"
            @change="e => toggleNotifyMethod('app', e.detail.value)"
            color="#0f95b0"
          />
        </view>
        <view class="notify-item">
          <view class="notify-info">
            <text class="name">短信通知</text>
            <text class="desc">通过短信接收重要提醒</text>
          </view>
          <switch 
            :checked="notifyMethods.sms"
            @change="e => toggleNotifyMethod('sms', e.detail.value)"
            color="#0f95b0"
          />
        </view>
        <view class="notify-item">
          <view class="notify-info">
            <text class="name">微信服务通知</text>
            <text class="desc">通过微信接收服务通知</text>
          </view>
          <switch 
            :checked="notifyMethods.wechat"
            @change="e => toggleNotifyMethod('wechat', e.detail.value)"
            color="#0f95b0"
          />
        </view>
      </view>
    </view>
  </view>
</template>
 
<script setup>
import { ref } from 'vue'
 
// 通知设置
const settings = ref({
  system: true,
  appointment: true,
  medical: true,
  payment: true
})
 
// 通知方式
const notifyMethods = ref({
  app: true,
  sms: true,
  wechat: true
})
 
// 消息列表
const messages = ref([
  {
    id: 1,
    type: 'appointment',
    title: '预约提醒',
    content: '您预约的明天上午9:30心内科张医生的门诊即将开始',
    time: '10分钟前',
    read: false
  },
  {
    id: 2,
    type: 'payment',
    title: '缴费提醒',
    content: '您有一笔¥360.00的待缴费订单,请及时处理',
    time: '1小时前',
    read: false
  },
  {
    id: 3,
    type: 'system',
    title: '系统通知',
    content: '系统将于今晚23:00-次日凌晨2:00进行维护升级',
    time: '2小时前',
    read: true
  },
  {
    id: 4,
    type: 'medical',
    title: '取药提醒',
    content: '您的处方药已准备就绪,请到3号窗口取药',
    time: '昨天',
    read: true
  }
])
 
// 切换通知设置
const toggleSetting = (key, value) => {
  settings.value[key] = value
  uni.showToast({
    title: value ? '已开启' : '已关闭',
    icon: 'success'
  })
}
 
// 切换通知方式
const toggleNotifyMethod = (key, value) => {
  notifyMethods.value[key] = value
  uni.showToast({
    title: value ? '已开启' : '已关闭',
    icon: 'success'
  })
}
 
// 获取图标类名
const getIconClass = (type) => {
  const icons = {
    system: 'icon-system',
    appointment: 'icon-calendar',
    medical: 'icon-medical',
    payment: 'icon-wallet'
  }
  return icons[type]
}
 
// 查看消息
const viewMessage = (message) => {
  // 标记为已读
  message.read = true
  // 这里可以跳转到消息详情页
  console.log('查看消息:', message)
}
 
// 清空消息
const clearMessages = () => {
  uni.showModal({
    title: '提示',
    content: '确定要清空所有消息吗?',
    success: (res) => {
      if (res.confirm) {
        messages.value = []
        uni.showToast({
          title: '已清空',
          icon: 'success'
        })
      }
    }
  })
}
</script>
 
<style lang="scss">
.notification {
  min-height: 100vh;
  background: $bg-color;
  padding: 20rpx;
  
  .section-card {
    background: #fff;
    border-radius: $radius-lg;
    padding: 30rpx;
    margin-bottom: 20rpx;
    
    .section-title {
      font-size: 32rpx;
      color: $text-primary;
      font-weight: bold;
      margin-bottom: 20rpx;
    }
    
    .section-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20rpx;
      
      .title {
        font-size: 32rpx;
        color: $text-primary;
        font-weight: bold;
      }
      
      .clear-btn {
        font-size: 28rpx;
        color: $text-secondary;
        
        &:active {
          opacity: 0.8;
        }
      }
    }
    
    .setting-list,
    .notify-list {
      .setting-item,
      .notify-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20rpx 0;
        border-bottom: 1rpx solid #eee;
        
        &:last-child {
          border-bottom: none;
        }
        
        .setting-info,
        .notify-info {
          flex: 1;
          margin-right: 20rpx;
          
          .name {
            font-size: 30rpx;
            color: $text-primary;
            margin-bottom: 4rpx;
            display: block;
          }
          
          .desc {
            font-size: 24rpx;
            color: $text-secondary;
          }
        }
      }
    }
    
    .message-list {
      .message-item {
        display: flex;
        align-items: flex-start;
        padding: 20rpx 0;
        border-bottom: 1rpx solid #eee;
        position: relative;
        
        &:last-child {
          border-bottom: none;
        }
        
        .message-icon {
          width: 80rpx;
          height: 80rpx;
          border-radius: $radius-lg;
          margin-right: 20rpx;
          display: flex;
          align-items: center;
          justify-content: center;
          flex-shrink: 0;
          
          .iconfont {
            font-size: 40rpx;
            color: #fff;
          }
          
          &.system {
            background: linear-gradient(135deg, #36D1DC, #5B86E5);
          }
          
          &.appointment {
            background: linear-gradient(135deg, #FF9A9E, #FAD0C4);
          }
          
          &.medical {
            background: linear-gradient(135deg, #A8EDEA, #FED6E3);
          }
          
          &.payment {
            background: linear-gradient(135deg, #D4FC79, #96E6A1);
          }
        }
        
        .message-content {
          flex: 1;
          
          .message-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8rpx;
            
            .title {
              font-size: 30rpx;
              color: $text-primary;
              font-weight: bold;
            }
            
            .time {
              font-size: 24rpx;
              color: $text-secondary;
            }
          }
          
          .desc {
            font-size: 26rpx;
            color: $text-regular;
            line-height: 1.5;
          }
        }
        
        .unread-dot {
          position: absolute;
          right: 0;
          top: 20rpx;
          width: 16rpx;
          height: 16rpx;
          background: $danger;
          border-radius: 50%;
        }
        
        &.unread {
          .message-header .title {
            color: $primary-color;
          }
        }
        
        &:active {
          opacity: 0.8;
        }
      }
    }
  }
}
</style>