index.vue 51 KB

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