profile.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="container">
  3. <!-- Tabbar 切换过渡页 -->
  4. <tab-transition v-if="showTabTransition" dimCode="wealth" />
  5. <!-- ===== 未登录状态 ===== -->
  6. <view v-if="!isLoggedIn" class="login-prompt">
  7. <view class="prompt-icon">👤</view>
  8. <text class="prompt-title">登录浠艾福</text>
  9. <text class="prompt-desc">登录后可查看个人资料、积分记录等</text>
  10. <button class="login-btn" @click="goLogin">登录 / 注册</button>
  11. </view>
  12. <!-- ===== 已登录状态 ===== -->
  13. <template v-else>
  14. <!-- 品牌头部 -->
  15. <PageBanner theme="wealth" tagline="丰盈内心,富足生活,厚德载物" quote="" />
  16. <!-- 用户卡片 + 富沛能量 + 切换 -->
  17. <ProfileHeader />
  18. <!-- 行动数据 + 财富数据 -->
  19. <ProfileStats />
  20. <!-- 成就徽章 -->
  21. <ProfileBadges />
  22. <!-- 成长报告 -->
  23. <ProfileGrowth />
  24. <!-- 菜单列表 -->
  25. <ProfileMenu :role="role" @invite-generate="onInviteGenerate" />
  26. </template>
  27. </view>
  28. </template>
  29. <script>
  30. import TabTransition from '../../components/tab-transition.vue'
  31. import PageBanner from '../../components/PageBanner.vue'
  32. import ProfileHeader from './components/ProfileHeader.vue'
  33. import ProfileStats from './components/ProfileStats.vue'
  34. import ProfileBadges from './components/ProfileBadges.vue'
  35. import ProfileGrowth from './components/ProfileGrowth.vue'
  36. import ProfileMenu from './components/ProfileMenu.vue'
  37. export default {
  38. components: {
  39. TabTransition,
  40. PageBanner,
  41. ProfileHeader,
  42. ProfileStats,
  43. ProfileBadges,
  44. ProfileGrowth,
  45. ProfileMenu
  46. },
  47. data() {
  48. return {
  49. shareData: null,
  50. showTabTransition: false
  51. }
  52. },
  53. computed: {
  54. isLoggedIn() {
  55. return !!uni.getStorageSync('token')
  56. },
  57. role() {
  58. return uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
  59. }
  60. },
  61. onShareAppMessage() {
  62. if (this.shareData) {
  63. return {
  64. title: this.shareData.title,
  65. path: this.shareData.path,
  66. imageUrl: '/static/invite-card.png'
  67. }
  68. }
  69. },
  70. onShow() {
  71. // Tabbar 切换过渡动画(最少停留 1 秒)
  72. this.showTabTransition = true
  73. var self = this
  74. setTimeout(function() {
  75. self.showTabTransition = false
  76. }, 1100)
  77. if (!uni.getStorageSync('token')) return
  78. const currentRole = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
  79. if (currentRole === 'teacher') {
  80. uni.redirectTo({ url: '/pages/teacher/teacher-profile' })
  81. }
  82. },
  83. methods: {
  84. goLogin() {
  85. uni.navigateTo({ url: '/pages/login/login' })
  86. },
  87. onInviteGenerate(shareData) {
  88. this.shareData = shareData
  89. }
  90. }
  91. }
  92. </script>
  93. <style scoped>
  94. .container {
  95. min-height: 100vh;
  96. background: #f5f7fa;
  97. padding-bottom: 120rpx;
  98. }
  99. .login-prompt {
  100. display: flex;
  101. flex-direction: column;
  102. align-items: center;
  103. justify-content: center;
  104. padding: 200rpx 60rpx;
  105. }
  106. .prompt-icon { font-size: 100rpx; margin-bottom: 30rpx; }
  107. .prompt-title { font-size: 40rpx; font-weight: bold; color: #333; margin-bottom: 16rpx; }
  108. .prompt-desc { font-size: 26rpx; color: #999; margin-bottom: 60rpx; }
  109. .login-btn {
  110. width: 80%;
  111. background: linear-gradient(135deg, #667eea, #764ba2);
  112. color: #fff;
  113. border-radius: 50rpx;
  114. font-size: 30rpx;
  115. padding: 24rpx;
  116. line-height: 1.5;
  117. }
  118. </style>