<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);
}
},
})