355 lines
8.5 KiB
Vue
355 lines
8.5 KiB
Vue
![]() |
<template>
|
||
|
<view class="page-content">
|
||
|
<scroll-view scroll-x class="bg-white nav">
|
||
|
<view class="flex text-center">
|
||
|
<view class="cu-item flex-sub tab" :class="tabCur == 0?'active cur':''" @tap="tabSelect" :data-id="0">
|
||
|
酒款
|
||
|
</view>
|
||
|
<view class="cu-item flex-sub tab" :class="tabCur == 1?'active cur':''" @tap="tabSelect" :data-id="1">
|
||
|
品牌
|
||
|
</view>
|
||
|
</view>
|
||
|
</scroll-view>
|
||
|
<view v-if="tabCur == 0" class="my-container">
|
||
|
<template v-if="favoriteBeerList.length > 0">
|
||
|
<scroll-view style="height: 100%;" enable-flex scroll-y @scrolltolower="changeBeerPage">
|
||
|
<view class="beer-grid">
|
||
|
<view class="beer-box" v-for="(item, index) in favoriteBeerList" :key="index" @click="toBeer(item)">
|
||
|
<view class="cover-box">
|
||
|
<image :src="item.cover" class="cover" mode="aspectFill"></image>
|
||
|
<view class="like">
|
||
|
<text class="cuIcon-likefill" style="color: #4E63E0"
|
||
|
@click.stop="cancelFavBeer(item)"></text>
|
||
|
</view>
|
||
|
</view>
|
||
|
<view class="info-box">
|
||
|
<view class="title">{{ item.beerName }}</view>
|
||
|
<view class="rating">
|
||
|
<text class="score">{{ item.beerOverallRating || '5' }}</text>
|
||
|
<text class="reviews">({{ item.beerReviewsCount || '0' }})</text>
|
||
|
</view>
|
||
|
</view>
|
||
|
</view>
|
||
|
</view>
|
||
|
<view class="cu-load" :class="favoriteBeerList.length == totalBeer ? 'over' :'more'"></view>
|
||
|
</scroll-view>
|
||
|
</template>
|
||
|
<template v-else>
|
||
|
<view class="flex align-center justify-center"
|
||
|
style="height: 140rpx;width: 100%;color: #747783;font-size: 24rpx;">暂无关注的酒款</view>
|
||
|
</template>
|
||
|
</view>
|
||
|
<view v-if="tabCur == 1" class="my-brandSide">
|
||
|
<template v-if="favoriteBreweryList.length > 0">
|
||
|
<scroll-view style="height: 100%;" scroll-y="true" @scrolltolower="changeBreweryPage">
|
||
|
<view class="brandSide-box" v-for="(item, index) in favoriteBreweryList" :key="index"
|
||
|
@click="toBrand(item)">
|
||
|
<view class="flex align-center justify-start">
|
||
|
<image :src="item.brandLogo" class="logo"></image>
|
||
|
<view>
|
||
|
<view class="title">{{ item.brandName }}</view>
|
||
|
<!-- <view class="desc">20241223</view> -->
|
||
|
</view>
|
||
|
</view>
|
||
|
<view class="cu-btn radius bg-gray" @click.stop="cancelFavBrewery(item)">取消关注</view>
|
||
|
</view>
|
||
|
<!-- <view class="cu-load" :class="favoriteBreweryList.length == totalBrewery ? 'over' :'more'"></view> -->
|
||
|
</scroll-view>
|
||
|
</template>
|
||
|
<template v-else>
|
||
|
<view class="flex align-center justify-center"
|
||
|
style="height: 140rpx;width: 100%;color: #747783;font-size: 24rpx;">暂无关注的品牌</view>
|
||
|
</template>
|
||
|
</view>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import {
|
||
|
listMyFavoriteBeer,
|
||
|
listMyFavoriteBrewery
|
||
|
} from '@/api/user.js'
|
||
|
import {
|
||
|
favorBeer,
|
||
|
favorBrewery
|
||
|
} from '@/api/bar.js'
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
tabCur: 0,
|
||
|
favoriteBeerList: [], // 收藏的酒款列表
|
||
|
favoriteBreweryList: [], // 收藏的酒厂列表
|
||
|
beerQuery: {
|
||
|
pageNum: 1,
|
||
|
pageSize: 10
|
||
|
},
|
||
|
breweryQuery: {
|
||
|
pageNum: 1,
|
||
|
pageSize: 10
|
||
|
},
|
||
|
totalBeer: 0,
|
||
|
totalBrewery: 0
|
||
|
};
|
||
|
},
|
||
|
onLoad() {
|
||
|
this.getFavoriteBeerList()
|
||
|
this.getFavoriteBreweryList()
|
||
|
},
|
||
|
methods: {
|
||
|
tabSelect(e) {
|
||
|
console.log(e)
|
||
|
this.tabCur = e.currentTarget.dataset.id;
|
||
|
// if(this.tabCur == 0) {
|
||
|
// this.favoriteBeerList = []
|
||
|
// this.beerQuery.pageNum = 1
|
||
|
// this.getFavoriteBeerList()
|
||
|
// } else {
|
||
|
// this.favoriteBreweryList = []
|
||
|
// this.breweryQuery.pageNum = 1
|
||
|
// this.getFavoriteBreweryList()
|
||
|
// }
|
||
|
},
|
||
|
// 获取收藏的酒款列表
|
||
|
getFavoriteBeerList() {
|
||
|
listMyFavoriteBeer(this.beerQuery).then(res => {
|
||
|
this.totalBeer = res.total
|
||
|
if (res.rows && res.rows.length > 0) {
|
||
|
res.rows.forEach(it => {
|
||
|
this.favoriteBeerList.push(it)
|
||
|
})
|
||
|
}
|
||
|
// for(let i = 0; i < 29; i++) {
|
||
|
// this.favoriteBeerList.push(res.rows[0])
|
||
|
// }
|
||
|
})
|
||
|
},
|
||
|
// 酒款翻页
|
||
|
changeBeerPage() {
|
||
|
console.log('f1')
|
||
|
if (this.favoriteBeerList.length < this.totalBeer) {
|
||
|
this.beerQuery.pageNum++
|
||
|
this.getFavoriteBeerList()
|
||
|
}
|
||
|
},
|
||
|
// 获取收藏的酒厂列表
|
||
|
getFavoriteBreweryList() {
|
||
|
listMyFavoriteBrewery(this.breweryQuery).then(res => {
|
||
|
this.totalBrewery = res.total
|
||
|
if (res.rows && res.rows.length > 0) {
|
||
|
res.rows.forEach(it => {
|
||
|
this.favoriteBreweryList.push(it)
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
// 品牌方翻页
|
||
|
changeBreweryPage() {
|
||
|
console.log('f')
|
||
|
if (this.favoriteBreweryList.length < this.totalBrewery) {
|
||
|
this.breweryQuery.pageNum++
|
||
|
this.getFavoriteBreweryList()
|
||
|
}
|
||
|
},
|
||
|
// 跳转到酒款详情
|
||
|
toBeer(item) {
|
||
|
uni.navigateTo({
|
||
|
url: "/pages/index/review?beerId=" + item.beerId
|
||
|
})
|
||
|
},
|
||
|
// 跳转到品牌详情
|
||
|
toBrand(item) {
|
||
|
uni.navigateTo({
|
||
|
url: '/pages/index/brandHome?breweryId=' + item.breweryId
|
||
|
})
|
||
|
},
|
||
|
// 取消关注酒款
|
||
|
cancelFavBeer(item) {
|
||
|
let data = {
|
||
|
beerId: item.beerId,
|
||
|
status: 2
|
||
|
}
|
||
|
favorBeer(data).then(res => {
|
||
|
// if (status == 1) {
|
||
|
// uni.showToast({
|
||
|
// title: '收藏成功',
|
||
|
// icon: 'success'
|
||
|
// })
|
||
|
// } else {
|
||
|
uni.showToast({
|
||
|
title: '取消收藏',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
// }
|
||
|
/* */
|
||
|
this.favoriteBeerList = []
|
||
|
this.beerQuery.pageNum = 1
|
||
|
this.getFavoriteBeerList()
|
||
|
|
||
|
})
|
||
|
},
|
||
|
// 取消关注酒厂
|
||
|
cancelFavBrewery(item) {
|
||
|
let data = {
|
||
|
breweryId: item.breweryId,
|
||
|
status: 2
|
||
|
}
|
||
|
favorBrewery(data).then(res => {
|
||
|
// if (status == 1) {
|
||
|
// uni.showToast({
|
||
|
// title: '收藏成功',
|
||
|
// icon: 'success'
|
||
|
// })
|
||
|
// } else {
|
||
|
uni.showToast({
|
||
|
title: '取消收藏',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
// }
|
||
|
|
||
|
this.favoriteBreweryList = []
|
||
|
this.breweryQuery.pageNum = 1
|
||
|
this.getFavoriteBreweryList()
|
||
|
|
||
|
})
|
||
|
},
|
||
|
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style lang="scss" scoped>
|
||
|
.page-content {
|
||
|
background: #FDFDFD;
|
||
|
height: 100vh;
|
||
|
|
||
|
.tab {
|
||
|
color: #A5A7B9;
|
||
|
font-size: 32rpx;
|
||
|
font-weight: 500;
|
||
|
}
|
||
|
|
||
|
.active {
|
||
|
color: #1A1A1A;
|
||
|
}
|
||
|
|
||
|
.my-container {
|
||
|
padding: 28rpx 36rpx;
|
||
|
height: calc(100vh - 100rpx);
|
||
|
|
||
|
.beer-grid {
|
||
|
display: flex;
|
||
|
flex-wrap: wrap;
|
||
|
justify-content: flex-start;
|
||
|
margin: -14rpx; // 抵消子元素的margin
|
||
|
|
||
|
.beer-box {
|
||
|
width: calc((100% - 84rpx) / 3); // 三等分宽度(减去两个间距)
|
||
|
margin: 14rpx; // 统一的间距
|
||
|
background: #FFFFFF;
|
||
|
box-sizing: border-box;
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
|
border-radius: 16rpx;
|
||
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||
|
overflow: hidden;
|
||
|
|
||
|
.cover-box {
|
||
|
width: 100%;
|
||
|
padding-bottom: 144%; // 保持图片比例
|
||
|
position: relative;
|
||
|
overflow: hidden;
|
||
|
|
||
|
.cover {
|
||
|
position: absolute;
|
||
|
top: 0;
|
||
|
left: 0;
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
object-fit: cover;
|
||
|
}
|
||
|
|
||
|
.like {
|
||
|
position: absolute;
|
||
|
right: 16rpx;
|
||
|
bottom: 18rpx;
|
||
|
width: 48rpx;
|
||
|
height: 48rpx;
|
||
|
border-radius: 50%;
|
||
|
background: rgba(255, 255, 255, 0.9);
|
||
|
backdrop-filter: blur(4rpx);
|
||
|
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
|
||
|
display: flex;
|
||
|
justify-content: center;
|
||
|
align-items: center;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.info-box {
|
||
|
padding: 12rpx;
|
||
|
|
||
|
.title {
|
||
|
font-size: 28rpx;
|
||
|
color: #19191B;
|
||
|
font-weight: 600;
|
||
|
margin-bottom: 8rpx;
|
||
|
overflow: hidden;
|
||
|
text-overflow: ellipsis;
|
||
|
display: -webkit-box;
|
||
|
-webkit-line-clamp: 2;
|
||
|
-webkit-box-orient: vertical;
|
||
|
}
|
||
|
|
||
|
.rating {
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
font-size: 24rpx;
|
||
|
|
||
|
.score {
|
||
|
color: #FFA033;
|
||
|
font-weight: 600;
|
||
|
margin-right: 4rpx;
|
||
|
}
|
||
|
|
||
|
.reviews {
|
||
|
color: #999999;
|
||
|
font-size: 20rpx;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.my-brandSide {
|
||
|
padding: 28rpx 36rpx;
|
||
|
height: calc(100vh - 100rpx);
|
||
|
|
||
|
.brandSide-box {
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
justify-content: space-between;
|
||
|
padding: 30rpx 0;
|
||
|
border-bottom: 1rpx solid #F0F4F9;
|
||
|
padding: 32rpx 0;
|
||
|
|
||
|
.logo {
|
||
|
width: 108rpx;
|
||
|
height: 108rpx;
|
||
|
border-radius: 50%;
|
||
|
margin-right: 28rpx;
|
||
|
}
|
||
|
|
||
|
.title {
|
||
|
font-size: 28rpx;
|
||
|
color: #19191B;
|
||
|
margin-bottom: 20rpx;
|
||
|
}
|
||
|
|
||
|
.desc {
|
||
|
font-size: 20rpx;
|
||
|
color: #9C9BA6;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</style>
|