zdtap-uniapp-main/pagesMy/myAttention.vue
LYL521LN\刘娜 36162035cd first commit
2025-03-29 16:01:43 +08:00

345 lines
8.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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 style="display: inline-block;" v-for="(item, index) in favoriteBeerList" :key="index" @click="toBeer(item)">
<view class="beer-box" >
<view class="cover-box">
<image :src="item.cover" class="cover"></image>
<view class="like">
<!-- <text v-if="index % 2 == 0" class="cuIcon-like" style="color: #1E2019"></text> -->
<text class="cuIcon-likefill" style="color: pink"
@click.stop="cancelFavBeer(item)"></text>
</view>
</view>
<view class="title">{{ item.beerName }}</view>
<!-- <view class="desc">爱美西啤酒</view> -->
<view class="flex align-center num">
<image src="@/static/vector.png" style="width: 20rpx;height: 20rpx;margin-right: 10rpx;">
</image>
{{ item.beerOverallRating }}{{ item.beerReviewsCount}}
</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;
// display: flex;
// flex-wrap: wrap;
// justify-content: flex-start;
height: calc(100vh - 100rpx);
.beer-box {
width: 208rpx;
background: #FFFFFF;
margin-right: 28rpx;
margin-bottom: 36rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: flex-start;
&:nth-child(3n) {
margin-right: 0;
}
.cover-box {
width: 208rpx;
height: 300rpx;
border-radius: 30rpx;
margin-bottom: 18rpx;
position: relative;
.cover {
width: 100%;
height: 100%;
border-radius: 12rpx;
}
.like {
position: absolute;
right: 16rpx;
bottom: 18rpx;
width: 48rpx;
height: 48rpx;
border-radius: 50%;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
}
// .cover {
// width: 208rpx;
// height: 300rpx;
// border-radius: 30rpx;
// margin-bottom: 18rpx;
// }
.title {
font-size: 28rpx;
color: #1E2019;
margin-bottom: 12rpx;
color: #19191B;
}
.desc {
font-size: 24rpx;
color: #A5A7B9;
margin-bottom: 12rpx;
color: #979797;
}
.num {
font-size: 20rpx;
color: #5F5F63;
}
}
}
.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>