find.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * 手机app发现tab页中的请求内容
  4. */
  5. defined('InShopNC') or exit('Access Invalid!');
  6. class findControl extends mobileHomeControl
  7. {
  8. public function __construct()
  9. {
  10. parent::__construct();
  11. }
  12. /**
  13. * 发现页面左边栏请求内容
  14. */
  15. public function category_listOp()
  16. {
  17. $category_list = Model()->table('category_item')->where(array('enable' => '1'))->order('sort asc')->select();
  18. $result = array();
  19. foreach ($category_list as $value) {
  20. $item['id'] = $value['id'];
  21. $item['name'] = $value['name'];
  22. $item['type'] = $value['category_type'];
  23. $item['gc_id'] = $value['gc_id'];
  24. array_push($result, $item);
  25. }
  26. joutput_data(array("category" => $result));
  27. }
  28. /**
  29. * 此时需要带图片了
  30. */
  31. public function category_list_2Op()
  32. {
  33. $category_list = Model()->table('category_item')->where(array('category_type' => 'keyword', 'enable' => '1'))->order('sort asc')->select();
  34. $result = array();
  35. foreach ($category_list as $value) {
  36. $item['id'] = $value['id'];
  37. $item['name'] = $value['name'];
  38. $item['type'] = $value['category_type'];
  39. $item['gc_id'] = $value['gc_id'];
  40. $item['img'] = $this->_formatPic($value['img']);
  41. // 子查询
  42. $child_list = Model()->table('goods_class')->where(array('gc_parent_id' => $value['gc_id']))->select();
  43. $child = array();
  44. foreach ($child_list as $child_value) {
  45. $child_item['id'] = $child_value['gc_id'];
  46. $child_item['gc_name'] = $child_value['gc_name'];
  47. $child_item['gc_id'] = $child_value['gc_id'];
  48. array_push($child, $child_item);
  49. }
  50. $item['child_item'] = $child;
  51. array_push($result, $item);
  52. }
  53. joutput_data(array("category" => $result));
  54. }
  55. /**
  56. * 添加图片路径
  57. */
  58. private function _formatPic($filename)
  59. {
  60. if (!isset($filename) || empty($filename)) {
  61. return '';
  62. }
  63. return UPLOAD_SITE_URL . '/shop/class/' . $filename;
  64. }
  65. }