tp5项目前台比赛列表

控制器

    public function game(){
        $id = input('id');
        $user = db('login')->where('id',$id)->select();
        $dqdata1 = date('Y-m-d',strtotime(date('Y-m-d')));
        $dqdata2 = date('Y-m-d',strtotime(date('Y-m-d'))+24*60*60);
        $dqdata3 = date('Y-m-d',strtotime(date('Y-m-d'))+2*24*60*60);
        $dqdata4 = date('Y-m-d',strtotime(date('Y-m-d'))+3*24*60*60);
        //计算今天,明天,后天,大后天凌晨四个时刻
        $blist1 = db('basgame')->where('time','>=',$dqdata1)->where('time','<',$dqdata2)->select();
        $slist1 = db('scogame')->where('time','>=',$dqdata1)->where('time','<',$dqdata2)->select();
        $blist2 = db('basgame')->where('time','>=',$dqdata2)->where('time','<',$dqdata3)->select();
        $slist2 = db('scogame')->where('time','>=',$dqdata2)->where('time','<',$dqdata3)->select();
        $blist3 = db('basgame')->where('time','>=',$dqdata3)->where('time','<',$dqdata4)->select();
        $slist3 = db('scogame')->where('time','>=',$dqdata3)->where('time','<',$dqdata4)->select();
        //筛选出今明后三天的各项比赛,然后在view适当的位置进行循环输出
        $this->assign('blist1',$blist1);
        $this->assign('slist1',$slist1);
        $this->assign('blist2',$blist2);
        $this->assign('slist2',$slist2);
        $this->assign('blist3',$blist3);
        $this->assign('slist3',$slist3);
        $this->assign('user',$user);
        $this->assign('dqdata1',$dqdata1);
        $this->assign('dqdata2',$dqdata2);
        $this->assign('dqdata3',$dqdata3);
        return $this->fetch();
    }
视图html
<div class="loljc J-hero-cont" >
      <dl class="jincai-schedule">
      <dt>{$dqdata1}</dt>
      {volist name="user" id="vo"}
        {volist name="blist1" id="voo"}
                <dd class="jincai-schedule-0">          <a href="{:url('index/bmatch',['id'=>$vo.id,'gid'=>$voo.id])}">
            <p><img src="/static/imgs/bas.jpg"></p>
            <p><i>{$voo.time}</i> <i>{$voo.contest}</i></p>
            <p>{$voo.team1}</p>
            <p><img src="{$voo.img1}"></p>
            <p><i>vs</i></p>
            <p><img src="{$voo.img2}"></p>
            <p>{$voo.team2}</p>
            <p>
            <i></i>
                            <i class="zt_4">{$voo.state}</i>
                            <i></i></p>
          </a>
        {/volist}
      {/volist}
      {volist name="user" id="vo"}
        {volist name="slist1" id="voo"}
                  <dd class="jincai-schedule-0">          <a href="{:url('index/smatch',['id'=>$vo.id,'gid'=>$voo.id])}">
              <p><img src="/static/imgs/sco.jpg"></p>
              <p><i>{$voo.time}</i> <i>{$voo.contest}</i></p>
              <p>{$voo.team1}</p>
              <p><img src="{$voo.img1}"></p>
              <p><i>vs</i></p>
              <p><img src="{$voo.img2}"></p>
              <p>{$voo.team2}</p>
              <p>
              <i></i>
                              <i class="zt_4">{$voo.state}</i>
                              <i></i></p>
            </a>     
        {/volist}
      {/volist}
    </div>
以此类推循环最近三天的比赛
posted @ 2020-08-13 14:49  HighKK  阅读(133)  评论(0编辑  收藏  举报