index.vue 3.3 KB

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