微信小程序实现翻牌抽奖动画


Posted in Javascript onSeptember 21, 2020

本文实例为大家分享了微信小程序实现翻牌抽奖的具体代码,供大家参考,具体内容如下

效果图如下所示

微信小程序实现翻牌抽奖动画

这里做的比较简陋,就花了一点时间实现了翻牌抽奖效果,提供思路

.wxml

<view class="button" bindtap="again">重新翻牌</view>
<view class="curin-index">
 <view bindtap="{{whether?'':'tamin'}}" wx:for="{{9}}" wx:key="index" data-index="{{index+1}}" class="currin {{really == index+1?'animt':''}} {{really != index+1 && surplus?'animt':''}} {{really == ''?'cinton'+(index+1):''}}" style="{{really == index+1 && implement > 1?'background-image: linear-gradient(45deg, #f43f3b, #ec008c);':''}}{{really != index+1 && surplus && implement > 2?'background-image: linear-gradient(45deg, #39b54a, #8dc63f);':''}}">
  {{really == index+1?flop:''}}{{really != index+1 && really != ''?biutin:''}}{{really == ''?'点击翻牌':''}}
 </view>
</view>

.wxss

view{
 box-sizing: border-box;
}
.button{
 width: 40%;
 height: 80rpx;
 line-height: 80rpx;
 background-color: #fadbd9;
 color: #e54d42;
 text-align: center;
 border-radius: 10rpx;
 margin: 30rpx 30%;
 float: left;
 position: relative;
}
.curin-index{
 width: 100%;
 float: left;
}
.currin{
 margin-left: 4%;
 margin-top: 50rpx;
 width: 28%;
 float: left;
 background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
 color: #fff;
 text-align: center;
 height: 200rpx;
 line-height: 200rpx;
 border-radius: 10rpx;
 position: relative;
}
.currin::before {
 content: "";
 display: block;
 background: inherit;
 filter: blur(10rpx);
 position: absolute;
 width: 100%;
 height: 100%;
 top: 10rpx;
 left: 10rpx;
 z-index: -1;
 opacity: 0.4;
 transform-origin: 0 0;
 border-radius: inherit;
 transform: scale(1, 1);
}
.cinton1{
 animation: cinton1 alternate linear 2 1s;
}
@keyframes cinton1{
 from {
  top: 0;
  left: 0;
 }
 to {
  top: 230rpx;
  left: 230rpx;
 }
}
.cinton2{
 animation: cinton2 alternate linear 2 1s;
}
@keyframes cinton2{
 from {
  top: 0;
  left: 0;
 }
 to {
  top: 230rpx;
  left: 0rpx;
 }
}
.cinton3{
 animation: cinton3 alternate linear 2 1s;
}
@keyframes cinton3{
 from {
  top: 0;
  left: 0;
 }
 to {
  top: 230rpx;
  left: -230rpx;
 }
}
.cinton4{
 animation: cinton4 alternate linear 2 1s;
}
@keyframes cinton4{
 from {
  top: 0;
  left: 0;
 }
 to {
  top: 0rpx;
  left: 230rpx;
 }
}
.cinton6{
 animation: cinton6 alternate linear 2 1s;
}
@keyframes cinton6{
 from {
  top: 0;
  left: 0;
 }
 to {
  top: 0rpx;
  left: -230rpx;
 }
}
.cinton7{
 animation: cinton7 alternate linear 2 1s;
}
@keyframes cinton7{
 from {
  top: 0;
  left: 0;
 }
 to {
  top: -230rpx;
  left: 230rpx;
 }
}
.cinton8{
 animation: cinton8 alternate linear 2 1s;
}
@keyframes cinton8{
 from {
  top: 0;
  left: 0;
 }
 to {
  top: -230rpx;
  left: 0rpx;
 }
}
.cinton9{
 animation: cinton9 alternate linear 2 1s;
}
@keyframes cinton9{
 from {
  top: 0;
  left: 0;
 }
 to {
  top: -230rpx;
  left: -230rpx;
 }
}
.animt{
 animation: fanzhuan 1.2s;
}
@keyframes fanzhuan{
 0% {
  transform: perspective(150px) rotateY(0deg);
 } 
 50% {
  transform: perspective(150px) rotateY(0deg);
 } 
 100% {
  transform: perspective(150px) rotateY(179.9deg);
 }
}

.js

Page({
 data: {
  whether: false,
  flop:'点击翻牌',
  really:'',
  implement: 0,
  surplus:false,
  biutin:'点击翻牌',
 }, 
 again:function(e){
  if (this.data.implement == 3 || this.data.implement == 0){
   this.setData({
    whether: false,
    flop: '点击翻牌',
    really: '',
    implement: 0,
    surplus: false,
    biutin: '点击翻牌',
   })
  }else{
   wx.showToast({
    title: '正在执行抽奖中...',
    icon: 'none',
    duration: 2000
   })
   return false
  }
 },
 tamin:function(e){
  let that = this
  let index = e.currentTarget.dataset.index
  that.setData({
   whether:true,
   really: index,
   implement:1,
  })
  setTimeout(function () {
   that.setData({
    flop: '',
   })
  }, 500)
  setTimeout(function () {
   that.setData({
    flop:'有奖品',
    surplus:true,
    implement: 2,
   })
  }, 1200)
  setTimeout(function () {
   that.setData({
    biutin: '',
   })
  }, 1700)
  setTimeout(function () {
   that.setData({
    biutin: '没有奖品',
    implement:3,
   })
  }, 2500)
 }
})

为大家推荐现在关注度比较高的微信小程序教程一篇:《微信小程序开发教程》小编为大家精心整理的,希望喜欢。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Javascript 相关文章推荐
一个简单的JavaScript数据缓存系统实现代码
Oct 24 Javascript
javascript之typeof、instanceof操作符使用探讨
May 19 Javascript
浏览器的JavaScript引擎的识别方法
Oct 20 Javascript
Javascript aop(面向切面编程)之around(环绕)分析
May 01 Javascript
js实现分割上传大文件
Mar 09 Javascript
神奇!js+CSS+DIV实现文字颜色渐变效果
Mar 16 Javascript
jQuery制作input提示内容(兼容IE8以上)
Jul 05 jQuery
使用AngularJS编写多选按钮选中时触发指定方法的指令代码详解
Jul 24 Javascript
Bootstrap实现下拉菜单多级联动
Nov 23 Javascript
ionic2中使用自动生成器的方法
Mar 04 Javascript
JS实现横向轮播图(中级版)
Jan 18 Javascript
详解vue实现坐标拾取器功能示例
Nov 18 Vue.js
不依任何赖第三方,单纯用vue实现Tree 树形控件的案例
Sep 21 #Javascript
微信小程序实现转盘抽奖
Sep 21 #Javascript
结合axios对项目中的api请求进行封装操作
Sep 21 #Javascript
微信小程序实现打卡签到页面
Sep 21 #Javascript
微信小程序实现签到弹窗动画
Sep 21 #Javascript
解决vue prop传值default属性如何使用,为何不生效的问题
Sep 21 #Javascript
微信小程序实现日历签到
Sep 21 #Javascript
You might like
改造一台复古桌面收音机
2021/03/02 无线电
PHP开发中四种查询返回结果分析
2011/01/02 PHP
php通过sort()函数给数组排序的方法
2015/03/18 PHP
php中mysql操作buffer用法详解
2015/03/19 PHP
JavaScript 节点操作 以及DOMDocument属性和方法
2007/12/06 Javascript
JQUERY复选框CHECKBOX全选,取消全选
2008/08/30 Javascript
JavaScript 设计模式学习 Singleton
2009/07/27 Javascript
一个简单的js动画效果代码
2010/07/20 Javascript
javascript 窗口加载蒙板 内嵌网页内容
2010/11/19 Javascript
Tab切换组件(选项卡功能)实例代码
2013/11/21 Javascript
jquery实现点击其他区域时隐藏下拉div和遮罩层的方法
2015/12/23 Javascript
javascript中不易分清的slice,splice和split三个函数
2016/03/29 Javascript
简单实现js悬浮导航效果
2017/02/05 Javascript
[01:05:40]VG vs Newbee 2018国际邀请赛小组赛BO2 第二场 8.17
2018/08/20 DOTA
在Python3中初学者应会的一些基本的提升效率的小技巧
2015/03/31 Python
详解在Python的Django框架中创建模板库的方法
2015/07/20 Python
Python中用psycopg2模块操作PostgreSQL方法
2017/11/28 Python
python中正则表达式与模式匹配
2019/05/07 Python
解决Numpy中sum函数求和结果维度的问题
2019/12/06 Python
python3+openCV 获取图片中文本区域的最小外接矩形实例
2020/06/02 Python
PyCharm2019 安装和配置教程详解附激活码
2020/07/31 Python
Tostadora意大利:定制T恤
2019/04/08 全球购物
Clarks其乐鞋荷兰官网:Clarks荷兰
2019/07/05 全球购物
美国价格实惠的在线眼镜网站:Zeelool
2020/12/25 全球购物
南京软件公司的.net程序员笔试题
2014/08/31 面试题
物业经理求职自我评价
2013/09/22 职场文书
公司人力资源的自我评价
2014/01/02 职场文书
高一生物教学反思
2014/01/17 职场文书
宣传保护环境的公益广告词
2014/03/13 职场文书
大学生安全责任书
2014/07/25 职场文书
2014年青年教师工作总结
2014/12/17 职场文书
中学生自我评价2015
2015/03/03 职场文书
思想工作总结范文
2015/08/12 职场文书
如何利用Python实现n*n螺旋矩阵
2022/01/18 Python
python 远程执行命令的详细代码
2022/02/15 Python
搭建Yolov5服务器
2022/04/30 Servers