基本信息
源码名称:微信小程序大转盘 示例源码
源码大小:0.02M
文件格式:.zip
开发语言:js
更新时间:2018-08-14
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
大转盘的背景图可以换成 具体的奖项图片
大转盘的背景图可以换成 具体的奖项图片
//index.js //获取应用实例 var app = getApp() var cxt_arc; var timer; var n=1; var timer; var which = 1;//中奖项 var luck = ["5积分", "5金币", "10积分", "10金币", "谢谢参与", "20金币"];//定义奖项 Page({ data: { animationData:{},//动画 isclick: "start",//按钮事件 hiddenModal:true,//弹框是否隐藏 detail: "恭喜您获得" luck[which-1]//弹框内容 }, //事件处理函数 bindViewTap: function() { wx.navigateTo({ url: '../logs/logs' }) }, onLoad: function () { if (app.globalData.userInfo) { this.setData({ userInfo: app.globalData.userInfo, hasUserInfo: true }) } else if (this.data.canIUse){ // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 // 所以此处加入 callback 以防止这种情况 app.userInfoReadyCallback = res => { this.setData({ userInfo: res.userInfo, hasUserInfo: true }) } } else { // 在没有 open-type=getUserInfo 版本的兼容处理 wx.getUserInfo({ success: res => { app.globalData.userInfo = res.userInfo this.setData({ userInfo: res.userInfo, hasUserInfo: true }) } }) } }, getUserInfo: function(e) { console.log(e) app.globalData.userInfo = e.detail.userInfo this.setData({ userInfo: e.detail.userInfo, hasUserInfo: true }) }, start: function (e) { var _this = this; n=1; this.setData({ isclick: "stop" }) reset.call(_this); timer = setInterval(function () { //开始旋转 star.call(_this); // n ; } , 300); //启动动画 function star() { console.log("开始动画.....") var animation = wx.createAnimation({ transformOrigin: "50% 50%", duration: 300, timingFunction: "linear" }); animation.rotate(360*n).step(); this.setData({ animationData: animation.export() }) } //重置动画 function reset() { console.log("重置动画.....") var animation = wx.createAnimation({ transformOrigin: "50% 50%", duration: 0, timingFunction: "linear" }); animation.rotate(0).step(); this.setData({ animationData: animation.export() }) } }, stop: function (e) { var _this = this; this.setData({ isclick:"" }) clearInterval(timer); timer = null; console.log("结束动画....."); sto.call(_this); function sto() { console.log("重置动画.....") var animation = wx.createAnimation({ transformOrigin: "50% 50%", duration: 1.4 * (2160 - (which - 1) * 60), timingFunction: "ease-out" }); console.log(Math.random()*60); animation.rotate(360 * n (2160 - ((which-2) * 60) - 35 - (Math.random() * 50))).step(); this.setData({ animationData: animation.export() }) } timer = setTimeout(function () { _this.setData({ hiddenModal: false }) } , 1.4 * (2160 - (which - 1) * 60 300)); }, listenerConfirm: function (e) { var _this = this; this.setData({ hiddenModal:true, isclick: "start" }) reset.call(_this); function reset() { console.log("重置动画.....") var animation = wx.createAnimation({ transformOrigin: "50% 50%", duration: 0, timingFunction: "linear" }); animation.rotate(0).step(); this.setData({ animationData: animation.export() }) } } }) // //index.js // //获取应用实例 // const app = getApp() // Page({ // data: { // motto: 'Hello World', // userInfo: {}, // hasUserInfo: false, // canIUse: wx.canIUse('button.open-type.getUserInfo') // }, // //事件处理函数 // bindViewTap: function() { // wx.navigateTo({ // url: '../logs/logs' // }) // }, // onLoad: function () { // if (app.globalData.userInfo) { // this.setData({ // userInfo: app.globalData.userInfo, // hasUserInfo: true // }) // } else if (this.data.canIUse){ // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 // // 所以此处加入 callback 以防止这种情况 // app.userInfoReadyCallback = res => { // this.setData({ // userInfo: res.userInfo, // hasUserInfo: true // }) // } // } else { // // 在没有 open-type=getUserInfo 版本的兼容处理 // wx.getUserInfo({ // success: res => { // app.globalData.userInfo = res.userInfo // this.setData({ // userInfo: res.userInfo, // hasUserInfo: true // }) // } // }) // } // }, // getUserInfo: function(e) { // console.log(e) // app.globalData.userInfo = e.detail.userInfo // this.setData({ // userInfo: e.detail.userInfo, // hasUserInfo: true // }) // } // })