index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="container">
  3. <view v-if="!isLoggedIn" class="login-prompt">
  4. <view class="prompt-icon">👤</view>
  5. <text class="prompt-title">登录浠艾福</text>
  6. <text class="prompt-desc">登录后可查看个人资料</text>
  7. <button class="login-btn" @click="goLogin">登录 / 注册</button>
  8. </view>
  9. <template v-else>
  10. <PageBanner theme="wealth" tagline="个人中心" quote="" />
  11. <!-- 从富页面进入的返回入口 -->
  12. <view v-if="fromWealth" class="back-to-wealth" @click="goToWealth">
  13. <text class="back-arrow">‹</text>
  14. <text class="back-label">返回富页面</text>
  15. </view>
  16. <ProfileHeader @avatar-click="goToEditInfo" />
  17. <ProfileMenu :role="role" @invite-generate="onInviteGenerate" />
  18. </template>
  19. </view>
  20. </template>
  21. <script>
  22. import PageBanner from '../../components/PageBanner.vue'
  23. import ProfileHeader from './components/ProfileHeader.vue'
  24. import ProfileMenu from './components/ProfileMenu.vue'
  25. export default {
  26. components: {
  27. PageBanner,
  28. ProfileHeader,
  29. ProfileMenu
  30. },
  31. data() {
  32. return {
  33. shareData: null,
  34. fromWealth: false
  35. }
  36. },
  37. computed: {
  38. isLoggedIn() {
  39. return !!uni.getStorageSync('token')
  40. },
  41. role() {
  42. return uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
  43. }
  44. },
  45. onLoad(options) {
  46. // 支持 wealth→profile 的跳转来源标识
  47. if (options && options.from === 'wealth') {
  48. this.fromWealth = true
  49. }
  50. },
  51. onShareAppMessage() {
  52. if (this.shareData) {
  53. return {
  54. title: this.shareData.title,
  55. path: this.shareData.path,
  56. imageUrl: '/static/invite-card.png'
  57. }
  58. }
  59. },
  60. methods: {
  61. goToWealth() {
  62. uni.navigateTo({ url: '/pages/wealth/index' })
  63. },
  64. goLogin() {
  65. uni.navigateTo({
  66. url: '/pages/login/login'
  67. })
  68. },
  69. goToEditInfo() {
  70. uni.navigateTo({
  71. url: '/pages/user-edit/user-edit'
  72. })
  73. },
  74. onInviteGenerate(data) {
  75. this.shareData = data
  76. uni.showToast({
  77. title: '点击右上角转发给TA',
  78. icon: 'none'
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style scoped>
  85. .container {
  86. min-height: 100vh;
  87. background: #f5f7fa;
  88. padding-bottom: 120rpx;
  89. }
  90. .login-prompt {
  91. display: flex;
  92. flex-direction: column;
  93. align-items: center;
  94. justify-content: center;
  95. min-height: 80vh;
  96. padding: 60rpx;
  97. }
  98. .prompt-icon {
  99. font-size: 120rpx;
  100. margin-bottom: 30rpx;
  101. width: 160rpx;
  102. height: 160rpx;
  103. line-height: 160rpx;
  104. text-align: center;
  105. background: #f5f5f5;
  106. border-radius: 50%;
  107. }
  108. .prompt-title {
  109. font-size: 36rpx;
  110. font-weight: bold;
  111. color: #333;
  112. margin-bottom: 16rpx;
  113. }
  114. .prompt-desc {
  115. font-size: 26rpx;
  116. color: #999;
  117. text-align: center;
  118. margin-bottom: 40rpx;
  119. }
  120. .login-prompt .login-btn {
  121. width: 60%;
  122. height: 80rpx;
  123. line-height: 80rpx;
  124. background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
  125. color: #fff;
  126. font-size: 30rpx;
  127. font-weight: bold;
  128. border-radius: 40rpx;
  129. text-align: center;
  130. border: none;
  131. }
  132. .login-prompt .login-btn::after {
  133. border: none;
  134. }
  135. /* 从富页面返回入口 */
  136. .back-to-wealth {
  137. display: flex;
  138. align-items: center;
  139. margin: 0 30rpx 20rpx;
  140. padding: 20rpx 24rpx;
  141. background: #fff;
  142. border-radius: 16rpx;
  143. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.05);
  144. }
  145. .back-arrow {
  146. font-size: 40rpx;
  147. color: #F59E0B;
  148. margin-right: 16rpx;
  149. font-weight: bold;
  150. }
  151. .back-label {
  152. font-size: 28rpx;
  153. color: #666;
  154. }
  155. </style>