index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <view class="discover-container">
  3. <!-- 品牌头部 -->
  4. <PageBanner theme="home"
  5. tagline="家庭健康成长俱乐部"
  6. quote="给全家的一站式幸福提案" />
  7. <!-- 五行沙盘预览 -->
  8. <wuxing-sandbox mode="preview" badgeText="登录查看完整报告" @point-click="handleLogin" />
  9. <!-- 活动/商品推荐 -->
  10. <view class="recommend-section">
  11. <view class="section-header">
  12. <text class="section-title">🔥 热门推荐</text>
  13. <text class="section-more" @click="goShop">查看更多 ›</text>
  14. </view>
  15. <scroll-view scroll-x enable-flex show-scrollbar="false" class="type-filter-scroll">
  16. <view
  17. v-for="item in typeList"
  18. :key="item.value"
  19. :class="['filter-chip', currentType === item.value ? 'active' : '']"
  20. @click="onTypeChange(item.value)"
  21. >
  22. {{ item.label }}
  23. </view>
  24. </scroll-view>
  25. <view v-if="loading" class="loading-state">
  26. <text class="loading-text">加载中...</text>
  27. </view>
  28. <view v-else-if="products.length === 0" class="empty-state">
  29. <text class="empty-text">暂无商品,去商城看看吧</text>
  30. </view>
  31. <view v-else class="product-grid">
  32. <view
  33. v-for="item in products"
  34. :key="item.id"
  35. class="product-card"
  36. @click="goDetail(item.id)"
  37. >
  38. <image class="product-cover" :src="item.coverImage || '/static/default-product.png'" mode="aspectFill" />
  39. <view class="product-info">
  40. <text class="product-name">{{ item.name }}</text>
  41. <view class="product-price-row">
  42. <text class="product-price">{{ formatPriceWithSymbol(item.price) }}</text>
  43. <text v-if="item.memberPrice" class="product-member">会员{{ formatPriceWithSymbol(item.memberPrice) }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- 家庭会员推荐卡片 -->
  50. <view v-if="!isMember" class="member-card" @click="goUpgrade">
  51. <view class="member-card-bg">
  52. <text class="member-card-icon">👑</text>
  53. <view class="member-card-texts">
  54. <text class="member-card-title">开通家庭会员</text>
  55. <text class="member-card-desc">享专属折扣 · 成长服务 · 规划指导</text>
  56. </view>
  57. <view class="member-card-action">
  58. <text class="member-card-btn">立即开通</text>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 知识中心 -->
  63. <view class="article-section">
  64. <view class="section-header">
  65. <text class="section-title">📖 知识中心</text>
  66. <text class="section-more" @click="goKnowledgeCenter">查看全部 ›</text>
  67. </view>
  68. <view class="article-list">
  69. <view v-for="(item, index) in featuredArticles" :key="item.id" class="article-card" @click="goArticleDetail(item.id)">
  70. <view class="article-cover" :style="{ background: coverGradients[index % coverGradients.length] }">
  71. <text class="article-cover-icon">{{ coverIcons[index % coverIcons.length] }}</text>
  72. </view>
  73. <view class="article-info">
  74. <text class="article-title">{{ item.title }}</text>
  75. <text class="article-desc">{{ item.summary || item.title }}</text>
  76. <text class="article-meta">{{ item.publishedAt ? item.publishedAt.slice(0, 10) : '' }} · {{ item.readTime || 3 }}分钟阅读</text>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <!-- 为何选择浠艾福 -->
  82. <view class="why-section">
  83. <view class="section-header">
  84. <text class="section-title">💡 为什么选择浠艾福</text>
  85. </view>
  86. <view class="feature-grid">
  87. <view class="feature-item">
  88. <text class="feature-icon">🎯</text>
  89. <text class="feature-title">科学评估</text>
  90. <text class="feature-desc">DAN少儿核心素养评估体系</text>
  91. </view>
  92. <view class="feature-item">
  93. <text class="feature-icon">🏆</text>
  94. <text class="feature-title">积分激励</text>
  95. <text class="feature-desc">完成任务得积分,兑换心愿</text>
  96. </view>
  97. <view class="feature-item">
  98. <text class="feature-icon">👨‍👩‍👧‍👦</text>
  99. <text class="feature-title">家庭参与</text>
  100. <text class="feature-desc">全家一起见证成长每一步</text>
  101. </view>
  102. <view class="feature-item">
  103. <text class="feature-icon">🌟</text>
  104. <text class="feature-title">专业规划</text>
  105. <text class="feature-desc">成长规划师一对一指导</text>
  106. </view>
  107. </view>
  108. </view>
  109. <!-- 底部登录按钮 -->
  110. <view class="login-footer">
  111. <button class="login-btn" @click="handleLogin">登录 / 注册</button>
  112. <text class="login-footer-text">登录即表示同意《用户协议》和《隐私政策》</text>
  113. </view>
  114. <!-- 底部占位 -->
  115. <view style="height: 20rpx;"></view>
  116. </view>
  117. </template>
  118. <script>
  119. import PageBanner from '../../components/PageBanner.vue'
  120. import { productList, getFeaturedArticles, getMyMembership } from '@/utils/api.js'
  121. import WuxingSandbox from '../../components/wuxing-sandbox.vue'
  122. export default {
  123. components: { PageBanner, WuxingSandbox },
  124. data() {
  125. return {
  126. typeList: [
  127. { label: '全部', value: '' },
  128. { label: '活动', value: 'activity' },
  129. { label: '课程', value: 'course' },
  130. { label: '实物', value: 'physical' },
  131. { label: '数字', value: 'digital' },
  132. { label: '服务', value: 'service' }
  133. ],
  134. currentType: '',
  135. products: [],
  136. loading: false,
  137. featuredArticles: [],
  138. coverGradients: [
  139. 'linear-gradient(135deg, #D6EAF8, #8FC5E8)',
  140. 'linear-gradient(135deg, #E8F5E9, #81C784)',
  141. 'linear-gradient(135deg, #FFF3E0, #FFB74D)',
  142. 'linear-gradient(135deg, #F3E5F5, #CE93D8)',
  143. 'linear-gradient(135deg, #FCE4EC, #F06292)'
  144. ],
  145. coverIcons: ['🌱', '🏃', '🎯', '🌟', '📚'],
  146. isMember: false
  147. }
  148. },
  149. onLoad(options) {
  150. if (options && options.type) {
  151. this.currentType = options.type
  152. }
  153. },
  154. onShow() {
  155. this.checkMemberStatus()
  156. this.loadProducts()
  157. this.loadFeaturedArticles()
  158. },
  159. methods: {
  160. checkMemberStatus() {
  161. var that = this
  162. getMyMembership().then(function(res) {
  163. if (res.data && res.data.memberLevel) {
  164. that.isMember = res.data.memberLevel !== 'FREE'
  165. }
  166. }).catch(function() {})
  167. },
  168. goUpgrade() {
  169. uni.navigateTo({ url: '/pages/membership/upgrade' })
  170. },
  171. loadProducts() {
  172. this.loading = true
  173. const params = { page: 1, size: 10 }
  174. if (this.currentType) {
  175. params.productType = this.currentType
  176. }
  177. productList(params).then(res => {
  178. this.loading = false
  179. if (res.code === 200 && res.data) {
  180. this.products = res.data.records || []
  181. }
  182. }).catch(() => {
  183. this.loading = false
  184. })
  185. },
  186. onTypeChange(value) {
  187. this.currentType = value
  188. this.loadProducts()
  189. },
  190. goShop() {
  191. uni.navigateTo({ url: '/pages/points/mall' })
  192. },
  193. goDetail(id) {
  194. uni.navigateTo({ url: '/pages/shop/detail/detail?id=' + id })
  195. },
  196. handleLogin() {
  197. uni.navigateTo({ url: '/pages/login/login?redirect=' + encodeURIComponent('/pages/discover/index') })
  198. },
  199. async loadFeaturedArticles() {
  200. try {
  201. const res = await getFeaturedArticles({ size: 3 })
  202. if (res.code === 200 && res.data) {
  203. let list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  204. this.featuredArticles = list
  205. }
  206. } catch (e) {
  207. // 静默处理
  208. }
  209. },
  210. goArticleDetail(id) {
  211. uni.navigateTo({ url: '/pages/mind/article-detail?id=' + id })
  212. },
  213. goKnowledgeCenter() {
  214. uni.navigateTo({ url: '/pages/mind-extra/articles' })
  215. }
  216. }
  217. }
  218. </script>
  219. <style scoped>
  220. .discover-container {
  221. min-height: 100vh;
  222. background: #f5f7fa;
  223. padding-bottom: 100rpx;
  224. }
  225. /* ===== 推荐 ===== */
  226. .recommend-section {
  227. margin: 20rpx 30rpx;
  228. }
  229. .section-header {
  230. display: flex;
  231. justify-content: space-between;
  232. align-items: center;
  233. margin-bottom: 20rpx;
  234. }
  235. .section-title {
  236. font-size: 30rpx;
  237. font-weight: bold;
  238. color: #333;
  239. }
  240. .section-more {
  241. font-size: 24rpx;
  242. color: #5B9BD5;
  243. }
  244. .type-filter-scroll {
  245. white-space: nowrap;
  246. margin-bottom: 20rpx;
  247. }
  248. .filter-chip {
  249. display: inline-block;
  250. padding: 8rpx 24rpx;
  251. font-size: 24rpx;
  252. color: #666;
  253. background: #f0f0f0;
  254. border-radius: 30rpx;
  255. margin-right: 16rpx;
  256. }
  257. .filter-chip.active {
  258. background: #5B9BD5;
  259. color: #fff;
  260. }
  261. .loading-state,
  262. .empty-state {
  263. display: flex;
  264. justify-content: center;
  265. padding: 60rpx 0;
  266. }
  267. .loading-text,
  268. .empty-text {
  269. font-size: 26rpx;
  270. color: #999;
  271. }
  272. .product-grid {
  273. display: flex;
  274. flex-wrap: wrap;
  275. justify-content: space-between;
  276. }
  277. .product-card {
  278. width: 48%;
  279. background: #fff;
  280. border-radius: 16rpx;
  281. overflow: hidden;
  282. margin-bottom: 20rpx;
  283. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  284. }
  285. .product-cover {
  286. width: 100%;
  287. height: 200rpx;
  288. background: #f0f0f0;
  289. }
  290. .product-info {
  291. padding: 14rpx;
  292. }
  293. .product-name {
  294. display: block;
  295. font-size: 26rpx;
  296. color: #333;
  297. margin-bottom: 10rpx;
  298. overflow: hidden;
  299. text-overflow: ellipsis;
  300. white-space: nowrap;
  301. }
  302. .product-price-row {
  303. display: flex;
  304. align-items: baseline;
  305. }
  306. .product-price {
  307. font-size: 28rpx;
  308. color: #5B9BD5;
  309. font-weight: bold;
  310. margin-right: 10rpx;
  311. }
  312. .product-member {
  313. font-size: 20rpx;
  314. color: #999;
  315. }
  316. .recommend-scroll {
  317. display: flex;
  318. white-space: nowrap;
  319. overflow-x: auto;
  320. padding-bottom: 10rpx;
  321. }
  322. .recommend-card {
  323. display: inline-flex;
  324. flex-direction: column;
  325. width: 260rpx;
  326. background: #fff;
  327. border-radius: 20rpx;
  328. overflow: hidden;
  329. margin-right: 20rpx;
  330. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  331. }
  332. .card-banner {
  333. padding: 14rpx 20rpx;
  334. background: #5B9BD5;
  335. color: #fff;
  336. font-size: 22rpx;
  337. font-weight: bold;
  338. text-align: center;
  339. }
  340. .card-body {
  341. padding: 16rpx;
  342. white-space: normal;
  343. }
  344. .card-title {
  345. font-size: 24rpx;
  346. font-weight: bold;
  347. color: #333;
  348. display: block;
  349. margin-bottom: 6rpx;
  350. }
  351. .card-desc {
  352. font-size: 20rpx;
  353. color: #999;
  354. display: block;
  355. margin-bottom: 10rpx;
  356. }
  357. .card-meta {
  358. display: flex;
  359. align-items: center;
  360. justify-content: space-between;
  361. }
  362. .card-price {
  363. font-size: 26rpx;
  364. color: #5B9BD5;
  365. font-weight: bold;
  366. }
  367. .card-tag {
  368. font-size: 18rpx;
  369. color: #5B9BD5;
  370. background: rgba(91,155,213,0.1);
  371. padding: 2rpx 10rpx;
  372. border-radius: 10rpx;
  373. }
  374. /* ===== 家庭会员推荐卡片 ===== */
  375. .member-card {
  376. margin: 20rpx 30rpx 0;
  377. }
  378. .member-card-bg {
  379. display: flex;
  380. align-items: center;
  381. background: linear-gradient(135deg, #F97316, #FB923C);
  382. border-radius: 20rpx;
  383. padding: 24rpx 30rpx;
  384. }
  385. .member-card-icon {
  386. font-size: 48rpx;
  387. margin-right: 16rpx;
  388. }
  389. .member-card-texts {
  390. flex: 1;
  391. display: flex;
  392. flex-direction: column;
  393. }
  394. .member-card-title {
  395. font-size: 30rpx;
  396. font-weight: bold;
  397. color: #fff;
  398. }
  399. .member-card-desc {
  400. font-size: 22rpx;
  401. color: rgba(255,255,255,0.85);
  402. margin-top: 4rpx;
  403. }
  404. .member-card-action {
  405. margin-left: 16rpx;
  406. }
  407. .member-card-btn {
  408. display: inline-block;
  409. padding: 8rpx 24rpx;
  410. background: #fff;
  411. color: #F97316;
  412. font-size: 24rpx;
  413. font-weight: bold;
  414. border-radius: 30rpx;
  415. }
  416. /* ===== 推荐文章 ===== */
  417. .article-section {
  418. margin: 20rpx 30rpx 0;
  419. }
  420. .article-list {
  421. display: flex;
  422. flex-direction: column;
  423. gap: 16rpx;
  424. }
  425. .article-card {
  426. display: flex;
  427. background: #fff;
  428. border-radius: 16rpx;
  429. overflow: hidden;
  430. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  431. cursor: pointer;
  432. }
  433. .article-cover {
  434. width: 180rpx;
  435. flex-shrink: 0;
  436. display: flex;
  437. align-items: center;
  438. justify-content: center;
  439. }
  440. .article-cover-icon {
  441. font-size: 48rpx;
  442. }
  443. .article-info {
  444. flex: 1;
  445. padding: 16rpx;
  446. display: flex;
  447. flex-direction: column;
  448. justify-content: center;
  449. }
  450. .article-title {
  451. font-size: 26rpx;
  452. font-weight: bold;
  453. color: #333;
  454. line-height: 1.4;
  455. overflow: hidden;
  456. text-overflow: ellipsis;
  457. white-space: nowrap;
  458. }
  459. .article-desc {
  460. font-size: 22rpx;
  461. color: #999;
  462. line-height: 1.3;
  463. margin-top: 6rpx;
  464. overflow: hidden;
  465. text-overflow: ellipsis;
  466. white-space: nowrap;
  467. }
  468. .article-meta {
  469. font-size: 20rpx;
  470. color: #ccc;
  471. margin-top: 6rpx;
  472. }
  473. /* ===== 为何选择 ===== */
  474. .why-section {
  475. margin: 30rpx;
  476. }
  477. .feature-grid {
  478. display: flex;
  479. flex-direction: row;
  480. flex-wrap: wrap;
  481. justify-content: space-between;
  482. }
  483. .feature-item {
  484. width: calc(50% - 10rpx);
  485. box-sizing: border-box;
  486. background: #fff;
  487. border-radius: 20rpx;
  488. padding: 24rpx;
  489. margin-bottom: 20rpx;
  490. display: flex;
  491. flex-direction: column;
  492. align-items: center;
  493. text-align: center;
  494. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  495. }
  496. .feature-icon {
  497. font-size: 48rpx;
  498. margin-bottom: 10rpx;
  499. }
  500. .feature-title {
  501. font-size: 24rpx;
  502. font-weight: bold;
  503. color: #333;
  504. margin-bottom: 6rpx;
  505. }
  506. .feature-desc {
  507. font-size: 20rpx;
  508. color: #999;
  509. }
  510. /* ===== 底部登录 ===== */
  511. .login-footer {
  512. margin: 40rpx 30rpx;
  513. display: flex;
  514. flex-direction: column;
  515. align-items: center;
  516. }
  517. .login-btn {
  518. width: 100%;
  519. height: 88rpx;
  520. line-height: 88rpx;
  521. background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
  522. color: #fff;
  523. font-size: 32rpx;
  524. font-weight: bold;
  525. border-radius: 44rpx;
  526. text-align: center;
  527. border: none;
  528. }
  529. .login-btn::after {
  530. border: none;
  531. }
  532. .login-footer-text {
  533. font-size: 20rpx;
  534. color: #bbb;
  535. margin-top: 16rpx;
  536. }
  537. </style>