var prize_word=[
    '家和万事兴',
    '和谐美满',
    '和和美美',
    '和和睦睦 ',
    '和气生财',
    '和蔼可亲'
];
var prize_lock=1;
$(document).ready(function () {

    try {
        window.Origami.fastclick(document.body);
    } catch (e) {
    }
    document.addEventListener("touchmove", function (e) {
        e.preventDefault();
    }, false);
    var clickEvent = $.isFunction($.fn.tap) ? 'tap' : 'click';
    window['max_zindex'] = 100;
    $.fn.show_dialog = function () {
        window['max_zindex'] += 1;
        this.css('z-index', window['max_zindex']);
        this.show();
    };
    if(window.type==1){
        $('.prize-type').text('已中奖，请麻烦找官方登记信息').show();
    }else {
        $('.btn-prize').show();
    }
    $('.btn-prize').on('click',function () {
        if(prize_lock==2){
            my_notify('点击太快');
            return;
        }
        btnPrize();
    });
});
function btnPrize() {
    prize_lock=2;
    $.ajax({
        url: '/index/tryPrize',
        type: 'post',
        data:'',
        success: function (resp) {
           var rank=RandomNumBoth(0,10);
            if (resp.errcode != 0) {
                my_notify(resp.errmsg);
                return;
            }else{
                if (resp.data.prize ==0) {
                    my_notify(prize_word[rank])
                }else{

                }
            }
            prize_lock=1;
        },
        error: function () {
            prize_lock=1;
            my_notify('网络异常，请稍后重试');
        }
    });

}
function RandomNumBoth(Min, Max) {
    var Range = Max - Min;
    var Rand = Math.random();
    var num = Min + Math.round(Rand * Range); //四舍五入
    return num;
}
window.wx && wx.ready(function () {

});