本帖最后由 qq_16097601 于 2014-10-31 12:02:02 编辑

解决方案 »

  1.   

    ActAction.class.php
    <?php
    define('LIB_PATH',APP_PATH.'Libraries');
    class ActAction extends CommonAction {    public function cqfs() {        $this->display();
        }    public function cqfso()
        {           
            $M=M('ActCqfs');
            $action = $_GET['action']; 
            if($action==""){ //读取数据,返回json 
            $list=$M->select();
            foreach ($list as $key => $value) {
                $arr[] = array( 
                    'id' => $value['id'], 
                    'mobile' => substr($value['mobile'],0,3)."****".substr($value['mobile'],-4,4) 
                ); 
            }
            echo json_encode($arr); 
            }else{ //标识中奖号码 
            $id = $_POST['id']; 
            $data['status']=1;
            if($M->where('id='.$id)->save($data)){ 
                echo '1'; 
            } 
        } 
        }
    }
    cqfs.html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>PHP抽奖程序</title>
    <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.9.0/jquery.min.js"></script>
    <style>
    .demo {
    width:300px;
    margin:60px auto;
    text-align:center
    }
    #roll {
    height:32px;
    line-height:32px;
    font-size:24px;
    color:#f30;
    text-align:center
    }
    .btn {
    width:80px;
    height:26px;
    line-height:26px;
    background:url(btn_bg.gif) repeat-x;
    border:1px solid #d3d3d3;
    cursor:pointer
    }
    #stop {
    display:none
    }
    #result {
    margin-top:20px;
    line-height:24px;
    font-size:16px;
    text-align:center
    }
    .con {
    text-align:center
    }
    </style>
    </head><body>
    <div id="roll"></div>
    <div class="con">
    <input type="hidden" id="mid" value="">
    <p>
      <input type="button" class="btn" id="start" value="开始">
      <input type="button" class="btn" id="stop" value="停止">
    </p>
    </div>
    <div id="result"></div>
    <script language="javascript" type="text/javascript">
    $(function(){ 
        var _gogo; 
        var start_btn = $("#start"); 
        var stop_btn = $("#stop"); 
         
        start_btn.click(function(){ 
            $.getJSON('__URL__/cqfso',function(json){ 
                if(json){ 
                    var obj = eval(json);//将JSON字符串转化为对象 
                    var len = obj.length; 
                    _gogo = setInterval(function(){ 
                        var num = Math.floor(Math.random()*len);//获取随机数 
                        var id = obj[num]['id']; //随机id 
                        var v = obj[num]['mobile']; //对应的随机号码 
                        $("#roll").html(v); 
                        $("#mid").val(id); 
                    },100); //每隔0.1秒执行一次 
                    stop_btn.show(); 
                    start_btn.hide(); 
                }else{ 
                    $("#roll").html('系统找不到数据源,请先导入数据。'); 
                } 
            }); 
        }); stop_btn.click(function(){ 
            clearInterval(_gogo); 
            var mid = $("#mid").val(); 
            $.post("__URL__/cqfso/action/ok",{id:mid},function(msg){             if(msg==1){ 
                    var mobile = $("#roll").html(); 
                    $("#result").append("<p>"+mobile+"</p>"); 
                } 
                stop_btn.hide(); 
                start_btn.show(); 
            }); 
        }); }); 
    </script>
    </body>
    </html>
    下载有这两个文件,要怎么应用到thinkphp?
    请详细说一下...谢谢
      

  2.   

    将对应的MVC放置到对应的文件夹下后,再导入数据库表结构及对应数据即可。
      

  3.   

    Modules你不前不用动,然后再C 中写自己的方法,对性的V中是视图显示,才配置文件中配置好数据库的相关配置。
      

  4.   

    第一段代码中没有'define('LIB_PATH',APP_PATH.'Libraries');'这一句
      

  5.   

    你下的文件里面没有使用说明吗。一般情况下:
    把项目文件夹放在根目录,比如文件夹叫xxx , 则以http://localhost/xxx 访问。当然你还要导入数据到MySQL。
      

  6.   


    这个我知道,直接打开会出错,他这个是基于thinkphp框架的,我没用过,不知道文件应该怎么放
      

  7.   

    ActAction.class.php 放在项目的 Lib 目录中
    cqfs.html 放在项目的 Tpl 目录中
    执行他提供的 sql 创建数据表,并填入数据既然你没用过 thinkphp ,那么就不要硬搞了
    号码滚动都是在 cqfs.html 中用 js 控制的
    你只需提供一个号码数组
      

  8.   

    我现在想知道的就是对应的文件夹还有配置好后 前端页面是不是直接运行?肯定是需要你按照URL进行访问才可以的,你要是直接打开文件肯定是不行的