index.vue 24 KB

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