169 行
3.1 KiB
Vue
169 行
3.1 KiB
Vue
<template>
|
|
<view>
|
|
<view v-if="list.length" class="box">
|
|
<view v-for="(item, index) of list" class="list" :key="index" @tap="$Router.push({ path: '/pages/app/video/detail', query: { id: item.id } })">
|
|
<view class="left">
|
|
<image :src="$IMG_URL + item.image" mode=""></image>
|
|
</view>
|
|
<view class="right">
|
|
<view class="title">{{item.title}}</view>
|
|
<view class="desc">{{item.desc}}</view>
|
|
<view class="bottom">
|
|
<view class="icon">
|
|
<image :src="$IMG_URL + '/assets/img/views_num.png'" mode=""></image>
|
|
<view class="num">{{item.views}}</view>
|
|
</view>
|
|
<view class="icon">
|
|
<image :src="$IMG_URL + '/assets/img/play_num.png'" mode=""></image>
|
|
<view class="num">{{item.play_num}}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-if="page < totalSize" class="loading">
|
|
<image :src="$IMG_URL + '/assets/img/loading-x.gif'" mode=""></image>
|
|
<view class="loading-text">正在加载中...</view>
|
|
</view>
|
|
</view>
|
|
<view v-else class="empty">
|
|
<u-empty text="暂无视频" mode="list"></u-empty>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
components: {},
|
|
data() {
|
|
return {
|
|
page: 1,
|
|
list: [],
|
|
totalSize: 1,
|
|
total: 0,
|
|
rows: 10
|
|
};
|
|
},
|
|
computed: {},
|
|
onLoad() {
|
|
this.getVideoList();
|
|
},
|
|
// 触底事件
|
|
onReachBottom() {
|
|
// 加载更多
|
|
if (this.page < this.totalSize) {
|
|
this.page += 1;
|
|
this.getVideoList();
|
|
}
|
|
},
|
|
methods: {
|
|
// 获取视频列表
|
|
getVideoList() {
|
|
this.$http('video.index', {
|
|
page: this.page
|
|
}).then(res => {
|
|
// 合并数据
|
|
this.list = [...this.list, ...res.data.list];
|
|
// 总页数
|
|
this.totalSize = res.data.totalSize;
|
|
// 总数据
|
|
this.total = res.data.total;
|
|
});
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
page {
|
|
background: #fff;
|
|
}
|
|
|
|
.empty {
|
|
margin-top: 80rpx;
|
|
}
|
|
|
|
.loading {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.loading image {
|
|
width: 120rpx;
|
|
height: 120rpx;
|
|
}
|
|
|
|
.loading .loading-text {
|
|
font-size: 28rpx;
|
|
color: #333;
|
|
}
|
|
|
|
.box {
|
|
margin: 20rpx;
|
|
padding-bottom: 40rpx;
|
|
}
|
|
|
|
.box .list {
|
|
display: flex;
|
|
margin-bottom: 30rpx;
|
|
border-bottom: 2rpx solid #f5f3f3;
|
|
padding-bottom: 20rpx;
|
|
}
|
|
|
|
.box .list:last-child {
|
|
border: none;
|
|
}
|
|
|
|
.box .list .left {
|
|
margin-right: 20rpx;
|
|
}
|
|
|
|
.box .list .left image {
|
|
width: 310rpx;
|
|
height: 200rpx;
|
|
border-radius: 10rpx;
|
|
}
|
|
|
|
.box .list .right .title {
|
|
font-size: 26rpx;
|
|
font-weight: bold;
|
|
display: -webkit-box;
|
|
-webkit-box-orient: vertical;
|
|
-webkit-line-clamp: 2;
|
|
overflow: hidden;
|
|
margin-bottom: 10rpx;
|
|
}
|
|
|
|
.box .list .right .desc {
|
|
font-size: 24rpx;
|
|
color: #bfbfbf;
|
|
display: -webkit-box;
|
|
-webkit-box-orient: vertical;
|
|
-webkit-line-clamp: 2;
|
|
overflow: hidden;
|
|
margin-bottom: 10rpx;
|
|
height: 100rpx;
|
|
}
|
|
|
|
.box .list .bottom {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.box .list .bottom .icon {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-right: 30rpx;
|
|
}
|
|
|
|
.box .list .bottom .icon image {
|
|
width: 42rpx;
|
|
height: 42rpx;
|
|
margin-right: 10rpx;
|
|
}
|
|
|
|
.box .list .bottom .icon {
|
|
color: #333;
|
|
font-size: 26rpx;
|
|
}
|
|
</style> |