Files
tuniao-ui/vipPage/components/waterfall/waterfall.vue
T
2026-03-19 10:47:37 +08:00

287 lines
9.6 KiB
Vue

<template>
<view class="vip-component-waterfall">
<!-- 顶部自定义导航 -->
<tn-nav-bar fixed>瀑布流</tn-nav-bar>
<!-- 页面内容 -->
<view :style="{paddingTop: vuex_custom_bar_height + 'px'}">
<view class="tn-padding">
<tn-waterfall ref="waterfall" v-model="list" @finish="handleWaterFallFinish">
<template v-slot:left="{ leftList }">
<view v-for="(item, index) in leftList" :key="item.id" class="product__item">
<view class="item__image">
<tn-lazy-load :threshold="-450" height="100%" :image="item.mainImage" :index="item.id" imgMode="widthFix"></tn-lazy-load>
</view>
<view class="item__data">
<view class="item__title-container">
<view v-if="item.newProduct" class="item__store-type tn-cool-bg-color-8">图鸟趋势</view>
<view v-else-if="item.storeType === 1" class="item__store-type tn-cool-bg-color-1">自营</view>
<text class="item__title">{{ item.title }}</text>
</view>
<view v-if="item.tags && item.tags.length > 0" class="item__tags-container">
<view v-for="(tagItem, tagIndex) in item.tags" :key="tagIndex" class="item__tag">{{ tagItem }}</view>
</view>
<view class="item__price-container">
<text class="item__price--unit"></text>
<text class="item__price--integer">{{ item.priceInteger }}</text>
<text class="item__price--dot">.</text>
<text class="item__price--decimal">{{ item.priceDecimal }}</text>
</view>
</view>
</view>
</template>
<template v-slot:right="{ rightList }">
<view v-for="(item, index) in rightList" :key="item.id" class="product__item">
<view class="item__image">
<tn-lazy-load :threshold="-450" height="100%" :image="item.mainImage" :index="item.id" imgMode="widthFix"></tn-lazy-load>
</view>
<view class="item__data">
<view class="item__title-container">
<view v-if="item.storeType === 1" class="item__store-type tn-cool-bg-color-1">自营</view>
<text class="item__title">{{ item.title }}</text>
</view>
<view class="item__tags-container">
<view v-for="(tagItem, tagIndex) in item.tags" :key="tagIndex" class="item__tag">{{ tagItem }}</view>
</view>
<view class="item__price-container">
<text class="item__price--unit"></text>
<text class="item__price--integer">{{ item.priceInteger }}</text>
<text class="item__price--dot">.</text>
<text class="item__price--decimal">{{ item.priceDecimal }}</text>
</view>
</view>
</view>
</template>
</tn-waterfall>
</view>
<tn-load-more :status="loadStatus"></tn-load-more>
</view>
</view>
</template>
<script>
export default {
data() {
return {
loadStatus: 'loadmore',
list: [],
data: [
{
title: '图鸟科技 设计师专属笔记本 告别卡慢热',
mainImage: 'https://resource.tuniaokj.com/images/shop/computer1.jpg',
storeType: 1, // 1 自营 2 第三方店铺
newProduct: true, // 是否为新品
tags: ['满1000减80','免息'],
price: 6999
},
{
title: '图鸟科技 开发便携笔记本 告别笨重外出',
mainImage: 'https://resource.tuniaokj.com/images/shop/computer2.jpg',
storeType: 1, // 1 自营 2 第三方店铺
newProduct: false, // 是否为新品
tags: ['免息'],
price: 7999
},
{
title: '图鸟科技 T10 宇宙9000 10G全网通',
mainImage: 'https://resource.tuniaokj.com/images/shop/phonecase2.jpg',
storeType: 1, // 1 自营 2 第三方店铺
newProduct: true, // 是否为新品
tags: [],
price: 4999
},
{
title: '图鸟科技 T10Pro 宇宙9010 10G全网通',
mainImage: 'https://resource.tuniaokj.com/images/shop/phonecase1.jpg',
storeType: 1, // 1 自营 2 第三方店铺
newProduct: true, // 是否为新品
tags: [],
price: 6999
},
{
title: '图鸟科技 运动手表 不用插卡即可通话',
mainImage: 'https://resource.tuniaokj.com/images/shop/watch1.jpg',
storeType: 1, // 1 自营 2 第三方店铺
newProduct: false, // 是否为新品
tags: [],
price: 2999
},
{
title: '图鸟科技 页面设计 专为第三方提供精美酷炫页面',
mainImage: 'https://resource.tuniaokj.com/images/shop/card.jpg',
storeType: 2, // 1 自营 2 第三方店铺
newProduct: false, // 是否为新品
tags: ['酷炫'],
price: 10999
},
{
title: '图鸟科技 海报设计 想不到就过来聊聊吧',
mainImage: 'https://resource.tuniaokj.com/images/shop/prototype1.jpg',
storeType: 2, // 1 自营 2 第三方店铺
newProduct: false, // 是否为新品
tags: ['哎呀'],
price: 399
},
{
title: '图鸟科技 环保袋',
mainImage: 'https://resource.tuniaokj.com/images/shop/bag1.jpg',
storeType: 1, // 1 自营 2 第三方店铺
newProduct: false, // 是否为新品
tags: ['合作免费送'],
price: 0
},
{
title: '图鸟科技 纸杯',
mainImage: 'https://resource.tuniaokj.com/images/shop/cup2.jpg',
storeType: 1, // 1 自营 2 第三方店铺
newProduct: false, // 是否为新品
tags: ['合作免费送'],
price: 0
},
{
title: '图鸟科技 抱枕',
mainImage: 'https://resource.tuniaokj.com/images/shop/pillow.jpg',
storeType: 1, // 1 自营 2 第三方店铺
newProduct: false, // 是否为新品
tags: [],
price: 99
}
]
}
},
onLoad() {
this.getRandomData()
},
onReachBottom() {
this.getRandomData()
},
methods: {
// 获取随机数据
getRandomData() {
this.loadStatus = 'loading'
for (let i = 0; i < 10; i++) {
let index = this.$tn.number.randomInt(0, this.data.length - 1)
let item = JSON.parse(JSON.stringify(this.data[index]))
let price = this.getPrice(item.price)
item.id = this.$tn.uuid()
item.priceInteger = price[0]
item.priceDecimal = price[1]
this.list.push(item)
}
},
// 瀑布流加载完毕事件
handleWaterFallFinish() {
this.loadStatus = 'loadmore'
},
// 获取价格整数和小数部分
getPrice(price) {
const priceStr = String(price)
if (priceStr.indexOf('.') !== -1) {
return priceStr.split('.')
} else {
return [priceStr, '00']
}
}
}
}
</script>
<style lang="scss" scoped>
.vip-component-waterfall {
background-color: $tn-bg-gray-color;
min-height: 100vh;
}
.product__item {
background-color: #FFFFFF;
border-radius: 10rpx;
overflow: hidden;
margin: 0 10rpx;
margin-bottom: 20rpx;
.item {
/* 图片 start */
&__image {
width: 100%;
height: auto;
background-color: #FFFFFF;
}
/* 图片 end */
/* 内容 start */
&__data {
padding: 8rpx 14rpx;
}
/* 标题 start */
&__title-container {
text-align: justify;
line-height: 38rpx;
vertical-align: middle;
}
&__store-type {
height: 28rpx;
font-size: 20rpx;
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0 4rpx;
border-radius: 6rpx;
white-space: nowrap;
text-align: center;
top: -2rpx;
margin-right: 6rpx;
}
&__title {
}
/* 标题 end */
/* 标签 start */
&__tags-container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
}
&__tag {
margin-left: 10rpx;
color: #E83A30;
border: 2rpx solid #E83A30;
padding: 0 6rpx;
border-radius: 10rpx;
font-size: 20rpx;
&:first-child {
margin-left: 0rpx !important;
}
}
/* 标签 end */
/* 价格 start */
&__price-container {
font-size: 24rpx;
color: #E83A30;
font-weight: bold;
}
&__price {
&--unit {
}
&--integer {
font-size: 38rpx;
}
&--decimal {
}
}
/* 价格 end */
/* 内容 end */
}
}
</style>