feat: 1. 优化页面样式和交互 2. 添加新的图标资源

This commit is contained in:
davy 2025-04-10 00:38:18 +08:00
parent aba7fe92d3
commit c022c02f2f
5 changed files with 158 additions and 45 deletions

View File

@ -73,7 +73,7 @@
width: 208rpx; width: 208rpx;
background: #FFFFFF; background: #FFFFFF;
margin-right: 16rpx; margin-right: 16rpx;
margin-bottom: 36rpx; margin-bottom: 24rpx;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@ -9,8 +9,8 @@
<scroll-view scroll-y style="height: 100%;width: 100%;"> <scroll-view scroll-y style="height: 100%;width: 100%;">
<!-- 活动标题和描述 --> <!-- 活动标题和描述 -->
<view class="activity-header"> <view class="activity-header">
<view class="activity-title">{{activityInfo.title || 'TasteRoom 风味屋 · 风味之旅系列'}}</view> <view class="activity-title">{{featureInfo.pageName || '专辑详情'}}</view>
<view class="activity-desc">{{activityInfo.description || '探索啤酒风味新边界'}}</view> <view class="activity-desc">{{featureInfo.subTitle || '探索啤酒风味新边界'}}</view>
</view> </view>
<!-- 酒款列表 --> <!-- 酒款列表 -->
@ -50,8 +50,8 @@
}, },
data() { data() {
return { return {
activityId: '', featureId: '',
activityInfo: {}, featureInfo: {},
beerList: [], beerList: [],
queryForm: { queryForm: {
search: '' search: ''
@ -61,28 +61,45 @@
}; };
}, },
onLoad(options) { onLoad(options) {
console.log('专辑详情页 onLoad options:', options)
if (options.id) { if (options.id) {
this.activityId = options.id this.featureId = options.id
this.getActivityDetail() console.log('专辑ID:', this.featureId)
this.getFeatureDetail()
} else {
console.error('未传递专辑ID')
uni.showToast({
title: '参数错误',
icon: 'none'
})
} }
}, },
onShow(){ onShow(){
// uni.showTabBar() // uni.showTabBar()
}, },
methods: { methods: {
// //
async getActivityDetail() { async getFeatureDetail() {
try { try {
const res = await getFeaturePage(this.activityId) console.log('开始获取专辑详情ID:', this.featureId)
const res = await getFeaturePage(this.featureId)
console.log('专辑详情接口返回数据:', res)
if (res.code === 200 && res.data) { if (res.code === 200 && res.data) {
this.activityInfo = res.data this.featureInfo = res.data
// console.log('专辑详情数据:', this.featureInfo)
//
this.getBeerList() this.getBeerList()
} else {
console.error('获取专辑详情失败,返回码:', res.code)
uni.showToast({
title: '获取专辑详情失败',
icon: 'none'
})
} }
} catch (error) { } catch (error) {
console.error('获取活动详情失败:', error) console.error('获取专辑详情失败:', error)
uni.showToast({ uni.showToast({
title: '获取活动详情失败', title: '获取专辑详情失败',
icon: 'none' icon: 'none'
}) })
} }
@ -91,9 +108,23 @@
// //
async getBeerList() { async getBeerList() {
try { try {
const res = await getBeerList(this.activityInfo.keyword || '') // 使ID
const params = {
featurePageId: this.featureId
}
console.log('开始获取酒款列表,参数:', params)
const res = await getBeerList(params)
console.log('酒款列表接口返回数据:', res)
if (res.code === 200 && res.data) { if (res.code === 200 && res.data) {
this.beerList = res.data this.beerList = res.data
console.log('酒款列表数据:', this.beerList)
} else {
console.error('获取酒款列表失败,返回码:', res.code)
uni.showToast({
title: '获取酒款列表失败',
icon: 'none'
})
} }
} catch (error) { } catch (error) {
console.error('获取酒款列表失败:', error) console.error('获取酒款列表失败:', error)

View File

@ -28,13 +28,13 @@
</view> </view>
<!-- 专辑列表 --> <!-- 专辑列表 -->
<view v-for="(item,i) in featurePageList" :key="i" class="bg-white"> <view v-for="(item,i) in featurePageList" :key="i" class="bg-white feature-item">
<view class="flex justify-between align-center title-box" @click="toFeaturePage(item)"> <view class="flex justify-between align-center title-box" @click="toFeaturePage(item)">
<view class="flex-1 flex flex-col"> <view class="flex-1 flex flex-col">
<text class="title">{{ item.pageName }}</text> <text class="title">{{ item.pageName }}</text>
<text class="sub">{{ item.subTitle}}</text> <text class="sub">{{ item.subTitle}}</text>
</view> </view>
<image src="@/static/arrow-right.png" style="width: 48rpx;height: 48rpx;"></image> <image src="@/static/arrow-right.svg" style="width: 48rpx;height: 48rpx;"></image>
</view> </view>
<rowBeer :beers="item.beers" /> <rowBeer :beers="item.beers" />
</view> </view>
@ -192,12 +192,14 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
/* 页面基础样式 */
.page { .page {
background: #F9F9F9; background: #F9F9F9;
height: 100vh; height: 100vh;
overflow-y: auto; overflow-y: auto;
} }
/* 固定搜索栏样式 */
.fixed-search { .fixed-search {
position: fixed; position: fixed;
left: 0; left: 0;
@ -209,10 +211,12 @@
transition: all 0.3s ease; transition: all 0.3s ease;
} }
/* 搜索框容器样式 */
.search-box { .search-box {
padding: 0 30rpx; padding: 0 30rpx;
} }
/* 搜索输入框样式 */
.search-input-container { .search-input-container {
display: flex; display: flex;
align-items: center; align-items: center;
@ -225,6 +229,7 @@
position: relative; position: relative;
} }
/* 搜索框占位符文本样式 */
.search-placeholder { .search-placeholder {
flex: 1; flex: 1;
padding: 0 20rpx; padding: 0 20rpx;
@ -233,6 +238,7 @@
position: relative; position: relative;
} }
/* 搜索图标容器样式 */
.search-icon-container { .search-icon-container {
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -250,11 +256,12 @@
} }
} }
/* 内容区域容器样式 */
.content-container { .content-container {
padding-top: 0rpx; padding-top: 0rpx;
} }
/* 筛选导航栏 */ /* 筛选导航栏样式 */
.filter-bar { .filter-bar {
position: sticky; position: sticky;
top:80rpx; top:80rpx;
@ -265,6 +272,7 @@
padding-top: 40rpx; padding-top: 40rpx;
} }
/* 筛选选项中心区域样式 */
.choose-center { .choose-center {
height: 112rpx; height: 112rpx;
width: 100%; width: 100%;
@ -272,6 +280,7 @@
background: #FFFFFF; background: #FFFFFF;
} }
/* 导航选项容器样式 */
.choose-navs { .choose-navs {
// //
font-family: Roboto; font-family: Roboto;
@ -279,6 +288,7 @@
font-weight: 500; font-weight: 500;
} }
/* 导航选项文本样式 */
.choose-navs-txt { .choose-navs-txt {
// //
width: 144rpx; width: 144rpx;
@ -295,16 +305,18 @@
} }
} }
/* 专辑标题区域样式 */
.title-box { .title-box {
padding: 24rpx 32rpx; padding: 24rpx 32rpx;
// margin-bottom: 24rpx; // margin-bottom: 24rpx;
// margin-top: 24rpx; // margin-top: 24rpx;
} }
/* 专辑主标题样式 */
.title { .title {
font-size: 32rpx; font-size: 32rpx;
color: #030303; color: #030303;
font-weight: 600; font-weight: bold;
line-height: 48rpx; line-height: 48rpx;
letter-spacing: normal; letter-spacing: normal;
margin-bottom: 8rpx; margin-bottom: 8rpx;
@ -314,6 +326,7 @@
text-overflow: ellipsis; text-overflow: ellipsis;
} }
/* 专辑副标题样式 */
.sub { .sub {
font-family: Roboto; font-family: Roboto;
font-size: 24rpx; font-size: 24rpx;
@ -329,4 +342,12 @@
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
} }
/* 专辑项样式 */
.feature-item {
margin: 24rpx 0; /* 上下间距24rpx */
border-radius: 24rpx 0rpx 0rpx 24rpx; /* 圆角 */
overflow: hidden; /* 确保内容不会溢出圆角 */
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05); /* 添加轻微阴影 */
}
</style> </style>

View File

@ -146,6 +146,7 @@
finished: false, finished: false,
navItems: ['新酒上市', '生成酒单', '酒币换购', '关注厂牌'], navItems: ['新酒上市', '生成酒单', '酒币换购', '关注厂牌'],
currentAdIndex: 0, // 广 currentAdIndex: 0, // 广
adLoading: false, // 广
}; };
}, },
created() { created() {
@ -160,6 +161,8 @@
if (this.featurePageList.length === 0) { if (this.featurePageList.length === 0) {
this.getActivityList() this.getActivityList()
} }
// 广
this.preloadAdData()
}, },
watch: { watch: {
featurePageList: { featurePageList: {
@ -181,7 +184,6 @@
// }) // })
// }, 500) // }, 500)
this.statusBaeHeight = uni.getWindowInfo.statusBarHeight this.statusBaeHeight = uni.getWindowInfo.statusBarHeight
this.getBannerListFun() // 广
uni.showShareMenu({ uni.showShareMenu({
menus: ['shareAppMessage', 'shareTimeline'] menus: ['shareAppMessage', 'shareTimeline']
}) })
@ -198,6 +200,9 @@
// //
this.resetAndLoadData() this.resetAndLoadData()
} }
// 广
this.checkAndShowAd()
}, },
methods: { methods: {
loginSuccess() { loginSuccess() {
@ -300,13 +305,30 @@
url: "/pages/index/review?beerId=" + it.id url: "/pages/index/review?beerId=" + it.id
}) })
}, },
// 广
async preloadAdData() {
try {
this.adLoading = true
await this.getBannerListFun()
} catch (error) {
console.error('广告预加载失败:', error)
} finally {
this.adLoading = false
}
},
// 广 banner // 广 banner
getBannerListFun() { async getBannerListFun() {
this.ADList = [] this.ADList = []
this.homeBanner = [] this.homeBanner = []
this.bannerJoin = null this.bannerJoin = null
getBannerList().then(res => {
if (!res.data || !Array.isArray(res.data)) return try {
const res = await getBannerList()
if (!res.data || !Array.isArray(res.data)) {
console.error('广告数据格式错误')
return
}
res.data.forEach(it => { res.data.forEach(it => {
if (it.bannerType === 'homeAD') { // 广 if (it.bannerType === 'homeAD') { // 广
@ -317,20 +339,46 @@
this.homeBanner.push(it) this.homeBanner.push(it)
} }
}) })
} catch (err) {
// 广 console.error('获取banner列表失败', err)
const lastShowTime = uni.getStorageSync('lastShowHomeADTime') uni.showToast({
const currentTime = new Date().getTime() title: '广告加载失败',
// 24 icon: 'none'
if (!lastShowTime || (currentTime - lastShowTime > 24 * 60 * 60 * 1000)) { })
if (this.ADList.length > 0) { }
},
// 广
checkAndShowAd() {
if (this.ADList.length === 0) {
// 广广
this.getBannerListFun().then(() => {
this.showAdIfNeeded()
})
return
}
this.showAdIfNeeded()
},
// 广
showAdIfNeeded() {
if (this.ADList.length === 0) return
const lastShowTime = uni.getStorageSync('lastShowHomeADTime')
const currentTime = new Date().getTime()
// 1
if (!lastShowTime || (currentTime - lastShowTime > 60 * 60 * 1000)) {
this.$nextTick(() => {
if (this.$refs.ADRef) {
this.$refs.ADRef.open() this.$refs.ADRef.open()
} }
} })
}).catch(err => { }
console.error('获取banner列表失败', err)
})
}, },
// 广
closeAd() { closeAd() {
// 广 // 广
uni.setStorageSync('lastShowHomeADTime', new Date().getTime()) uni.setStorageSync('lastShowHomeADTime', new Date().getTime())
@ -338,7 +386,12 @@
backgroundColor: '#ffffff' backgroundColor: '#ffffff'
}) })
this.$refs.ADRef.close() this.$refs.ADRef.close()
//
this.currentAdIndex = 0
}, },
// 广
handleAD(item) { handleAD(item) {
if (!item || !item.bannerLink) return if (!item || !item.bannerLink) return
@ -363,12 +416,29 @@
} }
}) })
} else if (item.bannerLink.startsWith('http')) { } else if (item.bannerLink.startsWith('http')) {
// 使web-view // 使web-view
uni.navigateTo({ uni.navigateTo({
url: `/pages/webview/webview?url=${encodeURIComponent(item.bannerLink)}` url: `/pages/webview/webview?url=${encodeURIComponent(item.bannerLink)}`
}) })
} }
}, },
// 广
handleAdSwiperChange(e) {
this.currentAdIndex = e.detail.current
},
//
handlePopupChange(e) {
if (!e.show) {
this.closeAd()
} else {
// 广
if (this.ADList.length === 0) {
this.closeAd()
}
}
},
// //
toJoin() { toJoin() {
if (!this.bannerJoin || !this.bannerJoin.bannerLink) return if (!this.bannerJoin || !this.bannerJoin.bannerLink) return
@ -430,16 +500,6 @@
break; break;
} }
}, },
// 广
handleAdSwiperChange(e) {
this.currentAdIndex = e.detail.current
},
//
handlePopupChange(e) {
if (!e.show) {
this.closeAd()
}
},
// //
toBeerList() { toBeerList() {
uni.switchTab({ uni.switchTab({

1
static/arrow-right.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.0 KiB