index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view @click="clickItem" class="user_item">
  3. <view
  4. v-if="checkVisible"
  5. class="check_wrap"
  6. :class="{ check_wrap_active: checked, check_wrap_disabled: disabled }">
  7. <u-icon v-show="checked" name="checkbox-mark" size="12" color="#fff" />
  8. </view>
  9. <my-avatar
  10. :src="item.faceURL"
  11. :desc="item.remark || item.nickname || item.showName"
  12. :isGroup="item.groupName !== undefined || isGroupConversation"
  13. size="42"
  14. />
  15. <view class="user_item_details">
  16. <view class="user_name">
  17. <text>{{
  18. item.remark || item.nickname || item.groupName || item.showName
  19. }}</text>
  20. <u-tag
  21. v-if="position"
  22. :text="position"
  23. plain
  24. shape="circle"
  25. style="margin-left: 8rpx"
  26. size="mini"
  27. ></u-tag>
  28. </view>
  29. <text v-if="item.roleLevel === 100 && showRole" class="user_role">群主</text>
  30. <text v-if="item.roleLevel === 60 && showRole" class="user_role admin_role"
  31. >管理员</text
  32. >
  33. <!-- <view class="bottom_line" /> -->
  34. </view>
  35. <slot name="action"></slot>
  36. </view>
  37. </template>
  38. <script>
  39. import MyAvatar from "../../components/MyAvatar/index.vue";
  40. import { SessionType } from "openim-uniapp-polyfill";
  41. export default {
  42. name: "UserItem",
  43. components: {
  44. MyAvatar,
  45. },
  46. props: {
  47. checkVisible: {
  48. type: Boolean,
  49. default: false,
  50. },
  51. checked: {
  52. type: Boolean,
  53. default: false,
  54. },
  55. disabled: {
  56. type: Boolean,
  57. default: false,
  58. },
  59. item: Object,
  60. position: {
  61. type: String,
  62. default: "",
  63. },
  64. showRole: {
  65. type: Boolean,
  66. default: true,
  67. }
  68. },
  69. data() {
  70. return {};
  71. },
  72. computed: {
  73. isGroupConversation() {
  74. return this.item.conversationType === SessionType.WorkingGroup;
  75. },
  76. },
  77. methods: {
  78. clickItem() {
  79. if (!this.disabled) {
  80. this.$emit(this.checkVisible ? "updateCheck" : "itemClick", this.item);
  81. }
  82. },
  83. },
  84. };
  85. </script>
  86. <style lang="scss" scoped>
  87. .user_item {
  88. @include vCenterBox();
  89. padding: 24rpx 44rpx;
  90. color: $uni-text-color;
  91. position: relative;
  92. .check_wrap {
  93. @include centerBox();
  94. box-sizing: border-box;
  95. width: 40rpx;
  96. min-width: 40rpx;
  97. height: 40rpx;
  98. min-height: 40rpx;
  99. border: 2px solid #979797;
  100. border-radius: 50%;
  101. margin-top: 16rpx;
  102. margin-right: 24rpx;
  103. &_active {
  104. background-color: #1d6bed;
  105. border: none;
  106. }
  107. &_disabled {
  108. background-color: #c8c9cc;
  109. }
  110. }
  111. &_details {
  112. @include vCenterBox();
  113. display: flex;
  114. flex-direction: row;
  115. justify-content: space-between;
  116. align-items: center;
  117. margin-left: 24rpx;
  118. width: 100%;
  119. position: relative;
  120. .bottom_line {
  121. height: 1px;
  122. width: 100%;
  123. background-color: #f0f0f0;
  124. position: absolute;
  125. bottom: -44rpx;
  126. }
  127. .user_name {
  128. display: flex;
  129. flex-direction: row;
  130. align-items: center;
  131. flex: 1;
  132. @include nomalEllipsis();
  133. color: $uni-text-color;
  134. }
  135. .user_role {
  136. font-size: 34rpx;
  137. // background-color: #f4da9a;
  138. // color: #FF8C00;
  139. padding: 8rpx 24rpx;
  140. border-radius: 24rpx;
  141. margin-left: 24rpx;
  142. color: $u-tips-color;
  143. }
  144. .admin_role {
  145. color: $u-tips-color;
  146. // background-color: #A2C9F8;
  147. // color: #2691ED;
  148. }
  149. }
  150. }
  151. .u-list-item:last-child {
  152. .bottom_line {
  153. height: 0;
  154. }
  155. }
  156. </style>