index.vue 13 KB

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