index.vue 34 KB

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