231 lines
5.3 KiB
Vue
231 lines
5.3 KiB
Vue
<template>
|
|
<view class="customBox">
|
|
<scroll-view scroll-y="true" class="contentBox" @scrolltolower="scorllBottom" :scroll-top="topNum">
|
|
<view class="content">
|
|
<view class="left">
|
|
<template v-for="(item, index) in list" :key="item.id">
|
|
<view class="row" @click="toPage(item.id)" v-if="index % 2 == 0">
|
|
<view class="img">
|
|
<image :src="item.explain_video + '?x-oss-process=video/snapshot,t_1000,m_fast'" mode="widthFix"></image>
|
|
<view class="icon"><up-icon name="play-right-fill" size="14" color="#fff" /></view>
|
|
</view>
|
|
<view class="desc">{{item.description}}</view>
|
|
<view class="num">{{item.visitor}}人看过 | {{item.order_count}}人跟团</view>
|
|
</view>
|
|
</template>
|
|
</view>
|
|
<view class="left">
|
|
<template v-for="(item, index) in list" :key="item.id">
|
|
<view class="row" @click="toPage(item.id)" v-if="index % 2 == 1">
|
|
<view class="img">
|
|
<image :src="item.explain_video + '?x-oss-process=video/snapshot,t_1000,m_fast'" mode="widthFix"></image>
|
|
<view class="icon"><up-icon name="play-right-fill" size="14" color="#fff" /></view>
|
|
</view>
|
|
<view class="desc">{{item.description}}</view>
|
|
<view class="num">{{item.visitor}}人看过 | {{item.order_count}}人跟团</view>
|
|
</view>
|
|
</template>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="noMore" v-if="list.length && !has_more && !loading">— 没有更多了 —</view>
|
|
<view v-if="!list.length && !loading">
|
|
<up-empty mode="list" icon="https://ct-upimg.yx090.com/g.ii090/images/sprite/empty/list.png" text="暂无数据"></up-empty>
|
|
</view>
|
|
<view v-if="loading" class="loadbox">
|
|
<up-loading-icon text="加载中..." textSize="14"></up-loading-icon>
|
|
</view>
|
|
</scroll-view>
|
|
|
|
<!-- 返回顶部 -->
|
|
<view @click="handleTop" v-if="showTop" class="top">
|
|
<up-icon name="arrow-upward" color="#000" size="24" />
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { ref, reactive, toRefs, onMounted } from 'vue'
|
|
import { get } from '@/api/request.js'
|
|
|
|
export default {
|
|
options: {
|
|
styleIsolation: 'shared'
|
|
},
|
|
props: {
|
|
},
|
|
setup(props, context) {
|
|
const data = reactive({
|
|
topNum: 0,
|
|
showTop: false,
|
|
last_id: 0,
|
|
loading: true,
|
|
has_more: true,
|
|
list: []
|
|
})
|
|
|
|
async function getFetchList() {
|
|
data.loading = true
|
|
uni.showLoading({
|
|
title: '加载中...',
|
|
mask: true
|
|
})
|
|
let params = {
|
|
last_id: data.last_id,
|
|
pageSize: 20
|
|
}
|
|
await get('/api/app/goods/videos', params).then((res) => {
|
|
data.list = data.list.concat(res.data)
|
|
data.last_id = res.last_id
|
|
data.has_more = res.has_more
|
|
data.loading = false
|
|
uni.hideLoading()
|
|
}).catch(() => {
|
|
data.loading = false
|
|
})
|
|
}
|
|
|
|
function scorllBottom() {
|
|
if (data.has_more && !data.loading) {
|
|
getFetchList()
|
|
}
|
|
}
|
|
|
|
function toPage(id) {
|
|
uni.navigateTo({
|
|
url: '/pages/groups/video?id=' + id
|
|
})
|
|
}
|
|
|
|
const handleTop = () => {
|
|
data.topNum = data.topNum == 0 ? 0.1 : 0
|
|
}
|
|
|
|
onMounted(() => {
|
|
getFetchList()
|
|
})
|
|
|
|
return {
|
|
...toRefs(data),
|
|
getFetchList,
|
|
scorllBottom,
|
|
handleTop,
|
|
toPage
|
|
}
|
|
|
|
},
|
|
onPageScroll(e) {
|
|
if (e.scrollTop > 300) {
|
|
this.showTop = true
|
|
} else {
|
|
this.showTop = false
|
|
}
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.customBox{
|
|
padding: 0 0 1rpx;
|
|
height: calc(100vh - 242rpx);
|
|
box-sizing: border-box;
|
|
.contentBox{
|
|
height: 100%;
|
|
overflow-y: auto;
|
|
position: relative;
|
|
}
|
|
.content{
|
|
padding: 24rpx 1.5%;
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
.left{
|
|
width: 50%;
|
|
padding: 0 1.5%;
|
|
box-sizing: border-box;
|
|
}
|
|
.row{
|
|
background-color: #fff;
|
|
border-radius: 10rpx;
|
|
width: 100%;
|
|
margin-bottom: 24rpx;
|
|
overflow: hidden;
|
|
.img{
|
|
width: 100%;
|
|
position: relative;
|
|
image{
|
|
width: 100%;
|
|
height: auto;
|
|
}
|
|
.icon{
|
|
position: absolute;
|
|
top: 20rpx;
|
|
right: 20rpx;
|
|
background-color: rgba(0,0,0,0.5);
|
|
border-radius: 50%;
|
|
width: 26px;
|
|
height: 26px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
}
|
|
.desc{
|
|
font-size: 28rpx;
|
|
overflow: hidden !important;
|
|
text-overflow: ellipsis !important;
|
|
display: -webkit-box !important;
|
|
-webkit-line-clamp: 2 !important;
|
|
-webkit-box-orient: vertical !important;
|
|
white-space: break-spaces !important;
|
|
padding: 0 20rpx;
|
|
margin: 10rpx 0;
|
|
}
|
|
.num{
|
|
font-size: 24rpx;
|
|
padding: 10rpx 20rpx 20rpx;
|
|
color: #999;
|
|
}
|
|
}
|
|
}
|
|
.noMore{
|
|
text-align: center;
|
|
font-size: 24rpx;
|
|
color: #999;
|
|
margin: auto;
|
|
padding: 0 0 60rpx;
|
|
width: 100%;
|
|
}
|
|
.noMsg{
|
|
width: 100%;
|
|
height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
flex-direction: column;
|
|
padding-top: 20%;
|
|
box-sizing: border-box;
|
|
font-size: 26rpx;
|
|
color: #9D9D9D;
|
|
}
|
|
.loadbox{
|
|
padding: 30rpx 0;
|
|
text-align: center;
|
|
color: #666;
|
|
}
|
|
.top {
|
|
position: fixed;
|
|
bottom: 15%;
|
|
right: 5%;
|
|
background: #fff;
|
|
width: 80rpx;
|
|
height: 80rpx;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.2);
|
|
z-index: 2;
|
|
}
|
|
}
|
|
</style>
|