referral.vue 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view class="page">
  3. <NavBar title="推荐记录" :showBack="true" />
  4. <scroll-view class="list-scroll" scroll-y @scrolltolower="loadMore">
  5. <view class="card-set">
  6. <view class="card" v-for="item in list" :key="item.id">
  7. <view class="card-head">
  8. <view class="card-left">
  9. <text class="card-name">{{ item.inviteeName || '用户' + item.inviteeId }}</text>
  10. <text class="card-time">{{ item.createTime }}</text>
  11. </view>
  12. <view class="card-status" :class="statusClass(item.status)">
  13. <text>{{ item.status === 1 ? '已激活' : item.status === 2 ? '已奖励' : '待激活' }}</text>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="load-tip" v-if="loading"><view class="dot-row"><view class="pulse-dot"></view><view class="pulse-dot"></view><view class="pulse-dot"></view></view></view>
  19. <view class="end-tip" v-if="!hasMore && list.length > 0"><text>没有更多了</text></view>
  20. <view class="empty-state" v-if="!loading && list.length === 0"><text class="empty-text">暂无推荐记录</text></view>
  21. </scroll-view>
  22. </view>
  23. </template>
  24. <script setup lang="ts">
  25. import { ref, onMounted } from 'vue';
  26. import NavBar from '@/components/NavBar.vue';
  27. import { get } from '@/utils/request';
  28. import { DEFAULT_PAGE_SIZE } from '@/utils/constants';
  29. const list = ref<any[]>([]); const loading = ref(false); const hasMore = ref(true); const page = ref(1);
  30. const statusClass = (s: number) => s === 2 ? 'done' : s === 1 ? 'active' : 'pending';
  31. const loadData = async () => {
  32. loading.value = true;
  33. try { const res = await get('/distribution/referral/list', { page: page.value, pageSize: DEFAULT_PAGE_SIZE }); if (page.value === 1) list.value = res.list || []; else list.value = [...list.value, ...(res.list || [])]; hasMore.value = list.value.length < (res.total || 0); } catch { }
  34. loading.value = false;
  35. };
  36. const loadMore = () => { if (loading.value || !hasMore.value) return; page.value++; loadData(); };
  37. onMounted(() => loadData());
  38. </script>
  39. <style lang="scss" scoped>
  40. .page { height: 100vh; background: $bg-color-page; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
  41. .list-scroll { flex: 1; height: 0; }
  42. .card-set { padding: 20rpx 24rpx; display: flex; flex-direction: column; gap: 16rpx; }
  43. .card { background: $bg-color-card; border-radius: $radius-md; padding: 24rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.05); }
  44. .card-head { display: flex; justify-content: space-between; align-items: center; }
  45. .card-left { flex: 1; }
  46. .card-name { font-size: 30rpx; font-weight: 600; color: $text-color-primary; display: block; margin-bottom: 6rpx; }
  47. .card-time { font-size: 24rpx; color: $text-color-muted; }
  48. .card-status { padding: 4rpx 14rpx; border-radius: 8rpx; font-size: 22rpx; font-weight: 500; }
  49. .card-status.done { background: $success-color-bg; color: $success-color; }
  50. .card-status.active { background: $info-color-bg; color: $info-color; }
  51. .card-status.pending { background: $warning-color-bg; color: $warning-color; }
  52. .load-tip { display: flex; justify-content: center; padding: 36rpx 0; }
  53. .dot-row { display: flex; gap: 8rpx; }
  54. .pulse-dot { width: 9rpx; height: 9rpx; background: $text-color-placeholder; border-radius: 50%; animation: pulse 1.2s ease-in-out infinite; }
  55. .pulse-dot:nth-child(2) { animation-delay: 0.2s; } .pulse-dot:nth-child(3) { animation-delay: 0.4s; }
  56. @keyframes pulse { 0%,80%,100% { transform: scale(0.5); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }
  57. .end-tip { text-align: center; padding: 36rpx; font-size: 24rpx; color: $text-color-muted; }
  58. .empty-state { display: flex; align-items: center; justify-content: center; padding: 100rpx 0; }
  59. .empty-text { font-size: 28rpx; color: $text-color-muted; }
  60. </style>