invite-list.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <div class="content">
  3. <div class="error" v-if="state.invited_list.length == 0">
  4. Invite people to hunt treasure with you!
  5. </div>
  6. <div class="list" v-else>
  7. <div class="item" v-for="item in state.invited_list">
  8. <div class="left">
  9. <img :src="item.userInfo.avatarUrl" alt="" />
  10. </div>
  11. <div class="right">
  12. <div>{{ item.userInfo.nickName }}</div>
  13. <div>{{ getTime(item.timestamp) }}</div>
  14. </div>
  15. </div>
  16. </div>
  17. <div class="footer">
  18. <v-btn :txt="state.open_btn.txt" :font-size="'17px'" class="btn" :icon="false"
  19. :disabled="state.open_btn.disabled" @onClick="clickBtn"></v-btn>
  20. </div>
  21. </div>
  22. </template>
  23. <script setup>
  24. import VBtn from '@/view/iframe/treasure-hunt/components/btn.vue'
  25. import { inviteList } from '@/http/treasure'
  26. import { inject, onMounted } from 'vue'
  27. var moment = require('moment')
  28. let state = inject('state')
  29. state.invited_list = []
  30. onMounted(() => {
  31. inviteList({
  32. params: {
  33. inviteCode: state.invite_code,
  34. postId: state.postId,
  35. pageNum: 1,
  36. pageSize: 10,
  37. }
  38. }).then((res) => {
  39. if (res.code == 0) {
  40. state.invited_list = res.data
  41. }
  42. })
  43. // btnStatus()
  44. })
  45. const getTime = (timestamp) => {
  46. let _d1 = moment(new Date().getTime())
  47. let _d2 = moment(timestamp)
  48. const plural = (n, s) => {
  49. let _str = `${n} ${s} ago`
  50. if (n > 1) {
  51. _str = `${n} ${s}s ago`
  52. }
  53. return _str
  54. }
  55. let _d = moment.duration(_d1.diff(_d2)).days()
  56. if (_d) {
  57. return plural(_d, 'day')
  58. }
  59. let _h = moment.duration(_d1.diff(_d2)).hours()
  60. if (_h) {
  61. return plural(_h, 'hour')
  62. }
  63. let _m = moment.duration(_d1.diff(_d2)).minutes()
  64. if (_m) {
  65. return plural(_m, 'min')
  66. }
  67. let _s = moment.duration(_d1.diff(_d2)).seconds()
  68. return plural(_s, 'sec')
  69. }
  70. const clickBtn = () => {
  71. state.treasureOpen()
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .content {
  76. position: relative;
  77. height: 292px;
  78. .footer {
  79. background: #fff;
  80. padding: 10px 16px 25px 16px;
  81. }
  82. .error {
  83. height: 204px;
  84. color: #BABABA;
  85. background-color: #fff;
  86. font-weight: 500;
  87. font-size: 15px;
  88. line-height: 204px;
  89. text-align: center;
  90. }
  91. .list {
  92. height: 204px;
  93. overflow-y: auto;
  94. .item {
  95. height: 60px;
  96. display: flex;
  97. align-items: center;
  98. .left {
  99. width: 58px;
  100. text-align: center;
  101. img {
  102. border-radius: 50px;
  103. width: 30px;
  104. height: 30px;
  105. }
  106. }
  107. .right {
  108. flex: 1;
  109. border-bottom: 1px solid #D9D9D9;
  110. display: flex;
  111. align-items: center;
  112. height: 100%;
  113. justify-content: space-between;
  114. div:nth-child(1) {
  115. color: #000000;
  116. font-weight: 500;
  117. font-size: 15px;
  118. }
  119. div:nth-child(2) {
  120. color: #A6A6A6;
  121. font-weight: 400;
  122. font-size: 12px;
  123. margin-right: 17px;
  124. }
  125. }
  126. }
  127. }
  128. }
  129. </style>