member-detail.vue 11 KB

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