添加根据经纬度获取城市
添加后台统计看板
This commit is contained in:
@@ -5,6 +5,7 @@ namespace app\api\controller;
|
||||
|
||||
use app\api\logic\AdLogic;
|
||||
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
@@ -13,7 +14,7 @@ header("Access-Control-Allow-Headers: Content-Type, Authorization");
|
||||
|
||||
class Ad extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['lists','channel','label','add_comost','add_comost','list_comost','follow_comost','comost_add','label_edit','comost_info','notice','position','position_list','vode_type','video_list','video_info','user_wages','user_wages_add','user_leave','fine','recruit','last_leave','last_fine','notice_list','leave','auth'];
|
||||
public $like_not_need_login = ['lists','popup','channel','label','add_comost','add_comost','list_comost','follow_comost','comost_add','label_edit','comost_info','notice','position','position_list','vode_type','video_list','video_info','user_wages','user_wages_add','user_leave','fine','recruit','last_leave','last_fine','notice_list','leave','auth'];
|
||||
|
||||
/**
|
||||
* @return void
|
||||
@@ -30,7 +31,22 @@ class Ad extends ApiBase
|
||||
}
|
||||
$this->_success('获取成功', $list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取弹窗
|
||||
public function popup()
|
||||
{
|
||||
$list = Db::name('ad')
|
||||
->where('status',1)
|
||||
->where('pid',25)
|
||||
->field('id,name,image,link_type,link')
|
||||
->find();
|
||||
if ($list != null){
|
||||
$list['image'] = UrlServer::getFileUrl($list['image']);
|
||||
}
|
||||
$this->_success('获取成功', $list);
|
||||
}
|
||||
|
||||
//获取客户的渠道
|
||||
public function channel(){
|
||||
$list=Db::name('staffchannel')->field('id,name')->select();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\server\CityService;
|
||||
use app\api\model\User;
|
||||
|
||||
class City extends ApiBase
|
||||
{
|
||||
@@ -25,4 +26,37 @@ class City extends ApiBase
|
||||
$array = $this->cityService->list();
|
||||
return $this->_success('成功',$array);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据经纬度获取所在城市
|
||||
* @return void
|
||||
*/
|
||||
public function getCity()
|
||||
{
|
||||
$lat = $this->request->param('lat', '');
|
||||
$lng = $this->request->param('lng', '');
|
||||
|
||||
if (empty($lat) || empty($lng)) {
|
||||
return $this->_error('请提供经纬度参数');
|
||||
}
|
||||
$uid = $this->user_id;
|
||||
//查询用户信息
|
||||
$userInfo = User::find($uid);
|
||||
if ($userInfo) {
|
||||
if ($userInfo->longitude == '' || $userInfo->latitude == '')
|
||||
{
|
||||
$userInfo->longitude = $lng; // 经度
|
||||
$userInfo->latitude = $lat; // 纬度
|
||||
$userInfo->save();
|
||||
}
|
||||
}
|
||||
$result = $this->cityService->getCityByLocation($lat, $lng);
|
||||
|
||||
if ($result['success']) {
|
||||
return $this->_success($result['msg'], $result['data']);
|
||||
} else {
|
||||
return $this->_error($result['msg'], $result['data']);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user