<?php
defined('G_IN_SYSTEM')or exit('No permission resources.');
System::load_app_class('base','member','no');
System::load_app_fun('my','go');
System::load_app_fun('user','go');
System::load_sys_fun('send');
System::load_sys_fun('user');
class app extends base {
    private $Mcartlist;

	public function __construct(){
		parent::__construct();
/* 		if(ROUTE_A!='userphotoup' and ROUTE_A!='singphotoup'){
			if(!$this->userinfo)_message("请登录",WEB_PATH."/mobile/user/login",3);
		}	 */
		$this->db = System::load_sys_class('model');


		//查询购物车的信息
		$Mcartlist=_getcookie("Cartlist");
		$this->Mcartlist=json_decode(stripslashes($Mcartlist),true);

		$Mcartlist_jf=_getcookie("Cartlist_jf");
		$this->Mcartlist_jf=json_decode(stripslashes($Mcartlist_jf),true);
	}

	//APP最新揭晓
	public function GetNewJX(){


	      $shopsum=$this->db->GetList("select * from `go_shoplist` where `q_uid` is not null and `q_showtime` = 'N'");

	   //最新揭晓
		$shoplist['listItems']=$this->db->GetList("select * from `go_shoplist` where `q_end_time` !='' and `q_showtime`='N' ORDER BY `q_end_time` DESC LIMIT 4");

		if(empty($shoplist['listItems'])){
		  $shoplist['code']=1;
		}else{
		 foreach($shoplist['listItems'] as $key=>$val){
		 //查询出购买次数
		   $recodeinfo=$this->db->GetOne("select `gonumber` from `@#_member_go_record` where `uid` ='$val[q_uid]'  and `shopid`='$val[id]' ");
		   //echo "select `gonumber` from `@#_member_go_record` where `uid` !='$val[q_uid]'  and `shopid`='$val[id]' ";
		   $shoplist['listItems'][$key]['q_user']=get_user_name($val['q_uid']);
		   $shoplist['listItems'][$key]['userphoto']=get_user_key($val['q_uid'],'img');
		   $shoplist['listItems'][$key]['q_end_time']=microt($val['q_end_time']);
		   $shoplist['listItems'][$key]['gonumber']=$recodeinfo['gonumber'];
		 }
		  $shoplist['code']=0;
		  $shoplist['count']=count($shopsum);
		}

		echo json_encode($shoplist);

	}
	//app商品详情图片
	public function GetIMGItem(){
		$mysql_model=System::load_sys_class('model');
		$itemid=safe_replace($this->segment(4));
		$item=$mysql_model->GetOne("select * from `@#_shoplist` where `id`='".$itemid."' LIMIT 1");
		$item['picarr'] = unserialize($item['picarr']) ;

		echo json_encode($item['picarr']);
	}
	//APP首页轮播揭晓
	public function GetIndexJX(){
		$mysql_model=System::load_sys_class('model');

		$shoplist['listItems']=$this->db->GetList("select * from `go_shoplist` where `q_end_time` !='' and `q_showtime`='N' ORDER BY `q_end_time` DESC LIMIT 1");

		foreach($shoplist['listItems'] as $key=>$val){
		 //查询出购买次数
		   $recodeinfo=$this->db->GetOne("select `gonumber` from `@#_member_go_record` where `uid` ='$val[q_uid]'  and `shopid`='$val[id]' ");
		   //echo "select `gonumber` from `@#_member_go_record` where `uid` !='$val[q_uid]'  and `shopid`='$val[id]' ";
		   $shoplist['listItems'][$key]['q_user']=get_user_name($val['q_uid']);
		   $shoplist['listItems'][$key]['userphoto']=get_user_key($val['q_uid'],'img');
		   $shoplist['listItems'][$key]['q_end_time']=microt($val['q_end_time']);
		   $shoplist['listItems'][$key]['gonumber']=$recodeinfo['gonumber'];
		 }
		echo json_encode($shoplist);
	}

}
?>