index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="group-page">
  3. <view v-if="groupInfo" class="group-card">
  4. <view class="group-header">
  5. <text class="group-name">{{ groupInfo.name }}</text>
  6. <text class="group-slogan" v-if="groupInfo.slogan">{{ groupInfo.slogan }}</text>
  7. </view>
  8. <view class="section-title">成员列表</view>
  9. <view class="member-list">
  10. <view class="member-item" v-for="(m, idx) in (groupInfo.members || [])" :key="idx">
  11. <text class="member-name">{{ m.name || '未命名' }}</text>
  12. <text class="member-role">{{ m.uid === groupInfo.spokespersonUid ? '🏆 发言人' : '成员' }}</text>
  13. </view>
  14. </view>
  15. <view class="section-title">分工认领</view>
  16. <view v-if="(groupInfo.assignments || []).length === 0" class="empty-text">暂无认领</view>
  17. <view class="assign-list" v-else>
  18. <view class="assign-item" v-for="(a, idx) in groupInfo.assignments" :key="idx">
  19. <text class="assign-type">{{ bookTypeLabel(a.bookType) }}</text>
  20. <text class="assign-role">{{ a.role === 'expert' ? '专家' : '支援' }}</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view v-else class="empty-card">
  25. <text class="empty-title">您尚未入组</text>
  26. <text class="empty-desc">请联系组管理员获取组ID入组</text>
  27. <input class="group-id-input" v-model="groupId" placeholder="输入组ID" type="number" />
  28. <button class="join-btn" @click="handleJoin" :loading="loading" :disabled="loading">入组</button>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { getMyGroup, joinGroup } from '@/utils/api.js'
  34. export default {
  35. data() {
  36. return {
  37. groupInfo: null,
  38. groupId: '',
  39. loading: false
  40. }
  41. },
  42. onShow() {
  43. this.loadGroup()
  44. },
  45. methods: {
  46. loadGroup() {
  47. var self = this
  48. getMyGroup().then(function(resp) {
  49. self.groupInfo = resp.data
  50. }).catch(function() {
  51. self.groupInfo = null
  52. })
  53. },
  54. handleJoin() {
  55. if (!this.groupId) {
  56. uni.showToast({ title: '请输入组ID', icon: 'none' })
  57. return
  58. }
  59. if (this.loading) return
  60. this.loading = true
  61. var self = this
  62. joinGroup(parseInt(this.groupId)).then(function() {
  63. uni.showToast({ title: '入组成功', icon: 'success' })
  64. self.loadGroup()
  65. }).catch(function(err) {
  66. uni.showToast({ title: (err && err.message) || '入组失败', icon: 'none' })
  67. }).finally(function() {
  68. self.loading = false
  69. })
  70. },
  71. bookTypeLabel(type) {
  72. var map = { wealth: '财富账', health: '健康账', growth: '成长账', support: '通用支援' }
  73. return map[type] || type
  74. }
  75. }
  76. }
  77. </script>
  78. <style scoped>
  79. .group-page { min-height: 100vh; background: #F5F5F5; padding: 32rpx; }
  80. .group-card, .empty-card { background: #FFF; border-radius: 16rpx; padding: 40rpx 32rpx; }
  81. .group-header { margin-bottom: 32rpx; }
  82. .group-name { display: block; font-size: 36rpx; font-weight: 700; color: #1E293B; margin-bottom: 8rpx; }
  83. .group-slogan { display: block; font-size: 26rpx; color: #F97316; }
  84. .section-title { font-size: 30rpx; font-weight: 600; color: #1E293B; margin: 24rpx 0 16rpx; border-left: 8rpx solid #F97316; padding-left: 16rpx; }
  85. .member-list { margin-bottom: 24rpx; }
  86. .member-item { display: flex; justify-content: space-between; padding: 16rpx 0; border-bottom: 1rpx solid #F1F5F9; }
  87. .member-name { font-size: 28rpx; color: #1E293B; }
  88. .member-role { font-size: 24rpx; color: #64748B; }
  89. .empty-text { font-size: 26rpx; color: #94A3B8; padding: 16rpx 0; }
  90. .assign-list { margin-bottom: 24rpx; }
  91. .assign-item { display: flex; justify-content: space-between; padding: 16rpx 0; border-bottom: 1rpx solid #F1F5F9; }
  92. .assign-type { font-size: 28rpx; color: #1E293B; font-weight: 500; }
  93. .assign-role { font-size: 24rpx; color: #F97316; }
  94. .empty-title { display: block; font-size: 36rpx; font-weight: 700; color: #1E293B; margin-bottom: 12rpx; text-align: center; }
  95. .empty-desc { display: block; font-size: 26rpx; color: #64748B; margin-bottom: 40rpx; text-align: center; }
  96. .group-id-input { width: 100%; height: 80rpx; border: 2rpx solid #E2E8F0; border-radius: 12rpx; padding: 0 24rpx; font-size: 28rpx; background: #F8FAFC; margin-bottom: 24rpx; }
  97. .join-btn { width: 100%; height: 88rpx; line-height: 88rpx; background: #F97316; color: #FFF; font-size: 30rpx; font-weight: 600; border-radius: 44rpx; border: none; }
  98. .join-btn:active { opacity: 0.85; }
  99. </style>