<?php


namespace Home\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){
        
        $this->channel=channelAuction(10);
        
        $endwhere=array('endtime'=>array('elt',time()),'endstatus'=>1);
        $this->endlist = D('Auction')->where($endwhere)->order('endtime desc')->limit(20)->select();
        
        $link = M('link');
        $this->linkA = $link->order('sort desc')->where('rec = 1')->select();
        $this->linkB = $link->order('sort desc')->where('rec = 0')->select();
        $this->display();
     }

     public function search(){
        $auction = D('Auction');
        $news=M('News');
        
        if(IS_POST){
            $searchtype=I('post.searchtype');
            $searchkey=I('post.searchkey');
        }
        if(IS_GET){
            $searchtype=I('get.searchtype');
            $searchkey=I('get.searchkey');
        }
       switch ($searchtype) {
            case 1:
                $whereA['pname'] = array('LIKE', '%' . $searchkey . '%');
                $count = $auction->where($whereA)->where(bidSection(0))->count();
                $pConf = page($count,12);
                $search['auction']=$auction->where($whereA)->where(bidSection(0))->limit($pConf['first'].','.$pConf['list'])->order('bidcount desc')->select();
                break;
            case 2:
                $whereB['title']=array('LIKE', '%' . $searchkey . '%');
                $whereB['cid']=3;
                $count = $news->where($whereB)->count();
                $pConf = page($count,20);
                $search['news'] = $news->where($whereB)->limit($pConf['first'].','.$pConf['list'])->select();
                break;
            default:
                $whereA['pname'] = array('LIKE', '%' . $searchkey . '%');
                $search['auction']=$auction->where($whereA)->where(bidSection(0))->order('bidcount desc')->select();
                $whereB['title']=array('LIKE', '%' . $searchkey . '%');
                $whereB['cid']=3;

                $search['news'] = $news->where($whereB)->select();
                break;
        } 
        
        
        $this->channel=channelAuction(10);
        $this->page = $pConf['show']; 
        $this->searchtype=$searchtype;
        $this->searchkey=$searchkey;
        
        $this->search=$search;
        $this->display();
     }
    function test(){
        $uc = new \Ucenter\Client\Client();
        $re = $uc->uc_user_login("zhangsan", "123456");
        dump($re);
    }

}?>
