前端小程序

这个提交包含在:
可乐加冰
2026-09-14 17:24:53 +08:00
父节点 bb69a43a0f
当前提交 019630f12c
共有 2629 个文件被更改,包括 403657 次插入 和 0 次删除

查看文件

@@ -0,0 +1,163 @@
<template>
<view>
<view class="video">
<video id="video" @play="handlePlayVideo" :title="detail.title" :src="$IMG_URL + detail.video"
controls></video>
</view>
<view class="content">
<view class="title">{{detail.title}}</view>
<view class="views">
<view class="left">
<view class="icon">
<image :src="$IMG_URL + '/assets/img/views_num.png'" mode=""></image>
<view class="num">{{detail.views}}</view>
</view>
<view class="icon">
<image :src="$IMG_URL + '/assets/img/play_num.png'" mode=""></image>
<view class="num">{{detail.play_num}}</view>
</view>
</view>
<view class="right">
{{detail.create_time}}
</view>
</view>
<view class="detail">
<view class="detail-title">
<image :src="$IMG_URL + '/assets/img/detail.png'" mode=""></image>
<view class="detail-text">视频详细介绍</view>
</view>
</view>
<view class="box" v-if="detail.content">
<u-parse :html="detail.content"></u-parse>
</view>
</view>
</view>
</template>
<script>
export default {
components: {},
data() {
return {
detail: [],
isPlayNum: false
};
},
computed: {},
onLoad(o) {
this.getVideoDetail(o.id);
},
methods: {
// 获取视频详情
getVideoDetail(id) {
uni.showLoading({
title: '正在加载中...'
})
this.$http('video.detail', {
id
}).then(res => {
uni.hideLoading();
this.detail = res.data;
});
},
handlePlayVideo(e) {
// 统计播放量
if (!this.isPlayNum) {
this.$http('video.playNum', {
id: this.detail.id
}).then(res => {
this.isPlayNum = true;
this.$set(this.detail, 'play_num', parseInt(this.detail.play_num) + 1);
});
}
},
}
};
</script>
<style>
page {
background: #fff;
}
._image {
display: block;
width: 100%;
height: 360px;
margin-top: -360px;
opacity: 0;
}
#video {
width: 100%;
height: 570rpx;
}
.content {
margin: 20rpx;
}
.content .title {
font-size: 30rpx;
font-weight: bold;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
margin-bottom: 30rpx;
}
.content .views {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 50rpx;
}
.content .left {
display: flex;
align-items: center;
}
.content .left .icon {
display: flex;
align-items: center;
margin-right: 30rpx;
}
.content .left .icon image {
width: 42rpx;
height: 42rpx;
margin-right: 10rpx;
}
.content .left .icon {
color: #333;
font-size: 26rpx;
}
.content .right {
color: #a9a7a7;
font-size: 26rpx;
}
.detail {
margin: 30rpx 0;
}
.detail .detail-title {
display: flex;
align-items: center;
}
.detail .detail-title image {
width: 48rpx;
height: 48rpx;
margin-right: 10rpx;
}
.detail .detail-title .detail-text {
font-size: 32rpx;
font-weight: bold;
}
</style>

查看文件

@@ -0,0 +1,169 @@
<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>