<?php
namespace wstmart\mobile\controller;
use wstmart\mobile\model\Index as M;
/**
 * ============================================================================
 * 默认控制器
 */
class Index extends Base{
	/**
     * 首页
     */
    public function index(){
    	$m = new M();
    	hook('mobileControllerIndexIndex',['getParams'=>input()]);

         //秒杀商品
        // $now_time = time();  //当前时间
        // if(is_int($now_time/7200)){      //双整点时间,如:10:00, 12:00
        //     $start_time = $now_time;
        // }else{
        //     $start_time = floor($now_time/7200)*7200; //取得前一个双整点时间
        // }
        // $end_time = $start_time+7200;   //结束时间

        $year = date("Y");
        $month = date("m");
        $day = date("d");
        $start_time = mktime(8,0,0,$month,$day,$year);//当天开始时间戳
        $end_time= mktime(20,0,0,$month,$day,$year);//当天结束时间戳
        $this->assign('start_time',$start_time);
        $this->assign('end_time',$end_time);
        
    	$news = $m->getSysMsg('msg');
    	$this->assign('news',$news);
    	$ads['count'] =  count(model("common/Tags")->listAds("mo-ads-index",99,86400));
    	$ads['width'] = 'width:'.$ads['count'].'00%';
    	$this->assign("ads", $ads);
    	return $this->fetch('index');
    }
    /**
     * 楼层
     */
    public function pageQuery(){
    	$m = new M();
    	$rs = $m->pageQuery();
    	if(isset($rs['goods'])){
    		foreach ($rs['goods'] as $key =>$v){
    			$rs['goods'][$key]['goodsImg'] = WSTImg($v['goodsImg'],2);
    		}
    	}
        return $rs;
    }
    /**
     * 猜你喜欢
     * @return [type] [description]
     */
    public function guess_like(){
        $m = new M();
        $rs = $m->guess_like();
        if(isset($rs['goods'])){
            foreach ($rs['goods'] as $key =>$v){
                $rs['goods'][$key]['goodsImg'] = WSTImg($v['goodsImg'],2);
            }
        }
        return $rs;
    }
    /**
     * 转换url
     */
    public function transfor(){
        $data = input('param.');
        $url = $data['url'];
        unset($data['url']);
        echo Url($url,$data);
    }
    /**
     * 跳去登录之前的地址
     */
    public function sessionAddress(){
    	session('WST_MO_WlADDRESS',input('url'));
    	return WSTReturn("", 1);
    }
}