123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * 手机app发现tab页中的请求内容
- */
- defined('InShopNC') or exit('Access Invalid!');
- class findControl extends mobileHomeControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * 发现页面左边栏请求内容
- */
- public function category_listOp()
- {
- $category_list = Model()->table('category_item')->where(array('enable' => '1'))->order('sort asc')->select();
- $result = array();
- foreach ($category_list as $value) {
- $item['id'] = $value['id'];
- $item['name'] = $value['name'];
- $item['type'] = $value['category_type'];
- $item['gc_id'] = $value['gc_id'];
- array_push($result, $item);
- }
- joutput_data(array("category" => $result));
- }
- /**
- * 此时需要带图片了
- */
- public function category_list_2Op()
- {
- $category_list = Model()->table('category_item')->where(array('category_type' => 'keyword', 'enable' => '1'))->order('sort asc')->select();
- $result = array();
- foreach ($category_list as $value) {
- $item['id'] = $value['id'];
- $item['name'] = $value['name'];
- $item['type'] = $value['category_type'];
- $item['gc_id'] = $value['gc_id'];
- $item['img'] = $this->_formatPic($value['img']);
- // 子查询
- $child_list = Model()->table('goods_class')->where(array('gc_parent_id' => $value['gc_id']))->select();
- $child = array();
- foreach ($child_list as $child_value) {
- $child_item['id'] = $child_value['gc_id'];
- $child_item['gc_name'] = $child_value['gc_name'];
- $child_item['gc_id'] = $child_value['gc_id'];
- array_push($child, $child_item);
- }
- $item['child_item'] = $child;
- array_push($result, $item);
- }
- joutput_data(array("category" => $result));
- }
- /**
- * 添加图片路径
- */
- private function _formatPic($filename)
- {
- if (!isset($filename) || empty($filename)) {
- return '';
- }
- return UPLOAD_SITE_URL . '/shop/class/' . $filename;
- }
- }
|