<?php 

defined('G_IN_SYSTEM')or exit('No permission resources.');
System::load_app_class('memberbase',null,'no');
System::load_app_fun('user','go');
System::load_app_fun('my','go');
System::load_sys_fun('send');
class user extends memberbase {
	public function __construct(){	
		parent::__construct();
		$this->db = System::load_sys_class("model");
	}

	public function cook_end(){
		_setcookie("uid","",time()-3600);
		_setcookie("ushell","",time()-3600);		
		//_message("退出成功",WEB_PATH."/mobile/mobile/");
		header("location: ".WEB_PATH."/mobile/mobile/");
	}
	//返回登录页面
	public function login(){	
		 $webname=$this->_cfg['web_name'];
		$user = $this->userinfo;
		if($user){			
			header("Location:".WEB_PATH."/mobile/home/");exit;
		}
		
		include templates("mobile/user","login");
		
	}
	//返回注册页面
	public function register(){
	  $webname=$this->_cfg['web_name'];
		include templates("mobile/user","register");
	}	
	
	//返回发送验证码页面
	public function mobilecode(){
	    $webname=$this->_cfg['web_name'];
	    $mobilename=$this->segment(4);
		
		include templates("mobile/user","mobilecheck");
	}
	
	public function mobilecheck(){
	    $webname=$this->_cfg['web_name'];
		$title="验证手机";	
		$time=3000;
		$name=$this->segment(4);		

		$member=$this->db->GetOne("SELECT * FROM `@#_member` WHERE `mobile` = '$name' LIMIT 1");
		 //var_dump($member);exit;
		if(!$member)_message("参数不正确!");
		if($member['mobilecode']==1){
			_message("该账号验证成功",WEB_PATH."/mobile/mobile");
		}
		if($member['mobilecode']==-1){
			$sendok = send_mobile_reg_code($name,$member['uid']);			
			if($sendok[0]!=1){
					_message($sendok[1]);
			}
			header("location:".WEB_PATH."/mobile/user/mobilecheck/".$member['mobile']);
			exit;
		}		
		 
	
		$enname=substr($name,0,3).'****'.substr($name,7,10);
		$time=120;
		include templates("mobile/user","mobilecheck");
	}
	
	
	public function buyDetail(){
	 $webname=$this->_cfg['web_name'];
	 $member=$this->userinfo;
	 $itemid=intval($this->segment(4));    
     
	 $itemlist=$this->db->GetList("select *,a.time as timego,sum(gonumber) as gonumber from `@#_member_go_record` a left join `@#_shoplist` b on a.shopid=b.id where a.uid='$member[uid]' and b.id='$itemid' group by a.id order by a.time" );
	 
	 if(!empty($itemlist)){
		 if($itemlist[0]['q_end_time']!=''){
	   //商品已揭晓
			$itemlist[0]['codeState']='已揭晓...';			 	   
			$itemlist[0]['class']='z-ImgbgC02';			 	   
	    }elseif($itemlist[0]['shenyurenshu']==0){
		//商品购买次数已满
			$itemlist[0]['codeState']='已满员...';			
			$itemlist[0]['class']='z-ImgbgC01';		
		}else{
		//进行中
			$itemlist[0]['codeState']='进行中...';
			$itemlist[0]['class']='z-ImgbgC01';
		 
		}
		$bl=($itemlist[0]['canyurenshu']/$itemlist[0]['zongrenshu'])*100;
	}	 
			 
     //echo "<pre>";	 
	 //print_r($itemlist);
	 include templates("mobile/user","userbuyDetail");
	}
	
}//

?>