model = Db::name('company'); } /** * 列表 * @return void */ public function getList() { try { $lng = $this->request->param('lng',''); $lat = $this->request->param('lat',''); $field = 'id,name,image,contacts,mobile,full_address,longitude,latitude,is_open,open_hours'; $where['status'] = 1; $result = $this->model->where($where)->field($field)->autopage()->select(); if (!empty($result)) { foreach ($result as $key => &$value) { $value['distance'] = getDistance($lng, $lat, $value['longitude'], $value['latitude'], false, 2,true); } } $this->success('获取成功',$result); } catch (Exception $e) { $this->error($e->getMessage()); } } }