index.vue 3.1 KB

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