function roll(){
$("#roll").attr(“onclick”, “null”);
$(’#turntable’).css(’-webkit-transition’,’-webkit-transform 0s’);
$(’#turntable’).css(‘transition’,‘transform 0s’);
$(’#turntable’).css(’-webkit-transform’,‘rotate(0deg)’);
$(’#turntable’).css(‘transform’,‘rotate(0deg)’);
setTimeout(function(){
$(’#turntable’).css(’-webkit-transition’,’-webkit-transform 4s’);
$(’#turntable’).css(‘transition’,‘transform 4s’);
ratating();
},100);
}
//转盘开始转
function ratating() {
mui.ajax(contextRootPath+’/weixin/roll.do’, {
data : {
“user_code”:user_code,
“id”: id
},
dataType : ‘json’,// 服务器返回json格式数据
type : ‘POST’,// HTTP请求类型
timeout : 10000,// 超时时间设置为10秒;
success : function(respData) {
retcode = respData.responsehead.retcode;
totalTimes = respData.responsebody.remain_times;
if (respData.responsehead.retcode == “0000”) {
var data = respData.responsebody.ruleGiftInfos;
var rule_code = data[0].rule_code;
if(map[rule_code]){
var luck_area = map[rule_code];
}
ruleGiftInfos = data;
var html = “”;
for (var i = 0; i < data.length; i ++) {
var ruleGiftInfo = data[i];
var giftCouponInfos = ruleGiftInfo.giftCouponInfos;
html += ‘<li class=“mui-table-view-cell” id="’ + i + ‘">’+
‘<div style=“height: 30px;line-height: 30px;color: #FD8800;”>’ + ruleGiftInfo.licenseNo + ‘</div>’;
for (var j = 0; j < giftCouponInfos.length; j ++) {
var giftCouponInfo = giftCouponInfos[j];
var backCouponDOs = giftCouponInfo.backCouponDOs;
var coupons = “”;
for (var k = 0; k < backCouponDOs.length; k ++) {
var backCouponDO = backCouponDOs[k];
if (k == 0) {
coupons = backCouponDO.coupon_name + “x” + backCouponDO.total_num;
} else {
coupons += “,” + backCouponDO.coupon_name + “x” + backCouponDO.total_num;
}
}
html += ‘<div class=“mui-input-row mui-radio mui-left”>’+
‘<label style=“text-align: left;”>’ + giftCouponInfo.gift_name + ‘</label>’+
‘<input name="radio’ + i + ‘" type=“radio” value="’ + j + ‘">’+
‘</div>’+
‘<div style=“text-align: left;font-size: 11px;color: #999999;line-height: 15px;padding: 3px 0 5px 20px;”>包含’ + coupons + ‘</div>’;
}
html += ‘</li>’;
}
$("#couponSelect").html(html);
reg = true;
var timer = null;
var rdm = 360 * 3 + (8-parseFloat(luck_area)) * 45 + (Math.random() * 45);
clearInterval(timer);
timer = setInterval(function() {
$(’#turntable’).css(’-webkit-transform’,‘rotate(’ + rdm + ‘deg)’);
$(’#turntable’).css(‘transform’,‘rotate(’ + rdm + ‘deg)’);
clearInterval(timer);
setTimeout(function() {
$(’#mui-backdrop1’).show();
}, 4000);
}, 30);
} else if (respData.responsehead.retcode == “0004”){
mui.toast(respData.responsehead.retmessage);
}else {
reg = true;
var timer = null;
var rdm = 360 * 3 + (8-parseFloat(8)) * 45 + (Math.random() * 45);
clearInterval(timer);
timer = setInterval(function() {
$(’#turntable’).css(’-webkit-transform’,‘rotate(’ + rdm + ‘deg)’);
$(’#turntable’).css(‘transform’,‘rotate(’ + rdm + ‘deg)’);
clearInterval(timer);
setTimeout(function() {
var backdrop5 = $(’#mui-backdrop5’);
backdrop5.find(’#remainTime’).text(totalTimes);
backdrop5.show();
}, 4000);
}, 30);
}
},
error : function(xhr, type, errorThrown) {
$("#roll").attr(“onclick”, “roll()”);
}
});
}