innate-portrait.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view class="portrait-container">
  3. <view class="loading-state" v-if="loading">
  4. <text>解读生成中...</text>
  5. </view>
  6. <template v-if="!loading && report">
  7. <view class="portrait-header">
  8. <text class="header-score">{{ report.portrait.mindBaseScore || 0 }}</text>
  9. <text class="header-label">心维度先天能量</text>
  10. </view>
  11. <view class="section">
  12. <view class="section-title">先天画像</view>
  13. <view class="bazi-grid" v-if="hasEightChars">
  14. <view class="bazi-column" v-for="(pillar, key) in report.portrait.eightCharacters" :key="key">
  15. <text class="bazi-label">{{ pillarLabel(key) }}</text>
  16. <text class="bazi-value">{{ pillar }}</text>
  17. </view>
  18. </view>
  19. <view class="info-row" v-if="report.portrait.zodiac">
  20. <text class="info-label">生肖</text>
  21. <text class="info-value">{{ report.portrait.zodiac }}</text>
  22. </view>
  23. <view class="info-row" v-if="report.portrait.bloodType">
  24. <text class="info-label">血型</text>
  25. <text class="info-value">{{ report.portrait.bloodType }}</text>
  26. </view>
  27. <view class="info-row" v-if="numSoulData">
  28. <text class="info-label">生命灵数</text>
  29. <text class="info-value">{{ numSoulData.lifePath }} {{ numSoulData.lifePathTitle || '' }}</text>
  30. </view>
  31. </view>
  32. <view class="section" v-if="report.aiReading">
  33. <view class="section-title">
  34. <text>AI 解读</text>
  35. <text class="fallback-tag" v-if="report.fallbackUsed">模板解读</text>
  36. </view>
  37. <text class="reading-text">{{ report.aiReading }}</text>
  38. </view>
  39. <view class="section" v-if="hasWuxing">
  40. <view class="section-title">五行能量</view>
  41. <view class="wuxing-item" v-for="(wv, wk) in report.portrait.wuxingElements" :key="wk">
  42. <text class="wuxing-label">{{ wuxingLabel(wk) }}</text>
  43. <view class="wuxing-track">
  44. <view class="wuxing-fill" :style="{ width: wv + '%', background: wuxingColor(wk) }"></view>
  45. </view>
  46. <text class="wuxing-value">{{ wv }}%</text>
  47. </view>
  48. </view>
  49. <view class="trajectory-entry" @click="goTrajectory">
  50. <text>查看先天+后天成长轨迹</text>
  51. <text class="arrow">›</text>
  52. </view>
  53. </template>
  54. <view class="empty-state" v-if="!loading && !report && loadError">
  55. <text>{{ loadError }}</text>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import { getInnateReading } from '../../utils/api'
  61. export default {
  62. data() {
  63. return {
  64. memberId: null,
  65. memberType: 'child',
  66. familyId: null,
  67. loading: false,
  68. report: null,
  69. loadError: '',
  70. wuxingConfig: {
  71. wood: { label: '木', color: '#10B981' },
  72. fire: { label: '火', color: '#FF6B9D' },
  73. earth: { label: '土', color: '#FF8C42' },
  74. metal: { label: '金', color: '#6366F1' },
  75. water: { label: '水', color: '#3B82F6' }
  76. },
  77. pillarLabels: { year: '年柱', month: '月柱', day: '日柱', hour: '时柱' }
  78. }
  79. },
  80. computed: {
  81. numSoulData() {
  82. if (!this.report || !this.report.portrait || !this.report.portrait.numSoul) return null
  83. return this.report.portrait.numSoul
  84. },
  85. hasEightChars() {
  86. return !!this.report && !!this.report.portrait && !!this.report.portrait.eightCharacters
  87. },
  88. hasWuxing() {
  89. return !!this.report && !!this.report.portrait && !!this.report.portrait.wuxingElements
  90. }
  91. },
  92. onLoad(options) {
  93. this.memberId = options.memberId ? Number(options.memberId) : null
  94. this.memberType = options.memberType || 'child'
  95. this.familyId = options.familyId ? Number(options.familyId) : null
  96. if (!this.memberId) {
  97. this.loadError = '缺少成员ID'
  98. return
  99. }
  100. this.load()
  101. },
  102. methods: {
  103. load() {
  104. var self = this
  105. self.loading = true
  106. getInnateReading({ memberId: self.memberId, memberType: self.memberType, familyId: self.familyId }).then(function (res) {
  107. self.loading = false
  108. if (res && res.code === 200) {
  109. self.report = res.data
  110. } else {
  111. self.loadError = (res && res.message) || '加载失败'
  112. }
  113. }).catch(function () {
  114. self.loading = false
  115. self.loadError = '网络异常'
  116. })
  117. },
  118. pillarLabel(key) {
  119. return this.pillarLabels[key] || key
  120. },
  121. wuxingLabel(key) {
  122. var cfg = this.wuxingConfig[key]
  123. return cfg ? cfg.label : key
  124. },
  125. wuxingColor(key) {
  126. var cfg = this.wuxingConfig[key]
  127. return cfg ? cfg.color : '#ccc'
  128. },
  129. goTrajectory() {
  130. uni.navigateTo({
  131. url: '/pages/mind-detail/innate-trajectory?memberId=' + this.memberId + '&memberType=' + this.memberType + '&familyId=' + (this.familyId || '')
  132. })
  133. }
  134. }
  135. }
  136. </script>
  137. <style scoped>
  138. .portrait-container {
  139. min-height: 100vh;
  140. background: #F8F6F0;
  141. padding-bottom: 60rpx;
  142. }
  143. .loading-state {
  144. display: flex;
  145. align-items: center;
  146. justify-content: center;
  147. padding: 120rpx 0;
  148. color: #999;
  149. font-size: 28rpx;
  150. }
  151. .portrait-header {
  152. display: flex;
  153. flex-direction: column;
  154. align-items: center;
  155. padding: 60rpx 32rpx 40rpx;
  156. background: linear-gradient(135deg, #FF6B9D 0%, #FF8C42 100%);
  157. }
  158. .header-score {
  159. font-size: 96rpx;
  160. font-weight: 700;
  161. color: #fff;
  162. line-height: 1.1;
  163. }
  164. .header-label {
  165. font-size: 28rpx;
  166. color: rgba(255,255,255,0.9);
  167. margin-top: 8rpx;
  168. }
  169. .section {
  170. margin: 24rpx 32rpx;
  171. background: #fff;
  172. border-radius: 20rpx;
  173. padding: 28rpx;
  174. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.04);
  175. }
  176. .section-title {
  177. font-size: 30rpx;
  178. font-weight: 600;
  179. color: #333;
  180. margin-bottom: 20rpx;
  181. display: flex;
  182. align-items: center;
  183. }
  184. .fallback-tag {
  185. font-size: 20rpx;
  186. color: #999;
  187. background: #F0F0F0;
  188. border-radius: 8rpx;
  189. padding: 4rpx 12rpx;
  190. margin-left: 16rpx;
  191. }
  192. .bazi-grid {
  193. display: flex;
  194. justify-content: space-around;
  195. padding: 16rpx 0;
  196. }
  197. .bazi-column {
  198. display: flex;
  199. flex-direction: column;
  200. align-items: center;
  201. }
  202. .bazi-label {
  203. font-size: 22rpx;
  204. color: #999;
  205. margin-bottom: 8rpx;
  206. }
  207. .bazi-value {
  208. font-size: 36rpx;
  209. font-weight: 700;
  210. color: #8B5CF6;
  211. background: #F5F0FF;
  212. padding: 12rpx 16rpx;
  213. border-radius: 12rpx;
  214. }
  215. .info-row {
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. padding: 16rpx 0;
  220. border-bottom: 1rpx solid #F5F5F5;
  221. }
  222. .info-row:last-child {
  223. border-bottom: none;
  224. }
  225. .info-label {
  226. font-size: 28rpx;
  227. color: #999;
  228. }
  229. .info-value {
  230. font-size: 28rpx;
  231. color: #333;
  232. font-weight: 500;
  233. }
  234. .reading-text {
  235. font-size: 28rpx;
  236. color: #444;
  237. line-height: 1.8;
  238. }
  239. .wuxing-item {
  240. display: flex;
  241. align-items: center;
  242. margin-bottom: 16rpx;
  243. }
  244. .wuxing-label {
  245. font-size: 28rpx;
  246. font-weight: 600;
  247. width: 48rpx;
  248. text-align: center;
  249. }
  250. .wuxing-track {
  251. flex: 1;
  252. height: 24rpx;
  253. background: #F0F0F0;
  254. border-radius: 12rpx;
  255. overflow: hidden;
  256. margin: 0 16rpx;
  257. }
  258. .wuxing-fill {
  259. height: 100%;
  260. border-radius: 12rpx;
  261. }
  262. .wuxing-value {
  263. font-size: 24rpx;
  264. color: #666;
  265. width: 60rpx;
  266. text-align: right;
  267. }
  268. .trajectory-entry {
  269. margin: 24rpx 32rpx;
  270. background: #fff;
  271. border-radius: 20rpx;
  272. padding: 28rpx;
  273. display: flex;
  274. align-items: center;
  275. justify-content: space-between;
  276. color: #FF6B9D;
  277. font-size: 28rpx;
  278. font-weight: 500;
  279. }
  280. .arrow {
  281. font-size: 36rpx;
  282. }
  283. .empty-state {
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. padding: 120rpx 0;
  288. color: #999;
  289. font-size: 28rpx;
  290. }
  291. </style>