index.vue 51 KB

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