parent-index.vue 69 KB

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