瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
5.3 KiB

  1. <template>
  2. <view class="group-item" @click="goToDetail">
  3. <view class="group-header">
  4. <view class="group-avatar">
  5. <image :src="item.image || '/static/image/logo.jpg'" mode="aspectFill"></image>
  6. </view>
  7. <view class="group-info">
  8. <view class="group-name">{{ item.title || '群组名称' }}</view>
  9. <view class="group-desc">{{ item.titleText || '群组描述' }}</view>
  10. <view class="group-stats">
  11. <text class="member-count">{{ item.num || 0 }}</text>
  12. <text v-if="item.classId_dictText" class="separator">·</text>
  13. <text v-if="item.classId_dictText" class="location">{{ item.classId_dictText }}</text>
  14. </view>
  15. </view>
  16. <view class="group-status">
  17. <!-- 如果是自己发布的群组显示编辑和删除按钮 -->
  18. <view v-if="isOwner" class="admin-actions" @click.stop="">
  19. <view class="action-btn edit-btn" @click="editGroup">
  20. <uv-icon name="edit-pen" size="40rpx" color="#5baaff"></uv-icon>
  21. </view>
  22. <view class="action-btn delete-btn" @click="deleteGroup">
  23. <uv-icon name="trash" size="40rpx" color="#ff4757"></uv-icon>
  24. </view>
  25. </view>
  26. <!-- 否则显示进入按钮 -->
  27. <view v-else class="join-btn">
  28. <uv-icon name="arrow-right" size="24rpx" color="#5baaff"></uv-icon>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import { mapState } from 'vuex'
  36. export default {
  37. props: {
  38. item: {
  39. type: Object,
  40. default: () => ({})
  41. },
  42. edit : {
  43. default : false
  44. }
  45. },
  46. computed: {
  47. ...mapState(['userInfo']),
  48. // 判断是否为群主
  49. isOwner() {
  50. return this.userInfo && this.item && this.userInfo.id === this.item.userId && this.edit
  51. }
  52. },
  53. methods: {
  54. // 跳转到群组详情
  55. goToDetail() {
  56. this.$utils.navigateTo(`/pages_order/group/groupDetail?id=${this.item.id}`)
  57. },
  58. // 编辑群组
  59. editGroup() {
  60. this.$utils.navigateTo(`/pages_order/group/createGroup?id=${this.item.id}`)
  61. },
  62. // 删除群组
  63. deleteGroup() {
  64. uni.showModal({
  65. title: '确认删除',
  66. content: '确定要删除这个群组吗?删除后无法恢复!',
  67. confirmText: '删除',
  68. confirmColor: '#ff4757',
  69. success: (res) => {
  70. if (res.confirm) {
  71. this.confirmDeleteGroup()
  72. }
  73. }
  74. })
  75. },
  76. // 确认删除群组
  77. confirmDeleteGroup() {
  78. uni.showLoading({
  79. title: '删除中...'
  80. })
  81. this.$api('deleteGroup', { id: this.item.id }, res => {
  82. uni.hideLoading()
  83. if (res.code === 200) {
  84. uni.showToast({
  85. title: '删除成功',
  86. icon: 'success'
  87. })
  88. // 通知父组件刷新列表
  89. this.$emit('refresh')
  90. } else {
  91. uni.showToast({
  92. title: res.message || '删除失败',
  93. icon: 'none'
  94. })
  95. }
  96. })
  97. }
  98. }
  99. }
  100. </script>
  101. <style scoped lang="scss">
  102. .group-item {
  103. margin: 20rpx;
  104. background-color: #fff;
  105. padding: 30rpx;
  106. border-radius: 20rpx;
  107. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
  108. transition: all 0.3s ease;
  109. &:active {
  110. transform: scale(0.98);
  111. box-shadow: 0 1rpx 8rpx rgba(0, 0, 0, 0.15);
  112. }
  113. .group-header {
  114. display: flex;
  115. align-items: center;
  116. .group-avatar {
  117. width: 120rpx;
  118. height: 120rpx;
  119. margin-right: 20rpx;
  120. border-radius: 20rpx;
  121. overflow: hidden;
  122. image {
  123. width: 100%;
  124. height: 100%;
  125. }
  126. }
  127. .group-info {
  128. flex: 1;
  129. min-width: 0; // 防止文本溢出
  130. .group-name {
  131. font-size: 32rpx;
  132. font-weight: bold;
  133. color: #333;
  134. margin-bottom: 8rpx;
  135. overflow: hidden;
  136. text-overflow: ellipsis;
  137. white-space: nowrap;
  138. }
  139. .group-desc {
  140. font-size: 26rpx;
  141. color: #666;
  142. margin-bottom: 8rpx;
  143. line-height: 1.4;
  144. overflow: hidden;
  145. text-overflow: ellipsis;
  146. white-space: nowrap;
  147. }
  148. .group-stats {
  149. display: flex;
  150. align-items: center;
  151. font-size: 24rpx;
  152. color: #999;
  153. .member-count {
  154. background: #f0f8ff;
  155. color: #5baaff;
  156. padding: 4rpx 12rpx;
  157. border-radius: 12rpx;
  158. font-size: 22rpx;
  159. }
  160. .separator {
  161. margin: 0 8rpx;
  162. color: #ddd;
  163. }
  164. .location {
  165. color: #999;
  166. font-size: 22rpx;
  167. }
  168. }
  169. }
  170. .group-status {
  171. display: flex;
  172. align-items: center;
  173. .admin-actions {
  174. display: flex;
  175. gap: 16rpx;
  176. .action-btn {
  177. width: 44rpx;
  178. height: 44rpx;
  179. border-radius: 50%;
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. transition: all 0.3s ease;
  184. &.edit-btn {
  185. background-color: rgba(91, 170, 255, 0.1);
  186. &:active {
  187. background-color: rgba(91, 170, 255, 0.2);
  188. transform: scale(0.9);
  189. }
  190. }
  191. &.delete-btn {
  192. background-color: rgba(255, 71, 87, 0.1);
  193. &:active {
  194. background-color: rgba(255, 71, 87, 0.2);
  195. transform: scale(0.9);
  196. }
  197. }
  198. }
  199. }
  200. .join-btn {
  201. width: 60rpx;
  202. height: 60rpx;
  203. background-color: #f8f9fa;
  204. border-radius: 50%;
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. transition: all 0.3s ease;
  209. &:active {
  210. background-color: #e9ecef;
  211. transform: scale(0.9);
  212. }
  213. }
  214. }
  215. }
  216. }
  217. </style>