index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. <template>
  2. <view class="wisdom-container">
  3. <!-- Tabbar 切换过渡页 -->
  4. <tab-transition v-if="showTabTransition" dimCode="wisdom" />
  5. <!-- 1. 品牌头部 -->
  6. <PageBanner theme="wisdom"
  7. tagline="学以启智 · 慧及未来"
  8. quote="知者不惑,仁者不忧" />
  9. <!-- 2. 游客专属区块 -->
  10. <template v-if="!isLoggedIn">
  11. <LoginGuideCard
  12. title="登录后查看全家智慧成长数据"
  13. :items="[
  14. '查看全家认知能量数据和测评报告',
  15. '记录每日成长,获取智慧能量',
  16. '参与认知训练,提升综合能力'
  17. ]" />
  18. </template>
  19. <!-- 3. 五维能量条(登录后) -->
  20. <FamilyEnergyBar
  21. v-if="isLoggedIn"
  22. dimensionCode="wisdom"
  23. :sandboxData="sandboxData"
  24. :dualDimension="dualDimension" />
  25. <!-- 4. 认知雷达图(登录后) -->
  26. <view class="section" v-if="isLoggedIn && cognitiveReport">
  27. <view class="section-header">
  28. <text class="section-title">认知雷达</text>
  29. <text class="section-more" @click="goCognitiveReport">查看详情 ›</text>
  30. </view>
  31. <RadarChart
  32. :dimensions="cognitiveDimensions"
  33. :scores="cognitiveScores"
  34. :avg-scores="cognitiveAvgScores"
  35. :childName="activeChildName"
  36. fillColor="#6366F1"
  37. gridColor="#E0E7FF"
  38. labelColor="#3730A3" />
  39. </view>
  40. <!-- 5. 家庭成员关系图谱(登录后) -->
  41. <FamilyRelationGraph
  42. v-if="isLoggedIn && familyMembersVisible.length > 0"
  43. dimensionCode="wisdom"
  44. :selfId="activeChildId"
  45. :members="familyMembersVisible"
  46. :energyMap="energyMapForGraph"
  47. :intimacyMap="intimacyMapForGraph"
  48. @memberTap="goMemberDetail" />
  49. <!-- 7. 功能入口 -->
  50. <view class="func-section" v-if="sectionVisible('func_entries')">
  51. <view class="func-grid">
  52. <view class="func-item" v-for="item in funcList" :key="item.label" @click="onFuncClick(item)">
  53. <view class="func-icon-wrap">
  54. <text class="func-icon">{{ item.icon }}</text>
  55. </view>
  56. <text class="func-label">{{ item.label }}</text>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 8. 维度任务 -->
  61. <DimensionTasks
  62. v-if="isLoggedIn"
  63. dimensionCode="wisdom"
  64. :tasks="dimensionTasks"
  65. @taskClick="onTaskClick"
  66. @moreTasks="goTasks" />
  67. <!-- 9. 维度活动 -->
  68. <DimensionActivities
  69. dimensionCode="wisdom"
  70. :activities="dimensionActivities"
  71. :isLoggedIn="isLoggedIn"
  72. @activityClick="goActivityDetail"
  73. @moreActivities="goMoreActivities" />
  74. <!-- 10. 维度商品 -->
  75. <DimensionProducts
  76. dimensionCode="wisdom"
  77. :products="dimensionProducts"
  78. @productClick="goProductDetail"
  79. @moreProducts="goMoreProducts" />
  80. <!-- 11. 推荐阅读 -->
  81. <DimensionArticles
  82. v-if="sectionVisible('recommended_reading')"
  83. dimensionCode="wisdom"
  84. :articles="wisdomArticles"
  85. :isLoggedIn="isLoggedIn"
  86. @articleClick="goArticleDetail"
  87. @moreArticles="goMoreArticles" />
  88. <!-- 12. 智慧小贴士 -->
  89. <view class="section" v-if="sectionVisible('wisdom_tips')">
  90. <view class="section-header">
  91. <text class="section-title">智慧小贴士</text>
  92. </view>
  93. <view class="tips-list">
  94. <view class="tip-card" v-for="item in wisdomTips" :key="item.id">
  95. <text class="tip-title">{{ item.title }}</text>
  96. <text class="tip-summary">{{ item.summary }}</text>
  97. </view>
  98. </view>
  99. </view>
  100. <!-- ===== DAN 报告(B4-智维度) ===== -->
  101. <view class="section" v-if="isLoggedIn && danReports.length > 0">
  102. <view class="section-header">
  103. <text class="section-title">&#x1F4CA; DAN 报告</text>
  104. <text class="section-more" @click="goDanUpload('wisdom')">上传 +</text>
  105. </view>
  106. <view class="dan-card" v-for="report in danReports" :key="report.id">
  107. <view class="dan-card-header">
  108. <text class="dan-report-date">{{ formatDate(report.assessmentDate) }}</text>
  109. <text :class="['dan-status', report.draftStatus === 'confirmed' ? 'confirmed' : 'pending']">
  110. {{ report.draftStatus === 'confirmed' ? '已确认' : '待确认' }}
  111. </text>
  112. </view>
  113. <text class="dan-report-desc">DAN B4 智维度测评报告</text>
  114. <view class="dan-card-footer" @click="viewDanReport(report)">
  115. <text class="dan-view-link">查看详情 &rarr;</text>
  116. </view>
  117. </view>
  118. </view>
  119. <!-- 13. 快捷操作按钮 -->
  120. <view class="section quick-actions" v-if="isLoggedIn">
  121. <view class="action-btn" @click="goCognitiveReport">
  122. <text class="action-icon">📊</text>
  123. <text class="action-text">认知报告</text>
  124. </view>
  125. <view class="action-btn" @click="goTrainingHub">
  126. <text class="action-icon">🧠</text>
  127. <text class="action-text">认知训练</text>
  128. </view>
  129. <view class="action-btn" @click="goAssessment">
  130. <text class="action-icon">📋</text>
  131. <text class="action-text">测评预约</text>
  132. </view>
  133. <view class="action-btn" @click="goHome">
  134. <text class="action-icon">🏠</text>
  135. <text class="action-text">返回首页</text>
  136. </view>
  137. </view>
  138. <!-- 底部占位 -->
  139. <view class="bottom-spacer"></view>
  140. <AIFloatingAvatar />
  141. </view>
  142. </template>
  143. <script>
  144. import TabTransition from '../../components/tab-transition.vue'
  145. import PageBanner from '../../components/PageBanner.vue'
  146. import LoginGuideCard from '../../components/LoginGuideCard.vue'
  147. import RadarChart from '../../components/RadarChart.vue'
  148. import FamilyEnergyBar from '../../components/FamilyEnergyBar.vue'
  149. import DimensionTasks from '../../components/DimensionTasks.vue'
  150. import DimensionActivities from '../../components/DimensionActivities.vue'
  151. import DimensionProducts from '../../components/DimensionProducts.vue'
  152. import DimensionArticles from '../../components/DimensionArticles.vue'
  153. import FamilyRelationGraph from '../../components/FamilyRelationGraph.vue'
  154. import AIFloatingAvatar from '../../components/AIFloatingAvatar.vue'
  155. import { getVisibleSections, getChildren, getTodayTasksByCategory, getActivityList, getProductsByDomain, getFamilyEnergySandbox, getAssessmentLatestResult, getFeaturedArticles, getContactList, getHealthAlerts, getMilestones, getDanReportByChild } from '../../utils/api.js'
  156. export default {
  157. components: { TabTransition, PageBanner, LoginGuideCard, RadarChart, FamilyEnergyBar, DimensionTasks, DimensionActivities, DimensionProducts, DimensionArticles, FamilyRelationGraph, AIFloatingAvatar },
  158. data() {
  159. return {
  160. isLoggedIn: false,
  161. role: null,
  162. showTabTransition: true,
  163. activeChildId: null,
  164. activeChildName: '',
  165. userName: '',
  166. children: [],
  167. familyMembersVisible: [],
  168. sandboxData: null,
  169. dualDimension: null,
  170. visibleSections: [],
  171. cognitiveReport: null,
  172. dimensionTasks: [],
  173. dimensionActivities: [],
  174. dimensionProducts: [],
  175. articles: [],
  176. wisdomTips: [],
  177. /** Mock 平均值(6维认知):感知/专注/记忆/逻辑/空间/加工速度 */
  178. cognitiveAvgScores: [70, 65, 72, 68, 66, 71],
  179. contactList: [],
  180. healthAlerts: [],
  181. milestones: [],
  182. danReports: [],
  183. funcList: [
  184. { icon: '\u{1F4CA}', label: '认知报告', needLogin: true, page: '/pages/wisdom-detail/cognitive-report' },
  185. { icon: '\u{270F}\uFE0F', label: '自己出题', needLogin: true, page: '/pages/wisdom-detail/self-quiz' },
  186. { icon: '\u{1F9E0}', label: '训练中心', needLogin: true, page: '/pages/wisdom-detail/training-hub' },
  187. { icon: '\u{1F3AF}', label: '测评预约', needLogin: false, page: '/pages/assessment/apply' },
  188. { icon: '\u{1F4D6}', label: '阅读天地', needLogin: false, page: '/pages/mind-extra/articles' }
  189. ]
  190. }
  191. },
  192. computed: {
  193. energyMapForGraph: function() {
  194. var map = {}
  195. if (this.sandboxData && this.sandboxData.members) {
  196. for (var i = 0; i < this.sandboxData.members.length; i++) {
  197. var m = this.sandboxData.members[i]
  198. map[m.memberId || m.id] = {
  199. bodyScore: m.bodyScore || 0,
  200. mindScore: m.mindScore || 0,
  201. actionScore: m.actionScore || 0,
  202. wisdomScore: m.wisdomScore || 0
  203. }
  204. }
  205. }
  206. return map
  207. },
  208. intimacyMapForGraph: function() {
  209. return {}
  210. },
  211. wisdomArticles: function() {
  212. if (!this.articles || this.articles.length === 0) return []
  213. var result = []
  214. for (var i = 0; i < this.articles.length; i++) {
  215. var a = this.articles[i]
  216. if (a.relatedDimensions && a.relatedDimensions.indexOf('wisdom') !== -1) {
  217. result.push(a)
  218. }
  219. }
  220. if (result.length === 0) return this.articles.slice(0, 5)
  221. return result.slice(0, 5)
  222. },
  223. cognitiveDimensions: function() {
  224. return [
  225. { label: '感知能力', key: 'perceptionScore' },
  226. { label: '专注力', key: 'focusScore' },
  227. { label: '记忆力', key: 'memoryScore' },
  228. { label: '逻辑思维', key: 'logicScore' },
  229. { label: '空间思维', key: 'spatialScore' },
  230. { label: '加工速度', key: 'processingSpeedScore' }
  231. ]
  232. },
  233. cognitiveScores: function() {
  234. if (!this.cognitiveReport) return []
  235. var dims = this.cognitiveDimensions
  236. var scores = []
  237. for (var i = 0; i < dims.length; i++) {
  238. scores.push(this.cognitiveReport[dims[i].key] || 0)
  239. }
  240. return scores
  241. }
  242. },
  243. onShow() {
  244. this.showTabTransition = true
  245. var token = uni.getStorageSync('token')
  246. this.isLoggedIn = !!token
  247. if (this.isLoggedIn) {
  248. this.role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  249. this.userName = uni.getStorageSync('nickname') || uni.getStorageSync('userName') || '家长'
  250. }
  251. this.loadSectionConfig()
  252. if (this.isLoggedIn) {
  253. this.loadChildren()
  254. this.loadFamilyMembersVisible()
  255. this.loadCognitiveReport()
  256. this.loadRelationshipHealth()
  257. this.loadDanReports()
  258. }
  259. this.loadDimensionActivities()
  260. this.loadDimensionProducts()
  261. // 游客也能浏览文章
  262. this.loadFeaturedArticles()
  263. this._watchPageReady()
  264. },
  265. methods: {
  266. loadSectionConfig: function() {
  267. var baseSections = ['func_entries', 'wisdom_tips', 'recommended_reading']
  268. if (!uni.getStorageSync('token')) {
  269. this.visibleSections = baseSections
  270. return
  271. }
  272. var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  273. var self = this
  274. getVisibleSections({ pageKey: 'wisdom', role: role }).then(function(res) {
  275. if (res.code === 200 && res.data) {
  276. var keys = res.data.map(function(s) { return s.sectionKey })
  277. var merged = baseSections.slice()
  278. keys.forEach(function(k) { if (merged.indexOf(k) === -1) merged.push(k) })
  279. self.visibleSections = merged
  280. }
  281. }).catch(function(e) {
  282. self.visibleSections = ['func_entries', 'wisdom_tips']
  283. })
  284. },
  285. loadChildren: function() {
  286. var self = this
  287. getChildren().then(function(res) {
  288. if (res.code === 200 && res.data) {
  289. self.children = res.data
  290. if (self.children.length > 0) {
  291. var activeId = uni.getStorageSync('currentChildId')
  292. if (activeId) {
  293. for (var i = 0; i < self.children.length; i++) {
  294. if (self.children[i].id == activeId) {
  295. self.activeChildId = activeId
  296. self.activeChildName = self.children[i].nickname || self.children[i].name || ''
  297. break
  298. }
  299. }
  300. }
  301. // Fallback: 首次进入或未选孩子时,默认选第一个孩子以加载认知数据(仅本地状态,不触发全局切换)
  302. if (!self.activeChildId && self.children.length > 0) {
  303. self.activeChildId = self.children[0].id
  304. self.activeChildName = self.children[0].nickname || self.children[0].name || ''
  305. }
  306. }
  307. // Load cognitive report if activeChildId is available
  308. if (self.activeChildId) {
  309. self.loadCognitiveReport()
  310. }
  311. }
  312. self.loadContacts()
  313. }).catch(function(e) {})
  314. },
  315. loadFamilyMembersVisible: function() {
  316. var self = this
  317. getFamilyEnergySandbox().then(function(res) {
  318. if (res && res.data) {
  319. self.sandboxData = res.data.sandboxData || null
  320. self.dualDimension = res.data.dualDimension || null
  321. if (res.data.members) {
  322. self.familyMembersVisible = res.data.members
  323. }
  324. }
  325. }).catch(function(e) {})
  326. },
  327. loadCognitiveReport: function() {
  328. var self = this
  329. var childId = this.activeChildId
  330. if (!childId) return
  331. getAssessmentLatestResult(childId).then(function(res) {
  332. if (res.code === 200 && res.data) {
  333. self.cognitiveReport = res.data
  334. }
  335. }).catch(function(e) {})
  336. },
  337. onChildChanged: function(childId) {
  338. this.activeChildId = childId
  339. // FIX: 同步提交到 Vuex store
  340. this.$store.commit('switchToChild', childId)
  341. for (var i = 0; i < this.children.length; i++) {
  342. if (this.children[i].id == childId) {
  343. this.activeChildName = this.children[i].nickname || this.children[i].name || ''
  344. break
  345. }
  346. }
  347. this.loadFamilyMembersVisible()
  348. this.loadCognitiveReport()
  349. },
  350. loadDimensionTasks: function() {
  351. var self = this
  352. var childId = this.activeChildId
  353. if (!childId) return
  354. getTodayTasksByCategory(childId, 'wisdom').then(function(res) {
  355. if (res && res.data) {
  356. self.dimensionTasks = res.data.slice(0, 5)
  357. }
  358. }).catch(function(e) {})
  359. },
  360. loadDimensionActivities: function() {
  361. var self = this
  362. getActivityList({ dimensionCode: 'wisdom', page: 1, size: 5 }).then(function(res) {
  363. if (res && res.data) {
  364. self.dimensionActivities = res.data.records || res.data
  365. }
  366. }).catch(function(e) {})
  367. },
  368. loadDimensionProducts: function() {
  369. var self = this
  370. getProductsByDomain('wisdom', 1, 4).then(function(res) {
  371. if (res && res.data) {
  372. self.dimensionProducts = res.data.records || res.data
  373. }
  374. }).catch(function(e) {})
  375. },
  376. sectionVisible: function(key) {
  377. return this.visibleSections.length === 0 || this.visibleSections.indexOf(key) !== -1
  378. },
  379. onFuncClick: function(item) {
  380. if (item.needLogin && !this.isLoggedIn) {
  381. uni.showModal({
  382. title: '提示',
  383. content: '请先登录后使用此功能',
  384. success: function(res) { if (res.confirm) uni.navigateTo({ url: '/pages/login/login' }) }
  385. })
  386. return
  387. }
  388. if (item.page) {
  389. var nativeTabs = ['/pages/tasks/tasks', '/pages/index/index', '/pages/body/index', '/pages/mind/index', '/pages/action/index', '/pages/wisdom/index', '/pages/profile/profile']
  390. if (nativeTabs.indexOf(item.page) !== -1) {
  391. uni.switchTab({ url: item.page })
  392. } else {
  393. uni.navigateTo({ url: item.page })
  394. }
  395. }
  396. },
  397. scrollToSection: function(section) {},
  398. goMemberDetail: function(memberId) {
  399. uni.navigateTo({ url: '/pages/member-detail/member-detail?memberId=' + memberId + '&entrySource=relation-graph&dimensionCode=wisdom' })
  400. },
  401. goFamilyMembers: function() {
  402. uni.navigateTo({ url: '/pages/profile-extra/family-members' })
  403. },
  404. goCognitiveReport: function() {
  405. uni.navigateTo({ url: '/pages/wisdom-detail/cognitive-report' })
  406. },
  407. goSelfQuiz: function() {
  408. uni.navigateTo({ url: '/pages/wisdom-detail/self-quiz' })
  409. },
  410. goTrainingHub: function() {
  411. uni.navigateTo({ url: '/pages/wisdom-detail/training-hub' })
  412. },
  413. goAssessment: function() {
  414. uni.navigateTo({ url: '/pages/assessment/apply' })
  415. },
  416. goHome: function() {
  417. uni.switchTab({ url: '/pages/index/index' })
  418. },
  419. onTaskClick: function(task) {},
  420. goTasks: function() { uni.switchTab({ url: '/pages/tasks/tasks' }) },
  421. goActivityDetail: function(id) {},
  422. goMoreActivities: function() {
  423. uni.navigateTo({ url: '/pages/activity/index' })
  424. },
  425. goActivityDetail: function(act) {
  426. if (!act || !act.id) return
  427. uni.navigateTo({ url: '/pages/discover-detail/activity-detail/activity-detail?id=' + act.id })
  428. },
  429. goProductDetail: function(prod) {
  430. if (prod && prod.id) {
  431. var token = uni.getStorageSync('token')
  432. if (token) {
  433. uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + prod.id })
  434. } else {
  435. uni.navigateTo({ url: '/pages/login/login?redirect=' + encodeURIComponent('/pages/wisdom/index') })
  436. }
  437. }
  438. },
  439. goMoreProducts: function() {
  440. uni.navigateTo({ url: '/pages/shop/index' })
  441. },
  442. parseRelatedDimensions: function(val) {
  443. if (!val) return []
  444. if (Array.isArray(val)) return val
  445. if (typeof val === 'string') {
  446. try {
  447. var parsed = JSON.parse(val)
  448. return Array.isArray(parsed) ? parsed : []
  449. } catch (e) {
  450. return val.split(',').map(function(s) { return s.trim() }).filter(function(s) { return s })
  451. }
  452. }
  453. return []
  454. },
  455. loadFeaturedArticles: function() {
  456. var self = this
  457. getFeaturedArticles({ size: 5, dimensionCode: 'wisdom' }).then(function(res) {
  458. if (res.code === 200 && res.data) {
  459. var gradientColors = [
  460. 'linear-gradient(135deg, #6366F1, #818CF8)',
  461. 'linear-gradient(135deg, #8B5CF6, #A78BFA)',
  462. 'linear-gradient(135deg, #5B9BD5, #8FC5E8)',
  463. 'linear-gradient(135deg, #10B981, #34D399)',
  464. 'linear-gradient(135deg, #F97316, #FB923C)'
  465. ]
  466. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  467. self.articles = list.map(function(item, index) {
  468. return {
  469. id: item.id,
  470. category: item.categoryName || '智慧养成',
  471. categoryColor: gradientColors[index % gradientColors.length],
  472. title: item.title || '',
  473. summary: item.summary || '',
  474. dimensionWeights: item.dimensionWeights || null,
  475. views: item.viewCount ? String(item.viewCount) : '0',
  476. likes: '0',
  477. date: item.publishedAt ? item.publishedAt.slice(0, 10) : '',
  478. relatedDimensions: self.parseRelatedDimensions(item.relatedDimensions)
  479. }
  480. })
  481. }
  482. }).catch(function() {})
  483. },
  484. goMoreArticles: function() {
  485. uni.navigateTo({ url: '/pages/article-center/index?dimension=wisdom' })
  486. },
  487. goArticleDetail: function(article) {
  488. uni.navigateTo({ url: '/pages/mind-detail/article-detail?id=' + (article.id || article) })
  489. },
  490. // ===== 重要关系 =====
  491. loadContacts: function() {
  492. var self = this
  493. getContactList({}).then(function(res) {
  494. if (res.code === 200 && res.data) {
  495. self.contactList = Array.isArray(res.data) ? res.data : []
  496. }
  497. }).catch(function(e) {
  498. console.log('获取联系人失败', e)
  499. })
  500. },
  501. loadRelationshipHealth: function() {
  502. var self = this
  503. getHealthAlerts({}).then(function(res) {
  504. if (res.code === 200 && res.data) {
  505. self.healthAlerts = Array.isArray(res.data) ? res.data : []
  506. }
  507. }).catch(function() {
  508. self.healthAlerts = []
  509. })
  510. getMilestones({}, 30).then(function(res) {
  511. if (res.code === 200 && res.data) {
  512. self.milestones = Array.isArray(res.data) ? res.data : []
  513. }
  514. }).catch(function() {
  515. self.milestones = []
  516. })
  517. },
  518. onContactClick: function(item) {
  519. uni.navigateTo({ url: '/pages/wisdom-detail/contact-detail?id=' + item.id })
  520. },
  521. onShowImport: function() {
  522. uni.showToast({ title: '导入通讯录', icon: 'none' })
  523. },
  524. goInteractionLog: function(memberId) {
  525. if (memberId) {
  526. uni.navigateTo({ url: '/pages/wisdom-detail/interaction-log?memberId=' + memberId })
  527. } else {
  528. uni.navigateTo({ url: '/pages/wisdom-detail/interaction-log' })
  529. }
  530. },
  531. goRelationshipQuestionnaire: function() {
  532. uni.navigateTo({ url: '/pages/wisdom-detail/relationship-questionnaire' })
  533. },
  534. _watchPageReady() {
  535. var self = this
  536. var unwatch = this.$watch(function() {
  537. if (self.isLoggedIn) {
  538. return !!(self.cognitiveReport || self.energyOverview)
  539. }
  540. return !!(self.dimensionActivities && self.dimensionActivities.length > 0) ||
  541. !!(self.dimensionProducts && self.dimensionProducts.length > 0)
  542. }, function(val) {
  543. if (val) {
  544. if (unwatch) unwatch()
  545. self.showTabTransition = false
  546. }
  547. })
  548. setTimeout(function() {
  549. if (unwatch) unwatch()
  550. self.showTabTransition = false
  551. }, 5000)
  552. },
  553. // ===== DAN 报告 =====
  554. loadDanReports: function() {
  555. var self = this
  556. var memberId = self.activeChildId
  557. if (!memberId) return
  558. getDanReportByChild(memberId, 'wisdom').then(function(res) {
  559. if (res.code === 200 && res.data) {
  560. self.danReports = res.data
  561. }
  562. }).catch(function() {})
  563. },
  564. goDanUpload: function() {
  565. uni.navigateTo({ url: '/pages/dan-assessment/report-upload' })
  566. },
  567. viewDanReport: function(report) {
  568. uni.navigateTo({ url: '/pages/dan-assessment/report-upload?draftId=' + report.id })
  569. },
  570. formatDate: function(dateStr) {
  571. if (!dateStr) return ''
  572. var d = new Date(dateStr)
  573. return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
  574. }
  575. }
  576. }
  577. </script>
  578. <style scoped>
  579. .wisdom-container {
  580. min-height: 100vh;
  581. background: #f5f7fa;
  582. padding-bottom: 120rpx;
  583. }
  584. .func-section {
  585. margin: -40rpx 20rpx 0;
  586. position: relative;
  587. z-index: 2;
  588. }
  589. .func-grid {
  590. background: #fff;
  591. border-radius: 24rpx;
  592. padding: 30rpx 16rpx;
  593. display: flex;
  594. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  595. }
  596. .func-item {
  597. flex: 1;
  598. display: flex;
  599. flex-direction: column;
  600. align-items: center;
  601. }
  602. .func-item:active {
  603. opacity: 0.7;
  604. }
  605. .func-icon-wrap {
  606. width: 88rpx;
  607. height: 88rpx;
  608. border-radius: 50%;
  609. background: #FFF8E1;
  610. display: flex;
  611. align-items: center;
  612. justify-content: center;
  613. margin-bottom: 10rpx;
  614. }
  615. .func-icon {
  616. font-size: 40rpx;
  617. }
  618. .func-label {
  619. font-size: 24rpx;
  620. color: #333;
  621. font-weight: 500;
  622. }
  623. /* ===== Section ===== */
  624. .section {
  625. margin: 20rpx 20rpx;
  626. }
  627. .section-header {
  628. display: flex;
  629. justify-content: space-between;
  630. align-items: center;
  631. margin-bottom: 20rpx;
  632. }
  633. .section-title {
  634. font-size: 30rpx;
  635. font-weight: bold;
  636. color: #333;
  637. }
  638. .section-more {
  639. font-size: 24rpx;
  640. color: #999;
  641. }
  642. /* ===== 智慧小贴士 ===== */
  643. .tips-list {
  644. display: flex;
  645. flex-direction: column;
  646. }
  647. .tip-card {
  648. background: #fff;
  649. border-radius: 16rpx;
  650. padding: 24rpx 20rpx;
  651. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  652. margin-bottom: 16rpx;
  653. }
  654. .tip-title {
  655. font-size: 28rpx;
  656. font-weight: bold;
  657. color: #333;
  658. display: block;
  659. margin-bottom: 8rpx;
  660. }
  661. .tip-summary {
  662. font-size: 24rpx;
  663. color: #888;
  664. line-height: 1.5;
  665. display: block;
  666. }
  667. /* ===== 快捷操作按钮 ===== */
  668. .quick-actions {
  669. display: flex;
  670. flex-direction: row;
  671. flex-wrap: wrap;
  672. justify-content: space-between;
  673. }
  674. .action-btn {
  675. width: 48%;
  676. background: #fff;
  677. border-radius: 16rpx;
  678. padding: 24rpx 0;
  679. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  680. display: flex;
  681. flex-direction: column;
  682. align-items: center;
  683. margin-bottom: 20rpx;
  684. }
  685. .action-btn:active {
  686. opacity: 0.8;
  687. }
  688. .action-icon {
  689. font-size: 40rpx;
  690. margin-bottom: 10rpx;
  691. }
  692. .action-text {
  693. font-size: 26rpx;
  694. color: #333;
  695. font-weight: 500;
  696. }
  697. /* ===== 底部占位 ===== */
  698. .bottom-spacer {
  699. height: 120rpx;
  700. }
  701. /* DAN 报告卡片 */
  702. .dan-card {
  703. background: #fff;
  704. border-radius: 16rpx;
  705. padding: 24rpx;
  706. margin-bottom: 16rpx;
  707. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  708. }
  709. .dan-card-header {
  710. display: flex;
  711. justify-content: space-between;
  712. align-items: center;
  713. margin-bottom: 12rpx;
  714. }
  715. .dan-report-date {
  716. font-size: 26rpx;
  717. color: #666;
  718. }
  719. .dan-status {
  720. font-size: 22rpx;
  721. padding: 4rpx 16rpx;
  722. border-radius: 8rpx;
  723. }
  724. .dan-status.confirmed {
  725. background: #D1FAE5;
  726. color: #065F46;
  727. }
  728. .dan-status.pending {
  729. background: #FEF3C7;
  730. color: #92400E;
  731. }
  732. .dan-report-desc {
  733. font-size: 28rpx;
  734. color: #333;
  735. font-weight: 500;
  736. margin-bottom: 12rpx;
  737. display: block;
  738. }
  739. .dan-card-footer {
  740. text-align: right;
  741. }
  742. .dan-view-link {
  743. font-size: 26rpx;
  744. color: #6366F1;
  745. }
  746. </style>