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>


目录
相关文章
|
小程序 JavaScript 前端开发
微信小程序 |从零实现酷炫纸质翻页效果
微信小程序 |从零实现酷炫纸质翻页效果
1926 0
微信小程序 |从零实现酷炫纸质翻页效果
|
数据采集 小程序 Python
搞定短视频!批量下载快手视频(附源码)
相信大家都接触了短视频平台,比如某音、某手等平台,竟然大家都熟悉了,那么今天辰哥分享的技术是:在某手上搜索视频,并实现下载!
1166 0
|
存储 缓存 编解码
Web端短视频编辑器的设计与实现 - 像做PPT一样做视频
对于视频的生产,一般的方案是交由专业机构去创作,但这将花费很多预算,如果我们能提供一个工具,基于知识的通用结构沉淀一些视频模版,让用户快速创作出视频知识内容岂不美哉?让想法再奔放些,如果我们能直接从知识库中抽取结构化的知识内容直接生成视频或是半成品视频,用户只需要稍作调整就能发布,这想想就很酷吧?是的,小蜜视频创作工具我就是想做这样一件事情。本篇分享来自阿里巴巴前端工程师李志成(敦固)在第十六届D2前端技术论坛的分享。
3192 0
Web端短视频编辑器的设计与实现 - 像做PPT一样做视频
|
3月前
|
小程序
婚纱摄影店铺微信小程序源码
婚纱摄影店铺微信小程序源码
38 2
|
2月前
|
开发工具 开发者
如何用 CocosCreator 对接抖音小游戏的侧边栏复访
最近小游戏的软著下来了,用 CocosCreator 做的游戏也完成了 1.0 版本。而当我打包成抖音小游戏进行提交时,还没到初审就给拒了,因为还有一个机审,机器检测到代码中没有接入 “侧边栏复访功能”。这个我还真不知道,那只能去官方看文档了,位置是小游戏开发文档 -> 指南 -> 开放能力 -> 侧边栏能力。
39 2
|
4月前
|
搜索推荐 小程序 前端开发
微信小程序|美食推荐系统的设计与实现
微信小程序|美食推荐系统的设计与实现
|
4月前
|
小程序 前端开发 JavaScript
微信小程序|电影交流平台小程序的设计与实现
微信小程序|电影交流平台小程序的设计与实现
直播源码app开发技术之特效功能的实现
想必说到这里大家都明白我说的这一个情况是直播源码app平台的哪一个常见的功能了,没错,这个功能就是直播源码app平台的特效功能,这个功能对于开发直播源码app平台是非常重要的,废话不多说,下面我就为大家分享直播源码app开发技术特效功能的实现。
直播源码app开发技术之特效功能的实现
|
小程序
微信小程序项目实例——图片处理小工具(自制低配版美图秀秀)
微信小程序项目实例——图片处理小工具(自制低配版美图秀秀)