stats.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="stats-page">
  3. <LoadingSkeleton v-if="loading" :rows="2" />
  4. <ErrorState v-else-if="error" message="记录加载失败" @retry="loadStats" />
  5. <EmptyState
  6. v-else-if="!stats.invited && !stats.paid"
  7. icon="📄"
  8. title="暂无来源记录"
  9. desc="有分享来源记录后会在此展示"
  10. />
  11. <template v-else>
  12. <view class="stat-card">
  13. <view class="stat-row">
  14. <view class="stat-item">
  15. <text class="stat-num">{{ stats.invited }}</text>
  16. <text class="stat-label">来源记录</text>
  17. </view>
  18. <view class="stat-item">
  19. <text class="stat-num">{{ stats.paid }}</text>
  20. <text class="stat-label">报名记录</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="tip-card">
  25. <text class="tip-title">记录说明</text>
  26. <text class="tip-desc">1. 本页仅展示您的来源与报名记录</text>
  27. <text class="tip-desc">2. 记录仅供本人查看</text>
  28. <text class="tip-desc">3. 如对记录有疑问,请联系机构</text>
  29. </view>
  30. <view class="poster-link" @click="goPoster">
  31. <text>查看分享资料</text>
  32. <text class="arrow">›</text>
  33. </view>
  34. </template>
  35. </view>
  36. </template>
  37. <script>
  38. import { getInviteStats } from '@/utils/api.js'
  39. import { guardPage } from '@/utils/guard.js'
  40. import LoadingSkeleton from '@/components/loading-skeleton.vue'
  41. import ErrorState from '@/components/error-state.vue'
  42. import EmptyState from '@/components/empty-state.vue'
  43. export default {
  44. components: { LoadingSkeleton, ErrorState, EmptyState },
  45. data() {
  46. return {
  47. stats: { invited: 0, paid: 0 },
  48. loading: false,
  49. error: false
  50. }
  51. },
  52. onShow() {
  53. if (!guardPage()) return
  54. this.loadStats()
  55. },
  56. methods: {
  57. loadStats() {
  58. var self = this
  59. self.loading = true
  60. self.error = false
  61. getInviteStats().then(function(resp) {
  62. var data = resp.data || {}
  63. self.stats = {
  64. invited: data.invited || 0,
  65. paid: data.paid || 0
  66. }
  67. }).catch(function() {
  68. self.error = true
  69. }).finally(function() {
  70. self.loading = false
  71. })
  72. },
  73. goPoster() {
  74. uni.navigateBack({})
  75. }
  76. }
  77. }
  78. </script>
  79. <style scoped>
  80. .stats-page { min-height: 100vh; background: #F5FAFE; padding: 24rpx 32rpx; }
  81. .stat-card { background: #FFF; border-radius: 16rpx; padding: 40rpx 24rpx; margin-bottom: 24rpx; }
  82. .stat-row { display: flex; justify-content: space-around; }
  83. .stat-item { display: flex; flex-direction: column; align-items: center; flex: 1; }
  84. .stat-num { font-size: 56rpx; font-weight: 700; color: #2E6FA8; }
  85. .stat-label { font-size: 26rpx; color: #3B5A78; margin-top: 12rpx; }
  86. .tip-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; margin-bottom: 24rpx; }
  87. .tip-title { display: block; font-size: 30rpx; font-weight: 700; color: #1E3A5F; margin-bottom: 16rpx; border-left: 8rpx solid #2E6FA8; padding-left: 16rpx; }
  88. .tip-desc { display: block; font-size: 26rpx; color: #3B5A78; line-height: 48rpx; }
  89. .poster-link { display: flex; align-items: center; justify-content: center; padding: 32rpx 0; color: #3B5A78; font-size: 28rpx; }
  90. .poster-link .arrow { color: #6B7B8C; font-size: 32rpx; margin-left: 8rpx; }
  91. </style>