index.vue 31 KB

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