index.vue 5.5 KB

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