index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  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. <text class="section-title">家庭关系</text>
  50. <text class="section-sub">了解每位家人的关系质量,改善沟通方式</text>
  51. <text class="section-sub">点击家人节点,查看关系详情</text>
  52. </view>
  53. <FamilyRelationGraph
  54. dimensionCode="action"
  55. :selfId="selfId"
  56. :members="graphMembers"
  57. :energyMap="energyMapForGraph"
  58. :intimacyMap="intimacyMapForGraph"
  59. :interactive="true" />
  60. </view>
  61. <!-- 登录后:章鱼图(关键人拓展) -->
  62. <view class="section" v-if="isLoggedIn">
  63. <view class="section-header">
  64. <view>
  65. <text class="section-title">🐙 章鱼图</text>
  66. <text class="section-sub">从成效出发,挖掘关键人,画出拓展路径</text>
  67. </view>
  68. <text class="section-link" @tap="goOctopusAddEffect">+ 记录成效</text>
  69. </view>
  70. <OctopusDiagram
  71. ref="octopusDiagram"
  72. :selfId="selfId"
  73. :effects="octopusEffects"
  74. :expansions="octopusExpansions"
  75. :interactive="true"
  76. @effect-click="onEffectClick"
  77. @expansion-click="onExpansionClick"
  78. @add-effect="goOctopusAddEffect"
  79. @reanalyze="onReanalyze" />
  80. </view>
  81. <!-- 登录后:珍珠图(我有什么) -->
  82. <view class="section" v-if="isLoggedIn">
  83. <view class="section-header">
  84. <view>
  85. <text class="section-title">🫧 珍珠图</text>
  86. <text class="section-sub">把可调用的资源串成珍珠项链——盘点我有什么</text>
  87. </view>
  88. <text class="section-link" @tap="goPearlAddResource">+ 登记</text>
  89. </view>
  90. <PearlDiagram
  91. ref="pearlDiagram"
  92. :selfId="selfId"
  93. :resources="pearlData"
  94. :overdue-map="overdueMap"
  95. :interactive="true"
  96. @add="goPearlAddResource"
  97. @delete="onDeletePearlResource" />
  98. </view>
  99. <!-- 登录后:能力图(谁会什么) -->
  100. <view class="section" v-if="isLoggedIn">
  101. <view class="section-header">
  102. <view>
  103. <text class="section-title">💡 能力图</text>
  104. <text class="section-sub">身边藏着什么技能——谁有能力帮到你</text>
  105. </view>
  106. </view>
  107. <AbilityDiagram
  108. ref="abilityDiagram"
  109. :selfId="selfId"
  110. :abilities="abilityData"
  111. :interactive="true" />
  112. </view>
  113. <!-- 行6维关系域雷达图(登录后) -->
  114. <view class="section" v-if="isLoggedIn && currentMemberEnergies">
  115. <view class="section-header">
  116. <text class="section-title">🫂 关系质量</text>
  117. </view>
  118. <RadarChart
  119. :dimensions="actionDimensions"
  120. :scores="actionScores"
  121. :avg-scores="actionFamilyScores"
  122. :population-scores="actionPopulationScores"
  123. fillColor="#10B981"
  124. gridColor="#D1FAE5"
  125. labelColor="#065F46"
  126. :width="580"
  127. :height="580" />
  128. </view>
  129. <!-- 功能入口 -->
  130. <view class="func-section" v-if="sectionVisible('func_entries')">
  131. <view class="func-grid">
  132. <view class="func-item" v-for="item in funcList" :key="item.label" @click="onFuncClick(item)">
  133. <view class="func-icon-wrap">
  134. <text class="func-icon">{{ item.icon }}</text>
  135. </view>
  136. <text class="func-label">{{ item.label }}</text>
  137. </view>
  138. </view>
  139. </view>
  140. <!-- 登录后:今日任务 -->
  141. <DimensionTasks
  142. v-if="isLoggedIn"
  143. :memberId="activeChildId"
  144. @taskClick="onTaskClick"
  145. @moreTasks="goTasks" />
  146. <!-- 登录后:活动 -->
  147. <DimensionActivities
  148. v-if="isLoggedIn"
  149. :isLoggedIn="true"
  150. @activityClick="goActivityDetail"
  151. @moreActivities="goMoreActivities" />
  152. <!-- 登录后:商品 -->
  153. <DimensionProducts
  154. v-if="isLoggedIn"
  155. :isLoggedIn="true"
  156. @productClick="goProductDetail"
  157. @moreProducts="goMoreProducts" />
  158. <!-- 行维度介绍卡片(登录后显示) -->
  159. <DimensionIntroCard dimCode="action" v-if="isLoggedIn" learn-more-url="/pages/action-detail/dimension-intro" />
  160. <!-- 底部占位 -->
  161. <view class="bottom-spacer"></view>
  162. <FloatingAvatar />
  163. </view>
  164. </template>
  165. <script>
  166. import TabTransition from '../../components/tab-transition.vue'
  167. import PageBanner from '../../components/PageBanner.vue'
  168. import FamilyEnergyBar from '../../components/FamilyEnergyBar.vue'
  169. import FamilyRelationGraph from '../../components/FamilyRelationGraph.vue'
  170. import PearlDiagram from '../../components/PearlDiagram.vue'
  171. import AbilityDiagram from '../../components/AbilityDiagram.vue'
  172. import OctopusDiagram from '../../components/OctopusDiagram.vue'
  173. import FamilyMemberStrip from '../../components/FamilyMemberStrip.vue'
  174. import DimensionTasks from '../../components/DimensionTasks.vue'
  175. import DimensionActivities from '../../components/DimensionActivities.vue'
  176. import DimensionProducts from '../../components/DimensionProducts.vue'
  177. import DimensionIntroCard from '../../components/DimensionIntroCard.vue'
  178. import FloatingAvatar from '../../components/AIFloatingAvatar.vue'
  179. import RadarChart from '../../components/RadarChart.vue'
  180. import DimensionSubDims from '../../components/DimensionSubDims.vue'
  181. import { getVisibleSections, getEnergyOverview, getChildren, getFamilyEnergySandbox, getEnergySandbox, getFamilyMemberList, getOctopusTentacles, getPearlResources, deletePearlResource, getAbilityMap, getRadarData, getPearlReminders, getOctopusEffects, getOctopusAnalysisSummary, getOctopusExpansionSuggest, getOctopusEffectKeyPersons } from '../../utils/api.js'
  182. export default {
  183. components: { TabTransition, PageBanner, FamilyEnergyBar, FamilyRelationGraph, PearlDiagram, AbilityDiagram, OctopusDiagram, FamilyMemberStrip, DimensionTasks, DimensionActivities, DimensionProducts, DimensionIntroCard, FloatingAvatar, RadarChart, DimensionSubDims },
  184. data() {
  185. return {
  186. isLoggedIn: false,
  187. role: null,
  188. showTabTransition: true,
  189. activeChildId: null,
  190. selectedMemberId: null,
  191. activeChildName: '',
  192. userName: '',
  193. children: [],
  194. familyMembersVisible: [],
  195. childrenChecked: false,
  196. membersChecked: false,
  197. actionSubDims: [],
  198. sandboxData: null,
  199. actionPopulationScoreMap: {},
  200. currentView: 'self', // 'self' | 'family'
  201. dualDimension: null,
  202. selfId: null,
  203. visibleSections: [],
  204. pearlData: null,
  205. abilityData: null,
  206. octopusEffects: null,
  207. octopusExpansions: [],
  208. octopusKeyPersons: {},
  209. overdueMap: null,
  210. funcList: [
  211. { icon: '\u{1F4AC}', label: '记录互动', needLogin: true, page: '/pages/action-detail/interaction-log' },
  212. { icon: '\u{1F4DD}', label: '关系问卷', needLogin: true, page: '/pages/action-detail/relationship-questionnaire' },
  213. { icon: '\u{1F465}', label: '家庭成员', needLogin: true, page: '/pages/profile-extra/family-members' },
  214. { icon: '\u{1F4CB}', label: '任务中心', needLogin: true, page: '/pages/tasks/tasks' }
  215. ]
  216. }
  217. },
  218. computed: {
  219. /** 关系图谱:成员节点(来自沙盘数据) */
  220. graphMembers: function() {
  221. if (!this.sandboxData || !this.sandboxData.members) return []
  222. return this.sandboxData.members.map(function(m) {
  223. return {
  224. id: m.memberId || m.id,
  225. nickname: m.name || m.nickname || '成员',
  226. memberType: m.memberType || 'child'
  227. }
  228. })
  229. },
  230. /** 关系图谱:节点能量映射 */
  231. energyMapForGraph: function() {
  232. var map = {}
  233. if (this.sandboxData && this.sandboxData.members) {
  234. for (var i = 0; i < this.sandboxData.members.length; i++) {
  235. var m = this.sandboxData.members[i]
  236. map[m.memberId || m.id] = {
  237. bodyScore: m.bodyScore || 0,
  238. mindScore: m.mindScore || 0,
  239. actionScore: m.actionScore || 0
  240. }
  241. }
  242. }
  243. return map
  244. },
  245. intimacyMapForGraph: function() {
  246. return {}
  247. },
  248. /** 每月引导语 */
  249. monthlyGuidance: function() {
  250. var month = new Date().getMonth()
  251. var messages = [
  252. '一月:新年伊始,增进家庭沟通',
  253. '二月:春节团聚,珍惜亲子时光',
  254. '三月:春暖花开,多陪伴孩子',
  255. '四月:清明踏青,共享家庭活动',
  256. '五月:劳动教育,培养家庭责任感',
  257. '六月:儿童节,倾听孩子心声',
  258. '七月:暑期陪伴,增进亲子关系',
  259. '八月:开学准备,共同规划',
  260. '九月:新学期,建立家庭规则',
  261. '十月:国庆假期,家庭协作时光',
  262. '十一月:感恩季节,表达家庭关爱',
  263. '十二月:年终总结,回顾家庭成长'
  264. ]
  265. return messages[month] || messages[0]
  266. },
  267. /** 当前选中成员的能量数据(从 sandboxData.members 中查找) */
  268. currentMemberEnergies: function() {
  269. if (!this.sandboxData || !this.sandboxData.members) return null
  270. var members = this.sandboxData.members
  271. var targetId = this.selectedMemberId || this.activeChildId
  272. for (var i = 0; i < members.length; i++) {
  273. var m = members[i]
  274. if (m && (m.memberId === targetId)) return m
  275. }
  276. return members[0] || null
  277. },
  278. /** 行6维关系域维度定义(根据角色切换家长版/孩子版) */
  279. actionDimensions: function() {
  280. var role = this.role || uni.getStorageSync('currentRole') || ''
  281. var isParent = (role === 'parent')
  282. if (isParent) {
  283. return [
  284. { key: 'actionParentChild', label: '亲子关系' },
  285. { key: 'actionMarital', label: '夫妻关系' },
  286. { key: 'actionParental', label: '父母关系' },
  287. { key: 'actionLeadership', label: '领导关系' },
  288. { key: 'actionSociality', label: '社会性' },
  289. { key: 'actionInterpersonal', label: '人际韧性' }
  290. ]
  291. } else {
  292. return [
  293. { key: 'actionChildParentChild', label: '亲子关系' },
  294. { key: 'actionSibling', label: '同胞关系' },
  295. { key: 'actionRelative', label: '亲属关系' },
  296. { key: 'actionTeacherStudent', label: '师生关系' },
  297. { key: 'actionChildSociality', label: '社会性' },
  298. { key: 'actionChildInterpersonal', label: '人际韧性' }
  299. ]
  300. }
  301. },
  302. /** 当前选中成员的行维度分数 */
  303. actionScore: function() {
  304. var member = this.currentMemberEnergies
  305. return member ? (member.actionScore || 0) : null
  306. },
  307. /** 行6维分值(从当前成员中提取,与 dimensions 顺序对应) */
  308. actionScores: function() {
  309. var member = this.currentMemberEnergies
  310. if (!member) return []
  311. var dims = this.actionDimensions
  312. var scores = []
  313. for (var i = 0; i < dims.length; i++) {
  314. scores.push(member[dims[i].key] || 0)
  315. }
  316. return scores
  317. },
  318. /** 行6维家庭平均分(从 sandboxData.members 各成员同维度均值) */
  319. actionFamilyScores: function() {
  320. if (!this.sandboxData || !this.sandboxData.members) return []
  321. var members = this.sandboxData.members
  322. var dims = this.actionDimensions
  323. var scores = []
  324. for (var i = 0; i < dims.length; i++) {
  325. var key = dims[i].key
  326. var sum = 0, count = 0
  327. for (var j = 0; j < members.length; j++) {
  328. var val = members[j][key]
  329. if (val !== undefined && val !== null && val > 0) { sum += val; count++ }
  330. }
  331. scores.push(count > 0 ? Math.round(sum / count) : 0)
  332. }
  333. return scores
  334. },
  335. /** 行6维人群位置分数(按 actionDimensions 顺序从 map 取值) */
  336. actionPopulationScores: function() {
  337. var dims = this.actionDimensions
  338. var scores = []
  339. for (var i = 0; i < dims.length; i++) {
  340. scores.push(this.actionPopulationScoreMap[dims[i].key] || 0)
  341. }
  342. return scores
  343. }
  344. },
  345. onShow() {
  346. this.showTabTransition = true
  347. var token = uni.getStorageSync('token')
  348. this.isLoggedIn = !!token
  349. if (this.isLoggedIn) {
  350. this.role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  351. this.userName = uni.getStorageSync('nickname') || uni.getStorageSync('userName') || '家长'
  352. this.selfId = uni.getStorageSync('userId') || null
  353. }
  354. this.loadSectionConfig()
  355. if (this.isLoggedIn) {
  356. this.loadChildren()
  357. this.loadFamilyMembersVisible()
  358. this.loadPearlResources()
  359. this.loadAbilityMap()
  360. this.loadOctopusData()
  361. this.loadActionRadarPopulationData()
  362. }
  363. this._watchPageReady()
  364. },
  365. methods: {
  366. loadSectionConfig: function() {
  367. var baseSections = ['func_entries']
  368. if (!uni.getStorageSync('token')) {
  369. this.visibleSections = baseSections
  370. return
  371. }
  372. var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  373. var self = this
  374. getVisibleSections({ pageKey: 'action', role: role }).then(function(res) {
  375. if (res.code === 200 && res.data) {
  376. var keys = res.data.map(function(s) { return s.sectionKey })
  377. var merged = baseSections.slice()
  378. keys.forEach(function(k) { if (merged.indexOf(k) === -1) merged.push(k) })
  379. self.visibleSections = merged
  380. }
  381. }).catch(function(e) {
  382. self.visibleSections = ['func_entries']
  383. })
  384. },
  385. loadChildren: function() {
  386. var self = this
  387. getChildren().then(function(res) {
  388. if (res.code === 200 && res.data) {
  389. self.children = res.data
  390. var savedChildId = uni.getStorageSync('currentChildId')
  391. var found = false
  392. for (var i = 0; i < self.children.length; i++) {
  393. if (self.children[i].memberId === savedChildId) {
  394. self.activeChildId = savedChildId
  395. self.activeChildName = self.children[i].name || self.children[i].nickname || '孩子'
  396. found = true
  397. break
  398. }
  399. }
  400. if (!found && self.children.length > 0) {
  401. self.activeChildId = self.children[0].memberId
  402. self.activeChildName = self.children[0].name || self.children[0].nickname || '孩子'
  403. uni.setStorageSync('currentChildId', self.activeChildId)
  404. }
  405. if (self.activeChildId) {
  406. self.loadDashboardData()
  407. }
  408. }
  409. self.childrenChecked = true
  410. }).catch(function(e) {
  411. console.log('获取孩子列表失败', e)
  412. self.childrenChecked = true
  413. })
  414. },
  415. loadDashboardData: function() {
  416. if (!this.activeChildId) return
  417. this.loadEnergyData()
  418. this.loadSandboxData()
  419. },
  420. loadSandboxData: function() {
  421. var self = this
  422. getFamilyEnergySandbox().then(function(res) {
  423. if (res && res.data) {
  424. self.sandboxData = res.data
  425. }
  426. }).catch(function(e) {
  427. console.log('获取沙盘数据失败', e)
  428. })
  429. },
  430. loadActionRadarPopulationData: function() {
  431. var self = this
  432. var memberId = this.selectedMemberId || this.activeChildId
  433. if (!memberId) return
  434. getRadarData({
  435. memberId: memberId,
  436. dimensions: ['actionParentChild','actionMarital','actionParental','actionLeadership','actionSociality','actionInterpersonal',
  437. 'actionChildParentChild','actionSibling','actionRelative','actionTeacherStudent','actionChildSociality','actionChildInterpersonal']
  438. }).then(function(res) {
  439. if (res && res.data && res.data.populationScores) {
  440. var dims = res.data.dimensions || []
  441. var scores = res.data.populationScores
  442. var map = {}
  443. for (var i = 0; i < dims.length && i < scores.length; i++) {
  444. map[dims[i]] = scores[i]
  445. }
  446. self.actionPopulationScoreMap = map
  447. }
  448. }).catch(function(e) { console.warn('[action] radar-data failed', e) })
  449. },
  450. switchView: function(view) {
  451. this.currentView = view
  452. if (view === 'family') {
  453. this.selectedMemberId = null
  454. var self = this
  455. getEnergySandbox('family').then(function(res) {
  456. if (res && res.data && !res.data.locked) {
  457. self.sandboxData = res.data.familyData || res.data
  458. }
  459. }).catch(function(e) { console.log('获取家庭数据失败', e) })
  460. } else {
  461. this.loadSandboxData()
  462. }
  463. },
  464. loadEnergyData: function() {
  465. var self = this
  466. getEnergyOverview(this.activeChildId).then(function(res) {
  467. if (res && res.data) {
  468. var dims = res.data.dimensions
  469. if (dims && dims.length > 0) {
  470. for (var i = 0; i < dims.length; i++) {
  471. if (dims[i].code === 'action') {
  472. self.dualDimension = dims[i]
  473. break
  474. }
  475. }
  476. }
  477. }
  478. }).catch(function(e) {
  479. console.log('获取能量概览失败', e)
  480. })
  481. },
  482. onFamilyMemberSelect: function(member) {
  483. this.selectedMemberId = member.id
  484. },
  485. loadFamilyMembersVisible: function() {
  486. var self = this
  487. getFamilyMemberList({ visibleOnly: true }).then(function(res) {
  488. self.familyMembersVisible = res.data || []
  489. self.membersChecked = true
  490. }).catch(function(e) {
  491. console.log('获取可见家庭成员失败', e)
  492. self.familyMembersVisible = []
  493. self.membersChecked = true
  494. })
  495. },
  496. sectionVisible: function(key) {
  497. return this.visibleSections.length === 0 || this.visibleSections.indexOf(key) !== -1
  498. },
  499. onFuncClick: function(item) {
  500. if (item.needLogin && !this.isLoggedIn) {
  501. uni.showModal({
  502. title: '提示',
  503. content: '请先登录后使用此功能',
  504. success: function(res) {
  505. if (res.confirm) uni.navigateTo({ url: '/pages/login/login' })
  506. }
  507. })
  508. return
  509. }
  510. if (item.page) uni.navigateTo({ url: item.page })
  511. },
  512. /** 加载珍珠图数据 */
  513. loadPearlResources: function() {
  514. var self = this
  515. getPearlResources().then(function(res) {
  516. self.pearlData = (res.code === 200 && res.data) ? res.data : null
  517. }).catch(function(e) {
  518. console.log('获取珍珠图数据失败', e)
  519. self.pearlData = null
  520. })
  521. // 构建逾期映射
  522. getPearlReminders().then(function(res) {
  523. var map = {}
  524. if (res.code === 200 && res.data) {
  525. for (var i = 0; i < res.data.length; i++) {
  526. map['' + res.data[i].resourceItemId] = res.data[i].daysSinceLast
  527. }
  528. }
  529. self.overdueMap = map
  530. }).catch(function(e) {
  531. self.overdueMap = null
  532. })
  533. },
  534. /** 登记珍珠图资源入口 */
  535. goPearlAddResource: function() {
  536. uni.navigateTo({ url: '/pages/action-detail/pearl-add-resource' })
  537. },
  538. /** 删除珍珠图资源 */
  539. onDeletePearlResource: function(item) {
  540. if (!item || !item.id) return
  541. var self = this
  542. uni.showModal({
  543. title: '提示',
  544. content: '确定删除该资源吗?',
  545. success: function(res) {
  546. if (!res.confirm) return
  547. deletePearlResource({ itemId: item.id }).then(function(r) {
  548. if (r.code === 200) {
  549. uni.showToast({ title: '已删除', icon: 'success' })
  550. self.loadPearlResources()
  551. } else {
  552. uni.showToast({ title: r.message || '删除失败', icon: 'none' })
  553. }
  554. }).catch(function(e) {
  555. console.log('删除珍珠图资源失败', e)
  556. uni.showToast({ title: '删除失败', icon: 'none' })
  557. })
  558. }
  559. })
  560. },
  561. /** 加载能力图数据 */
  562. loadAbilityMap: function() {
  563. var self = this
  564. getAbilityMap().then(function(res) {
  565. self.abilityData = (res.code === 200 && Array.isArray(res.data)) ? res.data : []
  566. }).catch(function(e) {
  567. console.log('获取能力图数据失败', e)
  568. self.abilityData = []
  569. })
  570. },
  571. /** 加载章鱼图数据 */
  572. loadOctopusData: function() {
  573. var self = this
  574. getOctopusEffects().then(function(res) {
  575. self.octopusEffects = (res.code === 200 && res.data) ? res.data : null
  576. }).catch(function(e) {
  577. console.log('获取章鱼图数据失败', e)
  578. self.octopusEffects = null
  579. })
  580. getOctopusAnalysisSummary().then(function(res) {
  581. if (res.code === 200 && res.data && res.data.directions) {
  582. self.octopusExpansions = res.data.directions
  583. }
  584. }).catch(function(e) {
  585. console.log('获取拓展方向失败', e)
  586. })
  587. },
  588. /** 跳转成效录入页 */
  589. goOctopusAddEffect: function() {
  590. uni.navigateTo({ url: '/pages/action-detail/octopus-add-effect' })
  591. },
  592. /** 点击成效节点 */
  593. onEffectClick: function(effect) {
  594. var self = this
  595. if (!self.octopusKeyPersons[effect.id]) {
  596. getOctopusEffectKeyPersons({ effectId: effect.id }).then(function(res) {
  597. if (res.code === 200) self.$set(self.octopusKeyPersons, effect.id, res.data || [])
  598. }).catch(function(e) { console.log('获取关键人失败', e) })
  599. }
  600. },
  601. /** 点击拓展方向节点 */
  602. onExpansionClick: function(expansion) {
  603. var prefill = encodeURIComponent(JSON.stringify(expansion.prefill || {}))
  604. uni.navigateTo({ url: '/pages/action-detail/octopus-add-key-person?prefill=' + prefill })
  605. },
  606. /** 重新分析 */
  607. onReanalyze: function() {
  608. this.loadOctopusData()
  609. },
  610. onTaskClick: function(task) {
  611. uni.navigateTo({ url: '/pages/tasks/tasks' })
  612. },
  613. goActivityDetail: function(act) {
  614. if (act && act.id) uni.navigateTo({ url: '/pages/activity/activity-detail/activity-detail?id=' + act.id })
  615. },
  616. goMoreActivities: function() {
  617. uni.navigateTo({ url: '/pages/activity/index' })
  618. },
  619. goProductDetail: function(prod) {
  620. if (prod && prod.id) uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + prod.id })
  621. },
  622. goMoreProducts: function() {
  623. uni.navigateTo({ url: '/pages/shop/index/index' })
  624. },
  625. goTasks: function() {
  626. uni.navigateTo({ url: '/pages/tasks/tasks' })
  627. },
  628. _watchPageReady() {
  629. var self = this
  630. var unwatch = this.$watch(function() {
  631. if (self.isLoggedIn) {
  632. return !!(self.dualDimension || self.sandboxData)
  633. }
  634. return true
  635. }, function(val) {
  636. if (val) {
  637. if (unwatch) unwatch()
  638. if (self.$refs.tabTransition) self.$refs.tabTransition.markReady()
  639. }
  640. })
  641. }
  642. }
  643. }
  644. </script>
  645. <style scoped>
  646. .container {
  647. min-height: 100vh;
  648. background: #f5f7fa;
  649. padding-bottom: 120rpx;
  650. }
  651. /* 品牌定位语 */
  652. .brand-strap {
  653. margin: 16rpx 30rpx 0;
  654. padding: 20rpx 28rpx;
  655. background: linear-gradient(135deg, #F0FFF4, rgba(16,185,129,0.12));
  656. border-radius: 16rpx;
  657. border-left: 4rpx solid #10B981;
  658. }
  659. .brand-strap-text {
  660. font-size: 26rpx;
  661. color: #065F46;
  662. font-weight: 500;
  663. }
  664. /* 每月引导语 */
  665. .monthly-guidance {
  666. margin: 16rpx 30rpx 0;
  667. padding: 20rpx 28rpx;
  668. background: linear-gradient(135deg, #F0FFF4, rgba(16,185,129,0.08));
  669. border-radius: 16rpx;
  670. border-left: 4rpx solid #10B981;
  671. display: flex;
  672. align-items: center;
  673. gap: 12rpx;
  674. }
  675. .guidance-icon { font-size: 32rpx; }
  676. .guidance-text {
  677. font-size: 26rpx;
  678. color: #065F46;
  679. font-weight: 500;
  680. }
  681. /* ===== 通用区块 ===== */
  682. .section {
  683. margin: 20rpx 30rpx 0;
  684. }
  685. .section-header {
  686. display: flex;
  687. flex-direction: row;
  688. align-items: center;
  689. justify-content: space-between;
  690. margin-bottom: 16rpx;
  691. }
  692. .section-title {
  693. font-size: 32rpx;
  694. font-weight: bold;
  695. color: #333;
  696. }
  697. .section-sub {
  698. font-size: 22rpx;
  699. color: #999;
  700. }
  701. /* ===== 功能入口 ===== */
  702. .func-section {
  703. margin: 20rpx 30rpx 0;
  704. }
  705. .func-grid {
  706. display: flex;
  707. flex-direction: row;
  708. justify-content: space-between;
  709. background: #fff;
  710. border-radius: 20rpx;
  711. padding: 24rpx 16rpx;
  712. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  713. }
  714. .func-item {
  715. display: flex;
  716. flex-direction: column;
  717. align-items: center;
  718. flex: 1;
  719. }
  720. .func-icon-wrap {
  721. width: 80rpx;
  722. height: 80rpx;
  723. border-radius: 40rpx;
  724. background: linear-gradient(135deg, #D1FAE5, #ECFDF5);
  725. display: flex;
  726. align-items: center;
  727. justify-content: center;
  728. margin-bottom: 10rpx;
  729. }
  730. .func-icon {
  731. font-size: 40rpx;
  732. }
  733. .func-label {
  734. font-size: 22rpx;
  735. color: #666;
  736. font-weight: 500;
  737. }
  738. .bottom-spacer {
  739. height: 40rpx;
  740. }
  741. </style>