| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552 |
- <template>
- <view class="discover-container">
- <!-- 品牌头部 -->
- <PageBanner theme="home"
- tagline="家庭健康成长俱乐部"
- quote="给全家的一站式幸福提案" />
- <!-- 五行沙盘预览 -->
- <wuxing-sandbox mode="preview" badgeText="登录查看完整报告" @point-click="handleLogin" />
- <!-- 活动/商品推荐 -->
- <view class="recommend-section">
- <view class="section-header">
- <text class="section-title">🔥 热门推荐</text>
- <text class="section-more" @click="goShop">查看更多 ›</text>
- </view>
- <scroll-view scroll-x enable-flex show-scrollbar="false" class="type-filter-scroll">
- <view
- v-for="item in typeList"
- :key="item.value"
- :class="['filter-chip', currentType === item.value ? 'active' : '']"
- @click="onTypeChange(item.value)"
- >
- {{ item.label }}
- </view>
- </scroll-view>
- <view v-if="loading" class="loading-state">
- <text class="loading-text">加载中...</text>
- </view>
- <view v-else-if="products.length === 0" class="empty-state">
- <text class="empty-text">暂无商品,去商城看看吧</text>
- </view>
- <view v-else class="product-grid">
- <view
- v-for="item in products"
- :key="item.id"
- class="product-card"
- @click="goDetail(item.id)"
- >
- <image class="product-cover" :src="item.coverImage || '/static/default-product.png'" mode="aspectFill" />
- <view class="product-info">
- <text class="product-name">{{ item.name }}</text>
- <view class="product-price-row">
- <text class="product-price">{{ formatPriceWithSymbol(item.price) }}</text>
- <text v-if="item.memberPrice" class="product-member">会员{{ formatPriceWithSymbol(item.memberPrice) }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 家庭会员推荐卡片 -->
- <view v-if="!isMember" class="member-card" @click="goUpgrade">
- <view class="member-card-bg">
- <text class="member-card-icon">👑</text>
- <view class="member-card-texts">
- <text class="member-card-title">开通家庭会员</text>
- <text class="member-card-desc">享专属折扣 · 成长服务 · 规划指导</text>
- </view>
- <view class="member-card-action">
- <text class="member-card-btn">立即开通</text>
- </view>
- </view>
- </view>
- <!-- 知识中心 -->
- <view class="article-section">
- <view class="section-header">
- <text class="section-title">📖 知识中心</text>
- <text class="section-more" @click="goKnowledgeCenter">查看全部 ›</text>
- </view>
- <view class="article-list">
- <view v-for="(item, index) in featuredArticles" :key="item.id" class="article-card" @click="goArticleDetail(item.id)">
- <view class="article-cover" :style="{ background: coverGradients[index % coverGradients.length] }">
- <text class="article-cover-icon">{{ coverIcons[index % coverIcons.length] }}</text>
- </view>
- <view class="article-info">
- <text class="article-title">{{ item.title }}</text>
- <text class="article-desc">{{ item.summary || item.title }}</text>
- <text class="article-meta">{{ item.publishedAt ? item.publishedAt.slice(0, 10) : '' }} · {{ item.readTime || 3 }}分钟阅读</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 为何选择浠艾福 -->
- <view class="why-section">
- <view class="section-header">
- <text class="section-title">💡 为什么选择浠艾福</text>
- </view>
- <view class="feature-grid">
- <view class="feature-item">
- <text class="feature-icon">🎯</text>
- <text class="feature-title">科学评估</text>
- <text class="feature-desc">DAN少儿核心素养评估体系</text>
- </view>
- <view class="feature-item">
- <text class="feature-icon">🏆</text>
- <text class="feature-title">积分激励</text>
- <text class="feature-desc">完成任务得积分,兑换心愿</text>
- </view>
- <view class="feature-item">
- <text class="feature-icon">👨👩👧👦</text>
- <text class="feature-title">家庭参与</text>
- <text class="feature-desc">全家一起见证成长每一步</text>
- </view>
- <view class="feature-item">
- <text class="feature-icon">🌟</text>
- <text class="feature-title">专业规划</text>
- <text class="feature-desc">成长规划师一对一指导</text>
- </view>
- </view>
- </view>
- <!-- 底部登录按钮 -->
- <view class="login-footer">
- <button class="login-btn" @click="handleLogin">登录 / 注册</button>
- <text class="login-footer-text">登录即表示同意《用户协议》和《隐私政策》</text>
- </view>
- <!-- 底部占位 -->
- <view style="height: 20rpx;"></view>
- </view>
- </template>
- <script>
- import PageBanner from '../../components/PageBanner.vue'
- import { productList, getFeaturedArticles, getMyMembership } from '@/utils/api.js'
- import WuxingSandbox from '../../components/wuxing-sandbox.vue'
- export default {
- components: { PageBanner, WuxingSandbox },
- data() {
- return {
- typeList: [
- { label: '全部', value: '' },
- { label: '活动', value: 'activity' },
- { label: '课程', value: 'course' },
- { label: '实物', value: 'physical' },
- { label: '数字', value: 'digital' },
- { label: '服务', value: 'service' }
- ],
- currentType: '',
- products: [],
- loading: false,
- featuredArticles: [],
- coverGradients: [
- 'linear-gradient(135deg, #D6EAF8, #8FC5E8)',
- 'linear-gradient(135deg, #E8F5E9, #81C784)',
- 'linear-gradient(135deg, #FFF3E0, #FFB74D)',
- 'linear-gradient(135deg, #F3E5F5, #CE93D8)',
- 'linear-gradient(135deg, #FCE4EC, #F06292)'
- ],
- coverIcons: ['🌱', '🏃', '🎯', '🌟', '📚'],
- isMember: false
- }
- },
- onLoad(options) {
- if (options && options.type) {
- this.currentType = options.type
- }
- },
- onShow() {
- this.checkMemberStatus()
- this.loadProducts()
- this.loadFeaturedArticles()
- },
- methods: {
- checkMemberStatus() {
- var that = this
- getMyMembership().then(function(res) {
- if (res.data && res.data.memberLevel) {
- that.isMember = res.data.memberLevel !== 'FREE'
- }
- }).catch(function() {})
- },
- goUpgrade() {
- uni.navigateTo({ url: '/pages/membership/upgrade' })
- },
- loadProducts() {
- this.loading = true
- const params = { page: 1, size: 10 }
- if (this.currentType) {
- params.productType = this.currentType
- }
- productList(params).then(res => {
- this.loading = false
- if (res.code === 200 && res.data) {
- this.products = res.data.records || []
- }
- }).catch(() => {
- this.loading = false
- })
- },
- onTypeChange(value) {
- this.currentType = value
- this.loadProducts()
- },
- goShop() {
- uni.navigateTo({ url: '/pages/points/mall' })
- },
- goDetail(id) {
- uni.navigateTo({ url: '/pages/shop/detail/detail?id=' + id })
- },
- handleLogin() {
- uni.navigateTo({ url: '/pages/login/login?redirect=' + encodeURIComponent('/pages/discover/index') })
- },
- async loadFeaturedArticles() {
- try {
- const res = await getFeaturedArticles({ size: 3 })
- if (res.code === 200 && res.data) {
- let list = Array.isArray(res.data) ? res.data : (res.data.records || [])
- this.featuredArticles = list
- }
- } catch (e) {
- // 静默处理
- }
- },
- goArticleDetail(id) {
- uni.navigateTo({ url: '/pages/mind/article-detail?id=' + id })
- },
- goKnowledgeCenter() {
- uni.navigateTo({ url: '/pages/mind-extra/articles' })
- }
- }
- }
- </script>
- <style scoped>
- .discover-container {
- min-height: 100vh;
- background: #f5f7fa;
- padding-bottom: 100rpx;
- }
- /* ===== 推荐 ===== */
- .recommend-section {
- margin: 20rpx 30rpx;
- }
- .section-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .section-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- }
- .section-more {
- font-size: 24rpx;
- color: #5B9BD5;
- }
- .type-filter-scroll {
- white-space: nowrap;
- margin-bottom: 20rpx;
- }
- .filter-chip {
- display: inline-block;
- padding: 8rpx 24rpx;
- font-size: 24rpx;
- color: #666;
- background: #f0f0f0;
- border-radius: 30rpx;
- margin-right: 16rpx;
- }
- .filter-chip.active {
- background: #5B9BD5;
- color: #fff;
- }
- .loading-state,
- .empty-state {
- display: flex;
- justify-content: center;
- padding: 60rpx 0;
- }
- .loading-text,
- .empty-text {
- font-size: 26rpx;
- color: #999;
- }
- .product-grid {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- }
- .product-card {
- width: 48%;
- background: #fff;
- border-radius: 16rpx;
- overflow: hidden;
- margin-bottom: 20rpx;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
- }
- .product-cover {
- width: 100%;
- height: 200rpx;
- background: #f0f0f0;
- }
- .product-info {
- padding: 14rpx;
- }
- .product-name {
- display: block;
- font-size: 26rpx;
- color: #333;
- margin-bottom: 10rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .product-price-row {
- display: flex;
- align-items: baseline;
- }
- .product-price {
- font-size: 28rpx;
- color: #5B9BD5;
- font-weight: bold;
- margin-right: 10rpx;
- }
- .product-member {
- font-size: 20rpx;
- color: #999;
- }
- .recommend-scroll {
- display: flex;
- white-space: nowrap;
- overflow-x: auto;
- padding-bottom: 10rpx;
- }
- .recommend-card {
- display: inline-flex;
- flex-direction: column;
- width: 260rpx;
- background: #fff;
- border-radius: 20rpx;
- overflow: hidden;
- margin-right: 20rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .card-banner {
- padding: 14rpx 20rpx;
- background: #5B9BD5;
- color: #fff;
- font-size: 22rpx;
- font-weight: bold;
- text-align: center;
- }
- .card-body {
- padding: 16rpx;
- white-space: normal;
- }
- .card-title {
- font-size: 24rpx;
- font-weight: bold;
- color: #333;
- display: block;
- margin-bottom: 6rpx;
- }
- .card-desc {
- font-size: 20rpx;
- color: #999;
- display: block;
- margin-bottom: 10rpx;
- }
- .card-meta {
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .card-price {
- font-size: 26rpx;
- color: #5B9BD5;
- font-weight: bold;
- }
- .card-tag {
- font-size: 18rpx;
- color: #5B9BD5;
- background: rgba(91,155,213,0.1);
- padding: 2rpx 10rpx;
- border-radius: 10rpx;
- }
- /* ===== 家庭会员推荐卡片 ===== */
- .member-card {
- margin: 20rpx 30rpx 0;
- }
- .member-card-bg {
- display: flex;
- align-items: center;
- background: linear-gradient(135deg, #F97316, #FB923C);
- border-radius: 20rpx;
- padding: 24rpx 30rpx;
- }
- .member-card-icon {
- font-size: 48rpx;
- margin-right: 16rpx;
- }
- .member-card-texts {
- flex: 1;
- display: flex;
- flex-direction: column;
- }
- .member-card-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #fff;
- }
- .member-card-desc {
- font-size: 22rpx;
- color: rgba(255,255,255,0.85);
- margin-top: 4rpx;
- }
- .member-card-action {
- margin-left: 16rpx;
- }
- .member-card-btn {
- display: inline-block;
- padding: 8rpx 24rpx;
- background: #fff;
- color: #F97316;
- font-size: 24rpx;
- font-weight: bold;
- border-radius: 30rpx;
- }
- /* ===== 推荐文章 ===== */
- .article-section {
- margin: 20rpx 30rpx 0;
- }
- .article-list {
- display: flex;
- flex-direction: column;
- gap: 16rpx;
- }
- .article-card {
- display: flex;
- background: #fff;
- border-radius: 16rpx;
- overflow: hidden;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
- cursor: pointer;
- }
- .article-cover {
- width: 180rpx;
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .article-cover-icon {
- font-size: 48rpx;
- }
- .article-info {
- flex: 1;
- padding: 16rpx;
- display: flex;
- flex-direction: column;
- justify-content: center;
- }
- .article-title {
- font-size: 26rpx;
- font-weight: bold;
- color: #333;
- line-height: 1.4;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .article-desc {
- font-size: 22rpx;
- color: #999;
- line-height: 1.3;
- margin-top: 6rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .article-meta {
- font-size: 20rpx;
- color: #ccc;
- margin-top: 6rpx;
- }
- /* ===== 为何选择 ===== */
- .why-section {
- margin: 30rpx;
- }
- .feature-grid {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: space-between;
- }
- .feature-item {
- width: calc(50% - 10rpx);
- box-sizing: border-box;
- background: #fff;
- border-radius: 20rpx;
- padding: 24rpx;
- margin-bottom: 20rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- text-align: center;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .feature-icon {
- font-size: 48rpx;
- margin-bottom: 10rpx;
- }
- .feature-title {
- font-size: 24rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 6rpx;
- }
- .feature-desc {
- font-size: 20rpx;
- color: #999;
- }
- /* ===== 底部登录 ===== */
- .login-footer {
- margin: 40rpx 30rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .login-btn {
- width: 100%;
- height: 88rpx;
- line-height: 88rpx;
- background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
- color: #fff;
- font-size: 32rpx;
- font-weight: bold;
- border-radius: 44rpx;
- text-align: center;
- border: none;
- }
- .login-btn::after {
- border: none;
- }
- .login-footer-text {
- font-size: 20rpx;
- color: #bbb;
- margin-top: 16rpx;
- }
- </style>
|