index.vue 56 KB

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