Volunteers.vue 10.5 KB
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 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
<template>
  <div class="page-container">
    <!-- 导航栏 -->
    <van-nav-bar title="义工服务" left-arrow @click-left="$router.back()" class="custom-nav">
      <template #right>
        <van-icon name="plus" size="18" @click="handleAddVolunteer" />
      </template>
    </van-nav-bar>

    <!-- 内容区域 -->
    <div class="content-container">
      <!-- 顶部统计 -->
      <div class="stats-section">
        <div class="stat-card">
          <div class="stat-icon">👥</div>
          <div class="stat-info">
            <div class="stat-number">{{ totalVolunteers }}</div>
            <div class="stat-label">总义工数</div>
          </div>
        </div>
        <div class="stat-card">
          <div class="stat-icon">✅</div>
          <div class="stat-info">
            <div class="stat-number">{{ activeVolunteers }}</div>
            <div class="stat-label">在岗义工</div>
          </div>
        </div>
        <div class="stat-card">
          <div class="stat-icon">📅</div>
          <div class="stat-info">
            <div class="stat-number">{{ todayTasks }}</div>
            <div class="stat-label">今日任务</div>
          </div>
        </div>
      </div>

      <!-- 筛选栏 -->
      <div class="filter-section">
        <van-tabs v-model:active="activeTab" @change="handleTabChange" class="custom-tabs">
          <van-tab title="全部" name="all"></van-tab>
          <van-tab title="在岗" name="active"></van-tab>
          <van-tab title="休息" name="rest"></van-tab>
          <van-tab title="请假" name="leave"></van-tab>
        </van-tabs>
      </div>

      <!-- 义工列表 -->
      <div class="volunteers-list">
        <div
          v-for="volunteer in filteredVolunteers"
          :key="volunteer.id"
          class="volunteer-card"
          @click="handleVolunteerClick(volunteer)"
        >
          <div class="volunteer-avatar">
            <img v-if="volunteer.avatar" :src="volunteer.avatar" :alt="volunteer.name" />
            <div v-else class="avatar-placeholder">
              <span>{{ volunteer.name.charAt(0) }}</span>
            </div>
            <div class="status-badge" :class="getStatusClass(volunteer.status)">
              {{ getStatusText(volunteer.status) }}
            </div>
          </div>

          <div class="volunteer-info">
            <div class="volunteer-header">
              <h4 class="volunteer-name">{{ volunteer.name }}</h4>
              <div class="volunteer-level" :class="getLevelClass(volunteer.level)">
                {{ volunteer.level }}
              </div>
            </div>

            <div class="volunteer-details">
              <p class="volunteer-department">{{ volunteer.department }}</p>
              <p class="volunteer-task">当前任务:{{ volunteer.currentTask || '暂无' }}</p>
              <div class="volunteer-meta">
                <span class="join-date">{{ volunteer.joinDate }}加入</span>
                <span class="service-hours">{{ volunteer.serviceHours }}小时</span>
              </div>
            </div>
          </div>

          <div class="volunteer-actions">
            <van-icon name="arrow" />
          </div>
        </div>
      </div>

      <!-- 空状态 -->
      <van-empty v-if="filteredVolunteers.length === 0" description="暂无义工信息" />
    </div>

    <!-- 浮动按钮 -->
    <van-floating-bubble
      axis="xy"
      icon="plus"
      @click="handleAddVolunteer"
      class="add-button"
    />
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'
import { Toast } from 'vant'

const router = useRouter()
const activeTab = ref('all')

// 统计数据
const totalVolunteers = ref(45)
const activeVolunteers = ref(32)
const todayTasks = ref(18)

// 义工数据
const volunteers = ref([
  {
    id: 1,
    name: '张慧敏',
    department: '客堂组',
    level: '资深义工',
    status: 'active',
    currentTask: '接待来访信众',
    joinDate: '2022-03-15',
    serviceHours: 520,
    avatar: null
  },
  {
    id: 2,
    name: '李明德',
    department: '维护组',
    level: '普通义工',
    status: 'active',
    currentTask: '大殿清洁维护',
    joinDate: '2023-01-20',
    serviceHours: 280,
    avatar: null
  },
  {
    id: 3,
    name: '王慈悲',
    department: '斋堂组',
    level: '组长',
    status: 'active',
    currentTask: '午斋准备工作',
    joinDate: '2021-08-10',
    serviceHours: 750,
    avatar: null
  },
  {
    id: 4,
    name: '陈智慧',
    department: '法务组',
    level: '资深义工',
    status: 'rest',
    currentTask: null,
    joinDate: '2022-06-05',
    serviceHours: 420,
    avatar: null
  },
  {
    id: 5,
    name: '刘精进',
    department: '安保组',
    level: '普通义工',
    status: 'leave',
    currentTask: null,
    joinDate: '2023-04-12',
    serviceHours: 150,
    avatar: null
  },
  {
    id: 6,
    name: '赵般若',
    department: '文宣组',
    level: '资深义工',
    status: 'active',
    currentTask: '活动摄影记录',
    joinDate: '2022-11-30',
    serviceHours: 380,
    avatar: null
  },
  {
    id: 7,
    name: '孙持戒',
    department: '客堂组',
    level: '普通义工',
    status: 'active',
    currentTask: '登记来访信息',
    joinDate: '2023-07-08',
    serviceHours: 95,
    avatar: null
  },
  {
    id: 8,
    name: '周忍辱',
    department: '斋堂组',
    level: '普通义工',
    status: 'rest',
    currentTask: null,
    joinDate: '2023-02-14',
    serviceHours: 220,
    avatar: null
  }
])

// 过滤后的义工列表
const filteredVolunteers = computed(() => {
  if (activeTab.value === 'all') {
    return volunteers.value
  }
  return volunteers.value.filter(volunteer => volunteer.status === activeTab.value)
})

// 获取状态样式类
const getStatusClass = (status) => {
  const classes = {
    active: 'status-active',
    rest: 'status-rest',
    leave: 'status-leave'
  }
  return classes[status] || 'status-rest'
}

// 获取状态文本
const getStatusText = (status) => {
  const texts = {
    active: '在岗',
    rest: '休息',
    leave: '请假'
  }
  return texts[status] || '休息'
}

// 获取等级样式类
const getLevelClass = (level) => {
  if (level === '组长') return 'level-leader'
  if (level === '资深义工') return 'level-senior'
  return 'level-normal'
}

// 处理标签切换
const handleTabChange = (name) => {
  activeTab.value = name
}

// 处理义工点击
const handleVolunteerClick = (volunteer) => {
  router.push(`/volunteers/${volunteer.id}`)
}

// 处理添加义工
const handleAddVolunteer = () => {
  Toast('添加义工功能开发中...')
}
</script>

<style scoped>
.page-container {
  min-height: 100vh;
  background: #fafafa;
}

.custom-nav {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  color: white;
}

.custom-nav :deep(.van-nav-bar__title) {
  color: white;
  font-weight: 600;
}

.custom-nav :deep(.van-icon) {
  color: white;
}

.content-container {
  padding-top: 46px;
}

.stats-section {
  display: flex;
  gap: 12px;
  padding: 16px;
}

.stat-card {
  flex: 1;
  background: white;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  font-size: 24px;
  margin-right: 12px;
}

.stat-info {
  flex: 1;
}

.stat-number {
  font-size: 20px;
  font-weight: 700;
  color: #f59e0b;
  margin-bottom: 2px;
}

.stat-label {
  font-size: 12px;
  color: #666;
}

.filter-section {
  background: white;
  border-bottom: 1px solid #eee;
}

.custom-tabs :deep(.van-tab) {
  font-weight: 500;
}

.custom-tabs :deep(.van-tab--active) {
  color: #f59e0b;
}

.custom-tabs :deep(.van-tabs__line) {
  background: #f59e0b;
}

.volunteers-list {
  padding: 16px;
}

.volunteer-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
}

.volunteer-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.volunteer-card:active {
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
}

.volunteer-avatar {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  margin-right: 16px;
  flex-shrink: 0;
}

.volunteer-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #fbbf24, #f97316);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  font-weight: 600;
}

.status-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 500;
  border: 2px solid white;
}

.status-active {
  background: #10b981;
  color: white;
}

.status-rest {
  background: #6b7280;
  color: white;
}

.status-leave {
  background: #ef4444;
  color: white;
}

.volunteer-info {
  flex: 1;
}

.volunteer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.volunteer-name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.volunteer-level {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.level-leader {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  color: white;
}

.level-senior {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}

.level-normal {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #d1d5db;
}

.volunteer-details {
  space-y: 4px;
}

.volunteer-department {
  font-size: 16px;
  color: #666;
  margin: 0 0 4px 0;
}

.volunteer-task {
  font-size: 14px;
  color: #999;
  margin: 0 0 8px 0;
}

.volunteer-meta {
  display: flex;
  gap: 16px;
}

.join-date,
.service-hours {
  font-size: 12px;
  color: #999;
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 4px;
}

.volunteer-actions {
  margin-left: 12px;
  color: #ccc;
}

.add-button {
  background: linear-gradient(135deg, #fbbf24, #f97316) !important;
  transition: all 0.3s ease;
  animation: float 3s ease-in-out infinite;
}

.add-button:hover {
  transform: translateY(-3px) scale(1.1);
  box-shadow: 0 8px 25px rgba(251, 191, 36, 0.6);
}

.add-button:active {
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.4);
}

.add-button :deep(.van-floating-bubble__icon) {
  color: white;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}
</style>