index.vue 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  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. <!-- 发现页/引流内容,登录后也保留 TabBar -->
  49. <view 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" v-if="!isLoggedIn()" @click="handleLogin">登录 / 注册</button>
  199. <button class="login-btn home-btn" v-else @click="goHomeDashboard">进入家庭首页</button>
  200. <text class="login-footer-text" v-if="!isLoggedIn()">登录即表示同意《用户协议》和《隐私政策》</text>
  201. </view>
  202. <!-- 底部占位 -->
  203. <view style="height: 120rpx;"></view>
  204. </view>
  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. // 登录用户:留在 TabBar 页,显示推荐内容
  369. // 不再 redirectTo 到 home 分包(分包页无 TabBar)
  370. this.loadProducts()
  371. this.loadDimensionActivities()
  372. this.loadFeaturedArticles()
  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. goHomeDashboard() {
  491. var targetUrl = this.currentRole === 'child'
  492. ? '/pages/home-pages/child-index'
  493. : '/pages/home-pages/parent-index'
  494. uni.navigateTo({ url: targetUrl })
  495. },
  496. async handleParentInvite(code) {
  497. // 延迟显示,等待登录完成
  498. setTimeout(async () => {
  499. const hasToken = uni.getStorageSync('token')
  500. if (!hasToken) {
  501. // 未登录,先去登录
  502. uni.reLaunch({
  503. url: '/pages/login/login?inviteCode=' + code
  504. })
  505. return
  506. }
  507. // 已登录,显示确认框
  508. uni.showModal({
  509. title: '加入家庭',
  510. content: '您已被邀请加入家庭,是否接受?',
  511. success: async (res) => {
  512. if (res.confirm) {
  513. try {
  514. uni.showLoading({ title: '加入中...' })
  515. const result = await acceptParentInvite(code)
  516. uni.hideLoading()
  517. if (result.code === 200) {
  518. const { familyId, role, token } = result.data
  519. uni.setStorageSync('familyId', familyId)
  520. uni.setStorageSync('role', role)
  521. uni.setStorageSync('token', token)
  522. uni.showToast({ title: '加入成功', icon: 'success' })
  523. // 刷新页面
  524. setTimeout(() => {
  525. uni.switchTab({ url: '/pages/index-home/index' })
  526. }, 1500)
  527. }
  528. } catch (e) {
  529. uni.hideLoading()
  530. uni.showToast({ title: e.message || '加入失败', icon: 'none' })
  531. }
  532. }
  533. }
  534. })
  535. }, 500)
  536. },
  537. },
  538. computed: {
  539. dimList: function() {
  540. return DIMENSIONS
  541. },
  542. energyDotColors: function() {
  543. return ['#8D6E63', '#FF6B35', '#FFD700', '#4CAF50', '#42A5F5']
  544. }
  545. }
  546. }
  547. </script>
  548. <style>
  549. .discover-container {
  550. min-height: 100vh;
  551. background: #f5f7fa;
  552. padding-bottom: 100rpx;
  553. }
  554. /* ===== 推荐 ===== */
  555. .recommend-section {
  556. margin: 20rpx 30rpx;
  557. }
  558. .section-header {
  559. display: flex;
  560. justify-content: space-between;
  561. align-items: center;
  562. margin-bottom: 20rpx;
  563. }
  564. .section-title {
  565. font-size: 30rpx;
  566. font-weight: bold;
  567. color: #333;
  568. }
  569. .section-more {
  570. font-size: 24rpx;
  571. color: #5B9BD5;
  572. }
  573. .type-filter-scroll {
  574. white-space: nowrap;
  575. margin-bottom: 20rpx;
  576. }
  577. .filter-chip {
  578. display: inline-block;
  579. padding: 8rpx 24rpx;
  580. font-size: 24rpx;
  581. color: #666;
  582. background: #f0f0f0;
  583. border-radius: 30rpx;
  584. margin-right: 16rpx;
  585. }
  586. .filter-chip.active {
  587. background: #5B9BD5;
  588. color: #fff;
  589. }
  590. .loading-state,
  591. .empty-state {
  592. display: flex;
  593. justify-content: center;
  594. padding: 60rpx 0;
  595. }
  596. .loading-text,
  597. .empty-text {
  598. font-size: 26rpx;
  599. color: #999;
  600. }
  601. .product-grid {
  602. display: flex;
  603. flex-wrap: wrap;
  604. justify-content: space-between;
  605. }
  606. .product-card {
  607. width: 48%;
  608. background: #fff;
  609. border-radius: 16rpx;
  610. overflow: hidden;
  611. margin-bottom: 20rpx;
  612. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  613. }
  614. .product-cover {
  615. width: 100%;
  616. height: 200rpx;
  617. background: #f0f0f0;
  618. }
  619. .product-info {
  620. padding: 14rpx;
  621. }
  622. .product-name {
  623. display: block;
  624. font-size: 26rpx;
  625. color: #333;
  626. margin-bottom: 10rpx;
  627. overflow: hidden;
  628. text-overflow: ellipsis;
  629. white-space: nowrap;
  630. }
  631. .product-price-row {
  632. display: flex;
  633. align-items: baseline;
  634. }
  635. .product-price {
  636. font-size: 28rpx;
  637. color: #5B9BD5;
  638. font-weight: bold;
  639. margin-right: 10rpx;
  640. }
  641. .product-price-login {
  642. font-size: 24rpx;
  643. color: #999;
  644. }
  645. .product-member {
  646. font-size: 20rpx;
  647. color: #999;
  648. }
  649. /* ===== 五维全景幸福矩阵 ===== */
  650. .why-section {
  651. margin: 30rpx;
  652. }
  653. .dim-matrix {
  654. display: flex;
  655. flex-wrap: wrap;
  656. gap: 20rpx;
  657. justify-content: center;
  658. }
  659. .dim-card {
  660. width: calc(33.33% - 14rpx);
  661. box-sizing: border-box;
  662. background: #fff;
  663. border-radius: 20rpx;
  664. padding: 28rpx 16rpx 24rpx;
  665. display: flex;
  666. flex-direction: column;
  667. align-items: center;
  668. text-align: center;
  669. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  670. transition: transform 0.2s ease, box-shadow 0.2s ease;
  671. position: relative;
  672. overflow: hidden;
  673. }
  674. .dim-card:active {
  675. transform: scale(0.96);
  676. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
  677. }
  678. .dim-icon-circle {
  679. width: 72rpx;
  680. height: 72rpx;
  681. border-radius: 50%;
  682. display: flex;
  683. align-items: center;
  684. justify-content: center;
  685. margin-bottom: 14rpx;
  686. flex-shrink: 0;
  687. }
  688. .dim-icon {
  689. font-size: 36rpx;
  690. line-height: 1;
  691. }
  692. .dim-tag {
  693. font-size: 22rpx;
  694. font-weight: 600;
  695. padding: 4rpx 14rpx;
  696. border-radius: 20rpx;
  697. margin-bottom: 10rpx;
  698. max-width: 100%;
  699. overflow: hidden;
  700. text-overflow: ellipsis;
  701. white-space: nowrap;
  702. }
  703. .dim-desc {
  704. font-size: 20rpx;
  705. color: #888;
  706. line-height: 1.5;
  707. display: -webkit-box;
  708. -webkit-line-clamp: 2;
  709. -webkit-box-orient: vertical;
  710. overflow: hidden;
  711. }
  712. /* 五维能量环 */
  713. .dim-energy-row {
  714. display: flex;
  715. justify-content: center;
  716. gap: 12rpx;
  717. margin-top: 24rpx;
  718. opacity: 0.5;
  719. }
  720. .energy-dot {
  721. width: 10rpx;
  722. height: 10rpx;
  723. border-radius: 50%;
  724. }
  725. /* ===== 底部登录 ===== */
  726. .login-footer {
  727. margin: 40rpx 30rpx;
  728. display: flex;
  729. flex-direction: column;
  730. align-items: center;
  731. }
  732. .login-btn {
  733. width: 100%;
  734. height: 88rpx;
  735. line-height: 88rpx;
  736. background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
  737. color: #fff;
  738. font-size: 32rpx;
  739. font-weight: bold;
  740. border-radius: 44rpx;
  741. text-align: center;
  742. border: none;
  743. }
  744. .login-btn::after {
  745. border: none;
  746. }
  747. .login-footer-text {
  748. font-size: 20rpx;
  749. color: #bbb;
  750. margin-top: 16rpx;
  751. }
  752. /* ===== 加载占位 ===== */
  753. .loading-container {
  754. display: flex;
  755. justify-content: center;
  756. align-items: center;
  757. height: 100vh;
  758. }
  759. /* ===== 角色切换淡入淡出 ===== */
  760. .role-switch-wrapper {
  761. width: 100%;
  762. min-height: 100vh;
  763. }
  764. .fade-enter-active,
  765. .fade-leave-active {
  766. transition: opacity 0.3s ease;
  767. }
  768. .fade-enter,
  769. .fade-leave-to {
  770. opacity: 0;
  771. }
  772. /* ===== 通用区块样式 ===== */
  773. .section {
  774. margin: 20rpx 30rpx;
  775. }
  776. .section-header {
  777. display: flex;
  778. justify-content: space-between;
  779. align-items: center;
  780. margin-bottom: 20rpx;
  781. }
  782. .section-title {
  783. font-size: 30rpx;
  784. font-weight: bold;
  785. color: #333;
  786. }
  787. .section-more {
  788. font-size: 24rpx;
  789. color: #5B9BD5;
  790. }
  791. .empty-state {
  792. display: flex;
  793. justify-content: center;
  794. padding: 60rpx 0;
  795. }
  796. .empty-text {
  797. font-size: 26rpx;
  798. color: #999;
  799. }
  800. /* ===== 活动列表 ===== */
  801. .activity-list {
  802. display: flex;
  803. flex-direction: column;
  804. gap: 16rpx;
  805. }
  806. .activity-card {
  807. background: #fff;
  808. border-radius: 16rpx;
  809. overflow: hidden;
  810. display: flex;
  811. flex-direction: row;
  812. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  813. }
  814. .activity-card:active {
  815. opacity: 0.8;
  816. }
  817. .activity-cover {
  818. width: 200rpx;
  819. height: 160rpx;
  820. flex-shrink: 0;
  821. background: #f0f0f0;
  822. }
  823. .activity-info {
  824. flex: 1;
  825. padding: 16rpx;
  826. display: flex;
  827. flex-direction: column;
  828. justify-content: space-between;
  829. }
  830. .activity-name {
  831. font-size: 28rpx;
  832. font-weight: bold;
  833. color: #333;
  834. margin-bottom: 8rpx;
  835. }
  836. .line-clamp-1 {
  837. overflow: hidden;
  838. text-overflow: ellipsis;
  839. white-space: nowrap;
  840. }
  841. .activity-meta {
  842. display: flex;
  843. align-items: center;
  844. margin-bottom: 8rpx;
  845. }
  846. .activity-time {
  847. font-size: 22rpx;
  848. color: #999;
  849. }
  850. .activity-bottom {
  851. display: flex;
  852. align-items: center;
  853. gap: 12rpx;
  854. }
  855. .activity-status {
  856. font-size: 20rpx;
  857. padding: 2rpx 10rpx;
  858. border-radius: 8rpx;
  859. background: #E8F5E9;
  860. color: #2E7D32;
  861. }
  862. .activity-status.status-upcoming {
  863. background: #E3F2FD;
  864. color: #1565C0;
  865. }
  866. .activity-status.status-ended {
  867. background: #F5F5F5;
  868. color: #999;
  869. }
  870. .activity-fee {
  871. font-size: 24rpx;
  872. color: #F97316;
  873. font-weight: bold;
  874. }
  875. .activity-fee.fee-free {
  876. color: #4CAF50;
  877. }
  878. /* ===== 文章列表 ===== */
  879. .article-list {
  880. display: flex;
  881. flex-direction: column;
  882. gap: 16rpx;
  883. }
  884. .article-card {
  885. background: #fff;
  886. border-radius: 16rpx;
  887. padding: 24rpx;
  888. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  889. }
  890. .article-card:active {
  891. opacity: 0.8;
  892. }
  893. .article-category {
  894. display: inline-block;
  895. padding: 4rpx 14rpx;
  896. border-radius: 8rpx;
  897. margin-bottom: 10rpx;
  898. }
  899. .article-category-text {
  900. font-size: 20rpx;
  901. color: #fff;
  902. }
  903. .article-title {
  904. display: block;
  905. font-size: 28rpx;
  906. font-weight: bold;
  907. color: #333;
  908. margin-bottom: 8rpx;
  909. line-height: 1.4;
  910. }
  911. .article-summary {
  912. display: block;
  913. font-size: 24rpx;
  914. color: #888;
  915. line-height: 1.5;
  916. margin-bottom: 12rpx;
  917. overflow: hidden;
  918. text-overflow: ellipsis;
  919. display: -webkit-box;
  920. -webkit-line-clamp: 2;
  921. -webkit-box-orient: vertical;
  922. }
  923. .article-meta {
  924. display: flex;
  925. align-items: center;
  926. gap: 16rpx;
  927. }
  928. .meta-item {
  929. display: flex;
  930. align-items: center;
  931. gap: 4rpx;
  932. }
  933. .meta-icon {
  934. font-size: 24rpx;
  935. }
  936. .meta-text {
  937. font-size: 22rpx;
  938. color: #999;
  939. }
  940. .article-date {
  941. font-size: 22rpx;
  942. color: #bbb;
  943. }
  944. /* ===== Splash Loading Overlay(冷启动蒙板,来自 merge splash.vue) ===== */
  945. .splash-overlay {
  946. position: fixed;
  947. top: 0; left: 0; right: 0; bottom: 0;
  948. z-index: 9999;
  949. display: flex;
  950. align-items: center;
  951. justify-content: center;
  952. background: linear-gradient(160deg, #FFF7ED 0%, #FFEDD5 50%, #FED7AA 100%);
  953. overflow: hidden;
  954. opacity: 1;
  955. transition: opacity 0.4s ease;
  956. }
  957. .splash-overlay.fade-out {
  958. opacity: 0;
  959. pointer-events: none;
  960. }
  961. /* ---- bg circles from splash.vue ---- */
  962. .splash-overlay-bg { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }
  963. .bg-circle {
  964. position: absolute;
  965. border-radius: 50%;
  966. opacity: 0.12;
  967. }
  968. .bg-circle-1 {
  969. width: 400rpx; height: 400rpx;
  970. background: #FF8C42;
  971. top: -100rpx; right: -80rpx;
  972. animation: splash-float-1 4s ease-in-out infinite;
  973. }
  974. .bg-circle-2 {
  975. width: 280rpx; height: 280rpx;
  976. background: #FF6B9D;
  977. bottom: 80rpx; left: -60rpx;
  978. animation: splash-float-2 5s ease-in-out infinite;
  979. }
  980. .bg-circle-3 {
  981. width: 180rpx; height: 180rpx;
  982. background: #6366F1;
  983. top: 50%; right: -40rpx;
  984. animation: splash-float-3 6s ease-in-out infinite;
  985. }
  986. @keyframes splash-float-1 {
  987. 0%, 100% { transform: translateY(0) scale(1); }
  988. 50% { transform: translateY(-30rpx) scale(1.05); }
  989. }
  990. @keyframes splash-float-2 {
  991. 0%, 100% { transform: translateY(0) scale(1); }
  992. 50% { transform: translateY(20rpx) scale(1.08); }
  993. }
  994. @keyframes splash-float-3 {
  995. 0%, 100% { transform: translateY(0) rotate(0deg); }
  996. 50% { transform: translateY(-20rpx) rotate(10deg); }
  997. }
  998. /* ---- body fade-in ---- */
  999. .splash-overlay-body {
  1000. display: flex;
  1001. flex-direction: column;
  1002. align-items: center;
  1003. animation: splash-body-in 0.8s cubic-bezier(0.16,1,0.3,1) forwards;
  1004. }
  1005. @keyframes splash-body-in {
  1006. from { opacity: 0; transform: translateY(40rpx) scale(0.96); }
  1007. to { opacity: 1; transform: translateY(0) scale(1); }
  1008. }
  1009. /* ---- logo ---- */
  1010. .splash-logo-wrap {
  1011. width: 160rpx; height: 160rpx;
  1012. border-radius: 40rpx;
  1013. background: rgba(255,255,255,0.95);
  1014. display: flex; align-items: center; justify-content: center;
  1015. margin-bottom: 16rpx;
  1016. box-shadow: 0 8rpx 32rpx rgba(249,115,22,0.25);
  1017. animation: splash-logo-pulse 2.5s ease-in-out infinite;
  1018. }
  1019. @keyframes splash-logo-pulse {
  1020. 0%, 100% { box-shadow: 0 8rpx 32rpx rgba(249,115,22,0.25); }
  1021. 50% { box-shadow: 0 8rpx 48rpx rgba(249,115,22,0.45); }
  1022. }
  1023. .splash-logo-img { width: 100rpx; height: 100rpx; }
  1024. /* ---- brand ---- */
  1025. .splash-brand-name {
  1026. font-size: 64rpx; font-weight: 800;
  1027. color: #7C2D12;
  1028. letter-spacing: 10rpx;
  1029. margin-bottom: 2rpx;
  1030. }
  1031. .splash-brand-en {
  1032. font-size: 20rpx;
  1033. color: rgba(124,45,18,0.5);
  1034. letter-spacing: 6rpx;
  1035. margin-bottom: 30rpx;
  1036. }
  1037. .splash-tagline {
  1038. font-size: 26rpx;
  1039. color: rgba(124,45,18,0.7);
  1040. letter-spacing: 4rpx;
  1041. margin-top: 24rpx;
  1042. }
  1043. /* ---- dims row from splash.vue (rounded circles) ---- */
  1044. .splash-dims-row {
  1045. display: flex; flex-direction: row;
  1046. align-items: center; justify-content: center;
  1047. gap: 28rpx;
  1048. }
  1049. .splash-dim-item {
  1050. display: flex; flex-direction: column;
  1051. align-items: center; gap: 8rpx;
  1052. }
  1053. .splash-dim-circle {
  1054. width: 80rpx; height: 80rpx;
  1055. border-radius: 50%;
  1056. display: flex; align-items: center; justify-content: center;
  1057. }
  1058. .splash-dim-icon { font-size: 36rpx; line-height: 1; }
  1059. .splash-dim-label {
  1060. font-size: 22rpx; font-weight: 500;
  1061. color: rgba(124,45,18,0.75);
  1062. line-height: 1;
  1063. }
  1064. /* ---- staggered dim entry from splash.vue ---- */
  1065. .splash-dim-item:nth-child(1) { animation: splash-dim-in 0.5s ease 0.1s both; }
  1066. .splash-dim-item:nth-child(2) { animation: splash-dim-in 0.5s ease 0.2s both; }
  1067. .splash-dim-item:nth-child(3) { animation: splash-dim-in 0.5s ease 0.3s both; }
  1068. .splash-dim-item:nth-child(4) { animation: splash-dim-in 0.5s ease 0.4s both; }
  1069. .splash-dim-item:nth-child(5) { animation: splash-dim-in 0.5s ease 0.5s both; }
  1070. @keyframes splash-dim-in {
  1071. from { opacity: 0; transform: translateY(16rpx) scale(0.8); }
  1072. to { opacity: 1; transform: translateY(0) scale(1); }
  1073. }
  1074. /* ---- loading dots ---- */
  1075. .splash-overlay-loading {
  1076. position: absolute;
  1077. bottom: 120rpx;
  1078. left: 0; right: 0;
  1079. display: flex;
  1080. justify-content: center;
  1081. align-items: center;
  1082. gap: 12rpx;
  1083. }
  1084. .splash-overlay-dot {
  1085. width: 14rpx; height: 14rpx;
  1086. border-radius: 50%;
  1087. background: rgba(249,115,22,0.6);
  1088. animation: splash-dot-bounce 1.4s ease-in-out infinite both;
  1089. }
  1090. .splash-overlay-dot:nth-child(1) { animation-delay: -0.32s; }
  1091. .splash-overlay-dot:nth-child(2) { animation-delay: -0.16s; }
  1092. .splash-overlay-dot:nth-child(3) { animation-delay: 0s; }
  1093. @keyframes splash-dot-bounce {
  1094. 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  1095. 40% { transform: scale(1); opacity: 1; }
  1096. }
  1097. </style>