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


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 跨域访问解决方案
Feb 14 Javascript
jQuery 事件的命名空间简单了解
Nov 22 Javascript
页面按钮禁用与解除禁用的方法
Feb 19 Javascript
jquery制作弹窗提示窗口代码分享
Mar 02 Javascript
node.js中的path.sep方法使用说明
Dec 08 Javascript
JavaScript实现浅拷贝与深拷贝的方法分析
Jul 05 Javascript
jquery判断滚动条距离顶部的距离方法
Sep 05 jQuery
JavaScript对象拷贝与赋值操作实例分析
Dec 10 Javascript
原生JavaScript实现日历功能代码实例(无引用Jq)
Sep 23 Javascript
JavaScript数组及常见操作方法小结
Nov 13 Javascript
jQuery与原生JavaScript选择HTML元素集合用法对比分析
Nov 26 jQuery
2020淘宝618理想生活列车自动领喵币js脚本的代码
Jun 02 Javascript
不依任何赖第三方,单纯用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
Laravel 5框架学习之向视图传送数据(进阶篇)
2015/04/08 PHP
php实现文件上传及头像预览功能
2017/01/15 PHP
PHP切割整数工具类似微信红包金额分配的思路详解
2019/09/18 PHP
javascript 页面只自动刷新一次
2009/07/10 Javascript
javascript-表格排序(降序/反序)实现介绍(附图)
2013/05/30 Javascript
js单例模式详解实例
2013/11/21 Javascript
js获取json元素数量的方法
2015/01/27 Javascript
Jquery使用val方法读写value值
2015/05/18 Javascript
JS建造者模式基本用法实例分析
2015/06/30 Javascript
JS实现的页面自定义滚动条效果
2015/10/26 Javascript
jQuery Validate初步体验(二)
2015/12/12 Javascript
javascript滚轮控制模拟滚动条
2016/10/19 Javascript
Vue组件模板形式实现对象数组数据循环为树形结构(实例代码)
2017/07/31 Javascript
解析Vue 2.5的Diff算法
2017/11/28 Javascript
Vue下的国际化处理方法
2017/12/18 Javascript
vue实现添加与删除图书功能
2018/10/07 Javascript
用node开发并发布一个cli工具的方法步骤
2019/01/03 Javascript
小程序中英文混合排序问题解决
2019/08/02 Javascript
JavaScript中的this基本问题实例小结
2020/03/09 Javascript
解决vue项目运行npm run serve报错的问题
2020/10/26 Javascript
python迭代器的使用方法实例
2013/11/21 Python
Python中使用第三方库xlutils来追加写入Excel文件示例
2015/04/05 Python
实例解析Python中的__new__特殊方法
2016/06/02 Python
搭建Python的Django框架环境并建立和运行第一个App的教程
2016/07/02 Python
Python中不同进制的语法及转换方法分析
2016/07/27 Python
python中sys.argv函数精简概括
2018/07/08 Python
django model通过字典更新数据实例
2020/04/01 Python
Python字符串格式化f-string多种功能实现
2020/05/07 Python
使用python-Jenkins批量创建及修改jobs操作
2020/05/12 Python
广州迈达威.net面试题目
2012/03/10 面试题
互联网创业计划书写作技巧攻略
2014/03/23 职场文书
傲慢与偏见电影观后感
2015/06/10 职场文书
化工厂员工工作总结
2015/10/15 职场文书
《自己去吧》教学反思
2016/02/16 职场文书
GTX1650super好不好 gtx1650super显卡属于什么级别
2022/04/08 数码科技
速龙x4-860k处理器相当于i几
2022/04/20 数码科技