DIY可视化实现仿抖音短视频代码生成器

简介: 这篇文章介绍了如何使用DIY工具创建一个兼容uniapp和微信小程序的高性能短视频展示器,具有丝滑切换、无限数据加载和流畅滑动功能,同时支持在线定制界面和API请求。

DIY可视化实现仿抖音短视频代码生成器,仿抖音短视频兼容uniapp、微信小程序 丝滑切换视频效果,无限数据加载不卡顿,高性能滑动不卡顿超流畅,观看视频丝滑切换,页面内容自定义,无限数据加载不卡顿。


在线设计请求远程数据源,绑定数据源、视频源、标题等。所有界面上的元素都支持在线自定义。


在线请求API

<template>
  <view class="container container21094">
    <view class="flex diygw-col-24">
      <swiper :current="swipersIndex" @animationfinish="playVideoFunction" class="swiper" @change="changeSwipers" indicator-color="rgba(51, 51, 51, 0.39)" indicator-active-color="rgba(64, 64, 64, 0.93)" interval="3000" vertical="true" circular="true" style="height: 100vh">
        <swiper-item v-for="(item, index) in datas.rows" :key="index" class="diygw-swiper-item">
          <view class="diygw-swiper-item-wrap">
            <view class="flex diygw-col-24">
              <video ref="refVideo" :id="'video' + index" :controls="false" :show-center-play-btn="true" :show-play-btn="false" :show-fullscreen-btn="false" :src="item.src" style="width: 100%; height: 100vh" object-fit="contain" :title="item.title" poster=""></video>
            </view>
            <view class="flex flex-wrap diygw-col-24 flex-direction-column flex-clz">
              <view class="diygw-col-24 text-clz">
                {{ item.title }}
              </view>
              <view class="diygw-col-24">
                {{ item.remark }}
              </view>
            </view>
            <view class="flex flex-wrap diygw-col-0 flex-direction-column flex1-clz">
              <view class="flex flex-wrap diygw-col-24 flex-direction-column items-center flex2-clz">
                <image :src="item.avatar" class="image8-size diygw-image diygw-col-0 image8-clz" mode="widthFix"></image>
              </view>
              <view class="flex flex-wrap diygw-col-24 flex-direction-column items-center flex5-clz" @tap="navigateTo" data-type="tip" data-tip="触发收藏">
                <text class="flex icon3 diygw-col-0 diy-icon-star"></text>
                <view class="diygw-col-0">
                  {{ item.star }}
                </view>
              </view>
              <view class="flex flex-wrap diygw-col-24 flex-direction-column items-center flex3-clz" @tap="navigateTo" data-type="tip" data-tip="触发消息">
                <text class="flex icon1 diygw-col-0 diy-icon-message"></text>
                <view class="diygw-col-0">
                  {{ item.comment }}
                </view>
              </view>
              <view class="flex flex-wrap diygw-col-24 flex-direction-column items-center flex4-clz" @tap="navigateTo" data-type="tip" data-tip="触发分享">
                <text class="flex icon2 diygw-col-0 diy-icon-share"></text>
                <view class="diygw-col-0">
                  {{ item.share }}
                </view>
              </view>
            </view>
          </view>
        </swiper-item>
      </swiper>
    </view>
    <view class="clearfix"></view>
  </view>
</template>
 
<script>
  export default {
    data() {
      return {
        //用户全局信息
        userInfo: {},
        //页面传参
        globalOption: {},
        //自定义全局变量
        globalData: {},
        datas: {
          code: 0,
          msg: '',
          rows: [
            {
              title: '',
              remark: '',
              share: '',
              comment: '',
              star: '',
              src: '',
              avatar: ''
            }
          ]
        },
        showVideo: false,
        swipersIndex: 0
      };
    },
    onShow() {
      this.setCurrentPage(this);
    },
    onLoad(option) {
      this.setCurrentPage(this);
      if (option) {
        this.setData({
          globalOption: this.getOption(option)
        });
      }
 
      this.init();
    },
    methods: {
      async init() {
        await this.datasApi();
      },
      // 获取视频接口 API请求方法
      async datasApi(param) {
        let thiz = this;
        param = param || {};
 
        //请求地址及请求数据,可以在加载前执行上面增加自己的代码逻辑
        let http_url = 'https://php.diygw.com/video.php';
        let http_data = {};
        let http_header = {};
 
        let datas = await this.$http.post(http_url, http_data, http_header, 'json');
 
        this.datas = datas;
        this.showVideo = true;
        this.$nextTick(() => {
          this.playVideoFunction({});
        });
      },
 
      // 播放视频 自定义方法
      async playVideoFunction(param) {
        let thiz = this;
        let swipersIndex = this.swipersIndex;
        if (param.detail) {
          swipersIndex = param.detail.current;
        }
        let currentId = 'video' + swipersIndex; // 获取当前视频id
        this.videoContent = uni.createVideoContext(currentId, thiz).play();
        // 获取视频列表
        let rows = this.datas.rows;
        rows.forEach((item, index) => {
          // 获取json对象并遍历, 停止非当前视频
          if (item.src != null && item.src != '') {
            let temp = 'video' + index;
            if (temp != currentId) {
              // 暂停其余视频
              uni.createVideoContext(temp, thiz).pause(); //暂停视频播放事件
            }
          }
        });
      },
      changeSwipers(evt) {
        let swipersIndex = evt.detail.current;
        this.setData({ swipersIndex });
      }
    }
  };
</script>
 
<style lang="scss" scoped>
  .flex-clz {
    padding-top: 20rpx;
    color: #ffffff;
    left: 0rpx;
    bottom: 0rpx;
    padding-left: 20rpx;
    padding-bottom: 20rpx;
    position: absolute;
    padding-right: 20rpx;
  }
  .text-clz {
    font-weight: bold;
    font-size: 28rpx !important;
  }
  .flex1-clz {
    padding-top: 20rpx;
    color: #ffffff;
    bottom: 200rpx;
    padding-left: 20rpx;
    padding-bottom: 20rpx;
    position: absolute;
    right: 0rpx;
    padding-right: 20rpx;
  }
  .flex2-clz {
    margin-left: 10rpx;
    width: calc(100% - 10rpx - 10rpx) !important;
    margin-top: 10rpx;
    margin-bottom: 10rpx;
    margin-right: 10rpx;
  }
  .image8-clz {
    border-bottom-left-radius: 120rpx;
    overflow: hidden;
    border-top-left-radius: 120rpx;
    border-top-right-radius: 120rpx;
    border-bottom-right-radius: 120rpx;
  }
  .image8-size {
    height: 96rpx !important;
    width: 96rpx !important;
  }
  .flex5-clz {
    margin-left: 10rpx;
    width: calc(100% - 10rpx - 10rpx) !important;
    margin-top: 10rpx;
    margin-bottom: 10rpx;
    margin-right: 10rpx;
  }
  .icon3 {
    font-size: 56rpx;
  }
  .flex3-clz {
    margin-left: 10rpx;
    width: calc(100% - 10rpx - 10rpx) !important;
    margin-top: 10rpx;
    margin-bottom: 10rpx;
    margin-right: 10rpx;
  }
  .icon1 {
    font-size: 56rpx;
  }
  .flex4-clz {
    margin-left: 10rpx;
    width: calc(100% - 10rpx - 10rpx) !important;
    margin-top: 10rpx;
    margin-bottom: 10rpx;
    margin-right: 10rpx;
  }
  .icon2 {
    font-size: 56rpx;
  }
  .container21094 {
    padding-left: 0px;
    padding-right: 0px;
    background-color: #000000;
  }
</style>


目录
相关文章
UniApp 获取当前页面标题(navigationBarTitleText)
UniApp 获取当前页面标题(navigationBarTitleText)
1998 0
|
前端开发
UniApp 中的 image 属性讲解
UniApp 中的 image 属性讲解
1266 2
|
4月前
|
人工智能 自然语言处理 算法
AI企业必看:最新结果标识合规要求及规范
随着《人工智能生成合成内容标识办法》及配套标准的发布,AI企业需快速掌握政策要求以确保合规运营。该办法明确指出,利用AI生成的内容(如文本、图片、音频、视频等)需通过显性标识(如“AI生成”字样)或隐性标识(如元数据、数字水印)进行标注。内容传播平台也需核验标识并提醒用户内容性质。此外,应用程序分发平台在审核时需确认是否提供AI生成服务及相关标识材料。对于AI企业而言,合规已成为必修课,需重点关注标识的规范性和溯源能力,以应对即将到来的监管要求。
|
7月前
|
供应链 JavaScript 前端开发
通过array.every()实现数据验证、权限检查和一致性检查;js数组元素检查的方法,every()的使用详解,array.some与array.every的区别(附实际应用代码)
array.every()可以用来数据验证、权限检查、一致性检查等数据校验工作,核心在于利用其短路机制,速度更快,节约性能。 博客不应该只有代码和解决方案,重点应该在于给出解决方案的同时分享思维模式,只有思维才能可持续地解决问题,只有思维才是真正值得学习和分享的核心要素。如果这篇博客能给您带来一点帮助,麻烦您点个赞支持一下,还可以收藏起来以备不时之需,有疑问和错误欢迎在评论区指出~
|
12月前
|
SQL 数据库 索引
SQL中COUNT函数结合条件使用的技巧与方法
在SQL查询中,COUNT函数是一个非常常用的聚合函数,用于计算表中满足特定条件的记录数
2095 5
|
人工智能
AI绘画,Stable Diffusion如何使用中文简体包,黑色页面切换参数http://127.0.0.1:7860/?__theme=dark 两个__,中文包下载和安装
AI绘画,Stable Diffusion如何使用中文简体包,黑色页面切换参数http://127.0.0.1:7860/?__theme=dark 两个__,中文包下载和安装
|
12月前
|
监控 Serverless 云计算
探索Serverless架构:开发的未来趋势
【10月更文挑战第5天】Serverless架构,即无服务器架构,正逐渐成为云计算领域的热点。它允许开发者构建和运行应用程序而无需管理底层服务器。本文介绍了Serverless架构的基本概念、核心优势及挑战,并展示了其在事件驱动编程、微服务架构和数据流处理等场景中的应用。通过优化冷启动、使用外部存储等实战技巧,开发者可以更好地利用Serverless架构提升开发效率和应用性能。随着技术的成熟,Serverless将在未来软件开发中扮演重要角色。
|
12月前
|
缓存 负载均衡 Java
谈谈springboot 微服务上下线动态感知
【10月更文挑战第3天】微服务上下线动态感知是微服务架构中一个非常重要的功能,它允许服务注册中心能够实时地感知到服务的上线和下线,从而确保系统的可用性和负载均衡。
143 1
|
SQL 网络安全 数据库
实时数仓 Hologres操作报错合集之如何解决错误代码SERVER_INTERNAL ERROR
实时数仓Hologres是阿里云推出的一款高性能、实时分析的数据库服务,专为大数据分析和复杂查询场景设计。使用Hologres,企业能够打破传统数据仓库的延迟瓶颈,实现数据到决策的无缝衔接,加速业务创新和响应速度。以下是Hologres产品的一些典型使用场景合集。
|
缓存 监控 安全
使用GraphQL构建高效数据查询:技术深度剖析与实践
【8月更文挑战第11天】GraphQL以其强大的灵活性和高效性,为现代Web开发提供了一种全新的数据查询和传输方式。通过合理使用GraphQL的核心特性和策略,开发者可以构建出高效、灵活且易于维护的API。然而,GraphQL的成功应用也需要开发者在Schema设计、查询优化、客户端缓存以及安全性等方面进行深入的思考和实践。希望本文能够为开发者在使用GraphQL构建高效数据查询方面提供一些有益的参考和启示。