index.vue 6.1 KB

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