stats.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view class="stats-page">
  3. <view class="stat-card">
  4. <view class="stat-row">
  5. <view class="stat-item">
  6. <text class="stat-num">{{ stats.invited }}</text>
  7. <text class="stat-label">邀请人数</text>
  8. </view>
  9. <view class="stat-item">
  10. <text class="stat-num">{{ stats.paid }}</text>
  11. <text class="stat-label">成功付费</text>
  12. </view>
  13. <view class="stat-item">
  14. <text class="stat-num">{{ stats.rewards }}</text>
  15. <text class="stat-label">已获奖励</text>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="tip-card">
  20. <text class="tip-title">如何获得奖励?</text>
  21. <text class="tip-desc">1. 在我的海报页复制专属邀请码</text>
  22. <text class="tip-desc">2. 把海报/邀请码分享给朋友</text>
  23. <text class="tip-desc">3. 朋友报名时填写邀请码并完成付费</text>
  24. <text class="tip-desc">4. 你将自动获得一张训练营积分</text>
  25. </view>
  26. <view class="poster-link" @click="goPoster">
  27. <text>去生成我的专属海报</text>
  28. <text class="arrow">›</text>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { getInviteStats } from '@/utils/api.js'
  34. import { guardPage } from '@/utils/guard.js'
  35. export default {
  36. data() {
  37. return {
  38. stats: { invited: 0, paid: 0, rewards: 0 }
  39. }
  40. },
  41. onShow() {
  42. if (!guardPage()) return
  43. this.loadStats()
  44. },
  45. methods: {
  46. loadStats() {
  47. var self = this
  48. getInviteStats().then(function(resp) {
  49. var data = resp.data || {}
  50. self.stats = {
  51. invited: data.invited || 0,
  52. paid: data.paid || 0,
  53. rewards: data.rewards || 0
  54. }
  55. }).catch(function() {})
  56. },
  57. goPoster() {
  58. uni.navigateBack({})
  59. }
  60. }
  61. }
  62. </script>
  63. <style scoped>
  64. .stats-page { min-height: 100vh; background: #F5F5F5; padding: 24rpx 32rpx; }
  65. .stat-card { background: #FFF; border-radius: 16rpx; padding: 40rpx 24rpx; margin-bottom: 24rpx; }
  66. .stat-row { display: flex; justify-content: space-around; }
  67. .stat-item { display: flex; flex-direction: column; align-items: center; flex: 1; }
  68. .stat-num { font-size: 56rpx; font-weight: 700; color: #F97316; }
  69. .stat-label { font-size: 26rpx; color: #64748B; margin-top: 12rpx; }
  70. .tip-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; margin-bottom: 24rpx; }
  71. .tip-title { display: block; font-size: 30rpx; font-weight: 700; color: #1E293B; margin-bottom: 16rpx; border-left: 8rpx solid #F97316; padding-left: 16rpx; }
  72. .tip-desc { display: block; font-size: 26rpx; color: #475569; line-height: 48rpx; }
  73. .poster-link { display: flex; align-items: center; justify-content: center; padding: 32rpx 0; color: #64748B; font-size: 28rpx; }
  74. .poster-link .arrow { color: #94A3B8; font-size: 32rpx; margin-left: 8rpx; }
  75. </style>