
<style>
		body{background-color: #F4F4F4}
	.topbox{margin-bottom: 10px;background-color: #fff;}
	.topbox img{width: 100%;}
	.surplus{float: right;color: #ADADAD;font-size: 12px;padding-top: 4px;}
	.points{color: #F4A619; font-size: 12px;}
	.topbox div{}
	.topbox div p span:nth-child(1){color:  #3EC381;border: 1px solid #3EC381; border-radius: 10px; display: block;float: left;padding: 0px 8px; text-align: center; font-size: 11px;margin-top: 4px;}
	.topbox div p span:nth-child(2){color:  #57B6D2;border: 1px solid #57B6D2; border-radius: 10px; display: block;float: left;padding: 1px 8px 0px 8px; text-align: center; font-size: 11px; margin-left: 10px;margin-top: 4px;}
	.topbox div p{overflow: hidden;border-top: 1px solid #ECECEC; border-bottom: 1px solid #ECECEC;padding: 14px;}
	.topbox div p a{display: inline-block;color: #fff;background-color: #FABF4B;border-radius: 3px;padding: 6px 11px;float: right; font-size: 13px;}

	.middlebox{background-color: #fff;}
	.nrxq{margin-left: 10px;padding: 7px 0px 4px 0px;}
	.textbox{margin: 0px 10px ;overflow: hidden;padding-bottom: 5px; font-size: 13px; color: #7D7D7D;}
	.shade{position:fixed;top: 0px;right: 0px;bottom: 0px;filter: alpha(opacity=60);background-color: #000;z-index: 1002;left: 0px;display: none;opacity: 0.65;-moz-opacity: 0.65;width: 100%;height: 100%;}

	.popdraw,.winning,.not-winning{width: 75%;position: absolute;z-index: 2000;display: none;background-color: #fff; border-radius: 5px;}
	.popdraw img,.winning img,.not-winning img{width: 70%;margin: 0px auto;display: block;}
	.closedraw{width: 20px !important;right: 10px;top: 10px;position: absolute;}
	.ppyq{color: #F78C11; font-size: 22px; text-align: center;margin: 12px 0px;}
	.chow{ text-align: center; background-color: #FABF4B; font-size: 18px; color: #fff; padding: 7px 0px;border-radius: 0px 0px 5px 5px;margin-top: 10px;}
	.gxzj{color: #FF7862; font-size: 22px; text-align: center;margin: 12px 0px;}
	.zjzl{color: #78BD50; font-size: 22px; text-align: center;margin: 12px 0px;}
	.qwlj{ text-align: center; background-color: #FF7862; font-size: 18px; color: #fff; padding: 7px 0px;border-radius: 0px 0px 5px 5px;margin-top: 10px;}
	.zcyc{ text-align: center; background-color: #78BD50; font-size: 18px; color: #fff; padding: 7px 0px;border-radius: 0px 0px 5px 5px;margin-top: 10px;}

	#windowcenter{position: absolute;}
	.window {
	    width: 250px;
	    position: fixed;
	    display: none;
	    z-index: 9999;
	    padding: 2px;
	    border-radius: 0.6em;
	    -webkit-border-radius: 0.6em;
	    -moz-border-radius: 0.6em;
	    background-color: #ffffff;
	    -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
	    -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
	    -o-box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
	    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
	    font: 14px/1.5 Microsoft YaHei,Helvitica,Verdana,Arial,san-serif;
	}
	.window .content {
	    /* min-height: 100px; */
	    overflow: auto;
	    color: #222222;
	    text-shadow: 0 1px 0 #FFFFFF;
	    border-radius: 0 0 0.6em 0.6em;
	    -webkit-border-radius: 0 0 0.6em 0.6em;
	    -moz-border-radius: 0 0 0.6em 0.6em;
	}
	.window #txt {
	    min-height: 30px;
	    font-size: 16px;
	    line-height: 22px;
	    text-align: center;
	    margin-top: 22px;
	    padding: 0px 5px;
	}
	.window .txtbtn {
	    background: #fff;
	    border-top: 1px solid #DDDDDE;
	    color: #0B7FFE;
	    font-weight: bold;
	    text-shadow: 0 1px 0 #FFFFFF;
	    display: block;
	    text-align: center;
	    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
	    text-overflow: ellipsis;
	    white-space: nowrap;
	    cursor: pointer;
	    text-align: windowcenter;
	    font-weight: bold;
	    font-size: 18px;
	    padding: 6px;
	    margin: 10px 0 0 0;
	    float: left;
	    width: 45.2%;
	}
.wpmz{display: block;font-size: 14px;}
</style>

<body>
	<div class="shade"></div>
	<div class="main">
		<div class="topbox">
			<img src="<?php echo $pic;?>" alt="">
			<div>
				<div style="padding:0px 10px 7px 10px;">
					<span class="wpmz"><?php echo $name;?></span>
					<span class="points"><?php echo $score?><?php echo $score_name;?></span>
					<span class="surplus">剩余<span><?php echo $num;?></span></span>
				</div>	
				<p>
					<span><?php echo $cate;?></span>
					<span><?php echo $get_type;?></span>
					<?php
						if($type==1)
						{
					?>
							<a id="duihuan" href="<?php echo $c_cate == 2?site_url('scorefront/goods/recharge/'.$id):$url.'index.php?mod=score&action=exchange&gid='.$gid.'&auth='.urlencode($auth)?>">点击兑换</a>
					<?php
						}
						else
						{
					?>
							<a href="javascript:void(0);" class="click_draw">点击抽奖</a>
					<?php
						}
					?>
					
					
				</p>
			</div>
		</div>
		<div class="middlebox">
			<p class="nrxq">内容详情</p>
			<div class="textbox">
			<?php echo $message;?>
			<ul>
				<li>联系人：<?php echo $shop['name'];?></li>
				<li>联系电话：<?php echo $shop['tel'];?></li>
				<li>联系手机：<?php echo $shop['phone'];?></li>
				<li>联系QQ：<?php echo $shop['qq'];?></li>
				<li>联系地址：<?php echo $shop['addr'];?></li>
			</ul>				
			</div>
		</div>
		<div class="popdraw">
			<p class="ppyq">碰碰运气</p>
			<img src="<?php echo sasset_url('images/draw.png')?>" alt="" class="drawimg">
			<a href="javascript:void(0);"><img src="<?php echo sasset_url('images/close.png')?>" alt="" class="closedraw"></a>
			<a href="javascript:void(0);"><p class="chow">点击抽奖</p></a>
		</div>
		<div class="winning">
				<p class="gxzj">恭喜中奖</p>
				<img src="<?php echo sasset_url('images/jackpot.png')?>" alt="" class="jackimg">
				<a href="javascript:void(0);"><img src="<?php echo sasset_url('images/close.png')?>" alt="" class="closedraw"></a>
				<a id="link" href="<?php echo site_url('/scorefront/goods/success/'.$gid)?>"><p class="qwlj">前往领奖</p></a>
		</div>
		<div class="not-winning">
				<p class="zjzl">再接再厉</p>
				<img src="<?php echo sasset_url('images/efforts.png')?>" alt="" class="jackimg">
				<a href="javascript:void(0);"><img src="<?php echo sasset_url('images/close.png')?>" alt="" class="closedraw"></a>
				<a id="zlyc" href="javascript:void(0);"><p class="zcyc">再抽一次</p></a>
		</div>
	</div>
	<div class="window" id="windowcenter" >
			<div class="content">
			 <div id="txt">是否确认兑换？</div>
			 <a href="javascript:void(0)" id="windowokbutton" name="兑换" class="txtbtn">兑换</a>
			 <a href="javascript:void(0)" id="windowclosebutton" name="取消" class="txtbtn"> 取消</a>	
			</div>
	</div>
	<script>


		$('#windowclosebutton').click(function(event) {
			$('.shade').hide();
			$('#windowcenter').hide();
		});


		var score = <?php echo $user->getScore();?>;
		$('.click_draw').click(function(event) {
			$('.shade').show();
			var a =$('.popdraw,.winning,.not-winning');
			a.css('left',parseInt(($(window).width()-a.width())/2)); 
			a.css('top',parseInt(($(window).height()-a.height())/2+$(document).scrollTop()));
			$('.popdraw').show();
		});

		$('.closedraw').click(function(event) {
			$('.shade').hide();
			$('.popdraw').hide();
			$('.not-winning').hide();
		});



		/*$('.chow').click(function(event) {
			$('.popdraw').hide();
			$('.shade').css({ "width": $(document).width(), "height": $(document).height()});
			$('.shade').show();
			var b =$('.winning div');
			b.css('left',parseInt(($('.winning').width()-b.width())/2)); 
			b.css('top',parseInt(($('.winning').height()-b.height())/2+$(document).scrollTop()-65));
			$('.winning').show();
		});*/

		$('.chow').click(function(event) {

			$.get('<?php echo $url;?>index.php?mod=score&action=lottery&gid=<?php echo $gid?>&auth=<?php echo urlencode($auth)?>',{},function(data){
				console.log(data);
				//未中奖
				if(data.code == 1 && data.data == 0){
					$('.popdraw').hide();
					$('.shade').css({ "width": $(document).width(), "height": $(document).height()});
					$('.shade').show();
					var c =$('.not-winning div');
					c.css('left',parseInt(($('.not-winning').width()-c.width())/2)); 
					c.css('top',parseInt(($('.not-winning').height()-c.height())/2-65));
					$('.not-winning').show();
				}
				//中奖
				if(data.code == 1 && data.data != 0){
					if(data.status == 2){
						$('#link').attr('href', '<?php echo site_url('/scorefront/goods/recharge/'.$gid);?>/'+data.data)
					}
					$('.popdraw').hide();
					$('.shade').css({ "width": $(document).width(), "height": $(document).height()});
					$('.shade').show();
					var b =$('.winning div');
					b.css('left',parseInt(($('.winning').width()-b.width())/2)); 
					b.css('top',parseInt(($('.winning').height()-b.height())/2-65));
					$('.winning').show();
				}

				if(data.code == 4){
					window.location.href = '/mocuz/manage/index.php?/scorefront/goods/recharge/'+data.gid+'/'+data.eid
				}
				if(data.code == 5){
						alert('超过兑换次数');
				}
				if(data.code == 2){
					alert('库存不足');
				}
				if(data.code == 3){
					alert('<?php echo $score_name;?>不足');
				}
			},'json')
			return false;
			
		});

		$('.not-winning a#zlyc').click(function(event) {
			$('.not-winning').hide();
			$('.shade').css({ "width": $(document).width(), "height": $(document).height()});
			$('.shade').show();
			var a =$('.popdraw,.winning,.not-winning');
			a.css('left',parseInt(($(window).width()-a.width())/2)); 
			a.css('top',parseInt(($(window).height()-a.height())/2+$(document).scrollTop()));
			$('.popdraw').show();
		});

		$(function(){

			$('#duihuan').click(function(){
				event.preventDefault();
				var d =$('#windowcenter');
				d.css('left',parseInt(($(window).width()-d.width())/2)); 
				d.css('top',parseInt(($(window).height()-d.height())/2+$(document).scrollTop()));
				$('.shade').show();
				$('#windowcenter').show();

			})
			$("#windowokbutton").on('click', function(event) {
				/* Act on the event */

				<?php if($c_cate == 2){ ?>
		
					if(score >= <?php echo $score?>){
						window.location.href = "<?php echo site_url('scorefront/goods/recharge/'.$id)?>"						
						return true;
					}else{
						alert('<?php echo $score_name;?>不足');
						return false;
					}
				<?php }?>


				var url = $("#duihuan").attr('href');

				$.get(url,{},function(data){
					if(data.code == 1){
						window.location.href = '/mocuz/manage/index.php?/scorefront/goods/success/'+data.gid
					}
					if(data.code == 2){
						alert('库存不足');
					}
					if(data.code == 5){
						alert('超过兑换次数');
					}
					if(data.code == 3){
						alert('<?php echo $score_name;?>不足');
					}
				},'json')
				return false;
			});

		})

	</script>
</body>
</html>