index.vue 33 KB

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