index.vue 50 KB

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