black-list.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view>
  3. <template v-if="!isShowContactInfo">
  4. <view
  5. class="item"
  6. v-for="(item, index) in contactListMap.blackList.list"
  7. :key="index"
  8. @click="selectItem(item)"
  9. >
  10. <view>
  11. <image :src="item.avatar" class="img" />
  12. </view>
  13. <view class="right">
  14. <text class="name">{{ item.nick }}</text>
  15. </view>
  16. </view>
  17. </template>
  18. <view v-if="isShowContactInfo">
  19. <view class="item">
  20. <view>
  21. <image :src="detailObj.avatar" class="img" />
  22. </view>
  23. <view class="right">
  24. <view class="name">{{ detailObj.nick }}</view>
  25. <view class="id">ID:{{ detailObj.userID }}</view>
  26. </view>
  27. </view>
  28. <view
  29. style="
  30. margin-top: 20px;
  31. display: flex;
  32. flex-direction: row;
  33. align-items: center;
  34. justify-content: space-between;
  35. padding: 0px 20px;
  36. "
  37. >
  38. 加入黑名单<u-switch v-model="switchValue" @change="change" size="60"></u-switch>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script setup lang="ts">
  44. import {
  45. TUITranslateService,
  46. TUIStore,
  47. StoreName,
  48. IGroupModel,
  49. TUIFriendService,
  50. Friend,
  51. FriendApplication,
  52. TUIUserService,
  53. TUIConversationService,
  54. } from "@tencentcloud/chat-uikit-engine";
  55. import ContactInfo from "../../TUIKit/components/TUIContact/contact-info/index.vue";
  56. import { isPC, isUniFrameWork } from "../../TUIKit/utils/env";
  57. import { onLoad, onShow } from "@dcloudio/uni-app";
  58. import {
  59. IContactList,
  60. IContactSearchResult,
  61. IBlackListUserItem,
  62. IUserStatus,
  63. IUserStatusMap,
  64. IContactInfoType,
  65. } from "../../TUIKit/interface";
  66. import { TUIGlobal } from "@tencentcloud/universal-api";
  67. import { Toast, TOAST_TYPE } from "../../TUIKit/components/common/Toast/index";
  68. import { ref, computed, onMounted, onUnmounted, provide } from "../../TUIKit/adapter-vue";
  69. const currentContactInfo = ref();
  70. const contactListMap = ref();
  71. const isShowContactInfo = ref(false);
  72. const switchValue = ref(true);
  73. onLoad((options) => {
  74. contactListMap.value = JSON.parse(options.list);
  75. console.log(contactListMap.value);
  76. });
  77. const change = () => {
  78. TUIUserService.removeFromBlacklist({
  79. userIDList: [detailObj.value.userID],
  80. })
  81. .then(() => {
  82. TUIGlobal?.navigateTo({
  83. url: "/TUIKit/components/TUIContact/index",
  84. });
  85. isShowContactInfo.value = !isShowContactInfo.value;
  86. })
  87. .catch((error: any) => {
  88. Toast({
  89. message: TUITranslateService.t("TUIContact.移除黑名单失败"),
  90. type: TOAST_TYPE.ERROR,
  91. });
  92. });
  93. };
  94. const detailObj = ref();
  95. const selectItem = (record) => {
  96. isShowContactInfo.value = !isShowContactInfo.value;
  97. detailObj.value = record;
  98. };
  99. </script>
  100. <style lang="scss" scope>
  101. .item {
  102. display: flex;
  103. flex-direction: row;
  104. align-items: center;
  105. padding: 20rpx;
  106. border-bottom: 1px solid #f1f1f1;
  107. .right {
  108. margin-left: 10px;
  109. .name {
  110. font-weight: 600;
  111. font-size: 32rpx;
  112. color: #333333;
  113. }
  114. }
  115. .img {
  116. width: 60px;
  117. height: 60px;
  118. border-radius: 50%;
  119. }
  120. }
  121. </style>