完善业务闭环,实现对轮播图的管理,优化数据库表文件
This commit is contained in:
@@ -74,6 +74,8 @@
|
||||
const store = require('../../store/index')
|
||||
const memberApi = require('../../api/member')
|
||||
const courseApi = require('../../api/course')
|
||||
const bannerApi = require('../../api/banner')
|
||||
const { resolveCoverUrl } = require('../../utils/request')
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -88,11 +90,7 @@
|
||||
totalSignDays: 0,
|
||||
pendingBookings: 0
|
||||
},
|
||||
banners: [
|
||||
{ imageUrl: 'https://img.zcool.cn/community/01f5c65e5d9c6ca801216518e1d2e0.jpg@1280w_1l_2o_100sh.jpg', title: '夏季燃脂计划', subtitle: 'HIIT + 动感单车,高效燃脂 7 天挑战' },
|
||||
{ imageUrl: 'https://img.zcool.cn/community/01a5fe5e5d9c4ba80121985ac87c5f.jpg@1280w_1l_2o_100sh.jpg', title: '瑜伽月卡特惠', subtitle: '新人专享 5 折,流瑜伽 / 普拉提任选' },
|
||||
{ imageUrl: 'https://img.zcool.cn/community/0177c85e5d9c84a8012165182ef63f.jpg@1280w_1l_2o_100sh.jpg', title: '私教一对一体验', subtitle: '免费体测 + 定制训练计划,限 30 名' }
|
||||
],
|
||||
banners: [],
|
||||
recommendCourses: []
|
||||
}
|
||||
},
|
||||
@@ -128,10 +126,11 @@
|
||||
async loadData() {
|
||||
this.loading = true
|
||||
try {
|
||||
// 并行获取会员信息和推荐课程
|
||||
const [memberResult, recommendResult] = await Promise.allSettled([
|
||||
// 并行获取会员信息、推荐课程和轮播图
|
||||
const [memberResult, recommendResult, bannerResult] = await Promise.allSettled([
|
||||
memberApi.getMemberInfo(),
|
||||
courseApi.getActiveRecommendations()
|
||||
courseApi.getActiveRecommendations(),
|
||||
bannerApi.getActiveBanners()
|
||||
])
|
||||
|
||||
// 处理会员信息
|
||||
@@ -153,13 +152,30 @@
|
||||
return {
|
||||
id: gc.id || r.courseId,
|
||||
courseName: gc.courseName || '推荐课程',
|
||||
imageUrl: gc.coverImage || '',
|
||||
imageUrl: resolveCoverUrl(gc.coverImage),
|
||||
recommendReason: r.recommendReason || '',
|
||||
priceLabel: (gc.storedValueAmount > 0 ? '¥' + gc.storedValueAmount : '免费'),
|
||||
bookedCount: gc.currentMembers || 0
|
||||
}
|
||||
})
|
||||
}
|
||||
// 处理轮播图
|
||||
if (bannerResult.status === 'fulfilled') {
|
||||
const rawBanners = bannerResult.value || []
|
||||
console.log('[Index] 获取到轮播图原始数据:', rawBanners.length, '条')
|
||||
this.banners = rawBanners.map(b => {
|
||||
const resolvedUrl = resolveCoverUrl(b.imageUrl)
|
||||
console.log('[Index] Banner id=' + b.id + ' imageUrl原始=' + b.imageUrl + ' → 解析后=' + resolvedUrl)
|
||||
return {
|
||||
imageUrl: resolvedUrl,
|
||||
title: b.title || '',
|
||||
subtitle: b.subtitle || ''
|
||||
}
|
||||
})
|
||||
console.log('[Index] 最终 banners:', JSON.stringify(this.banners))
|
||||
} else {
|
||||
console.error('[Index] 轮播图请求失败:', bannerResult.reason)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('首页数据加载失败:', e)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user