index.vue 3.6 KB

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