
$(document).ready(function () {

    try {
        window.Origami.fastclick(document.body);
    } catch (e) {
    }
    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').attr('src',window.cdn+'/images/prize.jpg').show();
    }else if(window.type==2){

        $('.prize-type').attr('src',window.cdn+'/images/no-num.jpg').show()
    }else {
        $('.map-bj').show();
        setTimeout(function () {
            btnPrize()
        },2000);

    }

});
function btnPrize() {
    $.ajax({
        url: '/index/tryPrize',
        type: 'post',
        data:{'channel':GetQueryString('channel')},
        success: function (resp) {

           $(".map-bj").hide();
            if (resp.errcode != 0) {
                $('.prize-type').attr('src',window.cdn+'/images/no-prize.jpg').show()
            }else{
                if(resp.errcode==2){
                    $('.prize-type').attr('src',window.cdn+'/images/no-num.jpg').show()
                    return;
                }else {
                    $('.prize-type').attr('src',window.cdn+'/images/prize.jpg').show()

                }

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

}
function RandomNumBoth(Min, Max) {
    var Range = Max - Min;
    var Rand = Math.random();
    var num = Min + Math.round(Rand * Range); //四舍五入
    return num;
}
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)return unescape(r[2]);
    return null;
}
window.wx && wx.ready(function () {
    // wx.hideMenuItems({
    //     menuList: ['menuItem:share:appMessage','menuItem:share:timeline','menuItem:share:qq','menuItem:share:facebook','menuItem:share:QZone','menuItem:copyUrl','menuItem:openWithQQBrowser',''] // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
    // });
    wx.hideAllNonBaseMenuItem();
});