index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  1. <template>
  2. <view class="container">
  3. <!-- Tabbar 切换过渡页 -->
  4. <tab-transition v-if="showTabTransition" dimCode="action" ref="tabTransition" @close="showTabTransition = false" />
  5. <!-- 品牌头部 -->
  6. <PageBanner theme="action"
  7. tagline="人际和谐 · 关系滋养"
  8. quote="和谐关系滋养幸福家庭" />
  9. <!-- 品牌定位语(登录前显示) -->
  10. <view class="brand-strap" v-if="!isLoggedIn">
  11. <text class="brand-strap-text">改善全家关系与沟通能力</text>
  12. </view>
  13. <!-- 家庭成员选择条 -->
  14. <FamilyMemberStrip
  15. v-if="currentView === 'self' && isLoggedIn"
  16. :members="familyMembersVisible"
  17. :selectedMemberId="selectedMemberId"
  18. @select="onFamilyMemberSelect"
  19. @removed="loadFamilyMembersVisible" />
  20. <!-- 游客引导语(每月更换) -->
  21. <view class="monthly-guidance" v-if="!isLoggedIn">
  22. <text class="guidance-icon">🌿</text>
  23. <text class="guidance-text">{{ monthlyGuidance }}</text>
  24. </view>
  25. <!-- 登录后:五维能量条 -->
  26. <FamilyEnergyBar
  27. v-if="isLoggedIn"
  28. dimensionCode="action"
  29. :sandboxData="sandboxData"
  30. :dualDimension="dualDimension" />
  31. <!-- 关系解读 -->
  32. <view class="section score-explain-card" v-if="isLoggedIn && currentView === 'self' && actionScore != null">
  33. <view class="explain-header">
  34. <text class="explain-icon">{{ actionScore >= 80 ? '✅' : actionScore >= 60 ? '⚠️' : '❗' }}</text>
  35. <text class="explain-title">关系解读</text>
  36. </view>
  37. <text class="explain-text">{{ actionScore >= 80 ? '家庭关系和谐,家人沟通顺畅。' : actionScore >= 60 ? '家庭关系一般,建议多花时间陪伴家人。' : '家庭关系需要改善,建议进行家庭沟通活动。' }}</text>
  38. </view>
  39. <!-- 关系六维 -->
  40. <dimension-sub-dims
  41. v-if="isLoggedIn && actionSubDims.length > 0"
  42. title="🌲 关系六维"
  43. subtitle="家庭关系的六个方面"
  44. accent-color="#10B981"
  45. :dims="actionSubDims" />
  46. <!-- 登录后:家庭关系(行维度核心) -->
  47. <view class="section" v-if="isLoggedIn">
  48. <view class="section-header">
  49. <view class="section-title-wrap">
  50. <text class="help-icon" @tap="showHelp('家庭关系', '了解每位家人的关系质量,改善沟通方式。点击家人节点,查看关系详情。')">?</text>
  51. <text class="section-title">家庭关系</text>
  52. </view>
  53. <text class="section-sub">了解每位家人的关系质量,改善沟通方式</text>
  54. <text class="section-sub">点击家人节点,查看关系详情</text>
  55. </view>
  56. <FamilyRelationGraph
  57. dimensionCode="action"
  58. :selfId="selfId"
  59. :members="graphMembers"
  60. :energyMap="energyMapForGraph"
  61. :intimacyMap="intimacyMapForGraph"
  62. :interactive="true" />
  63. </view>
  64. <!-- 登录后:章鱼图(关键人拓展) -->
  65. <view class="section" v-if="isLoggedIn">
  66. <view class="section-header">
  67. <view class="section-title-wrap">
  68. <text class="help-icon" @tap="showHelp('章鱼图', '从成效出发,挖掘关键人,画出拓展路径。记录感恩时刻,建立有温度的人脉网络。')">?</text>
  69. <view>
  70. <text class="section-title">🐙 章鱼图</text>
  71. <text class="section-sub">从成效出发,挖掘关键人,画出拓展路径</text>
  72. </view>
  73. </view>
  74. <text class="section-link section-link-octopus" @tap="goOctopusEffectsList">+ 感恩记录</text>
  75. </view>
  76. <OctopusDiagram
  77. ref="octopusDiagram"
  78. :selfId="selfId"
  79. :effects="octopusEffects"
  80. :expansions="octopusExpansions"
  81. :interactive="true"
  82. @effect-click="onEffectClick"
  83. @expansion-click="onExpansionClick"
  84. @add-effect="goOctopusAddEffect"
  85. @reanalyze="onReanalyze" />
  86. </view>
  87. <!-- 登录后:珍珠图(我有什么) -->
  88. <view class="section" v-if="isLoggedIn">
  89. <view class="section-header">
  90. <view class="section-title-wrap">
  91. <text class="help-icon" @tap="showHelp('珍珠图', '把可调用的资源串成珍珠项链——盘点我有什么。登记人脉、资源、信息缺口,画出一条清晰的成长珍珠链。')">?</text>
  92. <view>
  93. <text class="section-title">🫧 珍珠图</text>
  94. <text class="section-sub">把可调用的资源串成珍珠项链——盘点我有什么</text>
  95. </view>
  96. </view>
  97. <text class="section-link section-link-pearl" @tap="goPearlAddResource">+ 登记</text>
  98. </view>
  99. <PearlDiagram
  100. ref="pearlDiagram"
  101. :selfId="selfId"
  102. :resources="pearlData"
  103. :overdue-map="overdueMap"
  104. :interactive="true"
  105. @add="goPearlAddResource"
  106. @delete="onDeletePearlResource" />
  107. </view>
  108. <!-- 登录后:能力图(谁会什么) -->
  109. <view class="section" v-if="isLoggedIn">
  110. <view class="section-header">
  111. <view class="section-title-wrap">
  112. <text class="help-icon" @tap="showHelp('能力图', '身边藏着什么技能——谁有能力帮到你。记录技能类帮助后,这里会画出大家的能力图谱。')">?</text>
  113. <view>
  114. <text class="section-title">💡 能力图</text>
  115. <text class="section-sub">身边藏着什么技能——谁有能力帮到你</text>
  116. </view>
  117. </view>
  118. <text class="section-link section-link-ability" @tap="goInteractionLog">+ 记录帮助</text>
  119. </view>
  120. <AbilityDiagram
  121. ref="abilityDiagram"
  122. :selfId="selfId"
  123. :abilities="abilityData"
  124. :interactive="true" />
  125. </view>
  126. <!-- 行6维关系域雷达图(登录后) -->
  127. <view class="section" v-if="isLoggedIn && currentMemberEnergies">
  128. <view class="section-header">
  129. <text class="section-title">🫂 关系质量</text>
  130. </view>
  131. <RadarChart
  132. :dimensions="actionDimensions"
  133. :scores="actionScores"
  134. :avg-scores="actionFamilyScores"
  135. :population-scores="actionPopulationScores"
  136. fillColor="#10B981"
  137. gridColor="#D1FAE5"
  138. labelColor="#065F46"
  139. :width="580"
  140. :height="580" />
  141. </view>
  142. <!-- 功能入口 -->
  143. <view class="func-section" v-if="sectionVisible('func_entries')">
  144. <view class="func-grid">
  145. <view class="func-item" v-for="item in funcList" :key="item.label" @click="onFuncClick(item)">
  146. <view class="func-icon-wrap">
  147. <text class="func-icon">{{ item.icon }}</text>
  148. </view>
  149. <text class="func-label">{{ item.label }}</text>
  150. </view>
  151. </view>
  152. </view>
  153. <!-- 登录后:今日任务 -->
  154. <DimensionTasks
  155. v-if="isLoggedIn"
  156. :memberId="activeChildId"
  157. @taskClick="onTaskClick"
  158. @moreTasks="goTasks" />
  159. <!-- 登录后:活动 -->
  160. <DimensionActivities
  161. v-if="isLoggedIn"
  162. :isLoggedIn="true"
  163. @activityClick="goActivityDetail"
  164. @moreActivities="goMoreActivities" />
  165. <!-- 登录后:商品 -->
  166. <DimensionProducts
  167. v-if="isLoggedIn"
  168. :isLoggedIn="true"
  169. @productClick="goProductDetail"
  170. @moreProducts="goMoreProducts" />
  171. <!-- 行维度介绍卡片(登录后显示) -->
  172. <DimensionIntroCard dimCode="action" v-if="isLoggedIn" learn-more-url="/pages/action-detail/dimension-intro" />
  173. <!-- 底部占位 -->
  174. <view class="bottom-spacer"></view>
  175. <FloatingAvatar />
  176. <!-- 帮助说明弹窗 -->
  177. <view class="help-mask" v-if="helpPopup.visible" @tap="closeHelp">
  178. <view class="help-dialog" @tap.stop>
  179. <view class="help-dialog-header">
  180. <text class="help-dialog-title">{{ helpPopup.title }}</text>
  181. <text class="help-dialog-close" @tap="closeHelp">✕</text>
  182. </view>
  183. <text class="help-dialog-content">{{ helpPopup.content }}</text>
  184. </view>
  185. </view>
  186. </view>
  187. </template>
  188. <script>
  189. import TabTransition from '../../components/tab-transition.vue'
  190. import PageBanner from '../../components/PageBanner.vue'
  191. import FamilyEnergyBar from '../../components/FamilyEnergyBar.vue'
  192. import FamilyRelationGraph from '../../components/FamilyRelationGraph.vue'
  193. import PearlDiagram from '../../components/PearlDiagram.vue'
  194. import AbilityDiagram from '../../components/AbilityDiagram.vue'
  195. import OctopusDiagram from '../../components/OctopusDiagram.vue'
  196. import FamilyMemberStrip from '../../components/FamilyMemberStrip.vue'
  197. import DimensionTasks from '../../components/DimensionTasks.vue'
  198. import DimensionActivities from '../../components/DimensionActivities.vue'
  199. import DimensionProducts from '../../components/DimensionProducts.vue'
  200. import DimensionIntroCard from '../../components/DimensionIntroCard.vue'
  201. import FloatingAvatar from '../../components/AIFloatingAvatar.vue'
  202. import RadarChart from '../../components/RadarChart.vue'
  203. import DimensionSubDims from '../../components/DimensionSubDims.vue'
  204. import { getVisibleSections, getEnergyOverview, getChildren, getFamilyEnergySandbox, getEnergySandbox, getFamilyMemberList, getOctopusTentacles, getPearlResources, deletePearlResource, getAbilityMap, getRadarData, getPearlReminders, getOctopusEffects, getOctopusAnalysisSummary, getOctopusExpansionSuggest, getOctopusEffectKeyPersons } from '../../utils/api.js'
  205. export default {
  206. components: { TabTransition, PageBanner, FamilyEnergyBar, FamilyRelationGraph, PearlDiagram, AbilityDiagram, OctopusDiagram, FamilyMemberStrip, DimensionTasks, DimensionActivities, DimensionProducts, DimensionIntroCard, FloatingAvatar, RadarChart, DimensionSubDims },
  207. data() {
  208. return {
  209. isLoggedIn: false,
  210. role: null,
  211. showTabTransition: true,
  212. activeChildId: null,
  213. selectedMemberId: null,
  214. activeChildName: '',
  215. userName: '',
  216. children: [],
  217. familyMembersVisible: [],
  218. childrenChecked: false,
  219. membersChecked: false,
  220. actionSubDims: [],
  221. sandboxData: null,
  222. actionPopulationScoreMap: {},
  223. currentView: 'self', // 'self' | 'family'
  224. dualDimension: null,
  225. selfId: null,
  226. visibleSections: [],
  227. pearlData: null,
  228. abilityData: null,
  229. octopusEffects: null,
  230. octopusExpansions: [],
  231. octopusKeyPersons: {},
  232. overdueMap: null,
  233. // 帮助弹窗
  234. helpPopup: { visible: false, title: '', content: '' },
  235. funcList: [
  236. { icon: '\u{1F4AC}', label: '记录互动', needLogin: true, page: '/pages/action-detail/interaction-log' },
  237. { icon: '\u{1F4DD}', label: '关系问卷', needLogin: true, page: '/pages/action-detail/relationship-questionnaire' },
  238. { icon: '\u{1F465}', label: '家庭成员', needLogin: true, page: '/pages/profile-extra/family-members' },
  239. { icon: '\u{1F4CB}', label: '任务中心', needLogin: true, page: '/pages/tasks/tasks' }
  240. ]
  241. }
  242. },
  243. computed: {
  244. /** 关系图谱:成员节点(来自沙盘数据) */
  245. graphMembers: function() {
  246. if (!this.sandboxData || !this.sandboxData.members) return []
  247. return this.sandboxData.members.map(function(m) {
  248. return {
  249. id: m.memberId || m.id,
  250. nickname: m.name || m.nickname || '成员',
  251. memberType: m.memberType || 'child'
  252. }
  253. })
  254. },
  255. /** 关系图谱:节点能量映射 */
  256. energyMapForGraph: function() {
  257. var map = {}
  258. if (this.sandboxData && this.sandboxData.members) {
  259. for (var i = 0; i < this.sandboxData.members.length; i++) {
  260. var m = this.sandboxData.members[i]
  261. map[m.memberId || m.id] = {
  262. bodyScore: m.bodyScore || 0,
  263. mindScore: m.mindScore || 0,
  264. actionScore: m.actionScore || 0
  265. }
  266. }
  267. }
  268. return map
  269. },
  270. intimacyMapForGraph: function() {
  271. return {}
  272. },
  273. /** 每月引导语 */
  274. monthlyGuidance: function() {
  275. var month = new Date().getMonth()
  276. var messages = [
  277. '一月:新年伊始,增进家庭沟通',
  278. '二月:春节团聚,珍惜亲子时光',
  279. '三月:春暖花开,多陪伴孩子',
  280. '四月:清明踏青,共享家庭活动',
  281. '五月:劳动教育,培养家庭责任感',
  282. '六月:儿童节,倾听孩子心声',
  283. '七月:暑期陪伴,增进亲子关系',
  284. '八月:开学准备,共同规划',
  285. '九月:新学期,建立家庭规则',
  286. '十月:国庆假期,家庭协作时光',
  287. '十一月:感恩季节,表达家庭关爱',
  288. '十二月:年终总结,回顾家庭成长'
  289. ]
  290. return messages[month] || messages[0]
  291. },
  292. /** 当前选中成员的能量数据(从 sandboxData.members 中查找) */
  293. currentMemberEnergies: function() {
  294. if (!this.sandboxData || !this.sandboxData.members) return null
  295. var members = this.sandboxData.members
  296. var targetId = this.selectedMemberId || this.activeChildId
  297. for (var i = 0; i < members.length; i++) {
  298. var m = members[i]
  299. if (m && (m.memberId === targetId)) return m
  300. }
  301. return members[0] || null
  302. },
  303. /** 行6维关系域维度定义(根据角色切换家长版/孩子版) */
  304. actionDimensions: function() {
  305. var role = this.role || uni.getStorageSync('currentRole') || ''
  306. var isParent = (role === 'parent')
  307. if (isParent) {
  308. return [
  309. { key: 'actionParentChild', label: '亲子关系' },
  310. { key: 'actionMarital', label: '夫妻关系' },
  311. { key: 'actionParental', label: '父母关系' },
  312. { key: 'actionLeadership', label: '领导关系' },
  313. { key: 'actionSociality', label: '社会性' },
  314. { key: 'actionInterpersonal', label: '人际韧性' }
  315. ]
  316. } else {
  317. return [
  318. { key: 'actionChildParentChild', label: '亲子关系' },
  319. { key: 'actionSibling', label: '同胞关系' },
  320. { key: 'actionRelative', label: '亲属关系' },
  321. { key: 'actionTeacherStudent', label: '师生关系' },
  322. { key: 'actionChildSociality', label: '社会性' },
  323. { key: 'actionChildInterpersonal', label: '人际韧性' }
  324. ]
  325. }
  326. },
  327. /** 当前选中成员的行维度分数 */
  328. actionScore: function() {
  329. var member = this.currentMemberEnergies
  330. return member ? (member.actionScore || 0) : null
  331. },
  332. /** 行6维分值(从当前成员中提取,与 dimensions 顺序对应) */
  333. actionScores: function() {
  334. var member = this.currentMemberEnergies
  335. if (!member) return []
  336. var dims = this.actionDimensions
  337. var scores = []
  338. for (var i = 0; i < dims.length; i++) {
  339. scores.push(member[dims[i].key] || 0)
  340. }
  341. return scores
  342. },
  343. /** 行6维家庭平均分(从 sandboxData.members 各成员同维度均值) */
  344. actionFamilyScores: function() {
  345. if (!this.sandboxData || !this.sandboxData.members) return []
  346. var members = this.sandboxData.members
  347. var dims = this.actionDimensions
  348. var scores = []
  349. for (var i = 0; i < dims.length; i++) {
  350. var key = dims[i].key
  351. var sum = 0, count = 0
  352. for (var j = 0; j < members.length; j++) {
  353. var val = members[j][key]
  354. if (val !== undefined && val !== null && val > 0) { sum += val; count++ }
  355. }
  356. scores.push(count > 0 ? Math.round(sum / count) : 0)
  357. }
  358. return scores
  359. },
  360. /** 行6维人群位置分数(按 actionDimensions 顺序从 map 取值) */
  361. actionPopulationScores: function() {
  362. var dims = this.actionDimensions
  363. var scores = []
  364. for (var i = 0; i < dims.length; i++) {
  365. scores.push(this.actionPopulationScoreMap[dims[i].key] || 0)
  366. }
  367. return scores
  368. }
  369. },
  370. onShow() {
  371. this.showTabTransition = true
  372. var token = uni.getStorageSync('token')
  373. this.isLoggedIn = !!token
  374. if (this.isLoggedIn) {
  375. this.role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  376. this.userName = uni.getStorageSync('nickname') || uni.getStorageSync('userName') || '家长'
  377. this.selfId = uni.getStorageSync('userId') || null
  378. }
  379. this.loadSectionConfig()
  380. if (this.isLoggedIn) {
  381. this.loadChildren()
  382. this.loadFamilyMembersVisible()
  383. this.loadPearlResources()
  384. this.loadAbilityMap()
  385. this.loadOctopusData()
  386. this.loadActionRadarPopulationData()
  387. }
  388. this._watchPageReady()
  389. },
  390. methods: {
  391. loadSectionConfig: function() {
  392. var baseSections = ['func_entries']
  393. if (!uni.getStorageSync('token')) {
  394. this.visibleSections = baseSections
  395. return
  396. }
  397. var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  398. var self = this
  399. getVisibleSections({ pageKey: 'action', role: role }).then(function(res) {
  400. if (res.code === 200 && res.data) {
  401. var keys = res.data.map(function(s) { return s.sectionKey })
  402. var merged = baseSections.slice()
  403. keys.forEach(function(k) { if (merged.indexOf(k) === -1) merged.push(k) })
  404. self.visibleSections = merged
  405. }
  406. }).catch(function(e) {
  407. self.visibleSections = ['func_entries']
  408. })
  409. },
  410. loadChildren: function() {
  411. var self = this
  412. getChildren().then(function(res) {
  413. if (res.code === 200 && res.data) {
  414. self.children = res.data
  415. var savedChildId = uni.getStorageSync('currentChildId')
  416. var found = false
  417. for (var i = 0; i < self.children.length; i++) {
  418. if (self.children[i].memberId === savedChildId) {
  419. self.activeChildId = savedChildId
  420. self.activeChildName = self.children[i].name || self.children[i].nickname || '孩子'
  421. found = true
  422. break
  423. }
  424. }
  425. if (!found && self.children.length > 0) {
  426. self.activeChildId = self.children[0].memberId
  427. self.activeChildName = self.children[0].name || self.children[0].nickname || '孩子'
  428. uni.setStorageSync('currentChildId', self.activeChildId)
  429. }
  430. if (self.activeChildId) {
  431. self.loadDashboardData()
  432. }
  433. }
  434. self.childrenChecked = true
  435. }).catch(function(e) {
  436. console.log('获取孩子列表失败', e)
  437. self.childrenChecked = true
  438. })
  439. },
  440. loadDashboardData: function() {
  441. if (!this.activeChildId) return
  442. this.loadEnergyData()
  443. this.loadSandboxData()
  444. },
  445. loadSandboxData: function() {
  446. var self = this
  447. getFamilyEnergySandbox().then(function(res) {
  448. if (res && res.data) {
  449. self.sandboxData = res.data
  450. }
  451. }).catch(function(e) {
  452. console.log('获取沙盘数据失败', e)
  453. })
  454. },
  455. loadActionRadarPopulationData: function() {
  456. var self = this
  457. var memberId = this.selectedMemberId || this.activeChildId
  458. if (!memberId) return
  459. getRadarData({
  460. memberId: memberId,
  461. dimensions: ['actionParentChild','actionMarital','actionParental','actionLeadership','actionSociality','actionInterpersonal',
  462. 'actionChildParentChild','actionSibling','actionRelative','actionTeacherStudent','actionChildSociality','actionChildInterpersonal']
  463. }).then(function(res) {
  464. if (res && res.data && res.data.populationScores) {
  465. var dims = res.data.dimensions || []
  466. var scores = res.data.populationScores
  467. var map = {}
  468. for (var i = 0; i < dims.length && i < scores.length; i++) {
  469. map[dims[i]] = scores[i]
  470. }
  471. self.actionPopulationScoreMap = map
  472. }
  473. }).catch(function(e) { console.warn('[action] radar-data failed', e) })
  474. },
  475. switchView: function(view) {
  476. this.currentView = view
  477. if (view === 'family') {
  478. this.selectedMemberId = null
  479. var self = this
  480. getEnergySandbox('family').then(function(res) {
  481. if (res && res.data && !res.data.locked) {
  482. self.sandboxData = res.data.familyData || res.data
  483. }
  484. }).catch(function(e) { console.log('获取家庭数据失败', e) })
  485. } else {
  486. this.loadSandboxData()
  487. }
  488. },
  489. loadEnergyData: function() {
  490. var self = this
  491. getEnergyOverview(this.activeChildId).then(function(res) {
  492. if (res && res.data) {
  493. var dims = res.data.dimensions
  494. if (dims && dims.length > 0) {
  495. for (var i = 0; i < dims.length; i++) {
  496. if (dims[i].code === 'action') {
  497. self.dualDimension = dims[i]
  498. break
  499. }
  500. }
  501. }
  502. }
  503. }).catch(function(e) {
  504. console.log('获取能量概览失败', e)
  505. })
  506. },
  507. onFamilyMemberSelect: function(member) {
  508. this.selectedMemberId = member.id
  509. },
  510. loadFamilyMembersVisible: function() {
  511. var self = this
  512. getFamilyMemberList({ visibleOnly: true }).then(function(res) {
  513. self.familyMembersVisible = res.data || []
  514. self.membersChecked = true
  515. }).catch(function(e) {
  516. console.log('获取可见家庭成员失败', e)
  517. self.familyMembersVisible = []
  518. self.membersChecked = true
  519. })
  520. },
  521. sectionVisible: function(key) {
  522. return this.visibleSections.length === 0 || this.visibleSections.indexOf(key) !== -1
  523. },
  524. onFuncClick: function(item) {
  525. if (item.needLogin && !this.isLoggedIn) {
  526. uni.showModal({
  527. title: '提示',
  528. content: '请先登录后使用此功能',
  529. success: function(res) {
  530. if (res.confirm) uni.navigateTo({ url: '/pages/login/login' })
  531. }
  532. })
  533. return
  534. }
  535. if (item.page) uni.navigateTo({ url: item.page })
  536. },
  537. /** 加载珍珠图数据 */
  538. loadPearlResources: function() {
  539. var self = this
  540. getPearlResources().then(function(res) {
  541. self.pearlData = (res.code === 200 && res.data) ? res.data : null
  542. }).catch(function(e) {
  543. console.log('获取珍珠图数据失败', e)
  544. self.pearlData = null
  545. })
  546. // 构建逾期映射
  547. getPearlReminders().then(function(res) {
  548. var map = {}
  549. if (res.code === 200 && res.data) {
  550. for (var i = 0; i < res.data.length; i++) {
  551. map['' + res.data[i].resourceItemId] = res.data[i].daysSinceLast
  552. }
  553. }
  554. self.overdueMap = map
  555. }).catch(function(e) {
  556. self.overdueMap = null
  557. })
  558. },
  559. /** 登记珍珠图资源入口 */
  560. goPearlAddResource: function() {
  561. uni.navigateTo({ url: '/pages/action-detail/pearl-add-resource' })
  562. },
  563. /** 能力图记录帮助入口(跳转互动记录,记录技能类帮助) */
  564. goInteractionLog: function() {
  565. uni.navigateTo({ url: '/pages/action-detail/interaction-log' })
  566. },
  567. /** 删除珍珠图资源 */
  568. onDeletePearlResource: function(item) {
  569. if (!item || !item.id) return
  570. var self = this
  571. uni.showModal({
  572. title: '提示',
  573. content: '确定删除该资源吗?',
  574. success: function(res) {
  575. if (!res.confirm) return
  576. deletePearlResource({ itemId: item.id }).then(function(r) {
  577. if (r.code === 200) {
  578. uni.showToast({ title: '已删除', icon: 'success' })
  579. self.loadPearlResources()
  580. } else {
  581. uni.showToast({ title: r.message || '删除失败', icon: 'none' })
  582. }
  583. }).catch(function(e) {
  584. console.log('删除珍珠图资源失败', e)
  585. uni.showToast({ title: '删除失败', icon: 'none' })
  586. })
  587. }
  588. })
  589. },
  590. /** 加载能力图数据 */
  591. loadAbilityMap: function() {
  592. var self = this
  593. getAbilityMap().then(function(res) {
  594. self.abilityData = (res.code === 200 && Array.isArray(res.data)) ? res.data : []
  595. }).catch(function(e) {
  596. console.log('获取能力图数据失败', e)
  597. self.abilityData = []
  598. })
  599. },
  600. /** 加载章鱼图数据 */
  601. loadOctopusData: function() {
  602. var self = this
  603. getOctopusEffects().then(function(res) {
  604. self.octopusEffects = (res.code === 200 && res.data) ? res.data : null
  605. }).catch(function(e) {
  606. console.log('获取章鱼图数据失败', e)
  607. self.octopusEffects = null
  608. })
  609. getOctopusAnalysisSummary().then(function(res) {
  610. if (res.code === 200 && res.data && res.data.directions) {
  611. self.octopusExpansions = res.data.directions
  612. }
  613. }).catch(function(e) {
  614. console.log('获取拓展方向失败', e)
  615. })
  616. },
  617. /** 跳转成效录入页 */
  618. goOctopusAddEffect: function() {
  619. uni.navigateTo({ url: '/pages/action-detail/octopus-add-effect' })
  620. },
  621. /** 跳转感恩记录维护列表 */
  622. goOctopusEffectsList: function() {
  623. uni.navigateTo({ url: '/pages/action-detail/octopus-effects-list' })
  624. },
  625. /** 点击成效节点 */
  626. onEffectClick: function(effect) {
  627. var self = this
  628. if (!self.octopusKeyPersons[effect.id]) {
  629. getOctopusEffectKeyPersons({ effectId: effect.id }).then(function(res) {
  630. if (res.code === 200) self.$set(self.octopusKeyPersons, effect.id, res.data || [])
  631. }).catch(function(e) { console.log('获取关键人失败', e) })
  632. }
  633. },
  634. /** 点击拓展方向节点 */
  635. onExpansionClick: function(expansion) {
  636. var prefill = encodeURIComponent(JSON.stringify(expansion.prefill || {}))
  637. uni.navigateTo({ url: '/pages/action-detail/octopus-add-key-person?prefill=' + prefill })
  638. },
  639. /** 重新分析 */
  640. onReanalyze: function() {
  641. this.loadOctopusData()
  642. },
  643. /** 显示帮助弹窗 */
  644. showHelp: function(title, content) {
  645. this.helpPopup = { visible: true, title: title, content: content }
  646. },
  647. closeHelp: function() {
  648. this.helpPopup.visible = false
  649. },
  650. onTaskClick: function(task) {
  651. uni.navigateTo({ url: '/pages/tasks/tasks' })
  652. },
  653. goActivityDetail: function(act) {
  654. if (act && act.id) uni.navigateTo({ url: '/pages/activity/activity-detail/activity-detail?id=' + act.id })
  655. },
  656. goMoreActivities: function() {
  657. uni.navigateTo({ url: '/pages/activity/index' })
  658. },
  659. goProductDetail: function(prod) {
  660. if (prod && prod.id) uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + prod.id })
  661. },
  662. goMoreProducts: function() {
  663. uni.navigateTo({ url: '/pages/shop/index/index' })
  664. },
  665. goTasks: function() {
  666. uni.navigateTo({ url: '/pages/tasks/tasks' })
  667. },
  668. _watchPageReady() {
  669. var self = this
  670. var unwatch = this.$watch(function() {
  671. if (self.isLoggedIn) {
  672. return !!(self.dualDimension || self.sandboxData)
  673. }
  674. return true
  675. }, function(val) {
  676. if (val) {
  677. if (unwatch) unwatch()
  678. if (self.$refs.tabTransition) self.$refs.tabTransition.markReady()
  679. }
  680. })
  681. }
  682. }
  683. }
  684. </script>
  685. <style scoped>
  686. .container {
  687. min-height: 100vh;
  688. background: linear-gradient(180deg, #F0FFF4 0%, #F5F7FA 40%);
  689. padding-bottom: 120rpx;
  690. }
  691. /* 品牌定位语 */
  692. .brand-strap {
  693. margin: 24rpx 30rpx 0;
  694. padding: 28rpx 32rpx;
  695. background: linear-gradient(135deg, #10B981 0%, #34D399 50%, #6EE7B7 100%);
  696. border-radius: 24rpx;
  697. box-shadow: 0 8rpx 24rpx rgba(16, 185, 129, 0.25);
  698. position: relative;
  699. overflow: hidden;
  700. }
  701. .brand-strap::before {
  702. content: '';
  703. position: absolute;
  704. top: -30rpx;
  705. right: -30rpx;
  706. width: 120rpx;
  707. height: 120rpx;
  708. background: rgba(255, 255, 255, 0.15);
  709. border-radius: 50%;
  710. }
  711. .brand-strap::after {
  712. content: '';
  713. position: absolute;
  714. bottom: -20rpx;
  715. left: 20rpx;
  716. width: 60rpx;
  717. height: 60rpx;
  718. background: rgba(255, 255, 255, 0.1);
  719. border-radius: 50%;
  720. }
  721. .brand-strap-text {
  722. font-size: 30rpx;
  723. color: #FFFFFF;
  724. font-weight: 600;
  725. text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
  726. position: relative;
  727. z-index: 1;
  728. }
  729. /* 每月引导语 */
  730. .monthly-guidance {
  731. margin: 20rpx 30rpx 0;
  732. padding: 24rpx 28rpx;
  733. background: linear-gradient(135deg, #FFFFFF 0%, #F0FFF4 100%);
  734. border-radius: 20rpx;
  735. border: 1rpx solid rgba(16, 185, 129, 0.15);
  736. box-shadow: 0 4rpx 16rpx rgba(16, 185, 129, 0.08);
  737. display: flex;
  738. align-items: center;
  739. gap: 12rpx;
  740. }
  741. .guidance-icon { font-size: 36rpx; }
  742. .guidance-text {
  743. font-size: 26rpx;
  744. color: #065F46;
  745. font-weight: 500;
  746. }
  747. /* ===== 通用区块 ===== */
  748. .section {
  749. margin: 24rpx 30rpx 0;
  750. }
  751. .section-header {
  752. display: flex;
  753. flex-direction: row;
  754. align-items: center;
  755. justify-content: space-between;
  756. margin-bottom: 16rpx;
  757. }
  758. .section-title-wrap {
  759. display: flex;
  760. flex-direction: row;
  761. align-items: center;
  762. gap: 8rpx;
  763. }
  764. .help-icon {
  765. width: 36rpx;
  766. height: 36rpx;
  767. border-radius: 50%;
  768. border: 2rpx solid #D1D5DB;
  769. color: #9CA3AF;
  770. font-size: 22rpx;
  771. display: flex;
  772. align-items: center;
  773. justify-content: center;
  774. flex-shrink: 0;
  775. transition: all 0.2s;
  776. background: #FFFFFF;
  777. }
  778. .help-icon:active {
  779. border-color: #10B981;
  780. color: #10B981;
  781. background: #F0FFF4;
  782. transform: scale(1.1);
  783. }
  784. .section-title {
  785. font-size: 34rpx;
  786. font-weight: 700;
  787. color: #1E293B;
  788. letter-spacing: 0.5rpx;
  789. }
  790. .section-sub {
  791. font-size: 24rpx;
  792. color: #94A3B8;
  793. margin-top: 4rpx;
  794. line-height: 1.4;
  795. }
  796. .section-link {
  797. display: inline-flex;
  798. align-items: center;
  799. padding: 12rpx 28rpx;
  800. border-radius: 40rpx;
  801. font-size: 24rpx;
  802. font-weight: 500;
  803. white-space: nowrap;
  804. transition: all 0.2s;
  805. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  806. }
  807. .section-link:active {
  808. opacity: 0.85;
  809. transform: scale(0.98);
  810. }
  811. .section-link-octopus {
  812. background: linear-gradient(135deg, #F97316, #FB923C);
  813. color: #fff;
  814. box-shadow: 0 4rpx 16rpx rgba(249,115,22,0.3);
  815. }
  816. .section-link-pearl {
  817. background: linear-gradient(135deg, #0EA5E9, #38BDF8);
  818. color: #fff;
  819. box-shadow: 0 4rpx 16rpx rgba(14,165,233,0.3);
  820. }
  821. .section-link-ability {
  822. background: linear-gradient(135deg, #10B981, #34D399);
  823. color: #fff;
  824. box-shadow: 0 4rpx 16rpx rgba(16,185,129,0.3);
  825. }
  826. /* 关系解读卡片 */
  827. .score-explain-card {
  828. background: linear-gradient(135deg, #FFFFFF 0%, #F0FFF4 100%);
  829. border-radius: 20rpx;
  830. padding: 28rpx 32rpx;
  831. border: 1rpx solid rgba(16, 185, 129, 0.12);
  832. box-shadow: 0 4rpx 16rpx rgba(16, 185, 129, 0.08);
  833. }
  834. .explain-header {
  835. display: flex;
  836. align-items: center;
  837. gap: 12rpx;
  838. margin-bottom: 12rpx;
  839. }
  840. .explain-icon {
  841. font-size: 32rpx;
  842. }
  843. .explain-title {
  844. font-size: 30rpx;
  845. font-weight: 600;
  846. color: #1E293B;
  847. }
  848. .explain-text {
  849. font-size: 26rpx;
  850. color: #64748B;
  851. line-height: 1.7;
  852. }
  853. /* 帮助说明弹窗 */
  854. .help-mask {
  855. position: fixed;
  856. top: 0;
  857. left: 0;
  858. right: 0;
  859. bottom: 0;
  860. background: rgba(0, 0, 0, 0.5);
  861. display: flex;
  862. align-items: center;
  863. justify-content: center;
  864. z-index: 999;
  865. }
  866. .help-dialog {
  867. background: #FFFFFF;
  868. border-radius: 24rpx;
  869. width: 85%;
  870. max-width: 520rpx;
  871. max-height: 75vh;
  872. overflow: hidden;
  873. box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
  874. }
  875. .help-dialog-header {
  876. display: flex;
  877. justify-content: space-between;
  878. align-items: center;
  879. padding: 28rpx 32rpx 20rpx;
  880. border-bottom: 1rpx solid #F1F5F9;
  881. background: linear-gradient(135deg, #F0FFF4, #FFFFFF);
  882. }
  883. .help-dialog-title {
  884. font-size: 32rpx;
  885. font-weight: 700;
  886. color: #1E293B;
  887. }
  888. .help-dialog-close {
  889. font-size: 36rpx;
  890. color: #94A3B8;
  891. cursor: pointer;
  892. width: 48rpx;
  893. height: 48rpx;
  894. display: flex;
  895. align-items: center;
  896. justify-content: center;
  897. border-radius: 50%;
  898. transition: background 0.2s;
  899. }
  900. .help-dialog-close:active {
  901. background: #F1F5F9;
  902. }
  903. .help-dialog-content {
  904. padding: 28rpx 32rpx;
  905. font-size: 28rpx;
  906. color: #64748B;
  907. line-height: 1.8;
  908. }
  909. /* 功能入口网格 */
  910. .func-section {
  911. margin: 24rpx 30rpx 0;
  912. }
  913. .func-grid {
  914. display: flex;
  915. flex-direction: row;
  916. justify-content: space-around;
  917. background: linear-gradient(135deg, #FFFFFF 0%, #F0FFF4 100%);
  918. border-radius: 24rpx;
  919. padding: 32rpx 16rpx;
  920. box-shadow: 0 8rpx 24rpx rgba(16, 185, 129, 0.1);
  921. border: 1rpx solid rgba(16, 185, 129, 0.08);
  922. }
  923. .func-item {
  924. display: flex;
  925. flex-direction: column;
  926. align-items: center;
  927. flex: 1;
  928. padding: 8rpx;
  929. }
  930. .func-icon-wrap {
  931. width: 96rpx;
  932. height: 96rpx;
  933. border-radius: 28rpx;
  934. background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
  935. display: flex;
  936. align-items: center;
  937. justify-content: center;
  938. margin-bottom: 12rpx;
  939. box-shadow: 0 4rpx 12rpx rgba(16, 185, 129, 0.15);
  940. transition: all 0.2s;
  941. }
  942. .func-item:active .func-icon-wrap {
  943. transform: scale(0.95);
  944. box-shadow: 0 2rpx 8rpx rgba(16, 185, 129, 0.2);
  945. }
  946. .func-icon {
  947. font-size: 44rpx;
  948. }
  949. .func-label {
  950. font-size: 24rpx;
  951. color: #475569;
  952. font-weight: 500;
  953. }
  954. .bottom-spacer {
  955. height: 40rpx;
  956. }
  957. </style>