index.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123
  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" />
  48. <!-- 未登录态 — 发现页/引流内容,直接内嵌,不跳转 -->
  49. <view v-if="!currentRole" class="discover-container">
  50. <!-- 品牌头部 -->
  51. <PageBanner theme="home"
  52. tagline="家庭健康成长俱乐部"
  53. quote="给全家的一站式幸福提案" />
  54. <!-- 五行沙盘预览 -->
  55. <wuxing-sandbox mode="preview" badgeText="登录查看完整报告" @point-click="handleLogin" />
  56. <!-- 活动/商品推荐 -->
  57. <view class="recommend-section">
  58. <view class="section-header">
  59. <text class="section-title">🔥 热门推荐</text>
  60. <text class="section-more" @click="goShop">查看更多 ›</text>
  61. </view>
  62. <scroll-view scroll-x enable-flex show-scrollbar="false" class="type-filter-scroll">
  63. <view
  64. v-for="item in typeList"
  65. :key="item.value"
  66. :class="['filter-chip', currentType === item.value ? 'active' : '']"
  67. @click="onTypeChange(item.value)"
  68. >
  69. {{ item.label }}
  70. </view>
  71. </scroll-view>
  72. <view v-if="loading" class="loading-state">
  73. <text class="loading-text">加载中...</text>
  74. </view>
  75. <view v-else-if="products.length === 0" class="empty-state">
  76. <text class="empty-text">暂无商品,去商城看看吧</text>
  77. </view>
  78. <view v-else class="product-grid">
  79. <view
  80. v-for="item in products"
  81. :key="item.id"
  82. class="product-card"
  83. @click="handleLogin()"
  84. >
  85. <image class="product-cover" :src="item.coverImage || '/static/default-product.png'" mode="aspectFill" />
  86. <view class="product-info">
  87. <text class="product-name">{{ item.name }}</text>
  88. <view class="product-price-row">
  89. <!-- 游客不显示价格 -->
  90. <text class="product-price-login">登录查看</text>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 热门活动(无条件展示) -->
  97. <view class="section">
  98. <view class="section-header">
  99. <text class="section-title">🔥 热门活动</text>
  100. <text class="section-more" @click="goActivities">查看更多 ›</text>
  101. </view>
  102. <view v-if="dimensionActivities.length === 0" class="empty-state" style="padding: 40rpx 0;">
  103. <text class="empty-text">暂无活动</text>
  104. </view>
  105. <view class="activity-list" v-else>
  106. <view class="activity-card" v-for="act in dimensionActivities" :key="act.id" @click="goActivityDetail(act)">
  107. <image class="activity-cover" :src="act.coverImage || '/static/default-activity.png'" mode="aspectFill" />
  108. <view class="activity-info">
  109. <text class="activity-name line-clamp-1">{{ act.title }}</text>
  110. <view class="activity-meta">
  111. <text class="activity-time">{{ act.startTime }}</text>
  112. </view>
  113. <view class="activity-bottom">
  114. <text class="activity-status" :class="'status-' + (act.status || 'upcoming')">{{ act.status === 'ongoing' ? '进行中' : act.status === 'ended' ? '已结束' : '即将开始' }}</text>
  115. <text class="activity-fee" v-if="act.price && act.price > 0">¥{{ (act.price / 100).toFixed(0) }}</text>
  116. <text class="activity-fee fee-free" v-else>免费</text>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <!-- 推荐阅读(无条件展示) -->
  123. <view class="section">
  124. <view class="section-header">
  125. <text class="section-title">📖 推荐阅读</text>
  126. <text class="section-more" @click="goArticles">更多 ›</text>
  127. </view>
  128. <view v-if="articlesLoading" class="loading-state">
  129. <text class="loading-text">加载中...</text>
  130. </view>
  131. <view v-else-if="indexArticles.length === 0" class="empty-state" style="padding: 40rpx 0;">
  132. <text class="empty-text">暂无文章</text>
  133. </view>
  134. <view class="article-list" v-else>
  135. <view class="article-card" v-for="article in indexArticles" :key="article.id" @click="goArticleDetail(article.id)">
  136. <view class="article-category" :style="{ background: article.categoryColor }">
  137. <text class="article-category-text">{{ article.category }}</text>
  138. </view>
  139. <text class="article-title">{{ article.title }}</text>
  140. <text class="article-summary">{{ article.summary }}</text>
  141. <view class="article-meta">
  142. <view class="meta-item">
  143. <text class="meta-icon">&#x1F4D6;</text>
  144. <text class="meta-text">{{ article.views }}</text>
  145. </view>
  146. <text class="article-date">{{ article.date }}</text>
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. <!-- 五维全景幸福矩阵 -->
  152. <view class="why-section">
  153. <view class="section-header">
  154. <text class="section-title">🌏 五维全景幸福矩阵 — 给全家的一站式幸福提案</text>
  155. </view>
  156. <view class="dim-matrix">
  157. <view
  158. v-for="dim in dimList" :key="dim.code"
  159. class="dim-card"
  160. :style="'border-left:6rpx solid ' + dim.color"
  161. @click="handleLogin"
  162. >
  163. <view class="dim-icon-circle" :style="'background:' + dim.bgColor">
  164. <text class="dim-icon">{{ dim.icon }}</text>
  165. </view>
  166. <view class="dim-tag" :style="'color:' + dim.color + ';background:' + dim.bgColor">{{ dim.name }} · {{ dim.title }}</view>
  167. <text class="dim-desc">{{ dim.desc }}</text>
  168. </view>
  169. </view>
  170. <!-- 五维能量环装饰 -->
  171. <view class="dim-energy-row">
  172. <view
  173. v-for="c in energyDotColors" :key="c"
  174. class="energy-dot"
  175. :style="'background:' + c"
  176. ></view>
  177. </view>
  178. </view>
  179. <!-- 底部登录按钮 -->
  180. <view class="login-footer">
  181. <button class="login-btn" @click="handleLogin">登录 / 注册</button>
  182. <text class="login-footer-text">登录即表示同意《用户协议》和《隐私政策》</text>
  183. </view>
  184. <!-- 底部占位 -->
  185. <view style="height: 120rpx;"></view>
  186. </view>
  187. <!-- 登录态 — 按角色渲染(带淡入淡出过渡)-->
  188. <view v-else class="role-switch-wrapper">
  189. <transition name="fade" mode="out-in">
  190. <parent-index v-if="currentRole === 'parent'" key="parent" @ready="onChildReady" />
  191. <child-index v-else-if="currentRole === 'child'" key="child" @ready="onChildReady" />
  192. <!-- teacher-index 已废弃,教师功能折入 parent-index -->
  193. <view v-else class="loading-container" key="loading">
  194. <text>加载中...</text>
  195. </view>
  196. </transition>
  197. <AIFloatingAvatar />
  198. </view>
  199. </view>
  200. </template>
  201. <script>
  202. import ParentIndex from './parent-index.vue'
  203. import ChildIndex from './child-index.vue'
  204. // TeacherIndex 已废弃,教师功能折入 parent-index
  205. import PageBanner from '../../components/PageBanner.vue'
  206. import WuxingSandbox from '../../components/wuxing-sandbox.vue'
  207. import TabTransition from '../../components/tab-transition.vue'
  208. import AIFloatingAvatar from '../../components/AIFloatingAvatar.vue'
  209. import { acceptParentInvite, productList, getActivityList, getFeaturedArticles } from '../../utils/api.js'
  210. var DIMENSIONS = [
  211. { code: 'body', name: '身', icon: '🌏', color: '#8D6E63', bgColor: 'rgba(141,110,99,0.15)', title: '主动健康', desc: '用最适合的方法,从根源调理家人体质,畅享高质量长寿生活' },
  212. { code: 'mind', name: '心', icon: '🔥', color: '#FF6B35', bgColor: 'rgba(255,107,53,0.15)', title: '大爱传承', desc: '将长辈陪护升华为家族纽带,让家风温暖代代相传' },
  213. { code: 'wisdom', name: '智', icon: '⚡', color: '#FFD700', bgColor: 'rgba(255,215,0,0.15)', title: '赋能未来', desc: '专业测评与素质培养,开启孩子面向未来的大智慧' },
  214. { code: 'action', name: '行', icon: '🌿', color: '#4CAF50', bgColor: 'rgba(76,175,80,0.15)', title: '知行合一', desc: '在亲子户外与沙龙中,让健康生活方式真正知行合一' },
  215. { code: 'wealth', name: '富', icon: '💧', color: '#42A5F5', bgColor: 'rgba(66,165,245,0.15)', title: '利他创富', desc: '依托创客生态,在利他分享中实现家庭第二收入曲线' }
  216. ]
  217. export default {
  218. components: {
  219. ParentIndex,
  220. ChildIndex,
  221. PageBanner,
  222. WuxingSandbox,
  223. TabTransition,
  224. AIFloatingAvatar
  225. },
  226. data() {
  227. // 从 storage 预取登录态/角色,确保首次渲染即正确(WeChat 渲染层/逻辑层分离架构下 onLoad 执行前已渲染)
  228. var _token = uni.getStorageSync('token')
  229. var _currentRole = ''
  230. if (_token) {
  231. _currentRole = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || ''
  232. }
  233. // 冷启动标记(由 App.vue onLaunch 设置,仅在冷启动时存在)
  234. var _isFirstLaunch = (uni.getStorageSync('_showSplashOverlay') === '1')
  235. return {
  236. currentRole: _currentRole,
  237. // TabTransition 始终默认 true,确保首次渲染即出现;冷启动时被 splash overlay 覆盖不可见
  238. showTabTransition: true,
  239. // splash loading overlay(冷启动时展示,数据加载完关闭)
  240. splashOverlay: _isFirstLaunch,
  241. splashOverlayFading: false,
  242. _splashReady: false,
  243. typeList: [
  244. { label: '全部', value: '' },
  245. { label: '活动', value: 'activity' },
  246. { label: '课程', value: 'course' },
  247. { label: '实物', value: 'physical' },
  248. { label: '数字', value: 'digital' },
  249. { label: '服务', value: 'service' }
  250. ],
  251. currentType: '',
  252. products: [],
  253. loading: false,
  254. dimensionActivities: [],
  255. indexArticles: [],
  256. articlesLoading: false
  257. }
  258. },
  259. onLoad(options) {
  260. this._doInit(options)
  261. },
  262. onShow() {
  263. // splash overlay 已在 data() 中根据 storage 标记初始化,此处只需配置关闭条件
  264. if (this.splashOverlay) {
  265. uni.removeStorageSync('_showSplashOverlay')
  266. this._splashLoadCount = 0
  267. this._splashMinPassed = false
  268. var self = this
  269. // 最低展示 800ms
  270. setTimeout(function() {
  271. self._splashMinPassed = true
  272. self._tryHideSplash()
  273. }, 800)
  274. // 最多展示 5s
  275. setTimeout(function() {
  276. if (self.splashOverlay) self._hideSplashOverlay()
  277. }, 5000)
  278. } else {
  279. // tab 切回:TabTransition 已在 data() 中为 true,确保首次渲染即出现
  280. // 但组件缓存后再次切回时可能已被 _watchPageReady 置为 false,需要重置
  281. this.showTabTransition = true
  282. this._watchPageReady()
  283. }
  284. // 始终执行初始化,确保登录态变更后及时切换视图
  285. this._doInit()
  286. },
  287. methods: {
  288. _checkSplashReady() {
  289. this._splashLoadCount++
  290. this._tryHideSplash()
  291. },
  292. _tryHideSplash() {
  293. if (this.splashOverlayFading) return
  294. if (!this._splashMinPassed) return
  295. if (this.isLoggedIn()) {
  296. // 登录用户:等待子组件的 ready 信号
  297. if (this._splashReady) this._hideSplashOverlay()
  298. } else {
  299. // 游客:等待 3 个 API 全部返回
  300. if (this._splashLoadCount >= 3) this._hideSplashOverlay()
  301. }
  302. },
  303. _hideSplashOverlay() {
  304. if (this.splashOverlayFading) return
  305. this.splashOverlayFading = true
  306. // splash 关闭时同时隐藏 TabTransition(防止 splash 结束后闪现过渡页)
  307. this.showTabTransition = false
  308. var self = this
  309. setTimeout(function() {
  310. self.splashOverlay = false
  311. self.splashOverlayFading = false
  312. }, 400)
  313. },
  314. onChildReady() {
  315. this._splashReady = true
  316. this._tryHideSplash()
  317. },
  318. // 首页 TabTransition 动态关闭:检测关键内容是否就绪
  319. _watchPageReady() {
  320. var self = this
  321. var unwatch = this.$watch(function() {
  322. if (!self.isLoggedIn()) {
  323. return !!(self.products && self.products.length > 0) ||
  324. !!(self.dimensionActivities && self.dimensionActivities.length > 0) ||
  325. !!(self.indexArticles && self.indexArticles.length > 0)
  326. }
  327. // 登录用户:currentRole 存在代表子组件已渲染
  328. return !!self.currentRole
  329. }, function(val) {
  330. if (val) {
  331. if (unwatch) unwatch()
  332. self.showTabTransition = false
  333. }
  334. })
  335. // 5s 超时兜底
  336. setTimeout(function() {
  337. if (unwatch) unwatch()
  338. self.showTabTransition = false
  339. }, 5000)
  340. },
  341. _doInit(options) {
  342. options = options || {}
  343. if (!this.isLoggedIn()) {
  344. this.currentRole = ''
  345. this.loadProducts()
  346. this.loadDimensionActivities()
  347. this.loadFeaturedArticles()
  348. return
  349. }
  350. this.syncRoleAndTabBar()
  351. if (options.inviteCode && options.type === 'parent_invite') {
  352. this.handleParentInvite(options.inviteCode)
  353. } else {
  354. var storedCode = uni.getStorageSync('inviteCode')
  355. var storedType = uni.getStorageSync('inviteType')
  356. if (storedCode && storedType === 'parent_invite') {
  357. this.handleParentInvite(storedCode)
  358. uni.removeStorageSync('inviteCode')
  359. uni.removeStorageSync('inviteType')
  360. }
  361. }
  362. },
  363. isLoggedIn() {
  364. return !!uni.getStorageSync('token')
  365. },
  366. normalizeCurrentRole() {
  367. const role = uni.getStorageSync('role') || 'parent'
  368. const currentRole = uni.getStorageSync('currentRole')
  369. if (!currentRole) {
  370. return role
  371. }
  372. // 非规划师账号不允许落到规划师首页
  373. if (currentRole === 'teacher' && role !== 'teacher') {
  374. return role
  375. }
  376. // 只有家长账号允许切换到孩子视角
  377. if (currentRole === 'child' && role !== 'parent') {
  378. return role
  379. }
  380. return currentRole
  381. },
  382. syncRoleAndTabBar() {
  383. this.currentRole = this.normalizeCurrentRole()
  384. uni.setStorageSync('currentRole', this.currentRole)
  385. },
  386. // ===== 发现页 / 未登录态方法 =====
  387. loadProducts: function() {
  388. this.loading = true
  389. var params = { page: 1, size: 10 }
  390. if (this.currentType) {
  391. params.productType = this.currentType
  392. }
  393. var self = this
  394. productList(params).then(function(res) {
  395. self.loading = false
  396. if (res && res.code === 200) {
  397. // res.data is the response wrapper, products are in res.data.data or res.data.records
  398. var rawData = res.data && (Array.isArray(res.data) ? res.data : (res.data.data || res.data.records || []))
  399. self.products = Array.isArray(rawData) ? rawData : []
  400. }
  401. self._checkSplashReady()
  402. }).catch(function() {
  403. self.loading = false
  404. self._checkSplashReady()
  405. })
  406. },
  407. loadDimensionActivities: function() {
  408. var self = this
  409. getActivityList({ dimensionCode: '', page: 1, size: 3 }).then(function(res) {
  410. if (res && res.code === 200) {
  411. // res.data is the response wrapper, activities are in res.data.data or res.data.records
  412. var rawData = res.data && (Array.isArray(res.data) ? res.data : (res.data.data || res.data.records || []))
  413. self.dimensionActivities = Array.isArray(rawData) ? rawData.slice(0, 3) : []
  414. }
  415. self._checkSplashReady()
  416. }).catch(function() {
  417. self._checkSplashReady()
  418. })
  419. },
  420. loadFeaturedArticles: function() {
  421. var self = this
  422. this.articlesLoading = true
  423. getFeaturedArticles({ size: 5 }).then(function(res) {
  424. self.articlesLoading = false
  425. if (res && res.code === 200) {
  426. var gradientColors = [
  427. 'linear-gradient(135deg, #10B981, #34D399)',
  428. 'linear-gradient(135deg, #5B9BD5, #8FC5E8)',
  429. 'linear-gradient(135deg, #8B5CF6, #C084FC)',
  430. 'linear-gradient(135deg, #F97316, #FB923C)',
  431. 'linear-gradient(135deg, #6366F1, #818CF8)'
  432. ]
  433. // res.data is the response wrapper, articles are in res.data.data
  434. var rawList = res.data && (Array.isArray(res.data) ? res.data : (res.data.data || res.data.records || []))
  435. var list = Array.isArray(rawList) ? rawList : []
  436. self.indexArticles = list.map(function(item, index) {
  437. return {
  438. id: item.id,
  439. category: item.categoryName || item.category || '热门文章',
  440. categoryColor: gradientColors[index % gradientColors.length],
  441. title: item.title || '',
  442. summary: item.summary || '',
  443. views: item.viewCount ? String(item.viewCount) : '0',
  444. date: item.publishedAt ? item.publishedAt.slice(0, 10) : ''
  445. }
  446. })
  447. }
  448. self._checkSplashReady()
  449. }).catch(function() {
  450. self.articlesLoading = false
  451. self._checkSplashReady()
  452. })
  453. },
  454. goActivities: function() {
  455. uni.navigateTo({ url: '/pages/discover/index?type=activity' })
  456. },
  457. goActivityDetail: function(act) {
  458. uni.navigateTo({ url: '/pages/discover-detail/activity-detail/activity-detail?id=' + act.id })
  459. },
  460. goArticles: function() {
  461. uni.navigateTo({ url: '/pages/mind-detail/articles' })
  462. },
  463. goArticleDetail: function(id) {
  464. uni.navigateTo({ url: '/pages/mind-detail/article-detail?id=' + id })
  465. },
  466. onTypeChange(value) {
  467. this.currentType = value
  468. this.loadProducts()
  469. },
  470. goShop() {
  471. uni.navigateTo({ url: '/pages/discover/index' })
  472. },
  473. goDetail(id) {
  474. uni.navigateTo({ url: '/pages/discover/product-detail/product-detail?id=' + id })
  475. },
  476. handleLogin() {
  477. uni.navigateTo({ url: '/pages/login/login?redirect=' + encodeURIComponent('/pages/index/index') })
  478. },
  479. async handleParentInvite(code) {
  480. // 延迟显示,等待登录完成
  481. setTimeout(async () => {
  482. const hasToken = uni.getStorageSync('token')
  483. if (!hasToken) {
  484. // 未登录,先去登录
  485. uni.reLaunch({
  486. url: '/pages/login/login?inviteCode=' + code
  487. })
  488. return
  489. }
  490. // 已登录,显示确认框
  491. uni.showModal({
  492. title: '加入家庭',
  493. content: '您已被邀请加入家庭,是否接受?',
  494. success: async (res) => {
  495. if (res.confirm) {
  496. try {
  497. uni.showLoading({ title: '加入中...' })
  498. const result = await acceptParentInvite(code)
  499. uni.hideLoading()
  500. if (result.code === 200) {
  501. const { familyId, role, token } = result.data
  502. uni.setStorageSync('familyId', familyId)
  503. uni.setStorageSync('role', role)
  504. uni.setStorageSync('token', token)
  505. uni.showToast({ title: '加入成功', icon: 'success' })
  506. // 刷新页面
  507. setTimeout(() => {
  508. uni.switchTab({ url: '/pages/index/index' })
  509. }, 1500)
  510. }
  511. } catch (e) {
  512. uni.hideLoading()
  513. uni.showToast({ title: e.message || '加入失败', icon: 'none' })
  514. }
  515. }
  516. }
  517. })
  518. }, 500)
  519. },
  520. },
  521. computed: {
  522. dimList: function() {
  523. return DIMENSIONS
  524. },
  525. energyDotColors: function() {
  526. return ['#8D6E63', '#FF6B35', '#FFD700', '#4CAF50', '#42A5F5']
  527. }
  528. }
  529. }
  530. </script>
  531. <style>
  532. .discover-container {
  533. min-height: 100vh;
  534. background: #f5f7fa;
  535. padding-bottom: 100rpx;
  536. }
  537. /* ===== 推荐 ===== */
  538. .recommend-section {
  539. margin: 20rpx 30rpx;
  540. }
  541. .section-header {
  542. display: flex;
  543. justify-content: space-between;
  544. align-items: center;
  545. margin-bottom: 20rpx;
  546. }
  547. .section-title {
  548. font-size: 30rpx;
  549. font-weight: bold;
  550. color: #333;
  551. }
  552. .section-more {
  553. font-size: 24rpx;
  554. color: #5B9BD5;
  555. }
  556. .type-filter-scroll {
  557. white-space: nowrap;
  558. margin-bottom: 20rpx;
  559. }
  560. .filter-chip {
  561. display: inline-block;
  562. padding: 8rpx 24rpx;
  563. font-size: 24rpx;
  564. color: #666;
  565. background: #f0f0f0;
  566. border-radius: 30rpx;
  567. margin-right: 16rpx;
  568. }
  569. .filter-chip.active {
  570. background: #5B9BD5;
  571. color: #fff;
  572. }
  573. .loading-state,
  574. .empty-state {
  575. display: flex;
  576. justify-content: center;
  577. padding: 60rpx 0;
  578. }
  579. .loading-text,
  580. .empty-text {
  581. font-size: 26rpx;
  582. color: #999;
  583. }
  584. .product-grid {
  585. display: flex;
  586. flex-wrap: wrap;
  587. justify-content: space-between;
  588. }
  589. .product-card {
  590. width: 48%;
  591. background: #fff;
  592. border-radius: 16rpx;
  593. overflow: hidden;
  594. margin-bottom: 20rpx;
  595. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  596. }
  597. .product-cover {
  598. width: 100%;
  599. height: 200rpx;
  600. background: #f0f0f0;
  601. }
  602. .product-info {
  603. padding: 14rpx;
  604. }
  605. .product-name {
  606. display: block;
  607. font-size: 26rpx;
  608. color: #333;
  609. margin-bottom: 10rpx;
  610. overflow: hidden;
  611. text-overflow: ellipsis;
  612. white-space: nowrap;
  613. }
  614. .product-price-row {
  615. display: flex;
  616. align-items: baseline;
  617. }
  618. .product-price {
  619. font-size: 28rpx;
  620. color: #5B9BD5;
  621. font-weight: bold;
  622. margin-right: 10rpx;
  623. }
  624. .product-price-login {
  625. font-size: 24rpx;
  626. color: #999;
  627. }
  628. .product-member {
  629. font-size: 20rpx;
  630. color: #999;
  631. }
  632. /* ===== 五维全景幸福矩阵 ===== */
  633. .why-section {
  634. margin: 30rpx;
  635. }
  636. .dim-matrix {
  637. display: flex;
  638. flex-wrap: wrap;
  639. gap: 20rpx;
  640. justify-content: center;
  641. }
  642. .dim-card {
  643. width: calc(33.33% - 14rpx);
  644. box-sizing: border-box;
  645. background: #fff;
  646. border-radius: 20rpx;
  647. padding: 28rpx 16rpx 24rpx;
  648. display: flex;
  649. flex-direction: column;
  650. align-items: center;
  651. text-align: center;
  652. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  653. transition: transform 0.2s ease, box-shadow 0.2s ease;
  654. position: relative;
  655. overflow: hidden;
  656. }
  657. .dim-card:active {
  658. transform: scale(0.96);
  659. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
  660. }
  661. .dim-icon-circle {
  662. width: 72rpx;
  663. height: 72rpx;
  664. border-radius: 50%;
  665. display: flex;
  666. align-items: center;
  667. justify-content: center;
  668. margin-bottom: 14rpx;
  669. flex-shrink: 0;
  670. }
  671. .dim-icon {
  672. font-size: 36rpx;
  673. line-height: 1;
  674. }
  675. .dim-tag {
  676. font-size: 22rpx;
  677. font-weight: 600;
  678. padding: 4rpx 14rpx;
  679. border-radius: 20rpx;
  680. margin-bottom: 10rpx;
  681. max-width: 100%;
  682. overflow: hidden;
  683. text-overflow: ellipsis;
  684. white-space: nowrap;
  685. }
  686. .dim-desc {
  687. font-size: 20rpx;
  688. color: #888;
  689. line-height: 1.5;
  690. display: -webkit-box;
  691. -webkit-line-clamp: 2;
  692. -webkit-box-orient: vertical;
  693. overflow: hidden;
  694. }
  695. /* 五维能量环 */
  696. .dim-energy-row {
  697. display: flex;
  698. justify-content: center;
  699. gap: 12rpx;
  700. margin-top: 24rpx;
  701. opacity: 0.5;
  702. }
  703. .energy-dot {
  704. width: 10rpx;
  705. height: 10rpx;
  706. border-radius: 50%;
  707. }
  708. /* ===== 底部登录 ===== */
  709. .login-footer {
  710. margin: 40rpx 30rpx;
  711. display: flex;
  712. flex-direction: column;
  713. align-items: center;
  714. }
  715. .login-btn {
  716. width: 100%;
  717. height: 88rpx;
  718. line-height: 88rpx;
  719. background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
  720. color: #fff;
  721. font-size: 32rpx;
  722. font-weight: bold;
  723. border-radius: 44rpx;
  724. text-align: center;
  725. border: none;
  726. }
  727. .login-btn::after {
  728. border: none;
  729. }
  730. .login-footer-text {
  731. font-size: 20rpx;
  732. color: #bbb;
  733. margin-top: 16rpx;
  734. }
  735. /* ===== 加载占位 ===== */
  736. .loading-container {
  737. display: flex;
  738. justify-content: center;
  739. align-items: center;
  740. height: 100vh;
  741. }
  742. /* ===== 角色切换淡入淡出 ===== */
  743. .role-switch-wrapper {
  744. width: 100%;
  745. min-height: 100vh;
  746. }
  747. .fade-enter-active,
  748. .fade-leave-active {
  749. transition: opacity 0.3s ease;
  750. }
  751. .fade-enter,
  752. .fade-leave-to {
  753. opacity: 0;
  754. }
  755. /* ===== 通用区块样式 ===== */
  756. .section {
  757. margin: 20rpx 30rpx;
  758. }
  759. .section-header {
  760. display: flex;
  761. justify-content: space-between;
  762. align-items: center;
  763. margin-bottom: 20rpx;
  764. }
  765. .section-title {
  766. font-size: 30rpx;
  767. font-weight: bold;
  768. color: #333;
  769. }
  770. .section-more {
  771. font-size: 24rpx;
  772. color: #5B9BD5;
  773. }
  774. .empty-state {
  775. display: flex;
  776. justify-content: center;
  777. padding: 60rpx 0;
  778. }
  779. .empty-text {
  780. font-size: 26rpx;
  781. color: #999;
  782. }
  783. /* ===== 活动列表 ===== */
  784. .activity-list {
  785. display: flex;
  786. flex-direction: column;
  787. gap: 16rpx;
  788. }
  789. .activity-card {
  790. background: #fff;
  791. border-radius: 16rpx;
  792. overflow: hidden;
  793. display: flex;
  794. flex-direction: row;
  795. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  796. }
  797. .activity-card:active {
  798. opacity: 0.8;
  799. }
  800. .activity-cover {
  801. width: 200rpx;
  802. height: 160rpx;
  803. flex-shrink: 0;
  804. background: #f0f0f0;
  805. }
  806. .activity-info {
  807. flex: 1;
  808. padding: 16rpx;
  809. display: flex;
  810. flex-direction: column;
  811. justify-content: space-between;
  812. }
  813. .activity-name {
  814. font-size: 28rpx;
  815. font-weight: bold;
  816. color: #333;
  817. margin-bottom: 8rpx;
  818. }
  819. .line-clamp-1 {
  820. overflow: hidden;
  821. text-overflow: ellipsis;
  822. white-space: nowrap;
  823. }
  824. .activity-meta {
  825. display: flex;
  826. align-items: center;
  827. margin-bottom: 8rpx;
  828. }
  829. .activity-time {
  830. font-size: 22rpx;
  831. color: #999;
  832. }
  833. .activity-bottom {
  834. display: flex;
  835. align-items: center;
  836. gap: 12rpx;
  837. }
  838. .activity-status {
  839. font-size: 20rpx;
  840. padding: 2rpx 10rpx;
  841. border-radius: 8rpx;
  842. background: #E8F5E9;
  843. color: #2E7D32;
  844. }
  845. .activity-status.status-upcoming {
  846. background: #E3F2FD;
  847. color: #1565C0;
  848. }
  849. .activity-status.status-ended {
  850. background: #F5F5F5;
  851. color: #999;
  852. }
  853. .activity-fee {
  854. font-size: 24rpx;
  855. color: #F97316;
  856. font-weight: bold;
  857. }
  858. .activity-fee.fee-free {
  859. color: #4CAF50;
  860. }
  861. /* ===== 文章列表 ===== */
  862. .article-list {
  863. display: flex;
  864. flex-direction: column;
  865. gap: 16rpx;
  866. }
  867. .article-card {
  868. background: #fff;
  869. border-radius: 16rpx;
  870. padding: 24rpx;
  871. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  872. }
  873. .article-card:active {
  874. opacity: 0.8;
  875. }
  876. .article-category {
  877. display: inline-block;
  878. padding: 4rpx 14rpx;
  879. border-radius: 8rpx;
  880. margin-bottom: 10rpx;
  881. }
  882. .article-category-text {
  883. font-size: 20rpx;
  884. color: #fff;
  885. }
  886. .article-title {
  887. display: block;
  888. font-size: 28rpx;
  889. font-weight: bold;
  890. color: #333;
  891. margin-bottom: 8rpx;
  892. line-height: 1.4;
  893. }
  894. .article-summary {
  895. display: block;
  896. font-size: 24rpx;
  897. color: #888;
  898. line-height: 1.5;
  899. margin-bottom: 12rpx;
  900. overflow: hidden;
  901. text-overflow: ellipsis;
  902. display: -webkit-box;
  903. -webkit-line-clamp: 2;
  904. -webkit-box-orient: vertical;
  905. }
  906. .article-meta {
  907. display: flex;
  908. align-items: center;
  909. gap: 16rpx;
  910. }
  911. .meta-item {
  912. display: flex;
  913. align-items: center;
  914. gap: 4rpx;
  915. }
  916. .meta-icon {
  917. font-size: 24rpx;
  918. }
  919. .meta-text {
  920. font-size: 22rpx;
  921. color: #999;
  922. }
  923. .article-date {
  924. font-size: 22rpx;
  925. color: #bbb;
  926. }
  927. /* ===== Splash Loading Overlay(冷启动蒙板,来自 merge splash.vue) ===== */
  928. .splash-overlay {
  929. position: fixed;
  930. top: 0; left: 0; right: 0; bottom: 0;
  931. z-index: 9999;
  932. display: flex;
  933. align-items: center;
  934. justify-content: center;
  935. background: linear-gradient(160deg, #FFF7ED 0%, #FFEDD5 50%, #FED7AA 100%);
  936. overflow: hidden;
  937. opacity: 1;
  938. transition: opacity 0.4s ease;
  939. }
  940. .splash-overlay.fade-out {
  941. opacity: 0;
  942. pointer-events: none;
  943. }
  944. /* ---- bg circles from splash.vue ---- */
  945. .splash-overlay-bg { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }
  946. .bg-circle {
  947. position: absolute;
  948. border-radius: 50%;
  949. opacity: 0.12;
  950. }
  951. .bg-circle-1 {
  952. width: 400rpx; height: 400rpx;
  953. background: #FF8C42;
  954. top: -100rpx; right: -80rpx;
  955. animation: splash-float-1 4s ease-in-out infinite;
  956. }
  957. .bg-circle-2 {
  958. width: 280rpx; height: 280rpx;
  959. background: #FF6B9D;
  960. bottom: 80rpx; left: -60rpx;
  961. animation: splash-float-2 5s ease-in-out infinite;
  962. }
  963. .bg-circle-3 {
  964. width: 180rpx; height: 180rpx;
  965. background: #6366F1;
  966. top: 50%; right: -40rpx;
  967. animation: splash-float-3 6s ease-in-out infinite;
  968. }
  969. @keyframes splash-float-1 {
  970. 0%, 100% { transform: translateY(0) scale(1); }
  971. 50% { transform: translateY(-30rpx) scale(1.05); }
  972. }
  973. @keyframes splash-float-2 {
  974. 0%, 100% { transform: translateY(0) scale(1); }
  975. 50% { transform: translateY(20rpx) scale(1.08); }
  976. }
  977. @keyframes splash-float-3 {
  978. 0%, 100% { transform: translateY(0) rotate(0deg); }
  979. 50% { transform: translateY(-20rpx) rotate(10deg); }
  980. }
  981. /* ---- body fade-in ---- */
  982. .splash-overlay-body {
  983. display: flex;
  984. flex-direction: column;
  985. align-items: center;
  986. animation: splash-body-in 0.8s cubic-bezier(0.16,1,0.3,1) forwards;
  987. }
  988. @keyframes splash-body-in {
  989. from { opacity: 0; transform: translateY(40rpx) scale(0.96); }
  990. to { opacity: 1; transform: translateY(0) scale(1); }
  991. }
  992. /* ---- logo ---- */
  993. .splash-logo-wrap {
  994. width: 160rpx; height: 160rpx;
  995. border-radius: 40rpx;
  996. background: rgba(255,255,255,0.95);
  997. display: flex; align-items: center; justify-content: center;
  998. margin-bottom: 16rpx;
  999. box-shadow: 0 8rpx 32rpx rgba(249,115,22,0.25);
  1000. animation: splash-logo-pulse 2.5s ease-in-out infinite;
  1001. }
  1002. @keyframes splash-logo-pulse {
  1003. 0%, 100% { box-shadow: 0 8rpx 32rpx rgba(249,115,22,0.25); }
  1004. 50% { box-shadow: 0 8rpx 48rpx rgba(249,115,22,0.45); }
  1005. }
  1006. .splash-logo-img { width: 100rpx; height: 100rpx; }
  1007. /* ---- brand ---- */
  1008. .splash-brand-name {
  1009. font-size: 64rpx; font-weight: 800;
  1010. color: #7C2D12;
  1011. letter-spacing: 10rpx;
  1012. margin-bottom: 2rpx;
  1013. }
  1014. .splash-brand-en {
  1015. font-size: 20rpx;
  1016. color: rgba(124,45,18,0.5);
  1017. letter-spacing: 6rpx;
  1018. margin-bottom: 30rpx;
  1019. }
  1020. .splash-tagline {
  1021. font-size: 26rpx;
  1022. color: rgba(124,45,18,0.7);
  1023. letter-spacing: 4rpx;
  1024. margin-top: 24rpx;
  1025. }
  1026. /* ---- dims row from splash.vue (rounded circles) ---- */
  1027. .splash-dims-row {
  1028. display: flex; flex-direction: row;
  1029. align-items: center; justify-content: center;
  1030. gap: 28rpx;
  1031. }
  1032. .splash-dim-item {
  1033. display: flex; flex-direction: column;
  1034. align-items: center; gap: 8rpx;
  1035. }
  1036. .splash-dim-circle {
  1037. width: 80rpx; height: 80rpx;
  1038. border-radius: 50%;
  1039. display: flex; align-items: center; justify-content: center;
  1040. }
  1041. .splash-dim-icon { font-size: 36rpx; line-height: 1; }
  1042. .splash-dim-label {
  1043. font-size: 22rpx; font-weight: 500;
  1044. color: rgba(124,45,18,0.75);
  1045. line-height: 1;
  1046. }
  1047. /* ---- staggered dim entry from splash.vue ---- */
  1048. .splash-dim-item:nth-child(1) { animation: splash-dim-in 0.5s ease 0.1s both; }
  1049. .splash-dim-item:nth-child(2) { animation: splash-dim-in 0.5s ease 0.2s both; }
  1050. .splash-dim-item:nth-child(3) { animation: splash-dim-in 0.5s ease 0.3s both; }
  1051. .splash-dim-item:nth-child(4) { animation: splash-dim-in 0.5s ease 0.4s both; }
  1052. .splash-dim-item:nth-child(5) { animation: splash-dim-in 0.5s ease 0.5s both; }
  1053. @keyframes splash-dim-in {
  1054. from { opacity: 0; transform: translateY(16rpx) scale(0.8); }
  1055. to { opacity: 1; transform: translateY(0) scale(1); }
  1056. }
  1057. /* ---- loading dots ---- */
  1058. .splash-overlay-loading {
  1059. position: absolute;
  1060. bottom: 120rpx;
  1061. left: 0; right: 0;
  1062. display: flex;
  1063. justify-content: center;
  1064. align-items: center;
  1065. gap: 12rpx;
  1066. }
  1067. .splash-overlay-dot {
  1068. width: 14rpx; height: 14rpx;
  1069. border-radius: 50%;
  1070. background: rgba(249,115,22,0.6);
  1071. animation: splash-dot-bounce 1.4s ease-in-out infinite both;
  1072. }
  1073. .splash-overlay-dot:nth-child(1) { animation-delay: -0.32s; }
  1074. .splash-overlay-dot:nth-child(2) { animation-delay: -0.16s; }
  1075. .splash-overlay-dot:nth-child(3) { animation-delay: 0s; }
  1076. @keyframes splash-dot-bounce {
  1077. 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  1078. 40% { transform: scale(1); opacity: 1; }
  1079. }
  1080. </style>