manage-member.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <main v-if="!isUniFrameWork" class="member">
  3. <ul class="list">
  4. <li v-for="(item, index) in memberList" :key="index" class="list-item">
  5. <aside class="aside" @click="handleMemberProfileShow(item)">
  6. <img
  7. class="avatar"
  8. :src="
  9. item.avatar ||
  10. 'https://bucket.sxdirectpurchase.com/wx/static/img/ImAvatar.png'
  11. "
  12. onerror="this.onerror=null;this.src='https://bucket.sxdirectpurchase.com/wx/static/img/ImAvatar.png'"
  13. />
  14. <span class="name">{{ item.nick || item.userID }}</span>
  15. <span>{{ handleRoleName(item) }}</span>
  16. </aside>
  17. <div @click="submit(item)">
  18. <Icon
  19. v-if="item.role !== 'Owner' && isShowDeleteBtn"
  20. :file="delIcon"
  21. :width="'16px'"
  22. :height="'16px'"
  23. />
  24. </div>
  25. </li>
  26. <li v-if="memberList.length < totalMember" class="list-item" @click="getMore">
  27. {{ TUITranslateService.t(`TUIGroup.查看更多`) }}
  28. </li>
  29. </ul>
  30. </main>
  31. <div v-else class="edit-h5">
  32. <main class="main">
  33. <header class="edit-h5-header">
  34. <aside class="left">
  35. <h1>{{ TUITranslateService.t(`TUIGroup.群成员`) }}</h1>
  36. </aside>
  37. <span class="close" @click="close('member')">{{
  38. TUITranslateService.t(`关闭`)
  39. }}</span>
  40. </header>
  41. <div class="member">
  42. <ul class="list list-uniapp">
  43. <li v-for="(item, index) in memberList" :key="index" class="list-item">
  44. <aside class="aside" @click="handleMemberProfileShow(item)">
  45. <img
  46. class="avatar"
  47. :src="
  48. item.avatar ||
  49. 'https://bucket.sxdirectpurchase.com/wx/static/img/ImAvatar.png'
  50. "
  51. onerror="this.onerror=null;this.src='https://bucket.sxdirectpurchase.com/wx/static/img/ImAvatar.png'"
  52. />
  53. <span class="name">{{ item.nick || item.userID }}</span>
  54. <span>{{ handleRoleName(item) }}</span>
  55. </aside>
  56. <div @click="submit(item)">
  57. <Icon
  58. v-if="item.role !== 'Owner' && isShowDeleteBtn"
  59. :file="delIcon"
  60. :width="'16px'"
  61. :height="'16px'"
  62. />
  63. </div>
  64. </li>
  65. <li v-if="memberList.length < totalMember" class="list-item" @click="getMore">
  66. {{ TUITranslateService.t(`TUIGroup.查看更多`) }}
  67. </li>
  68. </ul>
  69. </div>
  70. </main>
  71. </div>
  72. </template>
  73. <script lang="ts" setup>
  74. import TUIChatEngine, { TUITranslateService } from "@tencentcloud/chat-uikit-engine";
  75. import { watchEffect, ref } from "../../../adapter-vue";
  76. import Icon from "../../common/Icon.vue";
  77. import delIcon from "../../../assets/icon/del-icon.svg";
  78. import { IGroupSelfInfo, IGroupMember } from "../../../interface";
  79. import { isUniFrameWork } from "../../../utils/env";
  80. const props = defineProps({
  81. list: {
  82. type: Array,
  83. default: () => [],
  84. },
  85. total: {
  86. type: Number,
  87. default: () => 0,
  88. },
  89. isShowDel: {
  90. type: Boolean,
  91. default: () => false,
  92. },
  93. self: {
  94. type: Object,
  95. default: () => ({}),
  96. },
  97. });
  98. const totalMember = ref(0);
  99. const memberList = ref<Array<IGroupMember>>([]);
  100. const isShowDeleteBtn = ref(false);
  101. const selfValue = ref<IGroupSelfInfo>({});
  102. watchEffect(() => {
  103. totalMember.value = props.total;
  104. isShowDeleteBtn.value = props.isShowDel;
  105. memberList.value = props.list as Array<IGroupMember>;
  106. selfValue.value = props.self;
  107. });
  108. const emits = defineEmits(["more", "del", "handleMemberProfileShow", "close"]);
  109. const handleRoleName = (item: any) => {
  110. let name = "";
  111. switch (item?.role) {
  112. case TUIChatEngine.TYPES.GRP_MBR_ROLE_ADMIN:
  113. name = TUITranslateService.t("TUIGroup.管理员");
  114. break;
  115. case TUIChatEngine.TYPES.GRP_MBR_ROLE_OWNER:
  116. name = TUITranslateService.t("TUIGroup.群主");
  117. break;
  118. }
  119. if (name) {
  120. name = `(${name})`;
  121. }
  122. if (item.userID === selfValue.value.userID) {
  123. name += ` (${TUITranslateService.t("TUIGroup.我")})`;
  124. }
  125. return name;
  126. };
  127. const getMore = () => {
  128. emits("more");
  129. };
  130. const submit = (item: any) => {
  131. emits("del", [item]);
  132. };
  133. const handleMemberProfileShow = (user: any) => {
  134. emits("handleMemberProfileShow", user);
  135. };
  136. const close = (tabName: string) => {
  137. emits("close", tabName);
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. @import "../../../assets/styles/common";
  142. .member {
  143. flex: 1;
  144. background: #fff;
  145. .list {
  146. display: flex;
  147. flex-direction: column;
  148. background: #f4f5f9;
  149. padding-top: 22px;
  150. &-uniapp {
  151. background: none;
  152. }
  153. &-item {
  154. padding: 13px;
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. background: #fff;
  159. font-size: 14px;
  160. overflow: hidden;
  161. cursor: pointer;
  162. &:hover {
  163. background: #f1f2f6;
  164. }
  165. .aside {
  166. display: flex;
  167. align-items: center;
  168. width: 100%;
  169. overflow: hidden;
  170. .name {
  171. margin-left: 8px;
  172. font-weight: 400;
  173. font-size: 14px;
  174. color: #000;
  175. flex: 1;
  176. overflow: hidden;
  177. white-space: nowrap;
  178. text-overflow: ellipsis;
  179. }
  180. }
  181. }
  182. }
  183. }
  184. .avatar {
  185. width: 36px;
  186. height: 36px;
  187. border-radius: 4px;
  188. }
  189. .edit-h5 {
  190. position: fixed;
  191. width: 100%;
  192. height: 100%;
  193. top: 0;
  194. left: 0;
  195. background: rgba(0, 0, 0, 0.5);
  196. display: flex;
  197. align-items: flex-end;
  198. z-index: 1;
  199. .main {
  200. background: #fff;
  201. flex: 1;
  202. padding: 18px;
  203. border-radius: 12px 12px 0 0;
  204. overflow: scroll;
  205. height: 50%;
  206. width: 80vw;
  207. }
  208. &-header {
  209. display: flex;
  210. align-items: center;
  211. justify-content: space-between;
  212. .close {
  213. font-family: PingFangSC-Regular;
  214. font-weight: 400;
  215. font-size: 18px;
  216. color: #3370ff;
  217. letter-spacing: 0;
  218. line-height: 27px;
  219. }
  220. }
  221. &-footer {
  222. display: flex;
  223. .btn {
  224. flex: 1;
  225. border: none;
  226. background: #147aff;
  227. border-radius: 5px;
  228. font-family: PingFangSC-Regular;
  229. font-weight: 400;
  230. font-size: 16px;
  231. color: #fff;
  232. letter-spacing: 0;
  233. line-height: 27px;
  234. padding: 8px 0;
  235. &:disabled {
  236. opacity: 0.3;
  237. }
  238. }
  239. }
  240. }
  241. </style>