123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- <template>
- <view class="content">
- <!-- 头部 -->
- <Header />
- <!-- 搜索框 -->
- <Search class="searchBox" />
- <!-- 头部导航 -- tab标签 -->
- <MenuTab :typeList="typeList" @changeTab="handleSelectTab" />
- <!-- 内容列表 -->
- <scroll-view style="height:calc(100% - 100rpx - (88rpx + 40rpx) - 80rpx)" :scroll-y="true"
- :refresher-enabled="true" :refresher-triggered="triggered" @scrolltolower="scrolltolower"
- @refresherrefresh="onRefresh" refresher-default-style="black">
- <!-- 需要滚动的区域 -->
- <view class="videoBox" v-for="item in videoList" :key="item.id">
- <view class="title">
- {{item.title}}
- </view>
- <view class="videoInfo" @click="goDetail(item)">
- <image class="bgImg" :src="getUrl(item.picPath)" alt=""></image>
- <view class="time">
- 04:30
- </view>
- <view class="func">
- <view class="collectCount">
- <i class="custom-icon custom-icon-collected"></i>
- 2145
- </view>
- <view class="share" @click.stop="handleShare(item)">
- <i class="custom-icon custom-icon-share"></i>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- <!-- 底部导航 -->
- <Tabbar :current-page="1" />
- <!-- 分享弹出组件 -->
- <Share :show="shareShow" @close="closeShare" />
- </view>
- </template>
- <script>
- import Header from "@/components/Header/index.vue";
- import Search from "@/components/Search/index.vue";
- import MenuTab from "@/components/MenuTab/index.vue";
- import Tabbar from "@/components/Tabbar/index.vue";
- import Share from '@/components/Share/index.vue'
- import {
- getVideoList,
- getVideoType
- } from '@/api/video.js'
- import {
- baseUrl
- } from "@/utils/apiconfig.js";
- export default {
- components: {
- Header,
- Search,
- MenuTab,
- Tabbar,
- Share
- },
- data() {
- return {
- baseUrl,
- typeList: [], // 分类
- triggered: false, // 下拉是否激活
- videoList: [],
- videoParams: {
- pageNum: 1,
- pageSize: 10,
- // checkStatus: '5', // 已发布的数据
- categoryId: '', // 分类
- },
- total: 0,
- pageNum: 1,
- pageSize: 10,
- isRequesting: false, // 是否正在请求,如果是则返回,用于节流
- shareShow: false,
- }
- },
- onLoad() {
- this.getType();
- this.getList();
- },
- methods: {
- // 获取图片完整地址
- getUrl(url) {
- return baseUrl + url
- },
- // 获取视频分类
- getType() {
- let params = {
- status: '0',
- pageNum: 1,
- pageSize: 9999,
- }
- getVideoType(params).then(res => {
- console.log(res)
- let obj = {
- id: -1,
- name: '全部'
- }
- this.typeList = [obj, ...res.rows]
- })
- },
- // 切换tab
- handleSelectTab(val) {
- // 切换tab时页面要回到顶部
- uni.pageScrollTo({
- scrollTop: 0,
- duration: 0, // 直接跳转到顶部,不需要动画
- })
- this.videoParams = {
- ...this.videoParams,
- pageNum: 1,
- categoryId: val.id === -1 ? '' : val.id,
- }
- this.getList()
- },
- // 上拉加载
- scrolltolower() {
- if (this.videoList.length < this.total) {
- this.pageNum += 1;
- // 继续请求下一页,记得保留原先数组
- this.getList();
- } else {
- uni.showToast({
- title: "没有更多了",
- icon: "none",
- duration: 2000,
- });
- return;
- }
- },
- // 自定义下拉刷新被触发
- onRefresh() {
- // 开启下拉自定义样式
- this.triggered = true;
- // 重新调用
- this.getList();
- // 1秒之后复位
- setTimeout(() => {
- this.triggered = false;
- }, 1000);
- },
- scrolltolower() {
- this.getList();
- },
- getList() {
- this.isRequesting = true
- getVideoList(this.videoParams).then(res => {
- // console.log("res:", res)
- this.videoList = [...this.videoList, ...res.rows]
- // console.log('videoList', this.videoList)
- this.total = res.total
- // this.loadingStatus = this.videoList.length >= this.total ? 'nomore' : 'loading'
- }).finally(() => this.isRequesting = false)
- },
- // 点击资讯跳转详情
- goDetail(val) {
- console.log('跳转')
- uni.navigateTo({
- url: '/pages/video/detail'
- });
- },
- // 点击弹出分享框
- handleShare(val) {
- console.log(111)
- this.shareShow = true
- },
- // 关闭分享弹出窗
- closeShare() {
- this.shareShow = false
- },
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #f9f9f9;
- font-size: 28rpx;
- height: 100%;
- // background-color: yellow;
- }
- .content {
- height: 100%;
- padding-top: 20rpx;
- .Search {
- margin: 20rpx 0;
- }
- .videoBox {
- margin: 20rpx auto;
- width: 100%;
- // display: flex;
- // justify-content: space-between;
- padding: 0 40rpx;
- .title {
- // font-size: 32rpx;
- margin-bottom: 20rpx;
- font-weight: 600;
- color: #666;
- }
- .videoInfo {
- border-radius: 30rpx;
- height: 360rpx;
- position: relative;
- .bgImg{
- position: absolute;
- z-index: -1;
- width: 100%;
- height: 100%;
- }
- .time {
- color: #fff;
- position: absolute;
- top: 20rpx;
- right: 20rpx;
- width: 100rpx;
- height: 50rpx;
- text-align: center;
- line-height: 50rpx;
- border-radius: 50rpx;
- background-color: rgba(255, 255, 255, 0.5);
- }
- .func {
- width: 100%;
- position: absolute;
- bottom: 0;
- left: 0;
- display: flex;
- justify-content: space-between;
- padding: 28rpx 40rpx;
- .collectCount,
- .share {
- height: 100rpx;
- background-color: #fff;
- text-align: center;
- line-height: 100rpx;
- border-radius: 20rpx;
- .custom-icon {
- &::before {
- background: -webkit-linear-gradient(left, #f84a1a, #f79234);
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- font-weight: bold;
- }
- }
- }
- .collectCount {
- padding: 0 20rpx;
- display: flex;
- align-items: center;
- .custom-icon {
- margin-right: 10rpx;
- }
- }
- .share {
- padding: 0 40rpx;
- .custom-icon {
- font-size: 24rpx;
- }
- }
- }
- }
- }
- }
- </style>
|