index.vue 55 KB

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