var priid='',model='';
  function timeCha(time){
	
	var now=new Date();
	var cha=Math.round((now.getTime()/1000)-time);
	var tm=0;
	if(cha<60){
		tm=cha+"秒前";
	}else if(cha<3600){
		tm=Math.round(cha/60)+"分钟前";
	}else if(cha<86400){
		tm=Math.round(cha/3600)+"小时前";
	}else if(cha<2592000){
		tm=Math.round(cha/86400)+"天前";
	}else{
	}
	return tm;
}


	if(QC.Login.check()){
		$(".newcj_weilogin").remove();
		$(".newcj_weilogin").css("display","none");
		$(".newcj_login").append('<div class="qqlogin">'+
                    	'<img src="icon_for_ios71.png"/*tpa=https://www.daohangtx.com/Skins/mb/images/icon_for_ios71.png*/ class="qqlogintouxiang" width="100px" height="100px" alt="QQ头像"/>'+
						'<span class="qqlogin_nicheng">昵称：<img src="favicon.ico"/*tpa=https://www.daohangtx.com/favicon.ico*/ class="qqlogin_huangzuan" width="25px" height="23px"><a class="qqlogin_nick">请先登录</a></span>'+
						'<p class="qqlogin_outwai"><a class="login_out" onclick="loginout();">退出</a></p>'+
						'<img src="qqico.png"/*tpa=https://www.daohangtx.com/Skins/mb/images/qqico.png*/ class="newqqico" ondragstart="return false;" />'+
                    '</div>');
		QC.Login.getMe(function(openId, accessToken){
			 setCookie("openId",openId,"","","/","");
			 setCookie("access_token",accessToken,"","","/","");
			 
			if(getCookie("auth_code")==null||getCookie("auth_code")==""){	
			$.get("https://www.daohangtx.com/config/qq_login/use.php",function(e){
								
					var d=eval("("+e+")");
					var code=d.code;
					var num=d.lottery_num;
					if(num==null){num=1;}
					setCookie("lottery_num",num,'','','/'); 
					$(".newcj_shengyuchoujiang a").html(num);
					if(code==0){//old
						layer.msg("登录成功！欢迎回来："+d.name,{icon:6,anim:5});
					}else if(code==1){
						layer.confirm("亲爱的 "+d.name+"你是第一次登录,需要绑定账号才能进行抽奖哦!",{
								  skin: 'layui-layer-warn',
								  btn: ['现在绑定','不了']   
								}, function(){
								 	bangding();
								}, function(){
								  layer.msg('不绑定信息,是不能抽奖的呢,亲', { time: 8000,   btn: ['再BB打你哦']  });
								});
					}});	
			}else{
			 		 $(".newcj_shengyuchoujiang a").html(getCookie("lottery_num"));
				 }
		})
		//获取头像和昵称等信息
		//从页面收集OpenAPI必要的参数。get_user_info不需要输入参数，因此paras中没有参数
		var paras = {};
		//用JS SDK调用OpenAPI
		QC.api("get_user_info", paras)
			//指定接口访问成功的接收函数，s为成功返回Response对象
			.success(function(s){
				//成功回调，通过s.data获取OpenAPI的返回数据
				$(".qqlogintouxiang").attr("src",s.data.figureurl_qq_2);
				$(".qqlogin_nick").html(s.data.nickname);
				if(s.data.is_yellow_vip=='1'){
					if(s.data.is_yellow_year_vip=='1'){
						$(".qqlogin_huangzuan").css("display","inline-block").attr("src","/Skins/mb/images/vip_year_lv"+s.data.yellow_vip_level+".png");	
					}else{
						$(".qqlogin_huangzuan").css("display","inline-block").attr("src","/Skins/mb/images/vip_lv"+s.data.yellow_vip_level+".png");
					}
				}
					
			})
			//指定接口访问失败的接收函数，f为失败返回Response对象
			.error(function(f){
				layer.alert("登录账号出错，请重试！",{skin: 'layui-layer-danger' ,closeBtn: 0,anim:0 });
			})
			//指定接口完成请求后的接收函数，c为完成请求返回Response对象
			.complete(function(c){
				//完成请求回调
			});
	}else if(getCookie('uinfo')!=null){
		alipaylogin();
	}

	//通用退出按钮
	$(".login_out").click(function(e) {
        loginout();
    });

	//弹出层关闭
	$(".newcjtanchu_close").click(function(e) {
        closepingbi();
		huifutuodong(".newcjtanchu");
		$(".newcjtanchu").css("display","none");
    });
    
	//抽奖记录
	$(".newcj_zhongjiangjilu").click(function(e){
		 
		prizeinfo(0);
    });	
	//分页
	$(".shoplist_fenye li").live( "click",function(e){
		if(!$(this).hasClass("shoplist_fenye_hover")){
				prizeinfo($(this).data("pageindex"));
			}
		
    });	

    function prizeinfo(pageindex){
    	var pageIndex=pageindex==undefined?0:pageindex;
    	   if(!QC.Login.check()&&(getCookie('auth_code')==""||getCookie('auth_code')==null)){
        	 layer.msg("请先登录再进行此操作",{icon:4,anim:6});
		}else{
			loading(1);
			$.get("https://www.daohangtx.com/config/qq_login/record.php","pageIndex="+pageIndex,function(res){
				
				layer.closeAll();
				var j=eval("("+res+")");
				 
				if(j.code==0){
			var li="";	
			
			 
			$.each(j.list, function(i,data) {
				var spname=data.shop_name;
				var prc=$.trim(data.prizeKey) ;
			 
			if(prc!=null&&prc!=""){
				pjson =eval("("+prc+")");
				spname=decodeURI(pjson['type']);
			 }
 				var t= spname=='未中奖' ? 0:'['+data.mer_name+']'+spname;
				var shifoulq = true;
				var fangfamc='';
				var stu='';
				var sj_leave='';
				if(t==0){
					shifoulq=false;
					fangfamc='------';
				}else if(data.use_account==undefined||data.use_account==''){
 
					var zt=data.isship;
					if(zt=='n'){
						 fangfamc='<font color="red">立刻领取</font>';
						
					}else if(zt=='qx'){
						t=0;
						zt='商家取消';
						shifoulq=false;
						sj_leave=(data.sj_leave==null?'商家没有说明原因，如果商家总是无故取消发货，请联系站长！':data.sj_leave);
						fangfamc='<span>'+zt+'</span>';
						stu='checkStatus';
					}else if(zt=='y'){
						t=0;
						zt='已发货';
						shifoulq=false;
						sj_leave=(data.sj_leave==null?'商家没有说明原因，如果商家总是无故取消发货，请联系站长！':data.sj_leave);
						fangfamc='<span>'+zt+'</span>';
						stu='checkStatus';
					}
					
				}else{
					t=0;
					shifoulq=false;
					var zt=data.isship;
					if(zt=='n'){
						zt='处理中';
						sj_leave=(data.sj_leave==null?'商家正在处理中,亲稍后再来!':data.sj_leave);
					}else if(zt=='y'){
						zt='已发货';
						sj_leave=(data.sj_leave==null?'商家没有给你留言!':data.sj_leave);
					}else if(zt=='qx'){
						zt='商家取消';
						sj_leave=(data.sj_leave==null?'商家没有说明原因，如果商家总是无故取消发货，请联系站长！':data.sj_leave);
					}
					fangfamc='<span> '+zt+' </span>';
					stu='checkStatus';
					
				};
			 
				li+='<li data-priid="'+data.pri_id+'"><a class="shopdemo">'+spname
				+'</a><a class="shoptime">'+$.formatTime.UnixToDate(parseInt(data.prize_date)+28600)
				+'</a><a style="border-right:0;" data-getaway="'+(shifoulq?decodeURI(data.getaway):decodeURI(sj_leave))
				+'" data-model="'+data.model+'" data-qq="'+(data.qq!=null?data.qq:'')+'" data-title="'+t+'"  class="shopget '+stu+'">'+(fangfamc)+'</a><div style="clear:both"></div></li>';
			});
			if($(".newcj_choujianglist").is(":hidden")){
			 
				$(".newcj_choujianglist").addClass("add_animation").show();
			}
			
			$(".newcj_choujianglist").html('<div class="newcj_choujianglist_title">中奖记录（仅保存近期25条数据,多余的将删除,以缓解数据库压力）！</div>'+
                   '<div class="newcj_choujianglist_list">'+
                    	'<ul class="newcj_choujianglist_list_title"><li>中奖商品</li><li>中奖时间</li><li style="border-right:0;">领取状态</li><div style="clear:both"></div></ul>'+
                        '<ul class="newcj_choujianglist_list_list">'+ li+
                        '</ul>'+
                        '<ul class="shoplist_fenye">'+
                        	'<li data-pageindex="0" '+(pageIndex==0?'class="shoplist_fenye_hover"':"")+'>1</li>'+
                            '<li data-pageindex="1" '+(pageIndex==1?'class="shoplist_fenye_hover"':"")+'>2</li>'+
                            '<li data-pageindex="2" '+(pageIndex==2?'class="shoplist_fenye_hover"':"")+'>3</li>'+
                            '<li data-pageindex="3" '+(pageIndex==3?'class="shoplist_fenye_hover"':"")+'>4</li>'+
                            '<li data-pageindex="4" '+(pageIndex==4?'class="shoplist_fenye_hover"':"")+' style="border-right:1px solid #e2e2e2">5</li>'+
                            '<div style="clear:both"></div>'+
                        '</ul>'+
                    '</div>'+
                    '<a class="newcj_choujianglist_close">关闭</a>');	
				}else if(j.msg=='没有下一页了'){
					layer.alert("没有下一页了");
				}else if(j.msg=="暂无记录,快去抽奖吧!"){
					layer.alert("暂无记录,快去抽奖吧!");
				}else{
					
                 //  layer.msg(j.msg,{ icon:5,anim:5});
				  
				 layer.confirm('出现点小小的意外，可能需要刷新当前页面才能正常使用',{
								skin: 'layui-layer-warn',
								  btn: ['现在刷新','不了']   
								}, function(){
								 	  location.reload();
								}, function(){
								  
								});
                    }
		
		});
					tuodong(".newcj_choujianglist");	
					$(".newcj_choujianglist_close").live("click",function(e) {
						closepingbi();
						$(".newcj_choujianglist").css("display","none");
						huifutuodong(".newcj_choujianglist");
					});	
					
		}
    };
  $('.checkStatus').live('click',function(){
	  layer.alert('<font style="color:#666">'+$(this).data('getaway')+'</font>',{ skin: 'layui-layer-warn' ,closeBtn: 0,anim:0 });
	  });  
  	//中奖记录数据
	
	$.ajax({
		type:"GET",
		url:"https://www.daohangtx.com/config/getSlideData.php",
		success:function(res){
			var a=eval(res);
			var li="";
		
			$.each(a, function(i,row) {
				//li+="<li>恭喜! "+row.user_name+"在"+timeCha(row.prize_date)+"抽中了 "+row.shop_name+"</li>";
					li+="<li>恭喜!<b style='color:;'>【"+decodeURI(row.user_name)+"】</b>在"+timeCha(row.prize_date)+"获得"+row.shop_name+"</li>";
			});
			scrollD(li);
		
		} 
	}); 
	 
 function scrollD(li){
 
	$("#newkm_qita_gundongul").append(li);
	var s1 = document.getElementById("newkm_qita_gundong1");
	var info1 = document.getElementById("newkm_qita_gundongul");
	var dibu = document.getElementById("newkm_gundongdibu");
	var speed=50;    //值越大速度越慢
	var nnn=200/info1.offsetHeight;
	dibu.innerHTML = info1.innerHTML    //克隆dibu为info
	function Marquee(){
		if(dibu.offsetTop-s1.scrollTop<=0)    //当滚动至info与dibu交界时
			s1.scrollTop-=info1.offsetHeight    //s1跳到最顶端
		else{
			s1.scrollTop++     //如果是横向的  
		}
	}
	var MyMar = setInterval(Marquee,speed);        //设置定时器
		s1.onmouseover = function(){clearInterval(MyMar)}    //鼠标滚动停止
		s1.onmouseout = function(){MyMar = setInterval(Marquee,speed)}    //鼠标移开时重设定时器
 }



//窗口拖动事件
function tuodong(e){
		var $div = $(e);
      /* 绑定鼠标左键按住事件 */
      $div.bind("mousedown",function(event){
        /* 获取需要拖动节点的坐标 */
        var offset_x = $(this)[0].offsetLeft;//x坐标
        var offset_y = $(this)[0].offsetTop;//y坐标
        /* 获取当前鼠标的坐标 */
        var mouse_x = event.pageX;
        var mouse_y = event.pageY;
        /* 绑定拖动事件 */
        /* 由于拖动时，可能鼠标会移出元素，所以应该使用全局（document）元素 */
        $(document).bind("mousemove",function(ev){
			$div.css({"margin-left":"0","margin-right":"0","margin-top":"0","margin-bottom":"0"});
          /* 计算鼠标移动了的位置 */
          var _x = ev.pageX - mouse_x;
          var _y = ev.pageY - mouse_y;
          /* 设置移动后的元素坐标 */
          var now_x = (offset_x + _x ) + "px";
          var now_y = (offset_y + _y ) + "px";
          /* 改变目标元素的位置 */
          $div.css({
            top:now_y,
            left:now_x
          });
        });
      });
      /* 当鼠标左键松开，接触事件绑定 */
      $(document).bind("mouseup",function(){
        $(this).unbind("mousemove");
      });	
}
//取消拖动恢复原始位置
function huifutuodong(e){
	var $huifutuodong = $(e);
	$huifutuodong.css({"margin-left":"","margin-right":"","margin-top":"","margin-bottom":"","top":"","bottom":"","left":"","right":"123"});	
}
//加入屏蔽层
function pingbi(){
	$(".newbg").append('<div class="newzuiwaiceng"></div>');
}
//计次关闭屏蔽层
function closepingbi(){
	$(".newzuiwaiceng").eq(0).remove();
}
//关闭账号绑定窗口
$(".bangdingclose").live('click',function(e){
    closepingbi();
	$(this).parent().css("height","");
	huifutuodong(".newcj_bangding");
	$(".newcj_bangding").css("display","none");
});
//关闭领取中奖商品窗口
$(".newcj_getclose").live('click',function(e){
    closepingbi();
	$(".newcj_get").css("display","none");
	huifutuodong(".newcj_get");
});
//通用提示框代码
function info(e){
	pingbi();
	tuodong(".newcjtanchu");
	$(".newcjtanchu").addClass("add_animation").css("display","block").children("span").html(e);
}
 
$("#zhongjiang").live('click',function(e){
	$(".newabout_container").append('<div class="newcj_zhixianpao">奖</div>');
	   $(".newcj_zhixianpao").animate({
			left:"706px",
			bottom:$(".newabout_container").height()-301
	   },1100);
	   
	setTimeout(function(){
    	$(".newcj_zhixianpao").slideUp(500);
		setTimeout(function(){
			$(".newcj_zhixianpao").remove();
		},500);
    },1100);
})

//键盘按键 FireFly萤火虫
$(document).keyup(function(event){
  if(event.keyCode ==13){
    	closepingbi();
		$(".newcjtanchu").css("display","none");
  }
});
//bangding() 绑定QQ以及支付宝微信账号提示框  newcjtanchu_close
function bangding(){
var	txt= '<span class="newcj_bangding"><br/><p><span>QQ：</span><input type="text" placeholder="请绑定您的QQ账号" maxlength="30" /></p>'+
        '<p><span>支付宝：</span><input type="text" placeholder="请绑定您的支付宝账号" maxlength="30" /></p>'+
        '<p><span>微信：</span><input type="text" placeholder="请绑定您的微信账号" maxlength="30" /></p>'+
        '<span class="site-tips newcj_bangding_biaozhu">请正确填写相关准确的账号信息,以后商家发货的时候可能会联系你们,无法修改。(请至少绑定一个账号)</span>'+
        '<a class="layui-layer-btn newcj_bangdingqueding">提交</a></span>';
		content("首次登陆绑定账号",1,txt);
}
function content(tit,tp,txt){
	layer.open({
	title:"<h3>"+tit+"</h3>",
	  type:tp,
	  skin: 'layui-layer-warn',  
	  content:txt
	});
}

$(".newcj_bangdingqueding").live("click",function(e) {
		var qqnumber = $(".newcj_bangding p input").eq(0).val();
		var alipay = $(".newcj_bangding p input").eq(1).val();
		var webchat = $(".newcj_bangding p input").eq(2).val();
		
		if(qqnumber.length<5&&alipay.length<6&&webchat.length<5){
			layer.alert("请认真填写至少一项，否则无法发放奖励！",{ skin: 'layui-layer-danger' ,closeBtn: 0,anim:0 });
		}else{
		layer.confirm('提交后将不能更改，这是领取奖品的凭证，请谨慎操作！',{
								skin: 'layui-layer-danger',
								  btn: ['确认提交','再看看']   
								}, function(){
								  	var load= layer.load(2,{ shade: [0.1,'#fff']});
									$.post("https://www.daohangtx.com/config/bangding.php",{"qq":qqnumber,"alipay":alipay,"weixin":webchat}, function(data){
										var d=eval("("+data+")");
										 if(d.code==-1){
											layer.close(load);
											layer.alert(d.msg,{ skin: 'layui-layer-danger' ,closeBtn: 0,anim:0 })
										 }else{
											layer.closeAll();
											layer.msg(d.msg, {icon: 1}); 
										 }
									});
								}, function(){
								   
								});
			
		 
			
			
			
		}
	});
 var qqnum=0;
 $(".shopget").live("click",function(){
	 priid = $(this).parent().data("priid");
	 model = $(this).data("model");
	 qqnum = $(this).data("qq");
 	var tit=$(this).data("title");
	var txt=$(this).data("getaway");
	if(tit!=0){
		lingqu(tit,txt);
		} 	
 })
 
function lingqu(tit,txt){
	//if($(".newcj_get").is(":vi")){		closepingbi();	}
	/*pingbi();
	txt='进入好点卡盟官网<a href="http://www.haodiankm.cn/" target="_blank">www.haodiankm.cn</a>注册1个卡盟账号</p>|在下方填写您注册的卡盟账号，然后等待商家发货即可。|如果检测用户到非法刷取奖品，会取消发货并封禁账号！|发货问题请联系该商家的客服QQ：81040253|投诉建议请联系技术导航客服邮箱guojiwangluo@qq.com<div class="newcj_get_input"><span class="newcj_inputleft">账号</span><input type="text" placeholder="请填写您在好点卡盟注册的账号" /><div style="clear:both"></div></div><a class="newcj_shoppost">提交收货信息</a>';*/
	var tarr=txt.split("|");
	var info="";
	//分割内容
	$.each(tarr,function(i,tx){
		info+='<p class="newcj_shopguize">'+(i+1)+'、'+tx+'</p>';
		});
	tuodong(".newcj_get");
	$(".newcj_get").addClass("add_animation").css("display","block").html('<h3>奖品收货信息填写<a class="newcj_getclose">关闭</a></h3>'+
        '<img src="kameng1yuan.png"/*tpa=https://www.daohangtx.com/Skins/mb/images/kameng1yuan.png*/ width="150px" height="95px" alt="商品样图" class="newcj_shopyangtu" />'+
        '<span class="newcj_shoptitle">'+tit+'</span>'+info + '<div class="newcj_get_input"><span class="newcj_inputleft">账号</span><input class="ac_num" type="text" placeholder="请填写在该商家平台注册的账号" /><div style="clear:both"></div></div><a class="newcj_shoppost">提交信息</a>'
         );
      if(qqnum!=null&&qqnum>10000){
	    var qinput= $(".newcj_get").find('.ac_num');
	   			 qinput.val(qqnum);qinput.css("cursor","not-allowed")
	   			 qinput.attr("disabled","disabled");
      }
}
	$(".selectCDK .layui-form-checkbox").live("click",function(){
		 $(".selectCDK .layui-form-checkbox").removeClass("checked");
		 $(this).addClass("checked");
	});

//通用退出按钮方法
	function loginout(){
		QC.Login.signOut();//QQ退出
		var a=["auth_code","openId","access_token","uinfo"];
		delCookie(a);	
	};
	
$('.newcj_shoppost').live('click',function(){
	var tj_zh=	$(this).parent().find('.ac_num').val();
	 if(tj_zh!=''){
			layer.confirm('你的账号是：<font color="#f60"><b>'+tj_zh+'</b></font>  确认提交吗？<font color="red">填写错误可能被取消发货</font>'+(model!=null?model:'')
			+'<textarea id="useleave" maxlength="150" rows="5"  style="width: 100%; padding: 7px 10px; box-sizing: border-box; border: 1px solid #ff9801;" placeholder="您可以在这里这个商家留言，也可以不填写。"></textarea>					',{
									skin: 'layui-layer-warn',
									  btn: ['确认提交','取消']
									}, function(){
										var pingbibi = layer.load(1,{shade:[0.1,'#000']});
										 	var cdktype=$(".selectCDK .checked").data("cdk");
										$.post('https://www.daohangtx.com/config/bd_zh.php',{"use_ace":tj_zh,"cdktp":cdktype,"priid":priid,"content":$("#useleave").val()},function(res){
											layer.close(pingbibi);
												var res=eval("("+res+")");
											layer.alert(res.msg,{ skin: 'layui-layer-warn' ,closeBtn: 0,anim:0 }),function(){alert()};});
									}, function(){
											layer.msg('已取消');
									});
		
	}else{
			layer.close(pingbibi);
			layer.tips('请先在此输入商家平台的账号！','.ac_num', { tips:1});
	}
});
	function alipaylogin(){
		if( getCookie('uinfo')!=null){
				var alipayjson = eval('(' + getCookie('uinfo') + ')');
				var num = alipayjson.lottery_num;
				if(num==null){num=1;}
				$(".newcj_shengyuchoujiang a").html(num);
				setCookie("lottery_num",alipayjson.lottery_num,"","","/");
				$(".newcj_weilogin").remove();
				$(".newcj_weilogin").css("display","none");
				$(".newcj_login").append('<div class="alipaylogin">'+
								'<img src="'+alipayjson.avatar+'" class="alitouxiang" width="100px" height="100px" alt="支付宝头像"/>'+
								'<span class="alipay_nicheng">昵称：<a class="alipay_nick">'+alipayjson.name+'</a></span>'+
								'<p class="alipay_outwai"><a class="login_out" onclick="loginout();">退出</a></p>'+
								'<img src="alipayico.png"/*tpa=https://www.daohangtx.com/Skins/mb/images/alipayico.png*/ class="newalipayico" ondragstart="return false;" />'+
						   '</div>');	}
		}
function getUrlParam(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");  
	var r = window.location.search.substr(1).match(reg);  
	if (r != null) return unescape(r[2]); return null; 
}

$(function (){
//微信接口屏蔽
	$("#webchatloginBtn").click(function(e) {
			layer.msg("暂时不提供微信登录，请换其他方式登录，感谢您的支持！",{ icon: 0,anim:0 });
    });
            var rotateTimeOut = function (){
                $('#rotate').rotate({
                    angle:0,
                    animateTo:2160,
                    duration:8000,
                    callback:function (){
                    	layer.msg("网络超时，请检查您的网络设置！",{icon:0});
                    }
                });
            };
            var bRotate = false;
            var rotateFn = function (awards, angles, txt,num){
                bRotate = !bRotate;
                $('#rotate').stopRotate();
                $('#rotate').rotate({
                    angle:0,
                    animateTo:angles+1800,
                    duration:8000,
                    callback:function (){
                    	if(txt!='未中奖'){
                      	  layer.msg("恭喜您获得"+txt,{icon:6});
                    	}else{
                    	    layer.msg("不开心,竟然"+txt,{icon:5});
                    	}
                        bRotate = !bRotate;
                    }
                })
            };
            $('.pointer').click(function (){
		 	 if(!QC.Login.check()&&(getCookie('auth_code')==""||getCookie('auth_code')==null)){
					layer.msg("请先在页面右侧使用QQ、微信或者支付宝等其他方式登录账号！",{icon:4,anim:6});
					return;
				}  
                if(bRotate)return;
                loading(1);
				$.post("https://www.daohangtx.com/config/lottery.php","cj=cj", function(data){
					layer.closeAll();
					var json = eval("("+data+")");
					if(json.code==-1){
						 layer.msg(json.msg,{anim:5,icon:5});
						 
						
					}else if(json.code==-2){
						layer.confirm(json.msg,{
								skin: 'layui-layer-warn',
								  btn: ['现在绑定','不了']   
								}, function(){
								 	bangding();
								}, function(){
								  layer.msg('不绑定信息,不能抽奖哦,亲', { time: 8000,   btn: ['再BB打你哦']  });
								});
					}else{
							if(getCookie("lottery_num")!=null){
								setCookie("lottery_num",(parseInt(json.lottery_num)-1),'','','/');
							}
						
						$(".newcj_shengyuchoujiang a").html(parseInt(json.lottery_num)-1);
						var lotternum=parseInt(json.lottery_code);
						var lotname=json.lottery_name;
						
						switch (lotternum){	
						case 1:
							//var angle = [26, 88, 137, 185, 235, 287, 337];
							rotateFn(0, 337, lotname,lotternum);
							break;
						case 2:
							//var angle = [88, 137, 185, 235, 287];
							rotateFn(1, 26, lotname,lotternum);
							break;
						case 3:
							//var angle = [137, 185, 235, 287];
							rotateFn(2, 88, lotname,lotternum);
							break;
						case 4:
							//var angle = [137, 185, 235, 287];
							rotateFn(3, 137, lotname,lotternum);
							break;
						case 5:
							//var angle = [185, 235, 287];
							rotateFn(4, 185, lotname,lotternum);
							break;
						case 6:
							//var angle = [235, 287];
							rotateFn(5, 235, lotname,lotternum);
							break;
						case 7:
							//var angle = [287];
							rotateFn(6, 287, lotname,lotternum);
							break;
						default:
							layer.msg("异常错误!操作不能太快");
							break;
					}
					}
				});
            });
        });
		
var pingbibi = layer.load(1,{shade:[0.1,'#000'],time:3000});

window.onload = function(){	
	layer.close(pingbibi);
	var auth = getUrlParam("auth_code");
		if(auth!=null&& !$(".newcj_login").children().hasClass("alipaylogin")){
			 
			$.get("https://www.daohangtx.com/config/alipay/use.php","auth_code="+auth, function(data) {
				
				var j=eval("("+data+")");
				if(j.code==0){
					layer.msg("登录成功！欢迎回来："+j.name,{icon:6,anim:5});
					alipaylogin();
				}else if(j.code==1){
					
					layer.confirm("亲爱的 "+j.name+"你是第一次登录,需要绑定账号才能进行抽奖哦!",{
								skin: 'layui-layer-warn',
								  btn: ['现在绑定','不了']   
								}, function(){
								 	bangding();
								}, function(){
								  layer.msg('不绑定信息,是不能抽奖的呢,亲', { time: 8000,   btn: ['别说了我知道']  });
								});
								alipaylogin();
				}
			});
		}
 var canshu = location+"";	if(canshu.indexOf('access_token')>0){setTimeout(function(){window.location.href="lottery.html"/*tpa=https://www.daohangtx.com/chara/lottery.html*/},500)	}	}
var loading = function(type) {layer.load(type,{
  shade: [0.1,'#fff']  
  
}); }


