小程序---抽奖轮盘制作

<view class='background-image'>
    <image src='pointer.png' class='point' bindtap="start"></image>
    <image src='turn.png' class='turn' animation="{{rotateData}}"></image>
</view>

let animation = wx.createAnimation({
    duration: 2000,
    timingFunction: 'linear',

});
Page({

    /**   * 页面的初始数据        */
    data: {
        rotateData: {},
        turning: false,
    },
    start() {
        let _this = this;
        if (!this.data.turning) {
            let rdm = 0; //随机度数
            rdm = Math.floor(Math.random() * 7200);
            let cat = 51.4;
            animation.rotate(rdm).step();
            this.setData({
                rotateData: animation.export(),
                turning: true,
            })
            setTimeout(() => {
                _this.setData({
                    turning: false
                });
                let num = rdm % 360;

                function showModal(str) {
                    wx.showModal({
                        title: '提示',
                        content: str,
                        success: function() {
                            let animation = wx.createAnimation({
                                duration: 10,
                                timingFunction: 'linear',
                            });
                            animation: rotate(0).step();
                            _this.setData({
                                rotateData: animation.export(),
                            })
                        },
                        fail: function(res) {},
                        complete: function(res) {},
                    })
                }
                if (num < cat * 1) {
                    showModal('4999');
                } else if (num <= cat * 2) {
                    showModal('50元');
                } else if (num <= cat * 3) {
                    showModal('10元');
                } else if (num <= cat * 4) {
                    showModal('5元');
                } else if (num <= cat * 5) {
                    showModal('免息服务');
                } else if (num <= cat * 6) {
                    showModal('提高白条额度');
                } else if (num <= cat * 7) {
                    showModal('未中奖');
                }
            }, 2000);
        }
    },
})

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值