index.vue 3.7 KB

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