index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="page_container">
  3. <custom-nav-bar title="通讯录黑名单" />
  4. <u-list v-if="blockList.length > 0" class="block_list" height="1">
  5. <u-list-item v-for="item in blockList" :key="item.userID">
  6. <user-item :item="item">
  7. <view @click="tryRemove(item)" class="user_action" slot="action">
  8. 移除
  9. </view>
  10. </user-item>
  11. </u-list-item>
  12. </u-list>
  13. <view v-else class="empty">
  14. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/block_empty.png"></image>
  15. <text class="empty_text">暂无黑名单</text>
  16. </view>
  17. <!-- <u-empty icon="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/block_empty.png" v-else text="暂无黑名单" iconSize="20" /> -->
  18. <u-modal
  19. width="500rpx"
  20. showCancelButton
  21. :show="showComfirm"
  22. @confirm="confirm"
  23. @cancel="closeModal"
  24. content="确定将用户移除黑名单吗?"
  25. :asyncClose="true"
  26. ></u-modal>
  27. </view>
  28. </template>
  29. <script>
  30. import IMSDK from "openim-uniapp-polyfill";
  31. import CustomNavBar from "../../../components/CustomNavBar/index.vue";
  32. import MyAvatar from "../../../components/MyAvatar/index.vue";
  33. import UserItem from "../../../components/UserItem/index.vue";
  34. export default {
  35. components: {
  36. CustomNavBar,
  37. MyAvatar,
  38. UserItem,
  39. },
  40. data() {
  41. return {
  42. showComfirm: false,
  43. selectedUser: {},
  44. };
  45. },
  46. computed: {
  47. blockList() {
  48. return this.$store.getters.storeBlackList;
  49. },
  50. },
  51. methods: {
  52. tryRemove(item) {
  53. this.selectedUser = {
  54. ...item,
  55. };
  56. this.showComfirm = true;
  57. },
  58. confirm() {
  59. IMSDK.asyncApi(
  60. IMSDK.IMMethods.RemoveBlack,
  61. IMSDK.uuid(),
  62. this.selectedUser.userID,
  63. )
  64. .then(() => uni.$u.toast("移除成功"))
  65. .catch(() => uni.$u.toast("移除失败"))
  66. .finally(() => (this.showComfirm = false));
  67. },
  68. closeModal() {
  69. this.showComfirm = false;
  70. },
  71. },
  72. };
  73. </script>
  74. <style lang="scss" scoped>
  75. .page_container {
  76. @include colBox(false);
  77. height: 100vh;
  78. background-color: #f8f8f8;
  79. .block_list {
  80. flex: 1;
  81. margin-top: 24rpx;
  82. .user_item {
  83. background-color: #fff;
  84. }
  85. .user_action {
  86. position: absolute;
  87. right: 44rpx;
  88. font-size: 28rpx;
  89. color: $uni-color-primary;
  90. }
  91. }
  92. .empty {
  93. @include centerBox();
  94. flex-direction: column;
  95. margin-top: 25vh !important;
  96. &_text {
  97. margin-top: 26rpx;
  98. color: #8e9ab0;
  99. }
  100. image {
  101. width: 237rpx;
  102. height: 244rpx;
  103. }
  104. }
  105. }
  106. </style>