index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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="MiSans-Medium color-primary shareCode" @tap="toShare">我的分享码</view>
  5. <view v-if="total" class="totalShow MiSans-Medium">恭喜你,已经成功邀请{{ total }}个新用户啦!</view>
  6. <view v-if="items.length" class="listBox">
  7. <!-- <m-list :items="items"></m-list> -->
  8. <uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据" style="width: 100%;">
  9. <uni-tr>
  10. <uni-th width="100" align="center" class="MiSans-Normal">用户名</uni-th>
  11. <uni-th align="center" class="MiSans-Normal">性别</uni-th>
  12. <uni-th align="center" class="MiSans-Normal">邀请时间</uni-th>
  13. </uni-tr>
  14. <uni-tr v-for="(item, index) in items" :key="index">
  15. <uni-td align="center" class="MiSans-Normal">{{ item.person?.name || item.user.phone }}</uni-td>
  16. <uni-td align="center" class="MiSans-Normal">{{ item.person?.sexName }}</uni-td>
  17. <uni-td align="center" class="MiSans-Normal">{{ item.user.createTime }}</uni-td>
  18. </uni-tr>
  19. </uni-table>
  20. <uni-load-more :status="more" />
  21. </view>
  22. <view v-else class="nodata-img-parent flex-column">
  23. <image
  24. src="https://minio.citupro.com/dev/static/nodata.png"
  25. mode="widthFix"
  26. style="width: 100vw"
  27. ></image>
  28. <view class="shareText">
  29. <span>您还没有邀请新用户,</span>
  30. <span class="color-primary" @tap="toShare">马上邀请</span>
  31. </view>
  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. const toShare = () => {
  100. uni.navigateTo({ url: '/pagesB/sharePoster/index' })
  101. }
  102. </script>
  103. <style scoped lang="scss">
  104. .listBox {
  105. padding: 30rpx;
  106. }
  107. .totalShow {
  108. margin: 30rpx 0 0 30rpx;
  109. color: #666;
  110. }
  111. .nodata-img-parent {
  112. flex-direction: column;
  113. }
  114. .shareText {
  115. margin-bottom: 150rpx;
  116. }
  117. .shareCode {
  118. text-align: right;
  119. margin: 30rpx;
  120. text-decoration: underline;
  121. }
  122. </style>