innate-trajectory.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="trajectory-container" :style="{ '--font-scale': fontScale }">
  3. <view class="loading-state" v-if="loading">
  4. <text>加载中...</text>
  5. </view>
  6. <template v-if="!loading && trajectory">
  7. <view class="section">
  8. <view class="section-title">先天 vs 后天</view>
  9. <view class="compare-row">
  10. <view class="compare-item">
  11. <text class="compare-label">先天心能量</text>
  12. <text class="compare-value">{{ trajectory.innateVsCurrent.mindInnate || 0 }}</text>
  13. </view>
  14. <view class="compare-item">
  15. <text class="compare-label">当前心能量</text>
  16. <text class="compare-value">{{ trajectory.innateVsCurrent.mindCurrent || 0 }}</text>
  17. </view>
  18. <view class="compare-item">
  19. <text class="compare-label">成长</text>
  20. <text class="compare-value" :style="{ color: growthColor }">{{ trajectory.innateVsCurrent.growth || '0' }}</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="section" v-if="hasInnateScores">
  25. <view class="section-title">五维先天基础分</view>
  26. <view class="dim-row" v-for="(score, dim) in trajectory.innateDimensionScores" :key="dim">
  27. <text class="dim-label">{{ dimLabel(dim) }}</text>
  28. <view class="dim-track">
  29. <view class="dim-fill" :style="{ width: score + '%' }"></view>
  30. </view>
  31. <text class="dim-value">{{ score }}</text>
  32. </view>
  33. </view>
  34. <view class="section" v-if="trajectory.growthTrend">
  35. <view class="section-title">成长趋势</view>
  36. <text class="trend-text">{{ trajectory.growthTrend }}</text>
  37. </view>
  38. <view class="section" v-if="trajectory.advice">
  39. <view class="section-title">成长建议</view>
  40. <text class="advice-text">{{ trajectory.advice }}</text>
  41. </view>
  42. </template>
  43. <view class="empty-state" v-if="!loading && !trajectory && loadError">
  44. <text>{{ loadError }}</text>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import { BrandColors } from '../../utils/brand-colors.js'
  50. import { getInnateTrajectory } from '../../utils/api'
  51. import fontScaleMixin from '@/mixins/font-scale.js'
  52. export default {
  53. mixins: [fontScaleMixin],
  54. data() {
  55. return {
  56. memberId: null,
  57. memberType: 'child',
  58. familyId: null,
  59. loading: false,
  60. trajectory: null,
  61. loadError: '',
  62. dimNames: { body: '身', mind: '心', wisdom: '智', action: '行', wealth: '富' }
  63. }
  64. },
  65. computed: {
  66. hasInnateScores() {
  67. return !!this.trajectory && !!this.trajectory.innateDimensionScores
  68. },
  69. growthColor() {
  70. if (!this.trajectory || !this.trajectory.innateVsCurrent) return BrandColors.textMuted
  71. var g = this.trajectory.innateVsCurrent.growth || '0'
  72. if (g.indexOf('-') === 0) return '#f56c6c'
  73. return '#07c160'
  74. }
  75. },
  76. onLoad(options) {
  77. this.memberId = options.memberId ? Number(options.memberId) : null
  78. this.memberType = options.memberType || 'child'
  79. this.familyId = options.familyId ? Number(options.familyId) : null
  80. if (!this.memberId) {
  81. this.loadError = '缺少成员ID'
  82. return
  83. }
  84. this.load()
  85. },
  86. methods: {
  87. load() {
  88. var self = this
  89. self.loading = true
  90. getInnateTrajectory({ memberId: self.memberId, memberType: self.memberType, familyId: self.familyId }).then(function (res) {
  91. self.loading = false
  92. if (res && res.code === 200) {
  93. self.trajectory = res.data
  94. } else {
  95. self.loadError = (res && res.message) || '加载失败'
  96. }
  97. }).catch(function () {
  98. self.loading = false
  99. self.loadError = '网络异常'
  100. })
  101. },
  102. dimLabel(dim) {
  103. return this.dimNames[dim] || dim
  104. }
  105. }
  106. }
  107. </script>
  108. <style scoped>
  109. .trajectory-container {
  110. min-height: 100vh;
  111. background: $facade-fill-warm-tint;
  112. padding-bottom: 60rpx;
  113. }
  114. .loading-state {
  115. display: flex;
  116. align-items: center;
  117. justify-content: center;
  118. padding: 120rpx 0;
  119. color: $facade-text-muted;
  120. font-size: calc(28rpx * var(--font-scale, 1));
  121. }
  122. .section {
  123. margin: 24rpx 32rpx;
  124. background: $app-surface;
  125. border-radius: 24rpx;
  126. padding: 28rpx;
  127. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.04);
  128. }
  129. .section-title {
  130. font-size: calc(30rpx * var(--font-scale, 1));
  131. font-weight: 600;
  132. color: $facade-text-strong;
  133. margin-bottom: 20rpx;
  134. }
  135. .compare-row {
  136. display: flex;
  137. justify-content: space-around;
  138. }
  139. .compare-item {
  140. display: flex;
  141. flex-direction: column;
  142. align-items: center;
  143. }
  144. .compare-label {
  145. font-size: calc(24rpx * var(--font-scale, 1));
  146. color: $facade-text-muted;
  147. margin-bottom: 8rpx;
  148. }
  149. .compare-value {
  150. font-size: calc(48rpx * var(--font-scale, 1));
  151. font-weight: 700;
  152. color: $facade-text-strong;
  153. }
  154. .dim-row {
  155. display: flex;
  156. align-items: center;
  157. margin-bottom: 16rpx;
  158. }
  159. .dim-label {
  160. font-size: calc(28rpx * var(--font-scale, 1));
  161. font-weight: 600;
  162. width: 48rpx;
  163. text-align: center;
  164. }
  165. .dim-track {
  166. flex: 1;
  167. height: 24rpx;
  168. background: $facade-fill;
  169. border-radius: 16rpx;
  170. overflow: hidden;
  171. margin: 0 16rpx;
  172. }
  173. .dim-fill {
  174. height: 100%;
  175. border-radius: 16rpx;
  176. background: linear-gradient(90deg, $dim-mind, $dim-body);
  177. }
  178. .dim-value {
  179. font-size: calc(24rpx * var(--font-scale, 1));
  180. color: $facade-text-body;
  181. width: 60rpx;
  182. text-align: right;
  183. }
  184. .trend-text, .advice-text {
  185. font-size: calc(28rpx * var(--font-scale, 1));
  186. color: $facade-text-deep-2;
  187. line-height: 1.8;
  188. }
  189. .empty-state {
  190. display: flex;
  191. align-items: center;
  192. justify-content: center;
  193. padding: 120rpx 0;
  194. color: $facade-text-muted;
  195. font-size: calc(28rpx * var(--font-scale, 1));
  196. }
  197. </style>