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>


目录
相关文章
|
网络协议 物联网 iOS开发
iOS - App 与外设间的通信方式
1、前言 一般 iOS 开发者做 App 开发大部分时候都是通过 Http(s) 请求跟后台服务器打交道,做一些信息展示和用户交互。很少涉及到去跟外部硬件设备连接的开发。随着近年来车联网和物联网的兴起,智能家居和智能硬件的逐步火热,越来越多的 App 被开发出来,用来跟硬件设备进行来连接,获取硬件相关信息展示或者发送指令控制硬件来提供服务。
3293 0
|
存储 安全 网络协议
阿里云SSL数字证书原理、使用、申请流程及部署方式
本文带您了解阿里云数字证书的基本原理、使用、申请流程及部署方式
|
Linux 计算机视觉 C++
【解决方案】Building wheel for opencv-python:安装卡顿的原因与解决方案
当你安装OpenCV时,命令行停在Building wheel for opencv-python (PEP 517) ... -似乎卡住了。这并非程序假死,而是其编译耗时巨大。本文将揭示原因,并提供优化安装体验的实用方法。
1625 88
|
12月前
|
新能源 5G 芯片
Ansys Electronics 全流程电磁仿真降本增效,附安装包
Ansys Electronics Suite是Ansys推出的电磁仿真与电子系统设计平台,覆盖芯片、组件到系统级的电磁、热、电路及多物理场耦合仿真,广泛应用于5G、汽车、航天等领域,助力工程师优化设计、提升性能,缩短研发周期,降低开发成本。
953 2
|
数据采集 存储 NoSQL
基于Scrapy-Redis的分布式景点数据爬取与热力图生成
基于Scrapy-Redis的分布式景点数据爬取与热力图生成
1229 67
|
测试技术
测试用例设计方法之基本路径测试法
基本路径测试法是在程序控制流图的基础上,通过分析控制构造的环路复杂性,导出基本可执行路径集合,从而设计测试用例的方法,设计出的测试用例要保证在测试中程序的语句覆盖100%,条件覆盖100%
1415 7
测试用例设计方法之基本路径测试法
汉化FC(红白机)游戏需要用到哪些技术?
这篇文章介绍了FC(红白机)游戏文本汉化的基本流程和技术知识。主要步骤包括分析游戏ROM、寻找文本字符串、学习游戏代码、修改文本、修改ROM头信息、重新映射、测试和修正。文章还提供了汉化实例,详细讲解了如何使用各种工具,如VirtuaNES Debugger、NO$NES、6502 Simulator等进行ROM分析和修改。此外,文章还介绍了如何使用汇编语言编写自定义程序以实现大字体汉化和在游戏画面切换时恢复原来的VROM。整个过程需要对6502汇编语言、NES硬件架构和ROM结构有一定的理解和编程经验。
|
UED
【打造梦幻联动!】揭秘钉钉宜搭中的单选关联选项设置与图文展示的魔术 —— 让你的表单瞬间变身智能导游!
【8月更文挑战第7天】随着企业信息化的发展,办公自动化工具如钉钉宜搭成为提高效率的关键。宜搭是一款低代码平台,支持灵活的表单设计与流程管理。以旅行社报名表为例,介绍如何实现单选字段联动图文展示:用户选择目的地后自动显示相关信息。设计上,先创建单选和图文字段,再设置联动逻辑。通过简单的后台配置即可实现动态展示效果,提升用户体验与数据准确性。
1106 0
|
开发框架 安全 网络安全
Qt5.14.2揭秘Qt与SSL/TLS的完美邂逅:打造坚不可摧的网络安全防线
Qt5.14.2揭秘Qt与SSL/TLS的完美邂逅:打造坚不可摧的网络安全防线
1074 0

热门文章

最新文章