index.vue 50 KB

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