有没有大神路过帮忙看一下这个问题,急需解决!

时间:2021-02-22 05:06:14
有没有大神路过帮忙看一下这个问题,急需解决!有没有大神路过帮忙看一下这个问题,急需解决!
页面代码
<link type="text/css" rel="stylesheet" href="<?php echo ADMIN_URL;?>tpl/6/css.css" media="all" />
<?php //$this->element('6/top',array('lang'=>$lang)); ?>
<style type="text/css"> 
.maind{width:100%; height:280px; position:relative; margin:20px auto}
#disk{width:100%; height:280px; background:url(<?php echo ADMIN_URL;?>images/disk.png) no-repeat;}
#start{width:163px; height:320px; position:absolute; top:22px; left:82px;}
#start img{cursor:pointer}
</style>
<script type="text/javascript" src="<?php echo ADMIN_URL;?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo ADMIN_URL;?>js/jQueryRotate.2.2.js"></script>
<script type="text/javascript" src="<?php echo ADMIN_URL;?>js/jquery.easing.min.js"></script>
<script type="text/javascript"> 
$(function(){
 $("#startbtn").click(function(){
lottery();
});
});
function lottery(){
$.ajax({
type: 'POST',
url: '<?php echo ADMIN_URL;?>user.php',
        data: "action=ajax_choujiang",
dataType: 'json',
cache: false,
error: function(){
alert('出错了!');
return false;
},
success:function(json){
            if(json.info){
                alert(json.info);return false;
            }
var a = json.angle;
var name = json.name;
var prize = json.prize;
var alt='恭喜你,中了'+prize+'!奖品是:'+name;
$("#startbtn").rotate({
duration:3000,
angle: 0,
             animateTo:1800+a,
easing: $.easing.easeOutSine,
callback: function(){
alert(alt);
window.location.href='<?php echo ADMIN_URL."daili.php?act=v2_mymoney";?>';
}
});
}
});
}
</script>
<!--background:#FFF;-->
<body style=" background:url(<?php echo ADMIN_URL;?>/images/bg.png);">

<div style="margin-left:10%;width=100%;" >
   <div id="main" style="">
   <div class="maind">
        <div id="disk"></div>
        <div id="start"><img src="<?php echo ADMIN_URL;?>images/start.png" id="startbtn"></div>
   </div>
</div> 
</div>
<style>
.jiangx p{ text-align:left;}
</style>
<center>
<div style="background:#FFF8B2;width:310px;height:300px;">
<div style="border:1px dashed #E3E09D;width:300px;height:295px;">
<div style="float:left;"><img src="images/jiang.png"></div>
<div style="float:left;color:#4B4918;" class="jiangx">
<P><strong>满100积分就可以参与抽奖一次哦!<?php //echo $rts['num'];?></strong></P></br>

<div style="float:left;" class="jiangx">
<?php if(!empty($rt))foreach($rt as $row){?>  
<P><strong><?php echo $row['lt_prize'];?>:<?php echo $row['lt_name'];?></strong></p></br>
<?php } ?>
</div>
</div>
</div>
</div>
<br/>
<style>
.jiangx2 p{ text-align:left; line-height:29px;}
</style>
<center>
<div style="background:#FFF8B2;width:310px;height:300px;">


<div style="border:1px dashed #E3E09D;width:300px;height:295px;">
<div style="float:left;"><img src="images/shuoming.png"></div>
<div style="float:left;color:#4B4918;"  class="jiangx2">
<p><strong><?php echo $rts['content'];?></strong></p>

<center><!--<a href="<?php // echo ADMIN_URL."user.php?act=prize" ?>">查看我的奖项</a>-->>>&nbsp;<a href="<?php echo ADMIN_URL."daili.php?act=v2_mymoney" ?>">查看我已抽中的红包</a></center>
</div>

</div>
</center> 

</div>

</body>


<?php $this->element('25/footer',array('lang'=>$lang)); ?>


控制器代码

function choujiang()
{
$uid = $this->checked_login();

    $sql = "select * FROM `gz_lottery` where lt_prize<>'' order by id asc";
$lt_list = $this->App->find($sql);
$sql = "select * from `gz_lottery_set` where id=1";
$rts = $this->App->findrow($sql);

$this->set('rt',$lt_list);
$this->set('rts',$rts);

if(!defined(NAVNAME)) define('NAVNAME', "抽奖环节");
$mb = $GLOBALS['LANG']['mubanid'] > 0 ? $GLOBALS['LANG']['mubanid'] : '';
$this->template($mb.'/choujiang');
}

function ajax_choujiang($data)
{
    $uid = $this->Session->read('User.uid');
       
$sql = "select * from `gz_lottery_set` where id=1";
$rt = $this->App->findrow($sql);
$num1 = $rt['num'];
$end_time = $rt['end_time'];

$sql = "select count(id) from `gz_lottery_user` where uid=".$uid;
$num2 = $this->App->findvar($sql); 

if(time() > $end_time){
$result['info'] = "当前活动已经结束,".$end_time."敬请期待下期活动!";
echo json_encode($result);
exit();    
}
        
/*if($num2 >= $num1){
$result['info'] = "每人只有".$num1."次抽奖机会哦,你的抽奖机会已经用完了!";
echo json_encode($result);
exit();    
}*/
//先查询出有多少积分,规定每次使用100积分可以玩一次
$sql = "SELECT mypoints FROM `{$this->App->prefix()}user` WHERE user_id='$uid' LIMIT 1";
$rt['userinfojf'] = $this->App->findrow($sql);
$mypoints = $rt['userinfojf']['mypoints'];//获取到积分


/*if($mypoints < 100){ 

$sqlhb = "SELECT stjhongbao FROM `{$this->App->prefix()}user` WHERE user_id = '$uid' LIMIT 1";
$stjhb = $this->App->findrow($sqlhb);
 
$stjhongbao = $stjhb['stjhongbao'];//取出现有的红包 
//发红包开始
 
  
$stjhongbao5 = 5;
$sql = "UPDATE `{$this->App->prefix()}user` SET `stjhongbao` = `stjhongbao`+$stjhongbao5 WHERE user_id = '$uid'";
$sql = "UPDATE `{$this->App->prefix()}user` SET `stjhongbao` = `share_ucount`+1 WHERE user_id = '$tid'";
$this->App->query($sql);

$result['info'] = "".$sql."";
echo json_encode($result);
exit();    
}*/



//$uid = $this->Session->read('User.uid');
if($mypoints < 100){//判断积分是否够用,如果小于100 不让玩提示一下。
$result['info'] = "每次需要100积分才可以抽奖哦,赶快推荐新的朋友加入增加您积分!";
echo json_encode($result);
exit();    
}

/*插入中奖记录表*/
$add_record_sql = "insert into `gz_lottery_user` (uid,lt_id,create_time)VALUES('$uid','$rid','".time()."')";
if($res['prize']){
$this->App->query($add_record_sql);  
}


//大转盘转一次给用户减少100积分 O(∩_∩)O哈哈~
$sql = "UPDATE `{$this->App->prefix()}user` SET `mypoints` = `mypoints`-100 WHERE user_id = '$uid'";
$this->App->query($sql);

//给用户发红包咯,
$sqlhb = "SELECT stjhongbao FROM `{$this->App->prefix()}user` WHERE user_id = '$uid' LIMIT 1";
$stjhb = $this->App->findrow($sqlhb);
$stjhongbao = $stjhb['stjhongbao'];//取出现有的红包 
//发红包开始
$sql = "UPDATE `{$this->App->prefix()}user` SET `stjhongbao` = `stjhongbao`+5 WHERE user_id = '$uid'";
$this->App->query($sql);
//发红包结束睡觉,20160113 05点10分 add 困死了。 

//读取抽奖配置信息
$sql = "select * FROM `gz_lottery` where lt_prize<>'' order by id asc";
$lt_list = $this->App->find($sql);
$prize_arr = array();
$i = 0;
foreach($lt_list as $rs){  
$i++;
$lt_min = explode(',',$rs['lt_min']); 
$lt_max = explode(',',$rs['lt_max']);    
$rs['lt_min'] = count($lt_min)>1?$lt_min:$rs['lt_min'];//如果多个角度,则返回数组 
$rs['lt_max'] = count($lt_max)>1?$lt_min:$rs['lt_max']; //如果多个角度,则返回数组
$sql = "select count(id) FROM `gz_lottery_user` where lt_id = ".$rs['id'];
$rs_count = $this->App->findvar($sql);
$count = empty($rs_count) ? 0 : $rs_count;
$prize_arr[$i] = array(
'id'=>$rs['id'],
'min'=>$rs['lt_min'],//最小角度(大于0度 小于360度) 多个角度用,分隔
'max'=>$rs['lt_max'],//最大角度 (大于0度 小于360度) 多个角度用,分隔
'prize'=>$rs['lt_prize'],//奖项
'name'=>$rs['lt_name'],//奖品名称
'v'=>$rs['lt_v'],//中奖概率 (单位 %)
'lt_allowed'=>$rs['lt_allowed'],//中奖名额
'c'=>$count //中奖记录表中的已中奖数量    
);   
}
 
/*如果中奖数量已达名额上限,则此奖项概率归零,并记录总概率*/
foreach ($prize_arr as $key =>$val) {
if($val['c'] >= $val['lt_allowed']){
$val['v'] = 0;
}else{
$val['v'] = $val['v'];
}  
$count_v += $val['v'];//奖项总概率 
   $prize_arr[$key] = $val;


/*判断总概率若为0 则表示名额已用完,不能再抽奖*/
if($count_v == 0){
$result['info'] = "当前所有奖项已被抽空,请下次再来!".$count_v;
echo json_encode($result);
exit();    
}

//取出中奖配置
foreach ($prize_arr as $key =>$val) {
$arr[$val['id']] = $val['v'];
}

$rid = $this->getRand($arr); //根据概率获取奖项id

$res = $prize_arr[$rid]; //中奖项

$min = $res['min'];//得到最小角度
$max = $res['max'];//得到最大角度
if($res['id']==7){ //七等奖
$i = mt_rand(0,5);//随机一个配置好的角度
$result['angle'] = mt_rand($min[$i],$max[$i]);
}else{
$result['angle'] = mt_rand($min,$max); //随机生成一个角度
}

$result['prize'] = $res['prize'];
$result['name'] = $res['name'];
 
unset($prize_arr);
echo json_encode($result);
}


//获取中奖项ID
function getRand($proArr) {
$result = '';
//概率数组的总概率精度
$proSum = array_sum($proArr);
//概率数组循环
foreach ($proArr as $key =>$proCur) {
$randNum = mt_rand(1, $proSum);
if ($randNum <= $proCur) {
$result = $key;
break;
} else {
$proSum -= $proCur;
}
}
unset ($proArr);
return $result;
}

function prize()
{
$uid = $this->checked_login();

$sql = "SELECT l.create_time,j.lt_prize,j.lt_name FROM `{$this->App->prefix()}lottery_user` AS l LEFT JOIN `{$this->App->prefix()}lottery` AS j ON l.lt_id = j.id where l.uid=$uid order by l.id ";
$rt=$this->App->find($sql);
$this->set('rt',$rt);
if(!defined(NAVNAME)) define('NAVNAME', "我的奖品");
$mb = $GLOBALS['LANG']['mubanid'] > 0 ? $GLOBALS['LANG']['mubanid'] : '';
$this->template($mb.'/prize');
}
上面两张图是在两个服务器上面访问的截图有没有大神帮忙看一下是什么原因,本地 的图片并没有损坏但是现实却出问题了!

1 个解决方案

#1


先抢个位置,坐等大神路过!

#1


先抢个位置,坐等大神路过!