getTopUrl(); $data['topUrl']=$topUrl;*/ $banner =$this->getBanner('轮播图'); $data['banner']=$banner; $category =$this->getBanner('分类'); $data['category']=$category; $this->success('',$data); } public function getIndexTwo() { $data =$this->getBlockShow(); $this->success('',$data); } public function getBlockShow() { $where['status']=1; $where['showType']=array('egt',1); $wheres['showType']=array('elt',7); $data=Db::name('appindex')->where($where)->where($wheres)->select(); $new =array(); foreach ($data as $k=> $v){ $new[$k]=$this->doHandle($v); } return $new; } public function doHandle($v) { $data=array(); $data['title'] = $v['name']; $data['showType'] = $v['showType'];// 1: best seller 2:new in 3:图片check now 4:flash deal 5:图片 wholesale 6:shop by looking 7: membership $data['imgUrl'] =''; $url=input('server.REQUEST_SCHEME') . '://' . input('server.SERVER_NAME'); if($v['image']){ $data['imgUrl'] =$url.$v['image']; } $data['type'] = $v['type']; $data['typeId'] = $v['link']; $data['titleArr'] = array(); if($data['showType'] ==6){ $ndata =array(); foreach ($this->getDetail($v['id']) as $k=> $vs){ $ndata[$k]['type'] = $vs['type']; $ndata[$k]['title'] = $vs['title']; $ndata[$k]['imgUrl'] = $url.$vs['image']; $ndata[$k]['typeId'] = $vs['link']; } $data['titleArr'] =$ndata; } $data['productList'] = array(); if($data['showType'] ==1||$data['showType'] ==2||$data['showType'] ==4){ $ndatas =array(); $currencyCode='USD'; $currency_code =$this->request->header("Content-Currency"); if($currency_code){ $currencyCode =$currency_code; } $priceData = $this->getPrice($currencyCode); foreach ($this->getDetail($v['id']) as $ks=> $vul){ $ndatas[$ks]['entity_id'] = $vul['link']; $ndatas[$ks]['name'] = $vul['title']; $ndatas[$ks]['image'] = $vul['images']; $ndatas[$ks]['price'] = round($vul['oldPrice']*$priceData[0],2); $ndatas[$ks]['final_price'] = round($vul['nowPrice']*$priceData[0],2); if($ndatas[$ks]['price']){ $percent = 100-round($vul['nowPrice']/$vul['oldPrice'],2)*100; $ndatas[$ks]['percent']= $percent; $ndatas[$ks]['discount_app']=$percent.'% Off'; } $ndatas[$ks]['currencySymbol']=$priceData[1]; //$ndatas[$ks]['sale_num'] = $vul['sale_num']; //$ndatas[$ks]['currencySymbol']=$currencySymbol; } $data['productList'] =$ndatas; } return $data; } public function getPrice($currencyCode) { $data['AUD']=[1.5,'A$']; $data['GBP']=[0.88,'£']; $data['CAD']=[1.33,'CA$']; $data['EUR']=[1.0022,'€']; $data['ZAR']=[17.8,'ZAR']; $data['USD']=[1,'$']; if(empty($data[$currencyCode])){ $currencyCode='USD'; } return $data[$currencyCode]; } public function getBanner($code) { $banner=$this->getBlockDetail($code); $new=array(); $url=input('server.REQUEST_SCHEME') . '://' . input('server.SERVER_NAME'); foreach ($banner as $k=> $v){ $new[$k]['title'] = $v['title']; $new[$k]['link'] = $v['link']; $new[$k]['type'] = $v['type']; $new[$k]['image'] =$url.$v['image']; } return $new; } public function getTopUrl($code) { $block =$this->getBlock($code); $new['title'] = $block['title']; $new['name'] = $block['name']; $new['link'] = $block['link']; $new['type'] = $block['type']; return $new; } public function getBlock($code) { $where['status']=1; $where['title']=$code; return Db::name('appindex')->where($where)->find(); } public function getDetail($id) { $where['pid']=$id; return Db::name('appindexdes')->where($where)->select(); } public function getBlockDetail($code) { $where['status']=1; $where['title']=$code; $block= Db::name('appindex')->where($where)->find(); unset($where); $where['pid']=$block['id']; return Db::name('appindexdes')->where($where)->select(); } }