正在显示
1 个修改的文件
包含
43 行增加
和
27 行删除
@@ -78,41 +78,57 @@ class Index extends Api | @@ -78,41 +78,57 @@ class Index extends Api | ||
78 | $params = $this->request->param(); | 78 | $params = $this->request->param(); |
79 | //用户所在省市区 | 79 | //用户所在省市区 |
80 | // $UserAddress = $this->getCity($params['lng'], $params['lat']); | 80 | // $UserAddress = $this->getCity($params['lng'], $params['lat']); |
81 | - $Map['address'] = ['LIKE', '%' . $params['city'] . '%']; | ||
82 | - $MapKey = []; | ||
83 | - if (!empty($params['keywords']) || $params['keywords'] != '' || $params['keywords'] != "" || $params['keywords'] != null) { | ||
84 | - $MapKey['title'] = ['LIKE', '%' . $params['keywords'] . '%']; | ||
85 | - } | ||
86 | - $SellerArray = Db::name('seller')->where($Map)->where($MapKey)->where('status', 0)->select(); | ||
87 | - //首页轮播图 | ||
88 | - $IndexBanner = []; | ||
89 | - $IndexBanner = Db::name('index_banner')->order('weigh desc')->field('id,image,web')->select(); | ||
90 | - if (!empty($IndexBanner)) { | ||
91 | - foreach ($IndexBanner as $k => $v) { | ||
92 | - $IndexBanner[$k]['image'] = $this->ImgUrl($v['image']); | 81 | + if (empty($params['lng']) || $params['lng'] == '' || $params['lng'] == "" || $params['lng'] == null) { |
82 | + //首页轮播图 | ||
83 | + $IndexBanner = []; | ||
84 | + $IndexBanner = Db::name('index_banner')->order('weigh desc')->field('id,image,web')->select(); | ||
85 | + if (!empty($IndexBanner)) { | ||
86 | + foreach ($IndexBanner as $k => $v) { | ||
87 | + $IndexBanner[$k]['image'] = $this->ImgUrl($v['image']); | ||
88 | + } | ||
93 | } | 89 | } |
94 | - } | ||
95 | - if (empty($SellerArray)) { | ||
96 | $data = [ | 90 | $data = [ |
97 | 'IndexBanner' => $IndexBanner, | 91 | 'IndexBanner' => $IndexBanner, |
98 | 'Count' => 0, | 92 | 'Count' => 0, |
99 | 'List' => [] | 93 | 'List' => [] |
100 | ]; | 94 | ]; |
101 | } else { | 95 | } else { |
102 | - foreach ($SellerArray as $k => $v) { | ||
103 | - $List[$k]['id'] = $v['id']; | ||
104 | - $List[$k]['Image'] = $this->ImgUrl($v['image']); | ||
105 | - $List[$k]['Title'] = $v['title']; | ||
106 | - $List[$k]['Content'] = $v['content']; | ||
107 | - $List[$k]['Form'] = $this->getDistance($params['lng'], $params['lat'], $v['lng'], $v['lat']); | 96 | + $Map['address'] = ['LIKE', '%' . $params['city'] . '%']; |
97 | + $MapKey = []; | ||
98 | + if (!empty($params['keywords']) || $params['keywords'] != '' || $params['keywords'] != "" || $params['keywords'] != null) { | ||
99 | + $MapKey['title'] = ['LIKE', '%' . $params['keywords'] . '%']; | ||
100 | + } | ||
101 | + $SellerArray = Db::name('seller')->where($Map)->where($MapKey)->where('status', 0)->select(); | ||
102 | + //首页轮播图 | ||
103 | + $IndexBanner = []; | ||
104 | + $IndexBanner = Db::name('index_banner')->order('weigh desc')->field('id,image,web')->select(); | ||
105 | + if (!empty($IndexBanner)) { | ||
106 | + foreach ($IndexBanner as $k => $v) { | ||
107 | + $IndexBanner[$k]['image'] = $this->ImgUrl($v['image']); | ||
108 | + } | ||
109 | + } | ||
110 | + if (empty($SellerArray)) { | ||
111 | + $data = [ | ||
112 | + 'IndexBanner' => $IndexBanner, | ||
113 | + 'Count' => 0, | ||
114 | + 'List' => [] | ||
115 | + ]; | ||
116 | + } else { | ||
117 | + foreach ($SellerArray as $k => $v) { | ||
118 | + $List[$k]['id'] = $v['id']; | ||
119 | + $List[$k]['Image'] = $this->ImgUrl($v['image']); | ||
120 | + $List[$k]['Title'] = $v['title']; | ||
121 | + $List[$k]['Content'] = $v['content']; | ||
122 | + $List[$k]['Form'] = $this->getDistance($params['lng'], $params['lat'], $v['lng'], $v['lat']); | ||
123 | + } | ||
124 | + $newarr = array_column($List, 'Form'); | ||
125 | + array_multisort($newarr, SORT_ASC, $List); | ||
126 | + $data = [ | ||
127 | + 'IndexBanner' => $IndexBanner, | ||
128 | + 'Count' => count($SellerArray), | ||
129 | + 'List' => $this->page_array($params['rows'], $params['pages'], $List, 0) | ||
130 | + ]; | ||
108 | } | 131 | } |
109 | - $newarr = array_column($List, 'Form'); | ||
110 | - array_multisort($newarr, SORT_ASC, $List); | ||
111 | - $data = [ | ||
112 | - 'IndexBanner' => $IndexBanner, | ||
113 | - 'Count' => count($SellerArray), | ||
114 | - 'List' => $this->page_array($params['rows'], $params['pages'], $List, 0) | ||
115 | - ]; | ||
116 | } | 132 | } |
117 | $this->success('成功', $data); | 133 | $this->success('成功', $data); |
118 | } | 134 | } |
-
请 注册 或 登录 后发表评论