index.vue 55 KB

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