<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied'); class goods_index_mod extends module { function __construct(){ parent::__construct(); } public function goods($arr){ $page_size = isset($arr['page_size'])?$arr['page_size']:'8'; $cquery = $this->db->query("select cid,pcid,px_hot,px_index,px_recommend,name,status from ".table('category')." "); while($crow = $this->db->fetch_array($cquery)){ $cats[$crow['cid']] = $crow; $cats_name[$crow['cid']] = $crow; $cats_arr[$crow['pcid']][$crow['cid']] = $crow['name']; } $lou = '1'; foreach($cats_arr[0] as $k=>$v){ $result_cats_arr = $this->module('goods')->cats_arr($k, $cats_arr); foreach($result_cats_arr as $vv){ if($cats[$vv]['px_index'] == '1'){ $data[$k]['cats'][] = $cats[$vv]; } } if(count($result_cats_arr) != 0){ $cats_in = implode(',',$result_cats_arr); $goods = $this->db->get_all("select id,cid,title,images,price,market_price,status from ".table('goods')." where cid in (".$cats_in.") and status = 1 and px_index = 1 order by id desc limit ".$page_size); } $data[$k]['ad_cid'] = 'index-floor-'.$lou.'f'; $data[$k]['m_ad_cid'] = 'm-index-floor-'.$lou.'f'; $data[$k]['lou'] = $lou; $data[$k]['goods'] = $goods; $data[$k]['cname'] = $cats_name[$k]['name']; $data[$k]['cid'] = $cats_name[$k]['cid']; unset($goods); unset($result_cats_arr); $lou++; } return $data; } public function like($arr){ $page = isset($arr['page'])?$arr['page']:'1'; $page_size = isset($arr['page_size'])?$arr['page_size']:'20'; $query = $this->db->get_all("select id,cid,title,images,price,act_price,market_price,volume  from ".table('goods')." where status = 1 order by id desc limit 10"); if($query){ foreach($query as $k=>$v){ $v['title'] = cut_str($v['title'],'20'); $data[] = $v; } $result['data'] = $data; $result['page'] = $this->uqcms_page(array('page'=>$page,'page_size'=>$page_size,'total'=>'1200')); return $result; }else{ return false; } } public function wap_index($arr){ $page = isset($arr['page'])?$arr['page']:'1'; $page_size = isset($arr['page_size'])?$arr['page_size']:'20'; $query = $this->db->get_all("select id,cid,title,images,price,market_price,volume from ".table('goods')." where px_index = 1 and status = 1 order by id desc limit ".($page-1)*$page_size.",".$page_size); if($query){ foreach($query as $k=>$v){ $v['title'] = cut_str($v['title'],'20'); $data[] = $v; } $result['data'] = $data; $total = $this->db->get_one("select id as total from ".table('goods')." where px_index and status = 1"); $result['page'] = $this->uqcms_page(array('page'=>$page,'page_size'=>$page_size,'total'=>$total['total'])); return $result; }else{ return false; } } }