index.vue 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459
  1. <template>
  2. <view>
  3. <!-- 冷启动 splash overlay — 覆盖首页直到数据加载完毕(tab 切回时不显示) -->
  4. <view class="splash-overlay" :class="{'fade-out': splashOverlayFading}" v-if="splashOverlay || splashOverlayFading">
  5. <view class="splash-overlay-bg">
  6. <view class="bg-circle bg-circle-1"></view>
  7. <view class="bg-circle bg-circle-2"></view>
  8. <view class="bg-circle bg-circle-3"></view>
  9. </view>
  10. <view class="splash-overlay-body">
  11. <view class="splash-logo-wrap">
  12. <image class="splash-logo-img" src="/static/logo.png" mode="aspectFit" />
  13. </view>
  14. <text class="splash-brand-name">浠艾福</text>
  15. <text class="splash-brand-en">Care Family</text>
  16. <view class="splash-dims-row">
  17. <view class="splash-dim-item">
  18. <view class="splash-dim-circle" style="background:rgba(255,140,66,0.3);"><text class="splash-dim-icon">🌏</text></view>
  19. <text class="splash-dim-label">身</text>
  20. </view>
  21. <view class="splash-dim-item">
  22. <view class="splash-dim-circle" style="background:rgba(255,107,157,0.3);"><text class="splash-dim-icon">🔥</text></view>
  23. <text class="splash-dim-label">心</text>
  24. </view>
  25. <view class="splash-dim-item">
  26. <view class="splash-dim-circle" style="background:rgba(99,102,241,0.3);"><text class="splash-dim-icon">⚡</text></view>
  27. <text class="splash-dim-label">智</text>
  28. </view>
  29. <view class="splash-dim-item">
  30. <view class="splash-dim-circle" style="background:rgba(16,185,129,0.3);"><text class="splash-dim-icon">🌿</text></view>
  31. <text class="splash-dim-label">行</text>
  32. </view>
  33. <view class="splash-dim-item">
  34. <view class="splash-dim-circle" style="background:rgba(245,158,11,0.3);"><text class="splash-dim-icon">💧</text></view>
  35. <text class="splash-dim-label">富</text>
  36. </view>
  37. </view>
  38. <text class="splash-tagline">给全家的一站式幸福提案</text>
  39. <view class="splash-overlay-loading">
  40. <view class="splash-overlay-dot"></view>
  41. <view class="splash-overlay-dot"></view>
  42. <view class="splash-overlay-dot"></view>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- 登录态 — 直接内嵌,保持底签可见 -->
  47. <view v-if="currentRole" class="logged-in-container">
  48. <!-- 品牌头部 -->
  49. <PageBanner theme="action"
  50. tagline="知行合一 · 快乐成长"
  51. quote="千里之行,始于足下" />
  52. <!-- 家庭成员选择条 -->
  53. <FamilyMemberStrip
  54. :members="familyMembersVisible"
  55. :selectedMemberId="selectedMemberId"
  56. :isParent="isFamilyAdmin"
  57. @select="onFamilyMemberSelect"
  58. @switch="onFamilyMemberSwitch"
  59. @removed="loadFamilyMembers" />
  60. <!-- 能量沙盘 — Canvas 五行星图 -->
  61. <view v-if="hasFamily">
  62. <WuxingSandbox
  63. v-if="sandboxData"
  64. mode="live"
  65. :scores="sandboxScores"
  66. :overallScore="sandboxData.overallScore || 0"
  67. :members="sandboxData.members || []"
  68. showDimensionBar
  69. starHeight="480rpx" />
  70. </view>
  71. <view v-else>
  72. <FamilyEmptyState type="card" />
  73. </view>
  74. <!-- 会员入口:非会员显示开通 / 快到期显示续费 -->
  75. <view v-if="showMemberEntry" class="member-entry" @click="goMembership">
  76. <view class="member-entry-icon-wrap">
  77. <text class="member-entry-icon">👑</text>
  78. </view>
  79. <view class="member-entry-texts">
  80. <text class="member-entry-title">{{ memberEntryTitle }}</text>
  81. <text class="member-entry-desc">{{ memberEntryDesc }}</text>
  82. </view>
  83. <view class="member-entry-btn">
  84. <text class="member-entry-btn-text">{{ memberEntryBtn }}</text>
  85. </view>
  86. </view>
  87. <!-- 功能入口网格(3列,与健康/成长页一致) -->
  88. <view class="section">
  89. <view class="grid-3col">
  90. <view class="grid-item" @click="navTo('/pages/tasks/tasks')">
  91. <view class="grid-icon" style="background:rgba(99,102,241,0.15)"><text>📋</text></view>
  92. <text class="grid-label">任务</text>
  93. </view>
  94. <view class="grid-item" @click="navTo('/pages/action-detail/interaction-log')">
  95. <view class="grid-icon" style="background:rgba(16,185,129,0.15)"><text>💬</text></view>
  96. <text class="grid-label">记录互动</text>
  97. </view>
  98. <view class="grid-item" @click="navTo('/pages/mind-detail/family-dashboard')">
  99. <view class="grid-icon" style="background:rgba(139,92,246,0.15)"><text>🏠</text></view>
  100. <text class="grid-label">家庭天盘</text>
  101. </view>
  102. <view class="grid-item" @click="navTo('/pages/profile-extra/family-members')">
  103. <view class="grid-icon" style="background:rgba(245,158,11,0.15)"><text>👨‍👩‍👧‍👦</text></view>
  104. <text class="grid-label">成员管理</text>
  105. </view>
  106. <view class="grid-item" @click="navTo('/pages/discover/circles')">
  107. <view class="grid-icon" style="background:rgba(255,107,157,0.15)"><text>🤝</text></view>
  108. <text class="grid-label">圈子</text>
  109. </view>
  110. <view class="grid-item" @click="navTo('/pages/shop/index/index')">
  111. <view class="grid-icon" style="background:rgba(249,115,22,0.15)"><text>🛒</text></view>
  112. <text class="grid-label">商城</text>
  113. </view>
  114. </view>
  115. </view>
  116. <!-- 家庭挑战任务 -->
  117. <view v-if="hasFamily" class="section">
  118. <view class="section-header">
  119. <text class="section-title">🔥 家庭挑战</text>
  120. <text class="section-more" @click="goChallengeManage">管理 ›</text>
  121. </view>
  122. <FamilyChallengeCard
  123. v-for="ch in activeChallenges"
  124. :key="ch.id"
  125. :challenge="ch"
  126. :showCheckin="showCheckinBtn"
  127. @checkin="onChallengeCheckin"
  128. @respond="onChallengeRespond" />
  129. </view>
  130. <view v-else>
  131. <FamilyEmptyState type="card" />
  132. </view>
  133. <!-- 推荐文章 -->
  134. <ArticleBookshelf
  135. :articles="actionArticles"
  136. :isLoggedIn="true"
  137. @articleClick="goArticleDetail"
  138. @moreArticles="goMoreArticles" />
  139. <!-- 推荐商品 -->
  140. <DimensionProducts
  141. dimensionCode="action"
  142. :products="dimensionProducts"
  143. :isLoggedIn="true"
  144. @productClick="goProductDetail"
  145. @moreProducts="goMoreProducts" />
  146. <!-- 底部占位 -->
  147. <view class="bottom-spacer" style="height: 40rpx;"></view>
  148. </view>
  149. <!-- 未登录态 — 发现页/引流内容,直接内嵌,不跳转 -->
  150. <view v-else class="discover-container">
  151. <!-- 品牌头部 -->
  152. <PageBanner theme="home"
  153. tagline="家庭健康成长俱乐部"
  154. quote="给全家的一站式幸福提案" />
  155. <!-- 五行沙盘预览 -->
  156. <wuxing-sandbox mode="preview" badgeText="登录查看完整报告" @point-click="handleLogin" />
  157. <!-- 活动/商品推荐 -->
  158. <view class="recommend-section">
  159. <view class="section-header">
  160. <text class="section-title">🔥 热门推荐</text>
  161. <text class="section-more" @click="goShop">查看更多 ›</text>
  162. </view>
  163. <scroll-view scroll-x enable-flex show-scrollbar="false" class="type-filter-scroll">
  164. <view
  165. v-for="item in typeList"
  166. :key="item.value"
  167. :class="['filter-chip', currentType === item.value ? 'active' : '']"
  168. @click="onTypeChange(item.value)"
  169. >
  170. {{ item.label }}
  171. </view>
  172. </scroll-view>
  173. <view v-if="loading" class="loading-state">
  174. <text class="loading-text">加载中...</text>
  175. </view>
  176. <view v-else-if="products.length === 0" class="empty-state">
  177. <text class="empty-text">暂无商品,去商城看看吧</text>
  178. </view>
  179. <view v-else class="product-grid">
  180. <view
  181. v-for="item in products"
  182. :key="item.id"
  183. class="product-card"
  184. @click="goDetail(item.id)"
  185. >
  186. <image class="product-cover" :src="getImageUrl(item.coverImage) || '/static/default-product.png'" mode="aspectFill" />
  187. <view class="product-info">
  188. <text class="product-name">{{ item.name }}</text>
  189. <view class="product-price-row">
  190. <text class="product-price" v-if="item.price && item.price > 0">¥{{ (item.price / 100).toFixed(0) }}</text>
  191. <text class="product-price-free" v-else>免费</text>
  192. </view>
  193. </view>
  194. </view>
  195. </view>
  196. </view>
  197. <!-- 热门活动(无条件展示) -->
  198. <view class="section">
  199. <view class="section-header">
  200. <text class="section-title">🔥 热门活动</text>
  201. <text class="section-more" @click="goActivities">查看更多 ›</text>
  202. </view>
  203. <view v-if="dimensionActivities.length === 0" class="empty-state" style="padding: 40rpx 0;">
  204. <text class="empty-text">暂无活动</text>
  205. </view>
  206. <view class="activity-list" v-else>
  207. <view class="activity-card" v-for="act in dimensionActivities" :key="act.id" @click="goActivityDetail(act)">
  208. <image class="activity-cover" :src="getImageUrl(act.coverImage) || '/static/default-activity.png'" mode="aspectFill" />
  209. <view class="activity-info">
  210. <text class="activity-name line-clamp-1">{{ act.title }}</text>
  211. <view class="activity-meta">
  212. <text class="activity-time">{{ act.startTime }}</text>
  213. </view>
  214. <view class="activity-bottom">
  215. <text class="activity-status" :class="'status-' + (act.status || 'upcoming')">{{ act.status === 'ongoing' ? '进行中' : act.status === 'ended' ? '已结束' : '即将开始' }}</text>
  216. <text class="activity-fee" v-if="act.price && act.price > 0">¥{{ (act.price / 100).toFixed(0) }}</text>
  217. <text class="activity-fee fee-free" v-else>免费</text>
  218. </view>
  219. </view>
  220. </view>
  221. </view>
  222. </view>
  223. <!-- 推荐阅读(无条件展示) -->
  224. <view class="section">
  225. <view class="section-header">
  226. <text class="section-title">📖 推荐阅读</text>
  227. <text class="section-more" @click="goArticles">更多 ›</text>
  228. </view>
  229. <view class="article-list">
  230. <view v-if="articlesLoading" class="loading-state" style="padding: 40rpx 0;">
  231. <text class="loading-text">加载中...</text>
  232. </view>
  233. <!-- 无数据时显示占位卡片 -->
  234. <template v-else-if="indexArticles.length === 0">
  235. <view class="article-card" v-for="(item, i) in [1,2,3]" :key="i">
  236. <view class="article-category" :style="{ background: gradientColors[(i-1) % gradientColors.length] }">
  237. <text class="article-category-text">推荐文章</text>
  238. </view>
  239. <text class="article-title">暂无推荐文章</text>
  240. <text class="article-summary">精彩内容即将上线,敬请期待</text>
  241. <view class="article-meta">
  242. <view class="meta-item">
  243. <text class="meta-icon">&#x1F4D6;</text>
  244. <text class="meta-text">0</text>
  245. </view>
  246. <text class="article-date">--</text>
  247. </view>
  248. </view>
  249. </template>
  250. <!-- 有数据时显示文章卡片 -->
  251. <template v-else>
  252. <view class="article-card" v-for="article in indexArticles" :key="article.id" @click="goArticleDetail(article.id)">
  253. <view class="article-category" :style="{ background: article.categoryColor }">
  254. <text class="article-category-text">{{ article.category }}</text>
  255. </view>
  256. <text class="article-title">{{ article.title }}</text>
  257. <text class="article-summary">{{ article.summary }}</text>
  258. <view class="article-meta">
  259. <view class="meta-item">
  260. <text class="meta-icon">&#x1F4D6;</text>
  261. <text class="meta-text">{{ article.views }}</text>
  262. </view>
  263. <text class="article-date">{{ article.date }}</text>
  264. </view>
  265. </view>
  266. </template>
  267. </view>
  268. </view>
  269. <!-- 底部登录按钮 -->
  270. <view class="login-footer">
  271. <button class="login-btn" @click="handleLogin">登录 / 注册</button>
  272. <text class="login-footer-text">登录即表示同意《用户协议》和《隐私政策》</text>
  273. </view>
  274. <!-- 底部占位 -->
  275. <view style="height: 120rpx;"></view>
  276. </view>
  277. </view>
  278. </template>
  279. <script>
  280. import store from '../../store/index.js'
  281. import WuxingSandbox from '../../components/wuxing-sandbox.vue'
  282. import PageBanner from '../../components/PageBanner.vue'
  283. import WuxingSandbox from '../../components/wuxing-sandbox.vue'
  284. import FamilyMemberStrip from '../../components/FamilyMemberStrip.vue'
  285. import DimensionProducts from '../../components/DimensionProducts.vue'
  286. import ArticleBookshelf from '../../components/ArticleBookshelf.vue'
  287. import FamilyChallengeCard from '../../components/FamilyChallengeCard.vue'
  288. import { acceptParentInvite, productList, getActivityList, getFeaturedArticles, getFamilyEnergySandbox, getVisibleFamilyMembers, getChildren, getProductsByDomain, getChallengeList, switchToFamilyMember, getMyMembership, updateChallengeProgress, respondChallenge } from '../../utils/api.js'
  289. import store from '../../store/index.js'
  290. import config from '@/config.js'
  291. export default {
  292. components: {
  293. PageBanner,
  294. WuxingSandbox,
  295. FamilyMemberStrip,
  296. DimensionProducts,
  297. ArticleBookshelf,
  298. FamilyChallengeCard
  299. },
  300. data() {
  301. // 从 storage 预取登录态/角色,确保首次渲染即正确(WeChat 渲染层/逻辑层分离架构下 onLoad 执行前已渲染)
  302. var _token = uni.getStorageSync('token')
  303. var _currentRole = ''
  304. if (_token) {
  305. _currentRole = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || ''
  306. }
  307. // 冷启动标记(由 App.vue onLaunch 设置,仅在冷启动时存在)
  308. var _isFirstLaunch = (uni.getStorageSync('_showSplashOverlay') === '1')
  309. return {
  310. currentRole: _currentRole,
  311. // splash loading overlay(冷启动时展示,数据加载完关闭)
  312. splashOverlay: _isFirstLaunch,
  313. splashOverlayFading: false,
  314. _splashReady: false,
  315. typeList: [
  316. { label: '全部', value: '' },
  317. { label: '活动', value: 'activity' },
  318. { label: '课程', value: 'course' },
  319. { label: '实物', value: 'physical' },
  320. { label: '数字', value: 'digital' },
  321. { label: '服务', value: 'service' }
  322. ],
  323. currentType: '',
  324. products: [],
  325. loading: false,
  326. dimensionActivities: [],
  327. indexArticles: [],
  328. articlesLoading: false,
  329. gradientColors: [
  330. 'linear-gradient(135deg, #10B981, #34D399)',
  331. 'linear-gradient(135deg, #5B9BD5, #8FC5E8)',
  332. 'linear-gradient(135deg, #8B5CF6, #C084FC)',
  333. 'linear-gradient(135deg, #F97316, #FB923C)',
  334. 'linear-gradient(135deg, #6366F1, #818CF8)'
  335. ],
  336. // 登录态数据
  337. familyMembersVisible: [],
  338. // 接口数据是否已检查(用于 hasFamily 判断,替代已失效的 store.familyId)
  339. childrenChecked: false,
  340. membersChecked: false,
  341. selectedMemberId: null,
  342. sandboxData: null,
  343. dimensionProducts: [],
  344. articles: [],
  345. children: [],
  346. currentChildId: null,
  347. activeChallenges: [],
  348. loggedInInitDone: false,
  349. // 会员状态(沙盘下方会员入口使用)
  350. isMember: false,
  351. membershipDays: 0
  352. }
  353. },
  354. computed: {
  355. hasFamily: function() {
  356. if (!this.isLoggedIn()) return false
  357. // 接口未返回前乐观显示内容区,避免"暂无数据"闪烁
  358. if (!this.childrenChecked || !this.membersChecked) return true
  359. // 有孩子成员或可见家庭成员即认为有家庭
  360. if (this.sandboxData) return true
  361. if (this.children && this.children.length > 0) return true
  362. if (this.familyMembersVisible && this.familyMembersVisible.length > 0) return true
  363. return this.$store.getters.hasFamily
  364. },
  365. isFamilyAdmin: function() {
  366. if (!this.familyMembersVisible || this.familyMembersVisible.length === 0) return false
  367. return this.familyMembersVisible[0].isAdmin === true
  368. },
  369. sandboxScores: function() {
  370. var d = this.sandboxData || {}
  371. return {
  372. body: d.bodyScore || 0,
  373. mind: d.mindScore || 0,
  374. wisdom: d.wisdomScore || 0,
  375. action: d.actionScore || 0,
  376. wealth: d.wealthScore || 0
  377. }
  378. },
  379. actionArticles: function() {
  380. if (!this.articles || this.articles.length === 0) return []
  381. var result = []
  382. for (var i = 0; i < this.articles.length; i++) {
  383. var a = this.articles[i]
  384. if (a.relatedDimensions && a.relatedDimensions.indexOf('action') !== -1) {
  385. result.push(a)
  386. }
  387. }
  388. if (result.length === 0) return this.articles.slice(0, 5)
  389. return result.slice(0, 5)
  390. },
  391. // 会员入口显示:非会员显示开通;会员剩余≤30天显示续费
  392. showMemberEntry: function() {
  393. if (!this.isLoggedIn()) return false
  394. if (!this.isMember) return true
  395. return this.membershipDays > 0 && this.membershipDays <= 30
  396. },
  397. showCheckinBtn: function() {
  398. return (uni.getStorageSync('role') || 'parent') === 'child'
  399. },
  400. memberEntryTitle: function() {
  401. if (!this.isMember) return '开通会员,解锁全部特权'
  402. return '会员即将到期,续费恢复权益'
  403. },
  404. memberEntryDesc: function() {
  405. if (!this.isMember) return '享专属折扣 · 成长服务 · 规划指导'
  406. return '剩余 ' + this.membershipDays + ' 天,续费保持权益不中断'
  407. },
  408. memberEntryBtn: function() {
  409. return this.isMember ? '立即续费' : '立即开通'
  410. }
  411. },
  412. onLoad(options) {
  413. this._doInit(options)
  414. },
  415. onShow() {
  416. // splash overlay 已在 data() 中根据 storage 标记初始化,此处只需配置关闭条件
  417. if (this.splashOverlay) {
  418. uni.removeStorageSync('_showSplashOverlay')
  419. this._splashLoadCount = 0
  420. this._splashMinPassed = false
  421. var self = this
  422. // 最低展示 800ms
  423. setTimeout(function() {
  424. self._splashMinPassed = true
  425. self._tryHideSplash()
  426. }, 800)
  427. // 最多展示 5s
  428. setTimeout(function() {
  429. if (self.splashOverlay) self._hideSplashOverlay()
  430. }, 5000)
  431. }
  432. // 始终执行初始化,确保登录态变更后及时切换视图
  433. this._doInit()
  434. },
  435. methods: {
  436. _checkSplashReady() {
  437. this._splashLoadCount++
  438. this._tryHideSplash()
  439. },
  440. _tryHideSplash() {
  441. if (this.splashOverlayFading) return
  442. if (!this._splashMinPassed) return
  443. if (this.isLoggedIn()) {
  444. // 登录用户:等待子组件的 ready 信号
  445. if (this._splashReady) this._hideSplashOverlay()
  446. } else {
  447. // 游客:等待 3 个 API 全部返回
  448. if (this._splashLoadCount >= 3) this._hideSplashOverlay()
  449. }
  450. },
  451. _hideSplashOverlay() {
  452. if (this.splashOverlayFading) return
  453. this.splashOverlayFading = true
  454. var self = this
  455. setTimeout(function() {
  456. self.splashOverlay = false
  457. self.splashOverlayFading = false
  458. }, 400)
  459. },
  460. // ===== 登录态数据加载 =====
  461. loadLoggedInData: function() {
  462. this.loadFamilyMembers()
  463. this.loadChildren()
  464. },
  465. loadChildren: function() {
  466. var self = this
  467. getChildren().then(function(res) {
  468. if (res.code === 200 && res.data) {
  469. self.children = res.data
  470. var savedChildId = uni.getStorageSync('currentChildId')
  471. if (savedChildId) {
  472. self.currentChildId = savedChildId
  473. }
  474. self.loadDimensionData()
  475. }
  476. self.childrenChecked = true
  477. }).catch(function(e) {
  478. console.log('获取孩子列表失败', e)
  479. self.childrenChecked = true
  480. })
  481. },
  482. loadDimensionData: function() {
  483. this.loadSandboxData()
  484. this.loadActionProducts()
  485. this.loadActionArticles()
  486. this.loadChallenges()
  487. },
  488. loadSandboxData: function() {
  489. var self = this
  490. getFamilyEnergySandbox().then(function(res) {
  491. if (res && res.data) {
  492. self.sandboxData = res.data
  493. self._splashReady = true
  494. self._tryHideSplash()
  495. }
  496. }).catch(function() {})
  497. },
  498. loadActionProducts: function() {
  499. var self = this
  500. getProductsByDomain('action', 1, 4).then(function(res) {
  501. if (res && res.data) {
  502. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  503. self.dimensionProducts = list.slice(0, 4)
  504. }
  505. }).catch(function() { self.dimensionProducts = [] })
  506. },
  507. loadActionArticles: function() {
  508. var self = this
  509. getFeaturedArticles({ size: 5, dimensionCode: 'action' }).then(function(res) {
  510. if (res.code === 200 && res.data) {
  511. var gradientColors = [
  512. 'linear-gradient(135deg, #10B981, #34D399)',
  513. 'linear-gradient(135deg, #5B9BD5, #8FC5E8)',
  514. 'linear-gradient(135deg, #8B5CF6, #C084FC)',
  515. 'linear-gradient(135deg, #F97316, #FB923C)',
  516. 'linear-gradient(135deg, #6366F1, #818CF8)'
  517. ]
  518. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  519. self.articles = list.map(function(item, index) {
  520. return {
  521. id: item.id,
  522. category: item.categoryName || '行动社交',
  523. categoryColor: gradientColors[index % gradientColors.length],
  524. title: item.title || '',
  525. summary: item.summary || '',
  526. dimensionWeights: item.dimensionWeights || null,
  527. views: item.viewCount ? String(item.viewCount) : '0',
  528. likes: '0',
  529. date: item.publishedAt ? item.publishedAt.slice(0, 10) : '',
  530. relatedDimensions: self.parseRelatedDimensions(item.relatedDimensions),
  531. coverImage: item.coverImage
  532. }
  533. })
  534. }
  535. }).catch(function() {})
  536. },
  537. loadChallenges: function() {
  538. var self = this
  539. getChallengeList({}).then(function(res) {
  540. if (res.code === 200 && Array.isArray(res.data)) {
  541. self.activeChallenges = res.data
  542. }
  543. }).catch(function() {
  544. self.activeChallenges = []
  545. })
  546. },
  547. onChallengeCheckin: function(payload) {
  548. var self = this
  549. updateChallengeProgress({ challengeId: payload.challengeId, delta: 1 }).then(function(res) {
  550. if (res && res.code === 200) {
  551. uni.showToast({ title: '打卡成功', icon: 'success' })
  552. self.loadChallenges()
  553. } else {
  554. uni.showToast({ title: (res && res.message) || '打卡失败', icon: 'none' })
  555. }
  556. }).catch(function() {
  557. uni.showToast({ title: '打卡失败,请重试', icon: 'none' })
  558. })
  559. },
  560. onChallengeRespond: function(payload) {
  561. var self = this
  562. respondChallenge({ challengeId: payload.challengeId, action: payload.action }).then(function(res) {
  563. if (res && res.code === 200) {
  564. uni.showToast({ title: payload.action === 'agree' ? '已同意' : '已拒绝', icon: 'success' })
  565. self.loadChallenges()
  566. } else {
  567. uni.showToast({ title: (res && res.message) || '操作失败', icon: 'none' })
  568. self.loadChallenges()
  569. }
  570. }).catch(function() {
  571. uni.showToast({ title: '操作失败,请重试', icon: 'none' })
  572. })
  573. },
  574. loadFamilyMembers: function() {
  575. var self = this
  576. getVisibleFamilyMembers().then(function(res) {
  577. if (res.code === 200 && res.data) {
  578. self.familyMembersVisible = Array.isArray(res.data) ? res.data : (res.data.list || [])
  579. }
  580. self.membersChecked = true
  581. }).catch(function(e) {
  582. console.log('获取可见家庭成员失败', e)
  583. self.familyMembersVisible = []
  584. self.membersChecked = true
  585. })
  586. },
  587. parseRelatedDimensions: function(val) {
  588. if (!val) return []
  589. if (Array.isArray(val)) return val
  590. if (typeof val === 'string') {
  591. try {
  592. var parsed = JSON.parse(val)
  593. return Array.isArray(parsed) ? parsed : []
  594. } catch (e) {
  595. return val.split(',').map(function(s) { return s.trim() }).filter(function(s) { return s })
  596. }
  597. }
  598. return []
  599. },
  600. onFamilyMemberSelect: function(member) {
  601. this.selectedMemberId = member.id
  602. },
  603. onFamilyMemberSwitch: function(member) {
  604. var self = this
  605. if (!member || !member.id) return
  606. switchToFamilyMember(member.id, member.source || 'family_member').then(function(res) {
  607. if (res.code === 200 && res.data) {
  608. store.commit('switchToMember', {
  609. memberId: res.data.memberId,
  610. effectiveRole: res.data.effectiveRole
  611. })
  612. uni.showToast({ title: '已切换到' + (member.nickname || '该成员'), icon: 'success' })
  613. setTimeout(function() {
  614. uni.reLaunch({ url: '/pages/index-home/index' })
  615. }, 1000)
  616. } else {
  617. uni.showToast({ title: res.message || '切换失败', icon: 'none' })
  618. }
  619. }).catch(function() {
  620. uni.showToast({ title: '切换失败', icon: 'none' })
  621. })
  622. },
  623. navTo: function(url) {
  624. uni.navigateTo({ url: url })
  625. },
  626. goActivityDetail: function(act) {
  627. if (!act || !act.id) return
  628. uni.navigateTo({ url: '/pages/activity/activity-detail/activity-detail?id=' + act.id })
  629. },
  630. goMoreActivities: function() {
  631. uni.navigateTo({ url: '/pages/activity/index' })
  632. },
  633. goProductDetail: function(prod) {
  634. uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + prod.id })
  635. },
  636. goMoreProducts: function() {
  637. uni.navigateTo({ url: '/pages/shop/index/index' })
  638. },
  639. goArticleDetail: function(article) {
  640. var id = article.id || article
  641. uni.navigateTo({ url: '/pages/article-center/article-detail?id=' + id })
  642. },
  643. goMoreArticles: function() {
  644. uni.navigateTo({ url: '/pages/article-center/index?dimension=action' })
  645. },
  646. _doInit(options) {
  647. options = options || {}
  648. if (!this.isLoggedIn()) {
  649. this.currentRole = ''
  650. this.loadProducts()
  651. this.loadDimensionActivities()
  652. this.loadFeaturedArticles()
  653. return
  654. }
  655. this.syncRoleAndTabBar()
  656. if (options.inviteCode && options.type === 'parent_invite') {
  657. this.handleParentInvite(options.inviteCode)
  658. return
  659. }
  660. var storedCode = uni.getStorageSync('inviteCode')
  661. var storedType = uni.getStorageSync('inviteType')
  662. if (storedCode && storedType === 'parent_invite') {
  663. this.handleParentInvite(storedCode)
  664. uni.removeStorageSync('inviteCode')
  665. uni.removeStorageSync('inviteType')
  666. return
  667. }
  668. // 登录用户:直接在 TabBar 页面内联渲染,保持底签可见
  669. if (!this.loggedInInitDone) {
  670. this.loggedInInitDone = true
  671. this.loadLoggedInData()
  672. }
  673. this.checkMemberStatus()
  674. this._watchPageReady()
  675. },
  676. isLoggedIn() {
  677. return !!uni.getStorageSync('token')
  678. },
  679. // ===== 会员状态(沙盘下方会员入口) =====
  680. checkMemberStatus: function() {
  681. var that = this
  682. getMyMembership().then(function(res) {
  683. var m = res.data || {}
  684. that.isMember = !!(m.memberLevel && m.memberLevel !== 'FREE') || !!(m.levelCode && m.levelCode !== 'FREE')
  685. var mem = m.membership || m
  686. if (mem.daysRemaining != null) {
  687. that.membershipDays = mem.daysRemaining
  688. }
  689. }).catch(function() {})
  690. },
  691. goMembership: function() {
  692. uni.navigateTo({ url: '/pages/membership/upgrade' })
  693. },
  694. normalizeCurrentRole() {
  695. const role = uni.getStorageSync('role') || 'parent'
  696. const currentRole = uni.getStorageSync('currentRole')
  697. if (!currentRole) {
  698. return role
  699. }
  700. // 非规划师账号不允许落到规划师首页
  701. if (currentRole === 'teacher' && role !== 'teacher') {
  702. return role
  703. }
  704. // 只有家长账号允许切换到孩子视角
  705. if (currentRole === 'child' && role !== 'parent') {
  706. return role
  707. }
  708. return currentRole
  709. },
  710. syncRoleAndTabBar() {
  711. this.currentRole = this.normalizeCurrentRole()
  712. uni.setStorageSync('currentRole', this.currentRole)
  713. },
  714. // ===== 发现页 / 未登录态方法 =====
  715. loadProducts: function() {
  716. this.loading = true
  717. var params = { page: 1, size: 10 }
  718. if (this.currentType) {
  719. params.productType = this.currentType
  720. }
  721. var self = this
  722. productList(params).then(function(res) {
  723. self.loading = false
  724. if (res && res.code === 200) {
  725. // res.data is the response wrapper, products are in res.data.data or res.data.records
  726. var rawData = res.data && (Array.isArray(res.data) ? res.data : (res.data.data || res.data.records || []))
  727. self.products = Array.isArray(rawData) ? rawData : []
  728. }
  729. self._checkSplashReady()
  730. }).catch(function() {
  731. self.loading = false
  732. self._checkSplashReady()
  733. })
  734. },
  735. loadDimensionActivities: function() {
  736. var self = this
  737. getActivityList({ dimensionCode: '', page: 1, size: 3 }).then(function(res) {
  738. if (res && res.code === 200) {
  739. // res.data is the response wrapper, activities are in res.data.data or res.data.records
  740. var rawData = res.data && (Array.isArray(res.data) ? res.data : (res.data.data || res.data.records || []))
  741. self.dimensionActivities = Array.isArray(rawData) ? rawData.slice(0, 3) : []
  742. }
  743. self._checkSplashReady()
  744. }).catch(function() {
  745. self._checkSplashReady()
  746. })
  747. },
  748. loadFeaturedArticles: function() {
  749. var self = this
  750. this.articlesLoading = true
  751. getFeaturedArticles({ size: 5 }).then(function(res) {
  752. self.articlesLoading = false
  753. if (res && res.code === 200) {
  754. var gradientColors = [
  755. 'linear-gradient(135deg, #10B981, #34D399)',
  756. 'linear-gradient(135deg, #5B9BD5, #8FC5E8)',
  757. 'linear-gradient(135deg, #8B5CF6, #C084FC)',
  758. 'linear-gradient(135deg, #F97316, #FB923C)',
  759. 'linear-gradient(135deg, #6366F1, #818CF8)'
  760. ]
  761. // res.data is the response wrapper, articles are in res.data.data
  762. var rawList = res.data && (Array.isArray(res.data) ? res.data : (res.data.data || res.data.records || []))
  763. var list = Array.isArray(rawList) ? rawList : []
  764. self.indexArticles = list.map(function(item, index) {
  765. return {
  766. id: item.id,
  767. category: item.categoryName || item.category || '热门文章',
  768. categoryColor: gradientColors[index % gradientColors.length],
  769. title: item.title || '',
  770. summary: item.summary || '',
  771. views: item.viewCount ? String(item.viewCount) : '0',
  772. date: item.publishedAt ? item.publishedAt.slice(0, 10) : '',
  773. coverImage: item.coverImage
  774. }
  775. })
  776. }
  777. self._checkSplashReady()
  778. }).catch(function() {
  779. self.articlesLoading = false
  780. self._checkSplashReady()
  781. })
  782. },
  783. goActivities: function() {
  784. uni.navigateTo({ url: '/pages/activity/index' })
  785. },
  786. goChallengeManage: function() {
  787. uni.navigateTo({ url: '/pages/health/challenge-manage' })
  788. },
  789. goArticles: function() {
  790. uni.navigateTo({ url: '/pages/mind-detail/articles' })
  791. },
  792. goArticleDetail: function(article) {
  793. var id = article && article.id ? article.id : article
  794. uni.navigateTo({ url: '/pages/article-center/article-detail?id=' + id })
  795. },
  796. onTypeChange(value) {
  797. this.currentType = value
  798. this.loadProducts()
  799. },
  800. goShop() {
  801. uni.navigateTo({ url: '/pages/shop/index/index' })
  802. },
  803. goDetail(id) {
  804. uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + id })
  805. },
  806. handleLogin() {
  807. uni.navigateTo({ url: '/pages/login/login?redirect=' + encodeURIComponent('/pages/index-home/index') })
  808. },
  809. async handleParentInvite(code) {
  810. // 延迟显示,等待登录完成
  811. setTimeout(async () => {
  812. const hasToken = uni.getStorageSync('token')
  813. if (!hasToken) {
  814. // 未登录,先去登录
  815. uni.reLaunch({
  816. url: '/pages/login/login?inviteCode=' + code
  817. })
  818. return
  819. }
  820. // 已登录,显示确认框
  821. uni.showModal({
  822. title: '加入家庭',
  823. content: '您已被邀请加入家庭,是否接受?',
  824. success: async (res) => {
  825. if (res.confirm) {
  826. try {
  827. uni.showLoading({ title: '加入中...' })
  828. const result = await acceptParentInvite(code)
  829. uni.hideLoading()
  830. if (result.code === 200) {
  831. const { role, token } = result.data
  832. uni.setStorageSync('role', role)
  833. uni.setStorageSync('token', token)
  834. uni.showToast({ title: '加入成功', icon: 'success' })
  835. // 刷新页面
  836. setTimeout(() => {
  837. uni.switchTab({ url: '/pages/index-home/index' })
  838. }, 1500)
  839. }
  840. } catch (e) {
  841. uni.hideLoading()
  842. uni.showToast({ title: e.message || '加入失败', icon: 'none' })
  843. }
  844. }
  845. }
  846. })
  847. }, 500)
  848. },
  849. getImageUrl: function(path) {
  850. return config.API_BASE_URL + path
  851. }
  852. }
  853. }
  854. </script>
  855. <style>
  856. .discover-container {
  857. min-height: 100vh;
  858. background: #f5f7fa;
  859. padding-bottom: 100rpx;
  860. }
  861. /* ===== 会员入口卡(能量沙盘下方) ===== */
  862. .member-entry {
  863. display: flex;
  864. align-items: center;
  865. margin: 20rpx 30rpx 0;
  866. background: linear-gradient(135deg, #F97316, #FB923C);
  867. border-radius: 20rpx;
  868. padding: 24rpx 30rpx;
  869. }
  870. .member-entry-icon-wrap {
  871. width: 64rpx;
  872. height: 64rpx;
  873. border-radius: 50%;
  874. background: rgba(255,255,255,0.2);
  875. display: flex;
  876. align-items: center;
  877. justify-content: center;
  878. margin-right: 16rpx;
  879. flex-shrink: 0;
  880. }
  881. .member-entry-icon {
  882. font-size: 36rpx;
  883. }
  884. .member-entry-texts {
  885. flex: 1;
  886. display: flex;
  887. flex-direction: column;
  888. min-width: 0;
  889. }
  890. .member-entry-title {
  891. font-size: 30rpx;
  892. font-weight: bold;
  893. color: #fff;
  894. }
  895. .member-entry-desc {
  896. font-size: 22rpx;
  897. color: rgba(255,255,255,0.85);
  898. margin-top: 4rpx;
  899. overflow: hidden;
  900. text-overflow: ellipsis;
  901. white-space: nowrap;
  902. }
  903. .member-entry-btn {
  904. margin-left: 16rpx;
  905. padding: 10rpx 24rpx;
  906. background: #fff;
  907. border-radius: 30rpx;
  908. flex-shrink: 0;
  909. }
  910. .member-entry-btn-text {
  911. font-size: 24rpx;
  912. color: #F97316;
  913. font-weight: bold;
  914. }
  915. /* ===== 推荐 ===== */
  916. .recommend-section {
  917. margin: 20rpx 30rpx;
  918. }
  919. .type-filter-scroll {
  920. white-space: nowrap;
  921. margin-bottom: 20rpx;
  922. }
  923. .filter-chip {
  924. display: inline-block;
  925. padding: 8rpx 24rpx;
  926. font-size: 24rpx;
  927. color: #666;
  928. background: #f0f0f0;
  929. border-radius: 30rpx;
  930. margin-right: 16rpx;
  931. }
  932. .filter-chip.active {
  933. background: #5B9BD5;
  934. color: #fff;
  935. }
  936. .loading-state,
  937. .empty-state {
  938. display: flex;
  939. justify-content: center;
  940. padding: 60rpx 0;
  941. }
  942. .loading-text,
  943. .empty-text {
  944. font-size: 26rpx;
  945. color: #999;
  946. }
  947. .product-grid {
  948. display: flex;
  949. flex-wrap: wrap;
  950. justify-content: space-between;
  951. }
  952. .product-card {
  953. width: 48%;
  954. background: #fff;
  955. border-radius: 16rpx;
  956. overflow: hidden;
  957. margin-bottom: 20rpx;
  958. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  959. }
  960. .product-cover {
  961. width: 100%;
  962. height: 200rpx;
  963. background: #f0f0f0;
  964. }
  965. .product-info {
  966. padding: 14rpx;
  967. }
  968. .product-name {
  969. display: block;
  970. font-size: 26rpx;
  971. color: #333;
  972. margin-bottom: 10rpx;
  973. overflow: hidden;
  974. text-overflow: ellipsis;
  975. white-space: nowrap;
  976. }
  977. .product-price-row {
  978. display: flex;
  979. align-items: baseline;
  980. }
  981. .product-price {
  982. font-size: 28rpx;
  983. color: #5B9BD5;
  984. font-weight: bold;
  985. margin-right: 10rpx;
  986. }
  987. .product-price-login {
  988. font-size: 24rpx;
  989. color: #999;
  990. }
  991. .product-member {
  992. font-size: 20rpx;
  993. color: #999;
  994. }
  995. /* ===== 五维全景幸福矩阵 ===== */
  996. /* ===== 底部登录 ===== */
  997. .login-footer {
  998. margin: 40rpx 30rpx;
  999. display: flex;
  1000. flex-direction: column;
  1001. align-items: center;
  1002. }
  1003. .login-btn {
  1004. width: 100%;
  1005. height: 88rpx;
  1006. line-height: 88rpx;
  1007. background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
  1008. color: #fff;
  1009. font-size: 32rpx;
  1010. font-weight: bold;
  1011. border-radius: 44rpx;
  1012. text-align: center;
  1013. border: none;
  1014. }
  1015. .login-btn::after {
  1016. border: none;
  1017. }
  1018. .login-footer-text {
  1019. font-size: 20rpx;
  1020. color: #bbb;
  1021. margin-top: 16rpx;
  1022. }
  1023. /* ===== 加载占位 ===== */
  1024. .loading-container {
  1025. display: flex;
  1026. justify-content: center;
  1027. align-items: center;
  1028. height: 100vh;
  1029. }
  1030. /* ===== 角色切换淡入淡出 ===== */
  1031. .role-switch-wrapper {
  1032. width: 100%;
  1033. min-height: 100vh;
  1034. }
  1035. .fade-enter-active,
  1036. .fade-leave-active {
  1037. transition: opacity 0.3s ease;
  1038. }
  1039. .fade-enter,
  1040. .fade-leave-to {
  1041. opacity: 0;
  1042. }
  1043. /* ===== 通用区块样式 ===== */
  1044. .section {
  1045. margin: 20rpx 30rpx;
  1046. }
  1047. .section-header {
  1048. display: flex;
  1049. justify-content: space-between;
  1050. align-items: center;
  1051. margin-bottom: 20rpx;
  1052. }
  1053. .section-title {
  1054. font-size: 30rpx;
  1055. font-weight: bold;
  1056. color: #333;
  1057. }
  1058. .section-more {
  1059. font-size: 24rpx;
  1060. color: #5B9BD5;
  1061. }
  1062. .empty-state {
  1063. display: flex;
  1064. justify-content: center;
  1065. padding: 60rpx 0;
  1066. }
  1067. .empty-text {
  1068. font-size: 26rpx;
  1069. color: #999;
  1070. }
  1071. /* ===== 活动列表 ===== */
  1072. .activity-list {
  1073. display: flex;
  1074. flex-direction: column;
  1075. gap: 16rpx;
  1076. }
  1077. .activity-card {
  1078. background: #fff;
  1079. border-radius: 16rpx;
  1080. overflow: hidden;
  1081. display: flex;
  1082. flex-direction: row;
  1083. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  1084. }
  1085. .activity-card:active {
  1086. opacity: 0.8;
  1087. }
  1088. .activity-cover {
  1089. width: 200rpx;
  1090. height: 160rpx;
  1091. flex-shrink: 0;
  1092. background: #f0f0f0;
  1093. }
  1094. .activity-info {
  1095. flex: 1;
  1096. padding: 16rpx;
  1097. display: flex;
  1098. flex-direction: column;
  1099. justify-content: space-between;
  1100. }
  1101. .activity-name {
  1102. font-size: 28rpx;
  1103. font-weight: bold;
  1104. color: #333;
  1105. margin-bottom: 8rpx;
  1106. }
  1107. .line-clamp-1 {
  1108. overflow: hidden;
  1109. text-overflow: ellipsis;
  1110. white-space: nowrap;
  1111. }
  1112. .activity-meta {
  1113. display: flex;
  1114. align-items: center;
  1115. margin-bottom: 8rpx;
  1116. }
  1117. .activity-time {
  1118. font-size: 22rpx;
  1119. color: #999;
  1120. }
  1121. .activity-bottom {
  1122. display: flex;
  1123. align-items: center;
  1124. gap: 12rpx;
  1125. }
  1126. .activity-status {
  1127. font-size: 20rpx;
  1128. padding: 2rpx 10rpx;
  1129. border-radius: 8rpx;
  1130. background: #E8F5E9;
  1131. color: #2E7D32;
  1132. }
  1133. .activity-status.status-upcoming {
  1134. background: #E3F2FD;
  1135. color: #1565C0;
  1136. }
  1137. .activity-status.status-ended {
  1138. background: #F5F5F5;
  1139. color: #999;
  1140. }
  1141. .activity-fee {
  1142. font-size: 24rpx;
  1143. color: #F97316;
  1144. font-weight: bold;
  1145. }
  1146. .activity-fee.fee-free {
  1147. color: #4CAF50;
  1148. }
  1149. /* ===== 文章列表 ===== */
  1150. .article-list {
  1151. display: flex;
  1152. flex-direction: column;
  1153. gap: 16rpx;
  1154. }
  1155. .article-card {
  1156. background: #fff;
  1157. border-radius: 16rpx;
  1158. padding: 24rpx;
  1159. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  1160. }
  1161. .article-card:active {
  1162. opacity: 0.8;
  1163. }
  1164. .article-category {
  1165. display: inline-block;
  1166. padding: 4rpx 14rpx;
  1167. border-radius: 8rpx;
  1168. margin-bottom: 10rpx;
  1169. }
  1170. .article-category-text {
  1171. font-size: 20rpx;
  1172. color: #fff;
  1173. }
  1174. .article-title {
  1175. display: block;
  1176. font-size: 28rpx;
  1177. font-weight: bold;
  1178. color: #333;
  1179. margin-bottom: 8rpx;
  1180. line-height: 1.4;
  1181. }
  1182. .article-summary {
  1183. display: block;
  1184. font-size: 24rpx;
  1185. color: #888;
  1186. line-height: 1.5;
  1187. margin-bottom: 12rpx;
  1188. overflow: hidden;
  1189. text-overflow: ellipsis;
  1190. display: -webkit-box;
  1191. -webkit-line-clamp: 2;
  1192. -webkit-box-orient: vertical;
  1193. }
  1194. .article-meta {
  1195. display: flex;
  1196. align-items: center;
  1197. gap: 16rpx;
  1198. }
  1199. .meta-item {
  1200. display: flex;
  1201. align-items: center;
  1202. gap: 4rpx;
  1203. }
  1204. .meta-icon {
  1205. font-size: 24rpx;
  1206. }
  1207. .meta-text {
  1208. font-size: 22rpx;
  1209. color: #999;
  1210. }
  1211. .article-date {
  1212. font-size: 22rpx;
  1213. color: #bbb;
  1214. }
  1215. /* ===== Splash Loading Overlay(冷启动蒙板,来自 merge splash.vue) ===== */
  1216. .splash-overlay {
  1217. position: fixed;
  1218. top: 0; left: 0; right: 0; bottom: 0;
  1219. z-index: 9999;
  1220. display: flex;
  1221. align-items: center;
  1222. justify-content: center;
  1223. background: linear-gradient(160deg, #FFF7ED 0%, #FFEDD5 50%, #FED7AA 100%);
  1224. overflow: hidden;
  1225. opacity: 1;
  1226. transition: opacity 0.4s ease;
  1227. }
  1228. .splash-overlay.fade-out {
  1229. opacity: 0;
  1230. pointer-events: none;
  1231. }
  1232. /* ---- bg circles from splash.vue ---- */
  1233. .splash-overlay-bg { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }
  1234. .bg-circle {
  1235. position: absolute;
  1236. border-radius: 50%;
  1237. opacity: 0.12;
  1238. }
  1239. .bg-circle-1 {
  1240. width: 400rpx; height: 400rpx;
  1241. background: #FF8C42;
  1242. top: -100rpx; right: -80rpx;
  1243. animation: splash-float-1 4s ease-in-out infinite;
  1244. }
  1245. .bg-circle-2 {
  1246. width: 280rpx; height: 280rpx;
  1247. background: #FF6B9D;
  1248. bottom: 80rpx; left: -60rpx;
  1249. animation: splash-float-2 5s ease-in-out infinite;
  1250. }
  1251. .bg-circle-3 {
  1252. width: 180rpx; height: 180rpx;
  1253. background: #6366F1;
  1254. top: 50%; right: -40rpx;
  1255. animation: splash-float-3 6s ease-in-out infinite;
  1256. }
  1257. @keyframes splash-float-1 {
  1258. 0%, 100% { transform: translateY(0) scale(1); }
  1259. 50% { transform: translateY(-30rpx) scale(1.05); }
  1260. }
  1261. @keyframes splash-float-2 {
  1262. 0%, 100% { transform: translateY(0) scale(1); }
  1263. 50% { transform: translateY(20rpx) scale(1.08); }
  1264. }
  1265. @keyframes splash-float-3 {
  1266. 0%, 100% { transform: translateY(0) rotate(0deg); }
  1267. 50% { transform: translateY(-20rpx) rotate(10deg); }
  1268. }
  1269. /* ---- body fade-in ---- */
  1270. .splash-overlay-body {
  1271. display: flex;
  1272. flex-direction: column;
  1273. align-items: center;
  1274. animation: splash-body-in 0.8s cubic-bezier(0.16,1,0.3,1) forwards;
  1275. }
  1276. @keyframes splash-body-in {
  1277. from { opacity: 0; transform: translateY(40rpx) scale(0.96); }
  1278. to { opacity: 1; transform: translateY(0) scale(1); }
  1279. }
  1280. /* ---- logo ---- */
  1281. .splash-logo-wrap {
  1282. width: 160rpx; height: 160rpx;
  1283. border-radius: 40rpx;
  1284. background: rgba(255,255,255,0.95);
  1285. display: flex; align-items: center; justify-content: center;
  1286. margin-bottom: 16rpx;
  1287. box-shadow: 0 8rpx 32rpx rgba(249,115,22,0.25);
  1288. animation: splash-logo-pulse 2.5s ease-in-out infinite;
  1289. }
  1290. @keyframes splash-logo-pulse {
  1291. 0%, 100% { box-shadow: 0 8rpx 32rpx rgba(249,115,22,0.25); }
  1292. 50% { box-shadow: 0 8rpx 48rpx rgba(249,115,22,0.45); }
  1293. }
  1294. .splash-logo-img { width: 100rpx; height: 100rpx; }
  1295. /* ---- brand ---- */
  1296. .splash-brand-name {
  1297. font-size: 64rpx; font-weight: 800;
  1298. color: #7C2D12;
  1299. letter-spacing: 10rpx;
  1300. margin-bottom: 2rpx;
  1301. }
  1302. .splash-brand-en {
  1303. font-size: 20rpx;
  1304. color: rgba(124,45,18,0.5);
  1305. letter-spacing: 6rpx;
  1306. margin-bottom: 30rpx;
  1307. }
  1308. .splash-tagline {
  1309. font-size: 26rpx;
  1310. color: rgba(124,45,18,0.7);
  1311. letter-spacing: 4rpx;
  1312. margin-top: 24rpx;
  1313. }
  1314. /* ---- dims row from splash.vue (rounded circles) ---- */
  1315. .splash-dims-row {
  1316. display: flex; flex-direction: row;
  1317. align-items: center; justify-content: center;
  1318. gap: 28rpx;
  1319. }
  1320. .splash-dim-item {
  1321. display: flex; flex-direction: column;
  1322. align-items: center; gap: 8rpx;
  1323. }
  1324. .splash-dim-circle {
  1325. width: 80rpx; height: 80rpx;
  1326. border-radius: 50%;
  1327. display: flex; align-items: center; justify-content: center;
  1328. }
  1329. .splash-dim-icon { font-size: 36rpx; line-height: 1; }
  1330. .splash-dim-label {
  1331. font-size: 22rpx; font-weight: 500;
  1332. color: rgba(124,45,18,0.75);
  1333. line-height: 1;
  1334. }
  1335. /* ---- staggered dim entry from splash.vue ---- */
  1336. .splash-dim-item:nth-child(1) { animation: splash-dim-in 0.5s ease 0.1s both; }
  1337. .splash-dim-item:nth-child(2) { animation: splash-dim-in 0.5s ease 0.2s both; }
  1338. .splash-dim-item:nth-child(3) { animation: splash-dim-in 0.5s ease 0.3s both; }
  1339. .splash-dim-item:nth-child(4) { animation: splash-dim-in 0.5s ease 0.4s both; }
  1340. .splash-dim-item:nth-child(5) { animation: splash-dim-in 0.5s ease 0.5s both; }
  1341. @keyframes splash-dim-in {
  1342. from { opacity: 0; transform: translateY(16rpx) scale(0.8); }
  1343. to { opacity: 1; transform: translateY(0) scale(1); }
  1344. }
  1345. /* ---- loading dots ---- */
  1346. .splash-overlay-loading {
  1347. position: absolute;
  1348. bottom: 120rpx;
  1349. left: 0; right: 0;
  1350. display: flex;
  1351. justify-content: center;
  1352. align-items: center;
  1353. gap: 12rpx;
  1354. }
  1355. .splash-overlay-dot {
  1356. width: 14rpx; height: 14rpx;
  1357. border-radius: 50%;
  1358. background: rgba(249,115,22,0.6);
  1359. animation: splash-dot-bounce 1.4s ease-in-out infinite both;
  1360. }
  1361. .splash-overlay-dot:nth-child(1) { animation-delay: -0.32s; }
  1362. .splash-overlay-dot:nth-child(2) { animation-delay: -0.16s; }
  1363. .splash-overlay-dot:nth-child(3) { animation-delay: 0s; }
  1364. @keyframes splash-dot-bounce {
  1365. 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  1366. 40% { transform: scale(1); opacity: 1; }
  1367. }
  1368. /* ---- 登录态内容布局 ---- */
  1369. .logged-in-container {
  1370. padding-bottom: 40rpx;
  1371. }
  1372. /* ===== 功能入口网格(3列,对齐健康/成长页) ===== */
  1373. .grid-3col {
  1374. display: flex;
  1375. flex-wrap: wrap;
  1376. background: #fff;
  1377. border-radius: 20rpx;
  1378. padding: 8rpx 0;
  1379. }
  1380. .grid-item {
  1381. width: 33.33%;
  1382. display: flex;
  1383. flex-direction: column;
  1384. align-items: center;
  1385. padding: 20rpx 0;
  1386. }
  1387. .grid-icon {
  1388. width: 72rpx;
  1389. height: 72rpx;
  1390. border-radius: 18rpx;
  1391. display: flex;
  1392. align-items: center;
  1393. justify-content: center;
  1394. margin-bottom: 8rpx;
  1395. }
  1396. .grid-icon text {
  1397. font-size: 32rpx;
  1398. }
  1399. .grid-item .grid-label {
  1400. font-size: 24rpx;
  1401. color: #666;
  1402. }
  1403. </style>