nft-group-list.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div class="list" v-if="detail">
  3. <div
  4. class="item"
  5. :key="index"
  6. v-for="(item, index) in detail"
  7. @click="clickHandler(item)">
  8. <div class="logo">
  9. <img :src="item.nftGroupIcon" />
  10. <div class="badge" v-if="showBadge">
  11. {{item.newPostCount}}
  12. </div>
  13. </div>
  14. <div class="text">{{item.nftGroupName}}</div>
  15. </div>
  16. </div>
  17. </template>
  18. <script setup>
  19. import { onBeforeMount, ref, defineEmits, defineProps } from 'vue'
  20. import { listJoinNftGroup } from '@/http/nft'
  21. const props = defineProps({
  22. showBadge: {
  23. type: Boolean,
  24. default: false,
  25. }
  26. })
  27. let pageNum = 1;
  28. let pageSize = 1000;
  29. let detail = ref(null);
  30. let emits = defineEmits(['clickCallBack']);
  31. const clickHandler = (item) => {
  32. emits('clickCallBack', item);
  33. }
  34. onBeforeMount(() => {
  35. listJoinNftGroup({
  36. params: {
  37. pageNum,
  38. pageSize
  39. }
  40. }).then(res => {
  41. let { data } = res;
  42. if (data !== null) {
  43. detail.value = data;
  44. }
  45. })
  46. })
  47. </script>
  48. <style lang='scss'>
  49. body {
  50. margin: 0;
  51. padding: 0;
  52. user-select: none;
  53. }
  54. .list {
  55. overflow-y: auto;
  56. .item {
  57. display: flex;
  58. height: 48px;
  59. margin: 2px 0;
  60. cursor: pointer;
  61. flex-direction: row;
  62. align-items: center;
  63. .logo {
  64. width: 38px;
  65. height: 38px;
  66. border: 1px solid #E3E3E3;
  67. border-radius: 6px;
  68. background: #FFFFFF;
  69. margin-right: 16px;
  70. position: relative;
  71. img {
  72. width: 100%;
  73. height: 100%;
  74. border-radius: 6px;
  75. }
  76. .badge {
  77. min-width: 16px;
  78. min-height: 16px;
  79. padding: 0 4px;
  80. font-weight: 600;
  81. font-size: 12px;
  82. color: #fff;
  83. background: #1D9BF0;
  84. border: 1px solid #F7F9F9;
  85. border-radius: 100px;
  86. box-sizing: border-box;
  87. position: absolute;
  88. top: -8px;
  89. left: 29px;
  90. min-width: 18px;
  91. min-height: 18px;
  92. display: flex;
  93. align-items: center;
  94. justify-content: center;
  95. }
  96. }
  97. .text {
  98. display: flex;
  99. flex: 1;
  100. font-size: 16px;
  101. font-weight: 500;
  102. line-height: 19px;
  103. }
  104. }
  105. }
  106. </style>