index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <layout-page>
  3. <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" style="height: calc(100vh - 72rpx);">
  4. <view v-if="items.length" class="listBox">
  5. <!-- <m-list :items="items"></m-list> -->
  6. <uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据" style="width: 100%;">
  7. <uni-tr>
  8. <uni-th width="100" align="center">用户名</uni-th>
  9. <uni-th align="center">性别</uni-th>
  10. <uni-th align="center">邀请时间</uni-th>
  11. </uni-tr>
  12. <uni-tr v-for="(item, index) in items" :key="index">
  13. <uni-td align="center">{{ item.person.name }}</uni-td>
  14. <uni-td align="center">{{ item.person.sexName }}</uni-td>
  15. <uni-td align="center">{{ item.user.createTime }}</uni-td>
  16. <!-- <uni-td align="center">
  17. <view class="uni-group">
  18. <button class="uni-button" size="mini" type="warn">删除</button>
  19. </view>
  20. </uni-td> -->
  21. </uni-tr>
  22. </uni-table>
  23. <uni-load-more :status="more" />
  24. </view>
  25. <view v-else class="nodata-img-parent">
  26. <image
  27. src="https://minio.citupro.com/dev/static/nodata.png"
  28. mode="widthFix"
  29. style="width: 100vw"
  30. ></image>
  31. </view>
  32. </scroll-view>
  33. </layout-page>
  34. </template>
  35. <script setup>
  36. import { ref, watch } from 'vue'
  37. import layoutPage from '@/layout'
  38. import { dealDictObjData } from '@/utils/position'
  39. import { timesTampChange } from '@/utils/date'
  40. // import MList from './list'
  41. // import { getDict } from '@/hooks/useDictionaries.js'
  42. import { getInviteRecord } from '@/api/position.js'
  43. // import { onLoad } from '@dcloudio/uni-app'
  44. import { userStore } from '@/store/user'
  45. const useUserStore = userStore()
  46. watch(() => useUserStore.refreshToken, (newVal, oldVal) => {
  47. if (useUserStore.refreshToken) {
  48. // 监听登录状态
  49. console.log('重新登录了')
  50. }
  51. })
  52. // 获取参数
  53. const pageInfo = ref({
  54. pageNo: 1,
  55. pageSize: 100
  56. })
  57. const total = ref(0)
  58. const items = ref([])
  59. const loading = ref(false)
  60. const more = ref('more')
  61. async function init () {
  62. try {
  63. loading.value = true
  64. const res = await getInviteRecord({
  65. ...pageInfo.value,
  66. })
  67. const data = res?.data?.list || []
  68. if (!data.length) {
  69. pageInfo.value.pageNo--
  70. return
  71. }
  72. const dealData = data.map(e => {
  73. e.person = dealDictObjData({}, e.person)
  74. if (e.user?.createTime) e.user.createTime = timesTampChange(e.user.createTime)
  75. return e
  76. })
  77. items.value.push(...dealData)
  78. total.value = items.value.length
  79. more.value = items.value.length === total.value ? 'noMore' : 'more'
  80. } catch (error) {
  81. pageInfo.value.pageNo--
  82. } finally {
  83. loading.value = false
  84. }
  85. }
  86. init()
  87. function loadingMore () {
  88. if (total.value === items.value.length) {
  89. return
  90. }
  91. if (loading.value) {
  92. return
  93. }
  94. more.value = 'loading'
  95. pageInfo.value.pageNo++
  96. init()
  97. }
  98. </script>
  99. <style scoped lang="scss">
  100. .listBox {
  101. padding: 30rpx;
  102. }
  103. </style>