member-detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <view class="member-detail-container">
  3. <!-- 自定义导航栏 -->
  4. <view class="custom-nav">
  5. <view class="nav-back" @click="goBack">‹ 返回</view>
  6. </view>
  7. <!-- 加载状态 -->
  8. <view class="loading-state" v-if="loading">
  9. <view class="loading-spinner"></view>
  10. <text>加载中...</text>
  11. </view>
  12. <!-- 错误状态 -->
  13. <view class="error-state" v-if="error && !loading">
  14. <text>{{ error }}</text>
  15. <button class="retry-btn" @click="loadData">重试</button>
  16. </view>
  17. <!-- 详情内容 -->
  18. <view class="detail-content" v-if="member && !loading">
  19. <!-- 基本信息卡片 -->
  20. <view class="info-card">
  21. <view class="member-header">
  22. <view class="avatar" :style="{ backgroundColor: memberColor }">
  23. <text class="avatar-text">{{ member.nickname ? member.nickname.charAt(0) : 'M' }}</text>
  24. </view>
  25. <view class="member-info">
  26. <text class="member-name">{{ member.nickname || member.name }}</text>
  27. <text class="member-role">{{ getRoleText(member.effectiveRole) }}</text>
  28. </view>
  29. </view>
  30. <view class="info-grid">
  31. <view class="info-item">
  32. <text class="info-label">生肖</text>
  33. <text class="info-value">{{ member.zodiac || '-' }}</text>
  34. </view>
  35. <view class="info-item">
  36. <text class="info-label">星座</text>
  37. <text class="info-value">{{ member.westernSign || '-' }}</text>
  38. </view>
  39. <view class="info-item">
  40. <text class="info-label">血型</text>
  41. <text class="info-value">{{ member.bloodType || '-' }}</text>
  42. </view>
  43. <view class="info-item">
  44. <text class="info-label">代际</text>
  45. <text class="info-value">{{ member.generation || '-' }}</text>
  46. </view>
  47. <view class="info-item">
  48. <text class="info-label">生命数字</text>
  49. <text class="info-value">{{ member.lifeNumber || '-' }}</text>
  50. </view>
  51. <view class="info-item">
  52. <text class="info-label">五行属性</text>
  53. <text class="info-value">{{ member.wuxing || '-' }}</text>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 五维能量卡片 -->
  58. <view class="energy-card">
  59. <view class="card-header">
  60. <text class="card-title">五维能量</text>
  61. </view>
  62. <view class="energy-bars">
  63. <view class="energy-bar-item" v-for="energy in memberEnergy" :key="energy.type">
  64. <view class="energy-info">
  65. <text class="energy-label">{{ energy.label }}</text>
  66. <text class="energy-desc">{{ energy.description }}</text>
  67. </view>
  68. <view class="energy-bar">
  69. <view class="energy-fill" :style="{ width: energy.value + '%', backgroundColor: energy.color }"></view>
  70. </view>
  71. <text class="energy-value">{{ energy.value }}</text>
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 关系质量卡片 -->
  76. <view class="relationship-card" v-if="relationships && relationships.length > 0">
  77. <view class="card-header">
  78. <text class="card-title">关系质量</text>
  79. </view>
  80. <view class="relationship-list">
  81. <view class="relationship-item" v-for="rel in relationships" :key="rel.toMemberId">
  82. <view class="rel-member">
  83. <text class="rel-name">{{ rel.toMemberName }}</text>
  84. <text class="rel-role">{{ getRoleText(rel.toMemberRole) }}</text>
  85. </view>
  86. <view class="rel-score">
  87. <text class="score-value" :class="!rel.score ? '' : (rel.score >= 80 ? 'score-good' : (rel.score >= 60 ? 'score-medium' : 'score-low'))">{{ rel.score }}</text>
  88. <text class="score-label">分</text>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 操作按钮 -->
  94. <view class="action-buttons">
  95. <button class="action-btn primary" @click="viewAnnualEnergy">查看年度能量</button>
  96. <button class="action-btn secondary" @click="viewCompatibility">查看兼容性分析</button>
  97. </view>
  98. </view>
  99. </view>
  100. </template>
  101. <script>
  102. import { mapActions } from 'vuex'
  103. export default {
  104. data: function() {
  105. return {
  106. memberId: '',
  107. member: null,
  108. relationships: [],
  109. loading: false,
  110. error: null
  111. }
  112. },
  113. computed: {
  114. memberColor: function() {
  115. if (!this.member || !this.member.effectiveRole) {
  116. return '#6B7280'
  117. }
  118. var colorMap = {
  119. 'parent': '#F97316',
  120. 'child': '#3B82F6',
  121. 'teacher': '#8B5CF6'
  122. }
  123. return colorMap[this.member.effectiveRole] || '#6B7280'
  124. },
  125. memberEnergy: function() {
  126. if (!this.member || !this.member.energy) {
  127. return []
  128. }
  129. var energyMap = {
  130. 'body': { label: '身', description: '身体健康', color: '#10B981' },
  131. 'mind': { label: '心', description: '心理健康', color: '#F59E0B' },
  132. 'wisdom': { label: '智', description: '智慧成长', color: '#3B82F6' },
  133. 'action': { label: '行', description: '行动力', color: '#8B5CF6' },
  134. 'wealth': { label: '富', description: '财富能量', color: '#F97316' }
  135. }
  136. var result = []
  137. for (var key in this.member.energy) {
  138. var energy = this.member.energy[key]
  139. var info = energyMap[key] || { label: key, description: '', color: '#6B7280' }
  140. result.push({
  141. type: key,
  142. label: info.label,
  143. description: info.description,
  144. value: energy,
  145. color: info.color
  146. })
  147. }
  148. return result
  149. }
  150. },
  151. onLoad: function(options) {
  152. if (options && options.id) {
  153. this.memberId = options.id
  154. this.loadData()
  155. }
  156. },
  157. methods: {
  158. ...mapActions('tianpan', ['loadMemberDetail']),
  159. loadData: function() {
  160. this.loading = true
  161. this.error = null
  162. this.loadMemberDetail({ memberId: this.memberId })
  163. .then(this.setMemberData)
  164. .catch(this.handleError)
  165. .finally(function() {
  166. this.loading = false
  167. }.bind(this))
  168. },
  169. setMemberData: function(data) {
  170. if (data) {
  171. this.member = data
  172. if (data.relationships) {
  173. this.relationships = data.relationships
  174. }
  175. }
  176. },
  177. handleError: function(e) {
  178. this.error = e.message || '加载失败'
  179. },
  180. getRoleText: function(role) {
  181. var roleMap = {
  182. 'parent': '家长',
  183. 'child': '孩子',
  184. 'teacher': '规划师'
  185. }
  186. return roleMap[role] || role
  187. },
  188. getScoreClass: function(score) {
  189. if (!score) {
  190. return ''
  191. }
  192. if (score >= 80) {
  193. return 'score-good'
  194. } else if (score >= 60) {
  195. return 'score-medium'
  196. } else {
  197. return 'score-low'
  198. }
  199. },
  200. goBack: function() {
  201. uni.navigateBack()
  202. },
  203. viewAnnualEnergy: function() {
  204. uni.navigateTo({
  205. url: '/pages/tianpan/annual-energy?memberId=' + this.memberId
  206. })
  207. },
  208. viewCompatibility: function() {
  209. uni.navigateTo({
  210. url: '/pages/tianpan/relation-detail?memberId=' + this.memberId
  211. })
  212. }
  213. }
  214. }
  215. </script>
  216. <style>
  217. .member-detail-container {
  218. min-height: 100vh;
  219. background: #F9FAFB;
  220. padding-bottom: 20px;
  221. }
  222. .custom-nav {
  223. background: linear-gradient(135deg, #F97316 0%, #FB923C 100%);
  224. padding: 44px 16px 16px;
  225. display: flex;
  226. align-items: center;
  227. }
  228. .loading-state, .error-state {
  229. display: flex;
  230. flex-direction: column;
  231. justify-content: center;
  232. align-items: center;
  233. padding: 80px 20px;
  234. text-align: center;
  235. }
  236. .loading-spinner {
  237. width: 40px;
  238. height: 40px;
  239. border: 4px solid #E5E7EB;
  240. border-top-color: #F97316;
  241. border-radius: 50%;
  242. animation: spin 1s linear infinite;
  243. margin-bottom: 16px;
  244. }
  245. @keyframes spin {
  246. to {
  247. transform: rotate(360deg);
  248. }
  249. }
  250. .retry-btn {
  251. margin-top: 16px;
  252. background: #F97316;
  253. color: #FFFFFF;
  254. border: none;
  255. padding: 10px 32px;
  256. border-radius: 20px;
  257. font-size: 14px;
  258. }
  259. .detail-content {
  260. padding: 16px;
  261. }
  262. .info-card {
  263. background: #FFFFFF;
  264. border-radius: 16px;
  265. padding: 20px;
  266. margin-bottom: 16px;
  267. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  268. }
  269. .member-header {
  270. display: flex;
  271. align-items: center;
  272. margin-bottom: 20px;
  273. }
  274. .avatar {
  275. width: 64px;
  276. height: 64px;
  277. border-radius: 50%;
  278. display: flex;
  279. justify-content: center;
  280. align-items: center;
  281. margin-right: 16px;
  282. }
  283. .avatar-text {
  284. color: #FFFFFF;
  285. font-size: 28px;
  286. font-weight: bold;
  287. }
  288. .member-info {
  289. flex: 1;
  290. }
  291. .member-name {
  292. font-size: 20px;
  293. font-weight: bold;
  294. color: #1F2937;
  295. display: block;
  296. margin-bottom: 4px;
  297. }
  298. .member-role {
  299. font-size: 14px;
  300. color: #6B7280;
  301. }
  302. .info-grid {
  303. display: flex;
  304. flex-wrap: wrap;
  305. }
  306. .info-item {
  307. width: 50%;
  308. padding: 12px 0;
  309. border-bottom: 1px solid #F3F4F6;
  310. }
  311. .info-item:nth-child(2n) {
  312. border-right: none;
  313. }
  314. .info-label {
  315. display: block;
  316. font-size: 12px;
  317. color: #9CA3AF;
  318. margin-bottom: 4px;
  319. }
  320. .info-value {
  321. display: block;
  322. font-size: 14px;
  323. color: #1F2937;
  324. font-weight: 500;
  325. }
  326. .energy-card, .relationship-card {
  327. background: #FFFFFF;
  328. border-radius: 16px;
  329. padding: 20px;
  330. margin-bottom: 16px;
  331. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  332. }
  333. .card-header {
  334. margin-bottom: 16px;
  335. }
  336. .card-title {
  337. font-size: 18px;
  338. font-weight: bold;
  339. color: #1F2937;
  340. }
  341. .energy-bars {
  342. margin-top: 16px;
  343. }
  344. .energy-bar-item {
  345. display: flex;
  346. align-items: center;
  347. margin-bottom: 16px;
  348. }
  349. .energy-info {
  350. width: 80px;
  351. }
  352. .energy-label {
  353. display: block;
  354. font-size: 14px;
  355. font-weight: 500;
  356. color: #1F2937;
  357. }
  358. .energy-desc {
  359. display: block;
  360. font-size: 12px;
  361. color: #9CA3AF;
  362. margin-top: 2px;
  363. }
  364. .energy-bar {
  365. flex: 1;
  366. height: 10px;
  367. background: #E5E7EB;
  368. border-radius: 5px;
  369. margin: 0 12px;
  370. overflow: hidden;
  371. }
  372. .energy-fill {
  373. height: 100%;
  374. border-radius: 5px;
  375. transition: width 0.3s ease;
  376. }
  377. .energy-value {
  378. width: 36px;
  379. text-align: right;
  380. font-size: 14px;
  381. font-weight: bold;
  382. color: #1F2937;
  383. }
  384. .relationship-list {
  385. margin-top: 16px;
  386. }
  387. .relationship-item {
  388. display: flex;
  389. justify-content: space-between;
  390. align-items: center;
  391. padding: 12px 0;
  392. border-bottom: 1px solid #F3F4F6;
  393. }
  394. .relationship-item:last-child {
  395. border-bottom: none;
  396. }
  397. .rel-member {
  398. flex: 1;
  399. }
  400. .rel-name {
  401. display: block;
  402. font-size: 14px;
  403. font-weight: 500;
  404. color: #1F2937;
  405. }
  406. .rel-role {
  407. display: block;
  408. font-size: 12px;
  409. color: #9CA3AF;
  410. margin-top: 2px;
  411. }
  412. .rel-score {
  413. display: flex;
  414. align-items: baseline;
  415. }
  416. .score-value {
  417. font-size: 24px;
  418. font-weight: bold;
  419. }
  420. .score-label {
  421. font-size: 12px;
  422. color: #9CA3AF;
  423. margin-left: 2px;
  424. }
  425. .score-good {
  426. color: #10B981;
  427. }
  428. .score-medium {
  429. color: #F59E0B;
  430. }
  431. .score-low {
  432. color: #EF4444;
  433. }
  434. .action-buttons {
  435. display: flex;
  436. flex-direction: column;
  437. gap: 12px;
  438. padding: 16px;
  439. }
  440. .action-btn {
  441. padding: 14px 24px;
  442. border-radius: 12px;
  443. font-size: 16px;
  444. border: none;
  445. }
  446. .action-btn.primary {
  447. background: linear-gradient(135deg, #F97316 0%, #FB923C 100%);
  448. color: #FFFFFF;
  449. }
  450. .action-btn.secondary {
  451. background: #FFFFFF;
  452. color: #F97316;
  453. border: 2px solid #F97316;
  454. }
  455. </style>