index.vue 31 KB

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