index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <layout-page>
  3. <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" style="height: calc(100vh - 102rpx);">
  4. <view v-if="total" class="totalShow MiSans-Medium">恭喜你,已经成功邀请{{ total }}个新用户啦!</view>
  5. <view v-if="items.length" class="listBox">
  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">
  22. <image
  23. src="https://minio.citupro.com/dev/static/nodata.png"
  24. mode="widthFix"
  25. style="width: 100vw"
  26. ></image>
  27. </view>
  28. </scroll-view>
  29. </layout-page>
  30. </template>
  31. <script setup>
  32. import { ref, watch } from 'vue'
  33. import layoutPage from '@/layout'
  34. import { dealDictObjData } from '@/utils/position'
  35. import { timesTampChange } from '@/utils/date'
  36. // import MList from './list'
  37. // import { getDict } from '@/hooks/useDictionaries.js'
  38. import { getInviteRecord } from '@/api/position.js'
  39. // import { onLoad } from '@dcloudio/uni-app'
  40. import { userStore } from '@/store/user'
  41. const useUserStore = userStore()
  42. watch(() => useUserStore.refreshToken, (newVal, oldVal) => {
  43. if (useUserStore.refreshToken) {
  44. // 监听登录状态
  45. console.log('重新登录了')
  46. }
  47. })
  48. // 获取参数
  49. const pageInfo = ref({
  50. pageNo: 1,
  51. pageSize: 100
  52. })
  53. const total = ref(0)
  54. const items = ref([])
  55. const loading = ref(false)
  56. const more = ref('more')
  57. async function init () {
  58. try {
  59. loading.value = true
  60. const res = await getInviteRecord({
  61. ...pageInfo.value,
  62. })
  63. const data = res?.data?.list || []
  64. if (!data.length) {
  65. pageInfo.value.pageNo--
  66. return
  67. }
  68. const dealData = data.map(e => {
  69. e.person = dealDictObjData({}, e.person)
  70. if (e.user?.createTime) e.user.createTime = timesTampChange(e.user.createTime)
  71. return e
  72. })
  73. items.value.push(...dealData)
  74. total.value = items.value.length
  75. more.value = items.value.length === total.value ? 'noMore' : 'more'
  76. } catch (error) {
  77. pageInfo.value.pageNo--
  78. } finally {
  79. loading.value = false
  80. }
  81. }
  82. init()
  83. function loadingMore () {
  84. if (total.value === items.value.length) {
  85. return
  86. }
  87. if (loading.value) {
  88. return
  89. }
  90. more.value = 'loading'
  91. pageInfo.value.pageNo++
  92. init()
  93. }
  94. </script>
  95. <style scoped lang="scss">
  96. .listBox {
  97. padding: 30rpx;
  98. }
  99. .totalShow {
  100. margin: 30rpx 0 0 30rpx;
  101. color: #666;
  102. }
  103. </style>