parent-index.vue 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894
  1. <template>
  2. <view class="container">
  3. <!-- 加载状态 -->
  4. <BaseLoading :loading="loading" text="正在加载..." />
  5. <template v-if="!loading">
  6. <!-- ===== a) 顶部 Banner ===== -->
  7. <PageBanner theme="home"
  8. tagline="家庭健康成长俱乐部"
  9. quote="给全家的一站式幸福提案" />
  10. <!-- ===== 家庭成员选择条 ===== -->
  11. <FamilyMemberStrip
  12. v-if="isLoggedIn"
  13. :members="familyMembersVisible"
  14. :selectedMemberId="selectedMemberId"
  15. @select="onFamilyMemberSelect" />
  16. <!-- ===== 微行动卡片(P0:有效启动) ===== -->
  17. <MicroActionCard
  18. v-if="selectedMemberId && selectedChild && selectedChild.id"
  19. :childId="selectedChild.id"
  20. @completed="onMicroActionCompleted" />
  21. <!-- ===== 健康预警横幅(P1-2) ===== -->
  22. <HealthAlertBanner
  23. v-if="selectedMemberId && selectedChild && selectedChild.id"
  24. :alerts="healthAlerts"
  25. @dismiss="onAlertDismiss" />
  26. <!-- ===== 家庭健康排行榜(P2-2) ===== -->
  27. <FamilyHealthRanking
  28. v-if="rankingMembers && rankingMembers.length > 0"
  29. :list="rankingMembers"
  30. :totalScore="rankingTotalScore" />
  31. <!-- ===== 家庭挑战卡片(P2-2) ===== -->
  32. <FamilyChallengeCard
  33. v-for="ch in activeChallenges"
  34. :key="ch.id"
  35. :challenge="ch" />
  36. <!-- ===== 健康圈入口(P3:社区扩散) ===== -->
  37. <view class="circle-entry-section">
  38. <!-- 有健康圈数据:显示排行榜预览 -->
  39. <PlayfulCard v-if="circleName && circleRankings.length > 0" variant="flat" shadow="sm" :clickable="true" @click="goToHealthCircle" class="circle-card-wide">
  40. <view class="circle-card-content">
  41. <view class="circle-header">
  42. <view class="circle-icon-wrap">
  43. <text class="circle-icon">🏅</text>
  44. </view>
  45. <view class="circle-header-body">
  46. <text class="circle-card-title">健康圈</text>
  47. <text class="circle-card-subtitle">{{ circleName }}</text>
  48. </view>
  49. </view>
  50. <view class="circle-ranking-preview">
  51. <view class="circle-rank-row" v-for="(item, idx) in circleRankings.slice(0, 3)" :key="idx">
  52. <text class="circle-rank-badge">{{ rankIcon(idx) }}</text>
  53. <text class="circle-rank-family">家庭 {{ idx + 1 }}</text>
  54. <text class="circle-rank-score">{{ item.totalScore || 0 }} 分</text>
  55. </view>
  56. </view>
  57. <view class="circle-action">
  58. <text class="circle-action-text">查看详情 →</text>
  59. </view>
  60. </view>
  61. </PlayfulCard>
  62. <!-- 无健康圈数据:邀请加入 -->
  63. <PlayfulCard v-else variant="flat" shadow="sm" :clickable="true" @click="goToHealthCircle" class="circle-card-wide circle-card-invite">
  64. <view class="circle-invite-content">
  65. <view class="circle-invite-icon">🏅</view>
  66. <text class="circle-invite-title">健康圈</text>
  67. <text class="circle-invite-desc">加入健康圈,和更多家庭一起健康打卡</text>
  68. <text class="circle-invite-cta">去看看 →</text>
  69. </view>
  70. </PlayfulCard>
  71. </view>
  72. <!-- ===== 家庭成员关系图谱 ===== -->
  73. <FamilyRelationGraph
  74. v-if="familyMembersVisible.length > 0"
  75. dimensionCode="home"
  76. :selfId="selfMemberId"
  77. :members="familyMembersVisible"
  78. :energyMap="energyMapForGraph"
  79. :intimacyMap="intimacyMapForGraph"
  80. @memberTap="goMemberDetail" />
  81. <!-- 能量沙盘 -->
  82. <WuxingSandbox
  83. v-if="sandboxData"
  84. mode="live"
  85. :scores="sandboxScores"
  86. :overallScore="sandboxData.overallScore || 0"
  87. :members="sandboxData.members || []"
  88. :dimensions="energyDimensions"
  89. :totalEnergy="totalEnergy"
  90. :totalHealthIndex="totalHealthIndex"
  91. starHeight="400rpx"
  92. showDimensionBar
  93. @point-click="onDomainClick" />
  94. <!-- 能量数据加载失败兜底 -->
  95. <view class="error-state" v-if="errorEnergy && !sandboxData" @click="loadData">
  96. <text class="error-state-text">家庭能量数据加载失败,点击重试</text>
  97. </view>
  98. <!-- ===== c) 成长数据 ===== -->
  99. <view class="stats-section animate-fade-in animate-stagger-5">
  100. <view class="section-title">成长数据</view>
  101. <view class="stats-row">
  102. <!-- 任务完成率:自己的 + 全家平均 -->
  103. <PlayfulCard variant="flat" shadow="sm" :clickable="true" @click="goToCompletionStats" class="stat-card-wide" padding="0">
  104. <view class="stat-card-content">
  105. <view class="stat-header">
  106. <view class="stat-icon-wrap stat-icon-orange">
  107. <text class="stat-icon-symbol">📋</text>
  108. </view>
  109. <view class="stat-body">
  110. <text class="stat-label-header">任务完成</text>
  111. </view>
  112. </view>
  113. <view class="stat-compare">
  114. <view class="stat-compare-row">
  115. <text class="compare-label">自己的</text>
  116. <text class="compare-value accent-color">{{ myCompletionRate }}%</text>
  117. </view>
  118. <view class="progress-bar-sm">
  119. <view class="progress-fill-sm" :style="{ width: myCompletionRate + '%' }"></view>
  120. </view>
  121. <view class="stat-compare-row">
  122. <text class="compare-label">全家平均</text>
  123. <text class="compare-value">{{ familyAvgCompletionRate }}%</text>
  124. </view>
  125. <view class="progress-bar-sm">
  126. <view class="progress-fill-sm muted" :style="{ width: familyAvgCompletionRate + '%' }"></view>
  127. </view>
  128. </view>
  129. <text class="stat-more">查看分析 ›</text>
  130. </view>
  131. </PlayfulCard>
  132. <!-- 成长积分:自己的 + 全家共 -->
  133. <PlayfulCard variant="flat" shadow="sm" :clickable="true" @click="goToRewards" class="stat-card-wide" padding="0">
  134. <view class="stat-card-content">
  135. <view class="stat-header">
  136. <view class="stat-icon-wrap stat-icon-gold">
  137. <text class="stat-icon-symbol">⭐</text>
  138. </view>
  139. <view class="stat-body">
  140. <text class="stat-label-header">成长积分</text>
  141. </view>
  142. </view>
  143. <view class="stat-compare">
  144. <view class="stat-compare-row">
  145. <text class="compare-label">自己的</text>
  146. <text class="compare-value gold-color">{{ myPoints }}</text>
  147. </view>
  148. <view class="stat-compare-row">
  149. <text class="compare-label">全家共</text>
  150. <text class="compare-value">{{ familyTotalPoints }}</text>
  151. </view>
  152. </view>
  153. <text class="stat-encourage" v-if="myPoints > 0">太棒了!</text>
  154. <text class="stat-encourage muted" v-else>开始赚星星吧</text>
  155. </view>
  156. </PlayfulCard>
  157. </view>
  158. </view>
  159. <!-- ===== d) 今日重点 ===== -->
  160. <view class="today-section animate-fade-in animate-stagger-7">
  161. <view class="section-title">今日重点</view>
  162. <PlayfulCard variant="flat" class="today-card">
  163. <template slot="header">
  164. <view class="today-header">
  165. <text class="today-label">今日待完成</text>
  166. <text class="today-count">{{ pendingTasks.length }}项任务</text>
  167. </view>
  168. </template>
  169. <view class="task-list" v-if="pendingTasks.length > 0">
  170. <view class="task-item" v-for="task in pendingTasks.slice(0, 3)" :key="task.id">
  171. <view class="task-dot" :class="'dot-color-' + (task.id % 5)"></view>
  172. <text class="task-title">{{ task.title }}</text>
  173. </view>
  174. </view>
  175. <BaseEmpty v-else icon="🎉" title="今日任务已完成" description="太棒了!" :compact="true" />
  176. <view slot="actions" class="task-view-all" @click="goToTaskList">
  177. <text>查看全部</text>
  178. <text class="arrow">→</text>
  179. </view>
  180. </PlayfulCard>
  181. </view>
  182. <!-- ===== e) 成长里程碑 ===== -->
  183. <view class="milestone-section animate-fade-in animate-stagger-8">
  184. <view class="section-title">成长里程碑</view>
  185. <PlayfulCard variant="flat" class="milestone-card">
  186. <view class="milestone-item" v-if="selectedChild && selectedChild.streakDays >= 7">
  187. <view class="milestone-icon-wrap milestone-star">
  188. <text class="milestone-icon">🌟</text>
  189. </view>
  190. <text class="milestone-text">连续7天打卡</text>
  191. </view>
  192. <view class="milestone-item" v-if="selectedChild && selectedChild.streakDays >= 30">
  193. <view class="milestone-icon-wrap milestone-trophy">
  194. <text class="milestone-icon">🏆</text>
  195. </view>
  196. <text class="milestone-text">坚持一个月啦!</text>
  197. </view>
  198. <view class="milestone-item" v-if="(selectedChild && selectedChild.totalPoints) >= 1000">
  199. <view class="milestone-icon-wrap milestone-sparkle">
  200. <text class="milestone-icon">💫</text>
  201. </view>
  202. <text class="milestone-text">积分突破1000</text>
  203. </view>
  204. <BaseEmpty v-if="!hasMilestones" icon="🌱" title="开始养成好习惯" description="见证成长" :compact="true" />
  205. </PlayfulCard>
  206. </view>
  207. <!-- ===== f) 待处理事项 ===== -->
  208. <view class="pending-section animate-fade-in animate-stagger-9">
  209. <view class="section-title">📋 待处理事项</view>
  210. <view class="pending-grid">
  211. <view class="pending-card" @click="goToReview">
  212. <view class="pending-icon pending-icon--blue">
  213. <text class="pending-emoji">📝</text>
  214. </view>
  215. <view class="pending-info">
  216. <text class="pending-count accent-color">{{ pendingReviewTasks.length }}</text>
  217. <text class="pending-label">待审核任务</text>
  218. </view>
  219. </view>
  220. <view class="pending-card" @click="goToWishApprove">
  221. <view class="pending-icon pending-icon--pink">
  222. <text class="pending-emoji">💝</text>
  223. </view>
  224. <view class="pending-info">
  225. <text class="pending-count pink-color">{{ pendingReviewWishes.length }}</text>
  226. <text class="pending-label">待审批心愿</text>
  227. </view>
  228. </view>
  229. <view class="pending-card" @click="goToAssessmentReport">
  230. <view class="pending-icon pending-icon--green">
  231. <text class="pending-emoji">📊</text>
  232. </view>
  233. <view class="pending-info">
  234. <text class="pending-count teal-color">{{ hasNewReport ? '有新' : '暂无' }}</text>
  235. <text class="pending-label">最新测评报告</text>
  236. </view>
  237. </view>
  238. <view class="pending-card" @click="goToActivities">
  239. <view class="pending-icon pending-icon--orange">
  240. <text class="pending-emoji">🎉</text>
  241. </view>
  242. <view class="pending-info">
  243. <text class="pending-count orange-color">{{ hotActivityCount > 0 ? hotActivityCount : '暂无' }}</text>
  244. <text class="pending-label">活动推荐</text>
  245. </view>
  246. </view>
  247. </view>
  248. </view>
  249. <!-- ===== 重要关系(外部通讯录) ===== -->
  250. <view class="contact-section" v-if="!loading && familyMembersVisible.length > 0">
  251. <view class="contact-header">
  252. <text class="contact-section-title">重要关系</text>
  253. <view class="contact-header-right">
  254. <text class="contact-more" @click="loadContacts">刷新</text>
  255. <text class="contact-import-btn" @click="onShowImport">+ 导入</text>
  256. </view>
  257. </view>
  258. <scroll-view class="contact-scroll" scroll-x enable-flex>
  259. <view class="contact-scroll-inner">
  260. <view class="contact-card-wrap" v-for="item in contactList" :key="item.id" @click="onContactClick(item)">
  261. <ContactCard :contact="item" />
  262. </view>
  263. <view class="contact-card-wrap contact-add-card" @click="onShowImport">
  264. <view class="add-card-inner">
  265. <text class="add-card-icon">+</text>
  266. <text class="add-card-label">导入通讯录</text>
  267. </view>
  268. </view>
  269. </view>
  270. </scroll-view>
  271. <view class="contact-empty" v-if="contactList.length === 0">
  272. <text class="contact-empty-text">暂无重要联系人,点击导入添加</text>
  273. </view>
  274. </view>
  275. <!-- 导入联系人弹窗 -->
  276. <ContactImport
  277. :visible="showImportModal"
  278. @close="onCloseImport"
  279. @success="onImportSuccess" />
  280. <!-- 邀请码二维码弹窗 -->
  281. <view class="qr-code-modal" v-if="showQrCodeModal" @touchmove.stop.prevent @click="onCloseQrCodeModal">
  282. <view class="qr-code-modal-content" @click.stop>
  283. <view class="qr-code-modal-header">
  284. <text class="qr-code-modal-title">邀请二维码</text>
  285. <text class="qr-code-modal-close" @click="onCloseQrCodeModal">×</text>
  286. </view>
  287. <view class="qr-code-modal-body">
  288. <view class="qr-code-image-container">
  289. <image :src="(qrCodeData && qrCodeData.qrCodeBase64) || ''" class="qr-code-image" mode="aspectFit" />
  290. </view>
  291. <view class="qr-code-referral-code">
  292. <text class="qr-code-label">邀请码:</text>
  293. <text class="qr-code-code">{{ (qrCodeData && qrCodeData.referralCode) || '' }}</text>
  294. <text class="qr-code-copy" @click="onCopyReferralCode">复制</text>
  295. </view>
  296. </view>
  297. </view>
  298. </view>
  299. <!-- ===== 推荐商品+活动(混合信息流) ===== -->
  300. <RecommendedFeed
  301. :products="recommendedProducts"
  302. :activities="recommendedActivities"
  303. :loading="loadingProducts || loadingActivities"
  304. @itemClick="onFeedItemClick"
  305. @more="goMoreDiscover" />
  306. <view class="error-state" v-if="errorProducts || errorActivities">
  307. <text class="error-state-text">推荐加载失败</text>
  308. </view>
  309. <!-- ===== 推荐阅读(书册风格) ===== -->
  310. <ArticleBookshelf
  311. :articles="indexArticles"
  312. :loading="articlesLoading"
  313. :isLoggedIn="isLoggedIn"
  314. @articleClick="goArticleDetail"
  315. @moreArticles="goArticles"
  316. />
  317. <!-- ===== h) 待审核任务 ===== -->
  318. <view class="review-section animate-fade-in animate-stagger-11" v-if="pendingReviewTasks.length > 0">
  319. <view class="section-title">待审核任务</view>
  320. <PlayfulCard
  321. variant="flat"
  322. shadow="sm"
  323. class="review-card"
  324. v-for="task in pendingReviewTasks"
  325. :key="task.id"
  326. padding="0"
  327. >
  328. <view class="review-card-content">
  329. <view class="review-info">
  330. <text class="task-name">{{ task.title }}</text>
  331. <text class="task-child" v-if="task.childName">提供者: {{ task.childName }}</text>
  332. </view>
  333. <view class="review-actions">
  334. <PlayfulButton variant="success" size="xs" @click="approveTask(task.id)">通过</PlayfulButton>
  335. <PlayfulButton variant="error" size="xs" @click="rejectTask(task.id)">拒绝</PlayfulButton>
  336. </view>
  337. </view>
  338. </PlayfulCard>
  339. </view>
  340. <!-- ===== g) 快捷操作 ===== -->
  341. <view class="quick-section animate-fade-in animate-stagger-10">
  342. <view class="section-title">快捷操作</view>
  343. <PlayfulCard variant="flat" class="quick-card">
  344. <view class="quick-actions">
  345. <view class="action-item" @click="addTask">
  346. <view class="action-icon act-add">
  347. <text class="action-icon-text">➕</text>
  348. </view>
  349. <text class="action-label">添加任务</text>
  350. </view>
  351. <view class="action-item" @click="goToReview">
  352. <view class="action-icon act-review">
  353. <text class="action-icon-text">📋</text>
  354. </view>
  355. <text class="action-label">审核任务</text>
  356. </view>
  357. <view class="action-item" @click="manageChildren">
  358. <view class="action-icon act-child">
  359. <text class="action-icon-text">👨‍👩‍👧</text>
  360. </view>
  361. <text class="action-label">成员管理</text>
  362. </view>
  363. <view class="action-item" @click="goToRewards">
  364. <view class="action-icon act-reward">
  365. <text class="action-icon-text">🎁</text>
  366. </view>
  367. <text class="action-label">奖励中心</text>
  368. </view>
  369. <!-- Added: QR Code button -->
  370. <view class="action-item" @click="onShowQrCodeModal">
  371. <view class="action-icon act-invite">
  372. <text class="action-icon-text">📱</text>
  373. </view>
  374. <text class="action-label">邀请码</text>
  375. </view>
  376. </view>
  377. </PlayfulCard>
  378. </view>
  379. </template>
  380. <!-- ===== L1 即时反馈:Toast + 庆祝 ===== -->
  381. <FeedbackToast
  382. :visible="toastVisible"
  383. :text="toastText"
  384. :icon="toastIcon"
  385. :animating="toastAnimating" />
  386. <MilestoneCelebration
  387. :visible="celebrationVisible"
  388. :title="celebrationTitle"
  389. :subtitle="celebrationSubtitle"
  390. :particles="celebrationParticles"
  391. @dismiss="celebrationVisible = false" />
  392. <!-- ===== L2 深度反馈:每日健康小语 ===== -->
  393. <DailySummary
  394. v-if="selectedMemberId && selectedChild && selectedChild.id"
  395. :childId="selectedChild.id"
  396. @dismiss="onDailySummaryDismiss" />
  397. </view>
  398. </template>
  399. <script>
  400. import { getFamilyMembers, getChildren, getPendingReviewTasks, getPendingWishes, approveTask, rejectTask, getChildCompletionStats, getParentDashboard, getFamilyEnergySandbox, getEnergyOverview, getVisibleFamilyMembers, getActivityList, getProductsByDomain, getContactList, getFeaturedArticles, getActiveAlerts, dismissAlert, getFamilyRanking, getChallengeList, getCircleRanking, getInviteQrCode } from '../../utils/api.js'
  401. import PageBanner from '../../components/PageBanner.vue'
  402. import PlayfulCard from '../../components/PlayfulCard.vue'
  403. import PlayfulButton from '../../components/PlayfulButton.vue'
  404. import BaseBadge from '../../components/BaseBadge.vue'
  405. import BaseEmpty from '../../components/BaseEmpty.vue'
  406. import BaseLoading from '../../components/BaseLoading.vue'
  407. import FamilyRelationGraph from '../../components/FamilyRelationGraph.vue'
  408. import WuxingSandbox from '../../components/wuxing-sandbox.vue'
  409. import ContactCard from '../../components/ContactCard.vue'
  410. import FamilyHealthRanking from '../../components/FamilyHealthRanking.vue'
  411. import FamilyChallengeCard from '../../components/FamilyChallengeCard.vue'
  412. import ContactImport from '../../components/ContactImport.vue'
  413. import RecommendedFeed from '../../components/RecommendedFeed.vue'
  414. import FamilyMemberStrip from '../../components/FamilyMemberStrip.vue'
  415. import MicroActionCard from '../../components/MicroActionCard.vue'
  416. import FeedbackToast from '../../components/FeedbackToast.vue'
  417. import MilestoneCelebration from '../../components/MilestoneCelebration.vue'
  418. import DailySummary from '../../components/DailySummary.vue'
  419. import HealthAlertBanner from '../../components/HealthAlertBanner.vue'
  420. import CircleRanking from '../../components/CircleRanking.vue'
  421. import ArticleBookshelf from '../../components/ArticleBookshelf.vue'
  422. import feedbackEngine from '../../utils/feedback-engine.js'
  423. export default {
  424. components: { PageBanner, RecommendedFeed, PlayfulCard, PlayfulButton, BaseBadge, BaseEmpty, BaseLoading, FamilyRelationGraph, WuxingSandbox, ContactCard, ContactImport, FamilyMemberStrip, MicroActionCard, FeedbackToast, MilestoneCelebration, DailySummary, HealthAlertBanner, FamilyHealthRanking, FamilyChallengeCard, CircleRanking, ArticleBookshelf },
  425. data() {
  426. return {
  427. nickname: '',
  428. familyMembers: [],
  429. children: [],
  430. selectedChild: null,
  431. pendingReviewTasks: [],
  432. pendingReviewWishes: [],
  433. pendingWishesCount: 0,
  434. pendingTasks: [],
  435. hotActivityCount: 0,
  436. hasNewReport: false,
  437. myCompletionRate: 0,
  438. familyAvgCompletionRate: 0,
  439. myPoints: 0,
  440. familyTotalPoints: 0,
  441. // membershipText removed (no real function)
  442. loading: true,
  443. currentChildId: '',
  444. _initialLoadDone: false,
  445. _familyId: null,
  446. familyMembersVisible: [],
  447. selfMemberId: null,
  448. energyData: null,
  449. energyDimensions: [],
  450. totalEnergy: 0,
  451. totalHealthIndex: 0,
  452. recommendedActivities: [],
  453. recommendedProducts: [],
  454. hasFamilyData: false,
  455. sandboxData: null,
  456. errorEnergy: false,
  457. errorTasks: false,
  458. errorActivities: false,
  459. errorProducts: false,
  460. loadingActivities: false,
  461. loadingProducts: false,
  462. contactList: [],
  463. showImportModal: false,
  464. // QR Code modal
  465. showQrCodeModal: false,
  466. qrCodeData: null,
  467. // 推荐阅读
  468. indexArticles: [],
  469. articlesLoading: false,
  470. isLoggedIn: false,
  471. gradientColors: [
  472. 'linear-gradient(135deg, #10B981, #34D399)',
  473. 'linear-gradient(135deg, #5B9BD5, #8FC5E8)',
  474. 'linear-gradient(135deg, #8B5CF6, #C084FC)',
  475. 'linear-gradient(135deg, #F97316, #FB923C)',
  476. 'linear-gradient(135deg, #6366F1, #818CF8)'
  477. ],
  478. selectedMemberId: null,
  479. // L1 即时反馈状态
  480. toastVisible: false,
  481. toastText: '',
  482. toastIcon: '✅',
  483. toastAnimating: false,
  484. celebrationVisible: false,
  485. celebrationTitle: '',
  486. celebrationSubtitle: '',
  487. celebrationParticles: [],
  488. // P1-2 健康预警
  489. healthAlerts: [],
  490. // P2-2 家庭互动
  491. rankingMembers: [],
  492. rankingTotalScore: 0,
  493. activeChallenges: [],
  494. // P3 健康圈(社区扩散)
  495. circleRankings: [],
  496. circleName: '',
  497. circleLoading: false
  498. }
  499. },
  500. computed: {
  501. topPendingTasks() {
  502. return this.pendingTasks.slice(0, 3)
  503. },
  504. energyScores() {
  505. var d = this.energyData
  506. if (!d) return { body: 0, mind: 0, wisdom: 0, action: 0, wealth: 0 }
  507. return { body: d.bodyScore, mind: d.mindScore, wisdom: d.wisdomScore, action: d.actionScore, wealth: d.wealthScore }
  508. },
  509. energyOverall() {
  510. return this.energyData ? this.energyData.overallScore : 0
  511. },
  512. energyMembers() {
  513. return this.energyData ? this.energyData.members : []
  514. },
  515. sandboxScores() {
  516. if (!this.sandboxData) return { body: 0, mind: 0, wisdom: 0, action: 0, wealth: 0 }
  517. return {
  518. body: this.sandboxData.bodyScore || 0,
  519. mind: this.sandboxData.mindScore || 0,
  520. wisdom: this.sandboxData.wisdomScore || 0,
  521. action: this.sandboxData.actionScore || 0,
  522. wealth: this.sandboxData.wealthScore || 0
  523. }
  524. },
  525. greetingText() {
  526. const hour = new Date().getHours()
  527. if (hour < 6) return '夜深了'
  528. if (hour < 9) return '早上好'
  529. if (hour < 12) return '上午好'
  530. if (hour < 14) return '中午好'
  531. if (hour < 18) return '下午好'
  532. if (hour < 22) return '晚上好'
  533. return '夜深了'
  534. },
  535. hasMilestones() {
  536. const c = this.selectedChild
  537. if (!c) return false
  538. return (c.streakDays >= 7) || (c.streakDays >= 30) || (c.totalPoints >= 1000)
  539. },
  540. energyMapForGraph() {
  541. var map = {}
  542. if (this.sandboxData && this.sandboxData.members) {
  543. for (var i = 0; i < this.sandboxData.members.length; i++) {
  544. var m = this.sandboxData.members[i]
  545. map[m.memberId || m.id] = {
  546. bodyScore: m.bodyScore || 0,
  547. mindScore: m.mindScore || 0,
  548. actionScore: m.actionScore || 0
  549. }
  550. }
  551. }
  552. return map
  553. },
  554. intimacyMapForGraph() {
  555. return {}
  556. }
  557. },
  558. // 使用 mounted 而非 onLoad,因为本组件作为条件渲染子组件(v-if),
  559. // page 生命周期钩子(onLoad/onShow)可能在组件挂载前已触发完毕
  560. mounted() {
  561. if (uni.getStorageSync('token')) {
  562. this.isLoggedIn = true
  563. this.loadData()
  564. }
  565. },
  566. onShow() {
  567. // 首次 onShow 紧接 mounted 之后,跳过避免双重加载
  568. if (!this._initialLoadDone) {
  569. this._initialLoadDone = true
  570. return
  571. }
  572. const currentRole = uni.getStorageSync('currentRole') || 'parent'
  573. if (currentRole === 'child') {
  574. uni.reLaunch({ url: '/pages/home-pages/child-index' })
  575. return
  576. }
  577. if (uni.getStorageSync('token')) {
  578. this.isLoggedIn = true
  579. this.loadData()
  580. }
  581. },
  582. onPullDownRefresh() {
  583. this.loadData().finally(() => {
  584. uni.stopPullDownRefresh()
  585. })
  586. },
  587. methods: {
  588. rankIcon: function(idx) {
  589. var medals = ['🥇', '🥈', '🥉']
  590. return medals[idx] || '#' + (idx + 1)
  591. },
  592. async loadData() {
  593. this.loading = true
  594. try {
  595. var userInfo = uni.getStorageSync('userInfo')
  596. this.nickname = (userInfo && userInfo.nickname) ? userInfo.nickname : ''
  597. this.selfMemberId = uni.getStorageSync('userId') || null
  598. // 优先使用仪表盘接口(包含孩子列表 + 统计数据)
  599. let dashboardLoaded = false
  600. try {
  601. const dashRes = await getParentDashboard()
  602. const dashData = dashRes.data || {}
  603. const dashChildren = dashData.children || []
  604. // 过滤:仅保留孩子角色成员,排除家长/本人
  605. var currentUserId = uni.getStorageSync('userId')
  606. var filteredChildren = dashChildren.filter(function(c) {
  607. return c && c.id && c.id !== currentUserId && (c.role === 'child' || c.memberType === 'child')
  608. })
  609. if (filteredChildren.length > 0) {
  610. this.children = filteredChildren
  611. this.selectedChild = filteredChildren[0]
  612. this.currentChildId = filteredChildren[0].id
  613. this.familyAvgCompletionRate = dashData.avgCompletionRate || 0
  614. // 家长自身数据(积分 + 任务完成率)
  615. this.myPoints = dashData.parentPoints || 0
  616. this.myCompletionRate = dashData.parentCompletionRate || 0
  617. // 从仪表盘获取 familyId
  618. if (dashData.familyId) {
  619. this._familyId = dashData.familyId
  620. }
  621. dashboardLoaded = true
  622. }
  623. } catch (e) {
  624. console.log('获取仪表盘数据失败,降级到单独接口', e)
  625. }
  626. // 降级:使用原有单独接口
  627. if (!dashboardLoaded) {
  628. try {
  629. const currentUserId = uni.getStorageSync('userId')
  630. const membersRes = await getFamilyMembers()
  631. const data = membersRes.data || {}
  632. const parents = (data.parents || []).filter(function(p) { return p && p.id && p.id !== currentUserId }).map(function(p) { return { ...p, role: 'parent' } })
  633. const children = (data.children || []).filter(function(c) { return c && c.id }).map(function(c) { return { ...c, role: 'child' } })
  634. this.familyMembers = [].concat(parents, children)
  635. if (children.length > 0) {
  636. this.selectedChild = children[0]
  637. this.currentChildId = children[0].id
  638. }
  639. // 保存 familyId 用于后续请求
  640. if (data.familyId) {
  641. this._familyId = data.familyId
  642. }
  643. } catch (e) {
  644. console.log('获取家庭成员失败', e)
  645. }
  646. if (this.children.length === 0) {
  647. try {
  648. const childrenRes = await getChildren()
  649. const rawChildren = childrenRes.data || []
  650. this.children = rawChildren
  651. if (this.children.length > 0 && !this.selectedChild) {
  652. this.selectedChild = this.children[0]
  653. this.currentChildId = this.children[0].id
  654. }
  655. } catch (e) {
  656. console.log('获取孩子列表失败', e)
  657. }
  658. }
  659. }
  660. const reviewRes = await getPendingReviewTasks()
  661. const allReviewTasks = reviewRes.data || []
  662. this.pendingReviewTasks = allReviewTasks.slice(0, 3)
  663. try {
  664. const wishRes = await getPendingWishes(this._familyId)
  665. this.pendingReviewWishes = wishRes.data || []
  666. } catch (e) {
  667. console.log('获取待处理心愿失败', e)
  668. this.pendingReviewWishes = []
  669. }
  670. const reviewMap = {}
  671. const wishMap = {}
  672. for (let i = 0; i < allReviewTasks.length; i++) {
  673. const task = allReviewTasks[i]
  674. const cid = task.childId || task.assigneeId
  675. if (cid) {
  676. reviewMap[cid] = (reviewMap[cid] || 0) + 1
  677. }
  678. }
  679. for (let j = 0; j < (this.pendingReviewWishes || []).length; j++) {
  680. const wish = this.pendingReviewWishes[j]
  681. const cid = wish.childId
  682. if (cid) {
  683. wishMap[cid] = (wishMap[cid] || 0) + 1
  684. }
  685. }
  686. this.children = this.children.map(function(c) {
  687. return {
  688. ...c,
  689. pendingReviewCount: reviewMap[c.id] || 0,
  690. pendingWishCount: wishMap[c.id] || 0
  691. }
  692. })
  693. // 计算全家总积分(家长 + 所有孩子)
  694. var totalPts = this.myPoints
  695. for (var pi = 0; pi < this.children.length; pi++) {
  696. totalPts += (this.children[pi].totalPoints || 0)
  697. }
  698. this.familyTotalPoints = totalPts
  699. // 如果仪表盘未加载到数据,降级:从孩子数据取近似值
  700. if (!dashboardLoaded) {
  701. // 降级:家长积分取自己的(从缓存或API),完成率取第一个孩子的
  702. const targetChild = this.selectedChild || (this.children.length > 0 ? this.children[0] : null)
  703. if (targetChild) {
  704. try {
  705. const statsRes = await getChildCompletionStats({ childId: targetChild.id })
  706. if (statsRes && statsRes.data) {
  707. this.myCompletionRate = statsRes.data.completionRate || 0
  708. }
  709. } catch (e) {
  710. console.log('获取个人完成率失败', e)
  711. }
  712. userInfo = uni.getStorageSync('userInfo')
  713. this.myPoints = (userInfo && userInfo.totalPoints) || 0
  714. this.familyAvgCompletionRate = this.myCompletionRate
  715. }
  716. }
  717. // 待完成任务 - 优先使用后端返回的真实任务列表
  718. this.pendingTasks = []
  719. if (this.children.length > 0) {
  720. const targetChild = this.selectedChild || this.children[0]
  721. try {
  722. const r2 = await getChildCompletionStats({ childId: targetChild.id })
  723. if (r2 && r2.data && r2.data.pendingTaskList && r2.data.pendingTaskList.length > 0) {
  724. this.pendingTasks = r2.data.pendingTaskList.slice(0, 3)
  725. } else if (r2 && r2.data && r2.data.pendingTasks > 0) {
  726. // 降级:只有数量没有列表时使用占位
  727. for (let k = 0; k < Math.min(r2.data.pendingTasks, 3); k++) {
  728. this.pendingTasks.push({ id: 'pending-' + k, title: '待完成任务' })
  729. }
  730. }
  731. } catch (e) {
  732. this.pendingTasks = []
  733. }
  734. }
  735. // 加载家庭能量沙盘数据(五维 + 所有成员)
  736. try {
  737. const energyRes = await getFamilyEnergySandbox()
  738. this.energyData = energyRes.data || null
  739. this.sandboxData = energyRes.data || null
  740. this.hasFamilyData = !!(energyRes.data && energyRes.data.members && energyRes.data.members.length > 0)
  741. } catch (e) {
  742. console.log('获取能量沙盘数据失败', e)
  743. this.energyData = null
  744. this.errorEnergy = true
  745. }
  746. // 加载推荐活动
  747. this.loadRecommendedActivities()
  748. // 加载推荐商品
  749. this.loadRecommendedProducts()
  750. // 加载家庭成员可见列表
  751. this.loadFamilyMembersVisible()
  752. // 加载健康预警(P1-2)
  753. this.loadAlerts()
  754. // 加载家庭健康互动(P2-2)
  755. this.loadFamilyInteraction()
  756. // 加载健康圈(P3:社区扩散)
  757. this.loadHealthCircle()
  758. // 加载外部联系人
  759. this.loadContacts()
  760. // 加载推荐阅读
  761. this.loadFeaturedArticles()
  762. // 加载五维能量概览(账本模式)
  763. var overviewChildId = this.currentChildId
  764. if (overviewChildId) {
  765. try {
  766. var overviewRes = await getEnergyOverview(overviewChildId)
  767. if (overviewRes && overviewRes.data) {
  768. this.energyDimensions = overviewRes.data.dimensions || []
  769. this.totalEnergy = overviewRes.data.totalEnergy || 0
  770. this.totalHealthIndex = overviewRes.data.totalHealthIndex || 0
  771. }
  772. } catch (e) {
  773. console.log('获取能量概览失败', e)
  774. }
  775. }
  776. } catch (e) {
  777. console.error('加载数据失败', e)
  778. } finally {
  779. this.loading = false
  780. this.$emit('ready')
  781. }
  782. },
  783. async approveTask(taskId) {
  784. try {
  785. await approveTask(taskId)
  786. uni.showToast({ title: '已通过', icon: 'success' })
  787. this.loadData()
  788. } catch (e) {
  789. uni.showToast({ title: '操作失败', icon: 'none' })
  790. }
  791. },
  792. async rejectTask(taskId) {
  793. try {
  794. await rejectTask(taskId)
  795. uni.showToast({ title: '已拒绝', icon: 'success' })
  796. this.loadData()
  797. } catch (e) {
  798. uni.showToast({ title: '操作失败', icon: 'none' })
  799. }
  800. },
  801. // 加载可见家庭成员
  802. async loadFamilyMembersVisible() {
  803. try {
  804. var res = await getVisibleFamilyMembers()
  805. this.familyMembersVisible = res.data || []
  806. } catch (e) {
  807. console.log('获取可见家庭成员失败', e)
  808. this.familyMembersVisible = []
  809. }
  810. },
  811. // 成员选择
  812. goToCompletionStats() {
  813. if (this.children.length === 1) {
  814. uni.navigateTo({ url: '/pages/stats/completion-rate?childId=' + this.children[0].id })
  815. } else {
  816. uni.navigateTo({ url: '/pages/stats/completion-rate?familyView=1' })
  817. }
  818. },
  819. onDomainClick(evt) {
  820. this.goToDomain(evt.code)
  821. },
  822. goToDomain(code) {
  823. // 跳转到能量详情页
  824. var childId = this.currentChildId
  825. if (!childId || !code) return
  826. uni.navigateTo({
  827. url: '/pages/energy/detail?childId=' + childId + '&code=' + code
  828. })
  829. },
  830. onFamilyMemberSelect(member) {
  831. this.selectedMemberId = member.id
  832. },
  833. onMicroActionCompleted() {
  834. this.loadData()
  835. feedbackEngine.trigger('micro_action')
  836. },
  837. onDailySummaryDismiss() {
  838. // DailySummary 已关闭,无额外操作
  839. },
  840. loadAlerts: function() {
  841. var childId = this.selectedChild && this.selectedChild.id
  842. if (!childId) return
  843. var self = this
  844. getActiveAlerts({ childId: childId }).then(function(res) {
  845. if (res.code === 200) {
  846. self.healthAlerts = res.data || []
  847. }
  848. }).catch(function() {})
  849. },
  850. handleDismissAlert: function(alertId) {
  851. var self = this
  852. dismissAlert({ id: alertId }).then(function(res) {
  853. if (res.code === 200) {
  854. self.healthAlerts = self.healthAlerts.filter(function(a) { return a.id !== alertId })
  855. }
  856. }).catch(function() {})
  857. },
  858. loadFamilyInteraction: function() {
  859. var familyId = this._familyId
  860. if (!familyId) return
  861. var self = this
  862. getFamilyRanking({ familyId: familyId }).then(function(res) {
  863. if (res.code === 200 && res.data) {
  864. self.rankingMembers = res.data.members || []
  865. self.rankingTotalScore = res.data.totalScore || 0
  866. }
  867. }).catch(function() {})
  868. getChallengeList({ familyId: familyId }).then(function(res) {
  869. if (res.code === 200 && Array.isArray(res.data)) {
  870. self.activeChallenges = res.data
  871. }
  872. }).catch(function() {})
  873. },
  874. loadHealthCircle: function() {
  875. var familyId = this._familyId
  876. if (!familyId) return
  877. var self = this
  878. self.circleLoading = true
  879. getCircleRanking({ familyId: familyId }).then(function(res) {
  880. if (res.code === 200 && res.data) {
  881. self.circleName = res.data.circleName || ''
  882. self.circleRankings = res.data.rankings || []
  883. }
  884. }).catch(function() {
  885. self.circleRankings = []
  886. self.circleName = ''
  887. }).finally(function() {
  888. self.circleLoading = false
  889. })
  890. },
  891. goToHealthCircle: function() {
  892. uni.navigateTo({ url: '/pages/share/index' })
  893. },
  894. goMemberDetail(member) {
  895. if (!member || !member.memberId) return
  896. uni.navigateTo({
  897. url: '/pages/member-detail/member-detail?memberId=' + member.memberId + '&memberType=' + (member.memberType || 'child') + '&entrySource=relation-graph'
  898. })
  899. },
  900. addTask() { uni.navigateTo({ url: '/pages/tasks/create-task' }) },
  901. goToReview() { uni.navigateTo({ url: '/pages/tasks/review' }) },
  902. goToWishApprove() { uni.navigateTo({ url: '/pages/wishes/approve' }) },
  903. goToAssessmentReport() { uni.navigateTo({ url: '/pages/assessment/report' }) },
  904. goToActivities() { uni.switchTab({ url: '/pages/discover/index' }) },
  905. goToRewards() { uni.switchTab({ url: '/pages/rewards/rewards' }) },
  906. onFeedItemClick(item) {
  907. if (item.type === 'product') {
  908. uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + item.id })
  909. } else if (item.type === 'activity') {
  910. uni.navigateTo({ url: '/pages/activity/activity-detail/activity-detail?id=' + item.id })
  911. }
  912. },
  913. goMoreDiscover() {
  914. uni.switchTab({ url: '/pages/discover/index' })
  915. },
  916. loadRecommendedActivities() {
  917. var self = this
  918. getActivityList({ page: 1, size: 6 }).then(function(res) {
  919. if (res && res.data) {
  920. self.recommendedActivities = res.data.records || []
  921. }
  922. }).catch(function() {
  923. self.errorActivities = true
  924. })
  925. },
  926. loadRecommendedProducts() {
  927. var self = this
  928. getProductsByDomain('all', 1, 6).then(function(res) {
  929. if (res && res.data) {
  930. self.recommendedProducts = res.data.records || []
  931. }
  932. }).catch(function() {
  933. self.errorProducts = true
  934. })
  935. },
  936. goToTaskList() { uni.switchTab({ url: '/pages/tasks/tasks' }) },
  937. manageChildren() { uni.navigateTo({ url: '/pages/profile-extra/family-members' }) },
  938. loadContacts: function() {
  939. var self = this
  940. getContactList({}).then(function(res) {
  941. if (res.code === 200 && res.data) {
  942. self.contactList = Array.isArray(res.data) ? res.data : []
  943. }
  944. }).catch(function(e) {
  945. console.log('获取联系人失败', e)
  946. })
  947. },
  948. onContactClick: function(item) {
  949. uni.navigateTo({ url: '/pages/action/contact-detail?id=' + item.id })
  950. },
  951. onShowImport: function() {
  952. this.showImportModal = true
  953. },
  954. onCloseImport: function() {
  955. this.showImportModal = false
  956. },
  957. onImportSuccess: function() {
  958. this.showImportModal = false
  959. this.loadContacts()
  960. },
  961. // QR Code modal methods
  962. onShowQrCodeModal: async function() {
  963. this.showQrCodeModal = true
  964. this.qrCodeData = null
  965. try {
  966. const res = await this.getInviteQrCode()
  967. if (res.code === 200) {
  968. this.qrCodeData = res.data
  969. }
  970. } catch (e) {
  971. console.error('获取二维码失败', e)
  972. uni.showToast({ title: '获取二维码失败', icon: 'none' })
  973. }
  974. },
  975. onCloseQrCodeModal: function() {
  976. this.showQrCodeModal = false
  977. this.qrCodeData = null
  978. },
  979. onCopyReferralCode: function() {
  980. if (this.qrCodeData && this.qrCodeData.referralCode) {
  981. uni.setClipboardData({
  982. data: this.qrCodeData.referralCode,
  983. success: () => {
  984. uni.showToast({ title: '复制成功', icon: 'success' })
  985. }
  986. })
  987. }
  988. },
  989. // 兼容旧引用
  990. getInviteQrCode: function() {
  991. return getInviteQrCode()
  992. },
  993. // ===== 推荐阅读 =====
  994. loadFeaturedArticles: function() {
  995. var self = this
  996. this.articlesLoading = true
  997. getFeaturedArticles({ size: 5 }).then(function(res) {
  998. self.articlesLoading = false
  999. if (res && res.code === 200) {
  1000. var rawList = res.data && (Array.isArray(res.data) ? res.data : (res.data.data || res.data.records || []))
  1001. var list = Array.isArray(rawList) ? rawList : []
  1002. self.indexArticles = list.map(function(item, index) {
  1003. return {
  1004. id: item.id,
  1005. category: item.categoryName || item.category || '热门文章',
  1006. categoryColor: self.gradientColors[index % self.gradientColors.length],
  1007. title: item.title || '',
  1008. summary: item.summary || '',
  1009. views: item.viewCount ? String(item.viewCount) : '0',
  1010. date: item.publishedAt ? item.publishedAt.slice(0, 10) : ''
  1011. }
  1012. })
  1013. }
  1014. }).catch(function() {
  1015. self.articlesLoading = false
  1016. })
  1017. },
  1018. goArticles: function() {
  1019. uni.navigateTo({ url: '/pages/mind-detail/articles' })
  1020. },
  1021. goArticleDetail: function(articleOrId) {
  1022. var id = typeof articleOrId === 'object' ? articleOrId.id : articleOrId
  1023. uni.navigateTo({ url: '/pages/article-center/article-detail?id=' + id })
  1024. }
  1025. }
  1026. }
  1027. </script>
  1028. <style scoped>
  1029. /* ========================================
  1030. Flat Card Design System — 家长端暖橙扁平
  1031. ======================================== */
  1032. .container {
  1033. padding: 32rpx;
  1034. background: var(--bg, #F5F9FC);
  1035. min-height: 100vh;
  1036. }
  1037. /* ========================================
  1038. 区块标题
  1039. ======================================== */
  1040. .section-title {
  1041. font-size: 32rpx;
  1042. font-weight: 700;
  1043. color: var(--text, #1E293B);
  1044. margin-bottom: var(--space-md);
  1045. }
  1046. /* ========================================
  1047. c) 成长数据
  1048. ======================================== */
  1049. .stats-section {
  1050. margin-bottom: 48rpx;
  1051. }
  1052. .stats-row {
  1053. display: flex;
  1054. gap: 16rpx;
  1055. }
  1056. .stat-card-wide {
  1057. flex: 1;
  1058. min-width: 0;
  1059. box-sizing: border-box;
  1060. }
  1061. .stat-card-content {
  1062. padding: 24rpx;
  1063. }
  1064. .stat-header {
  1065. display: flex;
  1066. align-items: center;
  1067. margin-bottom: 16rpx;
  1068. }
  1069. .stat-icon-wrap {
  1070. width: 56rpx;
  1071. height: 56rpx;
  1072. border-radius: var(--radius-sm, 12rpx);
  1073. display: flex;
  1074. align-items: center;
  1075. justify-content: center;
  1076. margin-right: 14rpx;
  1077. flex-shrink: 0;
  1078. }
  1079. .stat-icon-symbol {
  1080. font-size: 28rpx;
  1081. }
  1082. .stat-icon-orange { background: rgba(91, 155, 213, 0.12); }
  1083. .stat-icon-gold { background: rgba(245, 158, 11, 0.15); }
  1084. .stat-body {
  1085. flex: 1;
  1086. min-width: 0;
  1087. }
  1088. .stat-label-header {
  1089. font-size: 26rpx;
  1090. font-weight: 600;
  1091. color: var(--text, #1E293B);
  1092. }
  1093. /* 对比行布局 */
  1094. .stat-compare {
  1095. margin-bottom: 12rpx;
  1096. }
  1097. .stat-compare-row {
  1098. display: flex;
  1099. justify-content: space-between;
  1100. align-items: center;
  1101. margin-bottom: 4rpx;
  1102. }
  1103. .compare-label {
  1104. font-size: 22rpx;
  1105. color: var(--text-secondary, #64748B);
  1106. }
  1107. .compare-value {
  1108. font-size: 30rpx;
  1109. font-weight: 700;
  1110. }
  1111. /* 进度条 - 紧凑版 */
  1112. .progress-bar-sm {
  1113. height: 6rpx;
  1114. background: var(--border-light, #E2E8F0);
  1115. border-radius: 999rpx;
  1116. overflow: hidden;
  1117. margin-bottom: 8rpx;
  1118. }
  1119. .progress-fill-sm {
  1120. height: 100%;
  1121. background: linear-gradient(90deg, var(--color-primary, #5B9BD5), #F59E0B);
  1122. border-radius: 999rpx;
  1123. transition: width 0.3s ease;
  1124. }
  1125. .progress-fill-sm.muted {
  1126. background: linear-gradient(90deg, #94A3B8, #CBD5E1);
  1127. }
  1128. .accent-color { color: var(--color-primary, #5B9BD5); }
  1129. .gold-color { color: #F59E0B; }
  1130. .stat-more {
  1131. font-size: 22rpx;
  1132. color: var(--color-accent, #0EA5E9);
  1133. font-weight: 500;
  1134. display: block;
  1135. }
  1136. .stat-encourage {
  1137. font-size: 22rpx;
  1138. color: #10B981;
  1139. font-weight: 500;
  1140. margin-top: 8rpx;
  1141. display: block;
  1142. }
  1143. .stat-encourage.muted {
  1144. color: var(--muted, #94A3B8);
  1145. }
  1146. /* ========================================
  1147. d) 今日重点
  1148. ======================================== */
  1149. .today-section {
  1150. margin-bottom: 48rpx;
  1151. }
  1152. .today-card .today-header {
  1153. display: flex;
  1154. justify-content: space-between;
  1155. align-items: center;
  1156. }
  1157. .today-label {
  1158. font-size: 28rpx;
  1159. font-weight: 600;
  1160. color: var(--text, #1E293B);
  1161. }
  1162. .today-count {
  1163. font-size: 24rpx;
  1164. color: var(--color-primary, #5B9BD5);
  1165. font-weight: 600;
  1166. }
  1167. .task-list {
  1168. margin-bottom: 8rpx;
  1169. }
  1170. .task-item {
  1171. display: flex;
  1172. align-items: center;
  1173. padding: 18rpx 0;
  1174. border-bottom: 1rpx solid var(--border-light, #E2E8F0);
  1175. }
  1176. .task-item:last-child {
  1177. border-bottom: none;
  1178. }
  1179. .task-dot {
  1180. width: 14rpx;
  1181. height: 14rpx;
  1182. border-radius: 50%;
  1183. margin-right: 16rpx;
  1184. flex-shrink: 0;
  1185. }
  1186. .dot-color-0 { background: var(--color-primary, #5B9BD5); }
  1187. .dot-color-1 { background: #10B981; }
  1188. .dot-color-2 { background: var(--color-accent, #0EA5E9); }
  1189. .dot-color-3 { background: #F59E0B; }
  1190. .dot-color-4 { background: var(--color-error, #EF4444); }
  1191. .task-title {
  1192. font-size: 28rpx;
  1193. color: var(--text, #1E293B);
  1194. }
  1195. .task-view-all {
  1196. display: flex;
  1197. justify-content: flex-end;
  1198. align-items: center;
  1199. color: var(--text-secondary, #64748B);
  1200. font-size: 24rpx;
  1201. padding-top: 16rpx;
  1202. border-top: 1rpx solid var(--border-light, #E2E8F0);
  1203. }
  1204. .task-view-all .arrow {
  1205. margin-left: 8rpx;
  1206. }
  1207. /* ========================================
  1208. e) 成长里程碑
  1209. ======================================== */
  1210. .milestone-section {
  1211. margin-bottom: 48rpx;
  1212. }
  1213. .milestone-card {
  1214. padding: 24rpx !important;
  1215. }
  1216. .milestone-item {
  1217. display: flex;
  1218. align-items: center;
  1219. padding: 16rpx 0;
  1220. border-bottom: 1rpx solid var(--border-light, #E2E8F0);
  1221. }
  1222. .milestone-item:last-child {
  1223. border-bottom: none;
  1224. }
  1225. .milestone-icon-wrap {
  1226. width: 56rpx;
  1227. height: 56rpx;
  1228. border-radius: var(--radius-sm, 12rpx);
  1229. display: flex;
  1230. align-items: center;
  1231. justify-content: center;
  1232. margin-right: 16rpx;
  1233. flex-shrink: 0;
  1234. }
  1235. .milestone-icon {
  1236. font-size: 28rpx;
  1237. }
  1238. .milestone-star { background: rgba(245, 158, 11, 0.15); }
  1239. .milestone-trophy { background: rgba(91, 155, 213, 0.12); }
  1240. .milestone-sparkle { background: rgba(16, 185, 129, 0.12); }
  1241. .milestone-text {
  1242. font-size: 28rpx;
  1243. color: var(--text, #1E293B);
  1244. }
  1245. /* ========================================
  1246. f) 待处理事项
  1247. ======================================== */
  1248. .pending-section { margin-bottom: 48rpx; }
  1249. .pending-grid {
  1250. display: flex;
  1251. flex-wrap: wrap;
  1252. gap: 16rpx;
  1253. }
  1254. .pending-card {
  1255. background: #fff;
  1256. border-radius: 20rpx;
  1257. padding: 24rpx;
  1258. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  1259. display: flex;
  1260. align-items: center;
  1261. width: calc(50% - 8rpx);
  1262. box-sizing: border-box;
  1263. }
  1264. .pending-card:active { opacity: 0.8; }
  1265. .pending-icon {
  1266. width: 72rpx; height: 72rpx;
  1267. border-radius: 16rpx;
  1268. display: flex; align-items: center; justify-content: center;
  1269. margin-right: 16rpx; flex-shrink: 0;
  1270. }
  1271. .pending-icon--blue { background: rgba(91,155,213,0.12); }
  1272. .pending-icon--pink { background: rgba(236,72,153,0.12); }
  1273. .pending-icon--green { background: rgba(16,185,129,0.12); }
  1274. .pending-icon--orange { background: rgba(249,115,22,0.12); }
  1275. .pending-emoji { font-size: 32rpx; }
  1276. .pending-info { flex: 1; min-width: 0; }
  1277. .pending-count { font-size: 36rpx; font-weight: 800; display: block; }
  1278. .pending-label { font-size: 22rpx; color: #666; margin-top: 4rpx; display: block; }
  1279. .pink-color { color: #EC4899; }
  1280. .orange-color { color: #F97316; }
  1281. /* ========================================
  1282. g) 成长建议
  1283. ======================================== */
  1284. .advice-section { margin-bottom: 48rpx; }
  1285. .advice-card { margin-bottom: 12rpx; }
  1286. .advice-content {
  1287. display: flex; align-items: center; padding: 24rpx;
  1288. }
  1289. .advice-icon-wrap {
  1290. width: 56rpx; height: 56rpx;
  1291. border-radius: 14rpx;
  1292. background: rgba(91,155,213,0.1);
  1293. display: flex; align-items: center; justify-content: center;
  1294. margin-right: 16rpx; flex-shrink: 0;
  1295. }
  1296. .advice-icon { font-size: 28rpx; }
  1297. .advice-text-wrap { flex: 1; min-width: 0; }
  1298. .advice-title { font-size: 28rpx; font-weight: 600; color: #333; display: block; }
  1299. .advice-desc { font-size: 24rpx; color: #999; margin-top: 4rpx; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  1300. .advice-arrow { font-size: 36rpx; color: #ccc; margin-left: 12rpx; }
  1301. /* ========================================
  1302. h) 待审核任务
  1303. ======================================== */
  1304. .review-section {
  1305. margin-bottom: 48rpx;
  1306. }
  1307. .review-card {
  1308. margin-bottom: 16rpx;
  1309. }
  1310. .review-card:last-child {
  1311. margin-bottom: 0;
  1312. }
  1313. .review-card-content {
  1314. display: flex;
  1315. justify-content: space-between;
  1316. align-items: center;
  1317. padding: 24rpx;
  1318. }
  1319. .review-info {
  1320. flex: 1;
  1321. min-width: 0;
  1322. }
  1323. .review-info .task-name {
  1324. font-size: 28rpx;
  1325. color: var(--text, #1E293B);
  1326. display: block;
  1327. margin-bottom: 4rpx;
  1328. }
  1329. .review-info .task-child {
  1330. font-size: 22rpx;
  1331. color: var(--muted, #94A3B8);
  1332. }
  1333. .review-actions {
  1334. display: flex;
  1335. gap: 12rpx;
  1336. flex-shrink: 0;
  1337. margin-left: 16rpx;
  1338. }
  1339. /* ========================================
  1340. g) 快捷操作
  1341. ======================================== */
  1342. .quick-section {
  1343. margin-bottom: 48rpx;
  1344. }
  1345. .quick-card {
  1346. padding: 16rpx 12rpx !important;
  1347. }
  1348. .quick-actions {
  1349. display: flex;
  1350. flex-wrap: wrap;
  1351. }
  1352. .action-item {
  1353. display: flex;
  1354. flex-direction: column;
  1355. align-items: center;
  1356. width: 20%;
  1357. margin-bottom: 12rpx;
  1358. transition: transform 0.15s ease;
  1359. }
  1360. .action-item:active {
  1361. transform: scale(0.92);
  1362. }
  1363. .action-icon {
  1364. width: 80rpx;
  1365. height: 80rpx;
  1366. border-radius: var(--radius-sm, 12rpx);
  1367. display: flex;
  1368. align-items: center;
  1369. justify-content: center;
  1370. margin-bottom: 10rpx;
  1371. }
  1372. .action-icon-text {
  1373. font-size: 32rpx;
  1374. }
  1375. .act-add { background: rgba(91, 155, 213, 0.12); }
  1376. .act-review { background: rgba(16, 185, 129, 0.12); }
  1377. .act-child { background: rgba(14, 165, 233, 0.12); }
  1378. .act-reward { background: rgba(245, 158, 11, 0.15); }
  1379. .act-invite { background: rgba(139, 92, 246, 0.12); }
  1380. .action-label {
  1381. font-size: 22rpx;
  1382. color: var(--text-secondary, #64748B);
  1383. font-weight: 500;
  1384. text-align: center;
  1385. }
  1386. /* ===== Error State ===== */
  1387. .error-state {
  1388. display: flex;
  1389. align-items: center;
  1390. justify-content: center;
  1391. padding: 32rpx 24rpx;
  1392. margin-bottom: 24rpx;
  1393. background: #FFF;
  1394. border-radius: 16rpx;
  1395. border: 1rpx dashed #E2E8F0;
  1396. }
  1397. .error-state-text {
  1398. font-size: 26rpx;
  1399. color: #94A3B8;
  1400. text-align: center;
  1401. }
  1402. /* ===== 重要关系(通讯录) ===== */
  1403. .contact-section {
  1404. margin: 20rpx 20rpx 0;
  1405. }
  1406. .contact-header {
  1407. display: flex;
  1408. justify-content: space-between;
  1409. align-items: center;
  1410. margin-bottom: 16rpx;
  1411. }
  1412. .contact-section-title {
  1413. font-size: 30rpx;
  1414. font-weight: 600;
  1415. color: #333;
  1416. }
  1417. .contact-header-right {
  1418. display: flex;
  1419. gap: 16rpx;
  1420. align-items: center;
  1421. }
  1422. .contact-more {
  1423. font-size: 24rpx;
  1424. color: #999;
  1425. }
  1426. .contact-import-btn {
  1427. font-size: 24rpx;
  1428. color: #F97316;
  1429. font-weight: 500;
  1430. }
  1431. .contact-scroll {
  1432. white-space: nowrap;
  1433. overflow: hidden;
  1434. }
  1435. .contact-scroll-inner {
  1436. display: flex;
  1437. flex-direction: row;
  1438. gap: 16rpx;
  1439. padding: 8rpx 0 16rpx;
  1440. }
  1441. .contact-card-wrap {
  1442. flex-shrink: 0;
  1443. width: 220rpx;
  1444. }
  1445. .contact-card-wrap:active {
  1446. opacity: 0.8;
  1447. }
  1448. .contact-add-card {
  1449. width: 160rpx;
  1450. }
  1451. .add-card-inner {
  1452. width: 160rpx;
  1453. height: 280rpx;
  1454. background: #fff;
  1455. border-radius: 16rpx;
  1456. border: 2rpx dashed #ddd;
  1457. display: flex;
  1458. flex-direction: column;
  1459. align-items: center;
  1460. justify-content: center;
  1461. gap: 12rpx;
  1462. }
  1463. .add-card-icon {
  1464. font-size: 48rpx;
  1465. color: #ccc;
  1466. }
  1467. .add-card-label {
  1468. font-size: 22rpx;
  1469. color: #999;
  1470. }
  1471. .contact-empty {
  1472. padding: 40rpx 0;
  1473. text-align: center;
  1474. }
  1475. .contact-empty-text {
  1476. font-size: 26rpx;
  1477. color: #ccc;
  1478. }
  1479. /* ===== 推荐阅读 ===== */
  1480. .article-section {
  1481. margin-bottom: 48rpx;
  1482. }
  1483. .article-header {
  1484. display: flex;
  1485. justify-content: space-between;
  1486. align-items: center;
  1487. margin-bottom: var(--space-md);
  1488. }
  1489. .article-more {
  1490. font-size: 26rpx;
  1491. color: var(--color-primary, #F97316);
  1492. }
  1493. .article-list {
  1494. display: flex;
  1495. flex-direction: column;
  1496. gap: 16rpx;
  1497. }
  1498. .article-card {
  1499. background: #fff;
  1500. border-radius: 16rpx;
  1501. padding: 24rpx;
  1502. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  1503. }
  1504. .article-card:active {
  1505. opacity: 0.8;
  1506. }
  1507. .article-category {
  1508. display: inline-block;
  1509. padding: 4rpx 14rpx;
  1510. border-radius: 8rpx;
  1511. margin-bottom: 10rpx;
  1512. }
  1513. .article-category-text {
  1514. font-size: 20rpx;
  1515. color: #fff;
  1516. }
  1517. .article-title {
  1518. display: block;
  1519. font-size: 28rpx;
  1520. font-weight: bold;
  1521. color: #333;
  1522. margin-bottom: 8rpx;
  1523. line-height: 1.4;
  1524. }
  1525. .article-summary {
  1526. display: block;
  1527. font-size: 24rpx;
  1528. color: #888;
  1529. line-height: 1.5;
  1530. margin-bottom: 12rpx;
  1531. overflow: hidden;
  1532. text-overflow: ellipsis;
  1533. display: -webkit-box;
  1534. -webkit-line-clamp: 2;
  1535. -webkit-box-orient: vertical;
  1536. }
  1537. .article-meta {
  1538. display: flex;
  1539. align-items: center;
  1540. gap: 16rpx;
  1541. }
  1542. .meta-item {
  1543. display: flex;
  1544. align-items: center;
  1545. gap: 4rpx;
  1546. }
  1547. .meta-icon {
  1548. font-size: 24rpx;
  1549. }
  1550. .meta-text {
  1551. font-size: 22rpx;
  1552. color: #999;
  1553. }
  1554. .article-date {
  1555. font-size: 22rpx;
  1556. color: #bbb;
  1557. }
  1558. /* ===== 健康圈入口卡片(P3:社区扩散) ===== */
  1559. .circle-entry-section {
  1560. margin: 0 20rpx 28rpx 20rpx;
  1561. }
  1562. .circle-card-wide {
  1563. width: 100%;
  1564. }
  1565. .circle-card-content {
  1566. padding: 24rpx;
  1567. display: flex;
  1568. flex-direction: column;
  1569. gap: 16rpx;
  1570. }
  1571. .circle-header {
  1572. display: flex;
  1573. align-items: center;
  1574. gap: 12rpx;
  1575. }
  1576. .circle-icon-wrap {
  1577. width: 56rpx;
  1578. height: 56rpx;
  1579. border-radius: 14rpx;
  1580. background: linear-gradient(135deg, #10B981, #34D399);
  1581. display: flex;
  1582. align-items: center;
  1583. justify-content: center;
  1584. }
  1585. .circle-icon {
  1586. font-size: 28rpx;
  1587. }
  1588. .circle-header-body {
  1589. flex: 1;
  1590. }
  1591. .circle-card-title {
  1592. display: block;
  1593. font-size: 28rpx;
  1594. font-weight: 700;
  1595. color: #1E293B;
  1596. line-height: 1.4;
  1597. }
  1598. .circle-card-subtitle {
  1599. display: block;
  1600. font-size: 22rpx;
  1601. color: #6B7280;
  1602. margin-top: 2rpx;
  1603. }
  1604. .circle-ranking-preview {
  1605. background: #F0FDF4;
  1606. border-radius: 12rpx;
  1607. padding: 16rpx;
  1608. display: flex;
  1609. flex-direction: column;
  1610. gap: 10rpx;
  1611. }
  1612. .circle-rank-row {
  1613. display: flex;
  1614. align-items: center;
  1615. gap: 10rpx;
  1616. }
  1617. .circle-rank-badge {
  1618. font-size: 24rpx;
  1619. width: 40rpx;
  1620. text-align: center;
  1621. }
  1622. .circle-rank-family {
  1623. flex: 1;
  1624. font-size: 24rpx;
  1625. color: #374151;
  1626. font-weight: 500;
  1627. }
  1628. .circle-rank-score {
  1629. font-size: 24rpx;
  1630. color: #F97316;
  1631. font-weight: 600;
  1632. }
  1633. .circle-action {
  1634. display: flex;
  1635. justify-content: flex-end;
  1636. }
  1637. .circle-action-text {
  1638. font-size: 24rpx;
  1639. color: #F97316;
  1640. font-weight: 500;
  1641. }
  1642. /* 无数据:邀请加入样式 */
  1643. .circle-card-invite {
  1644. background: linear-gradient(135deg, #F0FDF4, #ECFDF5);
  1645. }
  1646. .circle-invite-content {
  1647. padding: 32rpx 24rpx;
  1648. display: flex;
  1649. flex-direction: column;
  1650. align-items: center;
  1651. gap: 12rpx;
  1652. }
  1653. .circle-invite-icon {
  1654. font-size: 48rpx;
  1655. margin-bottom: 4rpx;
  1656. }
  1657. .circle-invite-title {
  1658. font-size: 30rpx;
  1659. font-weight: 700;
  1660. color: #065F46;
  1661. }
  1662. .circle-invite-desc {
  1663. font-size: 24rpx;
  1664. color: #6B7280;
  1665. text-align: center;
  1666. line-height: 1.5;
  1667. }
  1668. .circle-invite-cta {
  1669. font-size: 26rpx;
  1670. color: #F97316;
  1671. font-weight: 600;
  1672. margin-top: 4rpx;
  1673. }
  1674. /* ===== 邀请码二维码弹窗 ===== */
  1675. .qr-code-modal {
  1676. position: fixed;
  1677. top: 0;
  1678. left: 0;
  1679. width: 100%;
  1680. height: 100%;
  1681. background: rgba(0, 0, 0, 0.6);
  1682. display: flex;
  1683. align-items: center;
  1684. justify-content: center;
  1685. z-index: 1000;
  1686. padding: 40rpx 20rpx;
  1687. box-sizing: border-box;
  1688. }
  1689. .qr-code-modal-content {
  1690. background: #fff;
  1691. border-radius: 20rpx;
  1692. padding: 40rpx 32rpx;
  1693. max-width: 600rpx;
  1694. width: 100%;
  1695. box-shadow: 0 10rpx 40rpx rgba(0, 0, 0, 0.2);
  1696. position: relative;
  1697. }
  1698. .qr-code-modal-header {
  1699. display: flex;
  1700. justify-content: space-between;
  1701. align-items: center;
  1702. margin-bottom: 32rpx;
  1703. }
  1704. .qr-code-modal-title {
  1705. font-size: 36rpx;
  1706. font-weight: 700;
  1707. color: #1E293B;
  1708. }
  1709. .qr-code-modal-close {
  1710. font-size: 48rpx;
  1711. color: #94A3B8;
  1712. line-height: 1;
  1713. padding: 8rpx;
  1714. cursor: pointer;
  1715. }
  1716. .qr-code-modal-body {
  1717. display: flex;
  1718. flex-direction: column;
  1719. align-items: center;
  1720. gap: 32rpx;
  1721. }
  1722. .qr-code-image-container {
  1723. width: 280rpx;
  1724. height: 280rpx;
  1725. display: flex;
  1726. align-items: center;
  1727. justify-content: center;
  1728. background: #f9fafb;
  1729. border-radius: 16rpx;
  1730. padding: 20rpx;
  1731. }
  1732. .qr-code-image {
  1733. width: 100%;
  1734. height: 100%;
  1735. object-fit: contain;
  1736. }
  1737. .qr-code-referral-code {
  1738. display: flex;
  1739. align-items: center;
  1740. gap: 16rpx;
  1741. padding: 24rpx;
  1742. background: #f9fafb;
  1743. border-radius: 16rpx;
  1744. width: 100%;
  1745. box-sizing: border-box;
  1746. }
  1747. .qr-code-label {
  1748. font-size: 26rpx;
  1749. color: #64748b;
  1750. font-weight: 500;
  1751. }
  1752. .qr-code-code {
  1753. flex: 1;
  1754. font-size: 32rpx;
  1755. font-weight: 700;
  1756. color: #1E293B;
  1757. word-break: break-all;
  1758. letter-spacing: 2rpx;
  1759. }
  1760. .qr-code-copy {
  1761. font-size: 24rpx;
  1762. color: #F97316;
  1763. font-weight: 500;
  1764. padding: 8rpx 16rpx;
  1765. background: #fff;
  1766. border-radius: 8rpx;
  1767. border: 1px solid #F97316;
  1768. cursor: pointer;
  1769. }
  1770. .qr-code-copy:active {
  1771. opacity: 0.8;
  1772. }
  1773. </style>