小程序模仿抖音

效果图:

 

一开始思路是使用swiper来实现上下滑的效果,并且在swiper-item里嵌套video,但是一直有莫名其妙的问题,后来在小程序API文档里也看到video无法在swiper中使用。转换思路改成监听用户上下滑,view上绑定如下事件

bindtouchstart="touchstart" bindtouchmove="touchmove" bindtouchend="touchend"

来判断用户是否上下滑

html部分:

<!--pages/index/index.wxml-->

 

<!-- start 视频区域 -->

<view class='middle' bindtouchstart="touchstart" bindtouchmove="touchmove" bindtouchend="touchend">

<view class='videoBox' style='height:100%;width:100%'>

<video style='height:100%;width:100%' src="{ {curvideo}}" controls='false' autoplay="true" id='video0' loop="true" bindtap='pauseVideo' bindtimeupdate="videoProgress">

<!-- start 导航部分 -->

<cover-view class='navBtns'>

<block wx:for="{ {typeList}}" wx:for-item="item" wx:for-index="index" >

<cover-view class='{ {index==typeChooseIndex?"active":""}} typeButton' data-index='{ {index}}' catchtap='styleClick'>

{ {item.name}}</cover-view>

</block>

<cover-view class='colorBtns'>

<block wx:for="{ {colorList}}" wx:for-item="item" wx:for-index="index" >

<cover-view class='{ {index==colorChooseIndex?"active":""}} colorbutton' data-index="{ {index}}" catchtap='colorClick' >{ {item.colorName}}</cover-view>

</block>

</cover-view>

</cover-view>

<!-- end 导航部分 -->

<!-- start 详情区 -->

<cover-view class='detail'>

<!-- start 左侧详情区 -->

<cover-view class='detailLeft'>

<cover-view class='catCon'>

<cover-view>#品种:{ {curCat.typeName}}</cover-view>

<cover-view>#颜色:{ {curCat.colorName}}</cover-view>

</cover-view>

<block wx:if="{ {curCat.saleStatus==1}}">

<button class='reserve' data-catid="{ {curCat.id}}" catchtap='goreserve'>继续支付</button>

</block>

<block wx:if="{ {curCat.saleStatus==2}}">

<button class='reserve' data-catid="{ {curCat.id}}" catchtap='goreserve'>立即预订</button>

</block>

<block wx:else>

<button class='sold'>已出售</button>

</block>

</cover-view>

<!-- end 左侧详情区 -->

<!-- start 右侧love分享区 -->

<cover-view class='detailRight'>

<cover-view class='detailRightCon'>

<cover-view class='loveCon { {curCat.likeStatus==1?"active":""}}'

catchtap='likeEnt'><!-- 点击喜欢 active-->

<cover-image src='../images/love1.png'></cover-image>

<cover-image src='../images/love2.png'></cover-image>

</cover-view>

<cover-view class='loveNum'>{ {curCat.likeNum}}</cover-view>

 

<cover-view class='shareCon'>

<cover-image src='../images/shareIcon.png'></cover-image>

<button open-type='share' title="袖虎宠物" class='shareBtn'>转发</button>

</cover-view>

<cover-view class='shareNum'>{ {curCat.shareNum}}</cover-view>

</cover-view>

</cover-view>

<!-- end 右侧love分享区 -->

<!-- start 底部导航 -->

<cover-view class='bottom clear' catchtap=''>

<cover-view class='vProgress' style='width:{ {vProgress}}%'></cover-view>

<cover-view class='bottomBorder'></cover-view>

<button class='active'>首页</button>

<cover-view class='space'></cover-view></

  • 6
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 82
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 82
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值