小程序?qū)崿F(xiàn)抽獎(jiǎng)動(dòng)畫
本文實(shí)例為大家分享了小程序?qū)崿F(xiàn)抽獎(jiǎng)動(dòng)畫展示的具體代碼,供大家參考,具體內(nèi)容如下
所有的抽獎(jiǎng)都是由后臺(tái)計(jì)算后得到的,前臺(tái)只做動(dòng)畫展示
<view class='top-banner center'> <!-- 輪播展示中獎(jiǎng)信息區(qū)域 --> <swiper autoplay="{{true}}" interval="{{1500}}" circular="{{true}}" vertical='{{true}}'> <block wx:for="{{prizeInfo}}" wx:key="index"> <swiper-item> <view>{{item.name}}{{item.prize}}</view> </swiper-item> </block> </swiper> </view> <!-- 輪播結(jié)束 抽獎(jiǎng)轉(zhuǎn)盤 --> <view class='turntable' bindtap='doLottery'> <image class='turntable-bj' style="transition:all {{time?time:'3s ease-in'}}; transform:rotate({{transformDeg + 'deg'}}) " src='../../../img/turntable.png'></image> <image class='arrow' src='../../../img/arrow.png'> </image> </view>
js:
const app = getApp(); var index = { data:{ prizeInfo:[ { name:'qiphon', prize:'5元' }, { name:'qiphon23423', prize:'53元' }, { name:'qipsdfhon', prize:'35元' } ], transformDeg:0, // 旋轉(zhuǎn)角度 transition:'all 3s cubic-bezier(0.005, 1.340, 1.000, 0.865)', time:'999s' }, onLoad(opt){ console.log(opt) }, onReady(){ this.animation = wx.createAnimation({ timingFunction:'esse-in-out', duration:2000 }); this.animationDeg = 360; }, loadCoupons(){ // 加載獲獎(jiǎng)信息 }, doLottery(){ // 抽獎(jiǎng) var _this = this; if(this.aniRotate)return; this.aniRotate = true; this.setData({ transformDeg:this.data.transformDeg + 360*900, time:'100s ease' }) setTimeout(function(){ console.log('請求完成'+_this.data.transformDeg) // setTimeout 模擬ajax請求 _this.setData({ transformDeg:-360*4, time:'3s ease' }) setTimeout(function(){ console.log('返回結(jié)果'+_this.data.transformDeg) _this.setData({ transformDeg:360*2 + 0, time:'6s cubic-bezier(0.000, 0.765, 0.000, 0.955)' }) setTimeout(function(){ _this.aniRotate = false; wx.showModal({ title:'中獎(jiǎng)信息', content:'恭喜獲得獎(jiǎng)品' }) },6000) },2000) },3000) }, } Page(index);
css:
.top-banner{ background: #fff; padding:20rpx; } .top-banner swiper{ height: 50rpx; line-height: 50rpx; } /* 轉(zhuǎn)盤 */ .turntable{ position: relative; width: 100%; height: 530rpx; } .turntable-bj{ display: block; margin:0 auto; width:600rpx; height: 530rpx; } .turntable .arrow{ position: absolute; top:0; right:0; left:0; bottom:110rpx; margin:auto; width:93.5rpx; height: 212rpx; }
想要學(xué)習(xí)更多關(guān)于抽獎(jiǎng)功能的實(shí)現(xiàn),請參考此專題:抽獎(jiǎng)功能
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 微信小程序?qū)崿F(xiàn)九宮格抽獎(jiǎng)
- 微信小程序?qū)崿F(xiàn)多宮格抽獎(jiǎng)活動(dòng)
- 微信小程序 搖一搖抽獎(jiǎng)簡單實(shí)例實(shí)現(xiàn)代碼
- 微信小程序開發(fā)之大轉(zhuǎn)盤 仿天貓超市抽獎(jiǎng)實(shí)例
- jquery 抽獎(jiǎng)小程序?qū)崿F(xiàn)代碼
- 基于PHP實(shí)現(xiàn)簡單的隨機(jī)抽獎(jiǎng)小程序
- 基于JavaScript實(shí)現(xiàn)簡單的隨機(jī)抽獎(jiǎng)小程序
- 基于C#實(shí)現(xiàn)簡單的隨機(jī)抽獎(jiǎng)小程序
- php抽獎(jiǎng)小程序的實(shí)現(xiàn)代碼
- 大轉(zhuǎn)盤抽獎(jiǎng)小程序版 轉(zhuǎn)盤抽獎(jiǎng)網(wǎng)頁版
相關(guān)文章
網(wǎng)絡(luò)之美 JavaScript中Get和Set訪問器的實(shí)現(xiàn)代碼
前兩天IE9 Beta版發(fā)布了,對于從事Web開發(fā)的朋友們來說真是個(gè)好消息啊,希望將來有一天各個(gè)瀏覽器都能遵循統(tǒng)一的標(biāo)準(zhǔn)。今天要和大家分享的是JavaScript中的Get和Set訪問器,和C#中的訪問器非常相似。2010-09-09詳解Web使用webpack構(gòu)建前端項(xiàng)目
本篇文章主要介紹了詳解Web使用webpack構(gòu)建前端項(xiàng)目,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09JS使用oumousemove和oumouseout動(dòng)態(tài)改變圖片顯示的方法
這篇文章主要介紹了JS使用oumousemove和oumouseout動(dòng)態(tài)改變圖片顯示的方法,涉及javascript鼠標(biāo)事件及圖片操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03JavaScript和ActionScript的交互實(shí)現(xiàn)代碼
JavaScript和ActionScript的交互實(shí)現(xiàn)代碼,需要js與flash交互的朋友可以學(xué)習(xí)下。2010-08-08javascript中不易分清的slice,splice和split三個(gè)函數(shù)
這篇文章主要為大家詳細(xì)介紹了javascript中不易分清的slice,splice和split三個(gè)函數(shù),感興趣的小伙伴們可以參考一下2016-03-03JavaScript聲明函數(shù)的5種方法小結(jié)
本文主要介紹了JavaScript聲明函數(shù)的5種方法小結(jié),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-02-02