index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <layout-page>
  3. <scroll-view class="scrollBox default-bgc" scroll-y="true" @scrolltolower="loadingMore" style="height: calc(100vh - 150rpx);">
  4. <view v-if="total" class="totalShow MiSans-Medium white-bgc">恭喜你,已经成功邀请{{ total }}个新用户啦!</view>
  5. <view v-if="items.length" class="listBox white-bgc">
  6. <!-- <m-list :items="items"></m-list> -->
  7. <uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据" style="width: 100%;">
  8. <uni-tr>
  9. <uni-th width="100" align="center" class="MiSans-Normal">用户名</uni-th>
  10. <uni-th align="center" class="MiSans-Normal">性别</uni-th>
  11. <uni-th align="center" class="MiSans-Normal">邀请时间</uni-th>
  12. </uni-tr>
  13. <uni-tr v-for="(item, index) in items" :key="index">
  14. <uni-td align="center" class="MiSans-Normal">{{ item.person?.name || item.user.phone }}</uni-td>
  15. <uni-td align="center" class="MiSans-Normal">{{ item.person?.sexName }}</uni-td>
  16. <uni-td align="center" class="MiSans-Normal">{{ item.user.createTime }}</uni-td>
  17. </uni-tr>
  18. </uni-table>
  19. <uni-load-more :status="more" />
  20. </view>
  21. <view v-else class="nodata-img-parent flex-column">
  22. <image
  23. src="https://minio.citupro.com/dev/static/nodata.png"
  24. mode="widthFix"
  25. style="width: 100vw"
  26. ></image>
  27. <view class="shareText">
  28. <span>您还没有邀请新用户</span>
  29. </view>
  30. </view>
  31. </scroll-view>
  32. <view class="bottom-sticky flex-column ss-p-b-30">
  33. <button class="recomm-button MiSans-Medium" style="margin-bottom: 0; border-radius: 25px;" @click="toShare">生成分享码</button>
  34. </view>
  35. </layout-page>
  36. </template>
  37. <script setup>
  38. import { ref, watch } from 'vue'
  39. import layoutPage from '@/layout'
  40. import { dealDictObjData } from '@/utils/position'
  41. import { timesTampChange } from '@/utils/date'
  42. // import MList from './list'
  43. // import { getDict } from '@/hooks/useDictionaries.js'
  44. import { getInviteRecord } from '@/api/position.js'
  45. // import { onLoad } from '@dcloudio/uni-app'
  46. import { userStore } from '@/store/user'
  47. const useUserStore = userStore()
  48. watch(() => useUserStore.refreshToken, (newVal, oldVal) => {
  49. if (useUserStore.refreshToken) {
  50. // 监听登录状态
  51. console.log('重新登录了')
  52. }
  53. })
  54. // 获取参数
  55. const pageInfo = ref({
  56. pageNo: 1,
  57. pageSize: 100
  58. })
  59. const total = ref(0)
  60. const items = ref([])
  61. const loading = ref(false)
  62. const more = ref('more')
  63. async function init () {
  64. try {
  65. loading.value = true
  66. const res = await getInviteRecord({
  67. ...pageInfo.value,
  68. })
  69. const data = res?.data?.list || []
  70. if (!data.length) {
  71. pageInfo.value.pageNo--
  72. return
  73. }
  74. const dealData = data.map(e => {
  75. e.person = dealDictObjData({}, e.person)
  76. if (e.user?.createTime) e.user.createTime = timesTampChange(e.user.createTime)
  77. return e
  78. })
  79. items.value.push(...dealData)
  80. total.value = items.value.length
  81. more.value = items.value.length === total.value ? 'noMore' : 'more'
  82. } catch (error) {
  83. pageInfo.value.pageNo--
  84. } finally {
  85. loading.value = false
  86. }
  87. }
  88. init()
  89. function loadingMore () {
  90. if (total.value === items.value.length) {
  91. return
  92. }
  93. if (loading.value) {
  94. return
  95. }
  96. more.value = 'loading'
  97. pageInfo.value.pageNo++
  98. init()
  99. }
  100. const toShare = () => {
  101. uni.navigateTo({ url: '/pagesB/sharePoster/index' })
  102. }
  103. </script>
  104. <style scoped lang="scss">
  105. .listBox {
  106. padding: 30rpx;
  107. }
  108. .totalShow {
  109. padding: 30rpx 0 0 30rpx;
  110. color: #666;
  111. }
  112. .nodata-img-parent {
  113. flex-direction: column;
  114. }
  115. .shareText {
  116. margin-bottom: 150rpx;
  117. color: #666;
  118. }
  119. </style>