parent-index.vue 57 KB

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