index.vue 12 KB

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