receive-list.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <!-- 领取人列表组件 -->
  2. <template>
  3. <div class="content">
  4. <img v-show="receive.loading" :src="require('@/assets/svg/icon-loading-gray2.svg')" alt="" class="loading" />
  5. <img v-if="receive.list.length == 0 && receive.end" :src="require('@/assets/svg/icon-empty-list.svg')" alt=""
  6. class="empty" />
  7. <div class="list" v-else @scroll="handleScroll($event)">
  8. <div class="item" v-for="item in receive.list" :key="item.userInfo.uid">
  9. <div class="left">
  10. <img :src="item.userInfo.avatarUrl" alt="" @click="clickItem(item)" />
  11. </div>
  12. <div class="right">
  13. <div>
  14. <div class="name" @click="clickItem(item)">{{ item.userInfo.nickName }}</div>
  15. <div class="time">{{ getBeforeTimeFormat(item.timestamp) }}</div>
  16. </div>
  17. <div>
  18. <div class="money">${{ item.amountUsdValue }}</div>
  19. <div class="count" :class="{ 'hide': Number(item.inviteNewFansCount) == 0 }">
  20. invited:{{ item.inviteNewFansCount }}</div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </template>
  27. <script setup>
  28. import { receiveListV2 } from '@/http/treasure'
  29. import { onMounted, reactive, inject, defineProps, watch } from 'vue'
  30. import { getBeforeTimeFormat } from "@/uilts/help"
  31. let state = inject('state')
  32. let receive = reactive({
  33. end: false,
  34. list: []
  35. })
  36. let props = defineProps({
  37. sortType: {
  38. type: Number,
  39. default: 2,
  40. }
  41. })
  42. watch(props, () => {
  43. sortType = props.sortType
  44. page_num = 1
  45. receive.loading = true
  46. receive.list = []
  47. receive.end = false
  48. list()
  49. })
  50. let page_num = 1
  51. let page_size = 10
  52. let sortType = 2;
  53. let list_end = false
  54. onMounted(() => {
  55. receive.loading = true
  56. list()
  57. })
  58. const clickItem = (item) => {
  59. window.open(`https://twitter.com/${item.userInfo.nickName}`)
  60. }
  61. function handleScroll(e) {
  62. if (list_end) {
  63. return
  64. }
  65. e = e.target
  66. if ((e.clientHeight + e.scrollTop) / e.scrollHeight > .8) {
  67. if (page_num * page_size == receive.list.length) {
  68. page_num++
  69. list()
  70. }
  71. list_end = true
  72. }
  73. }
  74. const list = () => {
  75. receiveListV2({
  76. params: {
  77. postId: state.postId,
  78. pageNum: page_num,
  79. pageSize: page_size,
  80. sortType
  81. }
  82. }).then((res) => {
  83. if (res.code == 0) {
  84. receive.loading = false
  85. if (page_num < 2) {
  86. receive.list = res.data || [];
  87. } else {
  88. receive.list = receive.list.concat(res.data)
  89. }
  90. receive.end = true
  91. list_end = false
  92. }
  93. })
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .content {
  98. position: relative;
  99. height: 100%;
  100. overflow-y: auto;
  101. background: #fff;
  102. .footer {
  103. background: #fff;
  104. padding: 10px 16px 25px 16px;
  105. }
  106. .error {
  107. height: 204px;
  108. color: #BABABA;
  109. background-color: #fff;
  110. font-weight: 500;
  111. font-size: 15px;
  112. line-height: 204px;
  113. text-align: center;
  114. }
  115. .list {
  116. height: 100%;
  117. background: #fff;
  118. overflow-y: auto;
  119. .item {
  120. height: 60px;
  121. display: flex;
  122. align-items: center;
  123. .left {
  124. width: 58px;
  125. text-align: center;
  126. img {
  127. cursor: pointer;
  128. border-radius: 50px;
  129. width: 30px;
  130. height: 30px;
  131. }
  132. }
  133. .right {
  134. flex: 1;
  135. box-shadow: inset 0px -1px 0px #F2F2F2;
  136. display: flex;
  137. align-items: center;
  138. height: 100%;
  139. justify-content: space-between;
  140. .name {
  141. color: #000000;
  142. font-weight: 500;
  143. font-size: 15px;
  144. cursor: pointer;
  145. margin-bottom: 5px;
  146. }
  147. .time {
  148. color: #A6A6A6;
  149. font-weight: 400;
  150. font-size: 12px;
  151. margin-right: 17px;
  152. }
  153. .money {
  154. color: #FCB936;
  155. font-weight: 500;
  156. font-size: 13px;
  157. margin-right: 16px;
  158. text-align: right;
  159. }
  160. .count {
  161. margin-right: 16px;
  162. color: #A9A9A9;
  163. font-weight: 400;
  164. font-size: 12px;
  165. text-align: right;
  166. margin-top: 5px;
  167. }
  168. .hide {
  169. visibility: hidden;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. .loading {
  176. width: 100px;
  177. height: 100px;
  178. position: absolute;
  179. top: 50%;
  180. left: 50%;
  181. margin-left: -50px;
  182. margin-top: -50px;
  183. animation: rotation 1s linear infinite;
  184. }
  185. .empty {
  186. width: 100px;
  187. height: 100px;
  188. position: absolute;
  189. top: 50%;
  190. left: 50%;
  191. margin-left: -50px;
  192. margin-top: -50px;
  193. }
  194. @keyframes rotation {
  195. from {
  196. -webkit-transform: rotate(0deg);
  197. }
  198. to {
  199. -webkit-transform: rotate(360deg);
  200. }
  201. }
  202. </style>