123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2020-09-07
- * Time: 14:38
- */
-
- namespace api\js\controller;
- use api\js\model\JsModel;
- use api\js\model\JsProjectModel;
- use cmf\controller\RestBaseController;
- use think\Db;
- use api\js\model\RegionModel;
- class JsProjectController extends RestBaseController
- {
-
- /**
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * 获取分类列表
- */
- public function getList()
- {
- $where = [];
-
- $JsProjectModel = new JsProjectModel();
- $categoryId = $this->request->param('category_id');
- $page = $this->request->param('page',1);
- $district = $this->request->param('district');
- $xlng = $this->request->param('xlng');
- $xlat = $this->request->param('xlat');
- $lng = $this->request->param('lng');
- $lat = $this->request->param('lat');
- $lat = isset($xlat) ? $xlat : $lat;
- $lng = isset($xlng) ? $xlng : $lng;
- // if($lat && $lng) {
- // $res = getdistrict($xlng, $xlat);
-
- // if ($res['status'] == 0) {
- // $this->success('经纬度不正确', []);
- // } else {
- // $district = $res['regeocode']['addressComponent']['district'];
- // }
- // }
- // $district = isset($district) ? $district : $district1;
- $RegionModel = new RegionModel();
- $serviceId = $RegionModel->getId($district);
-
-
- if($categoryId){
- $projectIds = Db::name('js_project_category_relevancy')->where('category_id',$categoryId)->field('project_id')->select();
- $project_id = [];
- foreach ($projectIds as $vo){
- $project_id[] = $vo['project_id'];
- }
- if($project_id){
- $where = $project_id;
- }else{
- $list = [];
- $this->success('ok',$list);
- }
-
- }
-
- $name = $this->request->param('name');
- $user_id = $this->userId;
- $js_id = 0;
- if($user_id){
- $JsModel = new JsModel();
- $js_id = $JsModel->where('user_id',$user_id)->value('id');
- }
- $list = $JsProjectModel->getList($name,$where,$page,$serviceId,$js_id);
- $this->success('ok',$list);
- }
-
-
- public function getInfo()
- {
- $id = $this->request->param('id');
- $district= $this->request->param('district');
- $xlng = $this->request->param('xlng');
- $xlat = $this->request->param('xlat');
- $lng = $this->request->param('lng');
- $lat = $this->request->param('lat');
- $lat = isset($xlat) ? $xlat : $lat;
- $lng = isset($xlng) ? $xlng : $lng;
- // if($lng && $lat){
-
- // $res = getdistrict($lng,$lat);
- // if($res['status'] == 0){
- // $this->success('经纬度不正确',[]);
- // }else{
- // $district = $res['regeocode']['addressComponent']['district'];
- // }
- // }
- // $district = isset($district) ? $district : $district1;
- $JsProjectModel = new JsProjectModel();
- $info = $JsProjectModel->getInfo($id,$district);
- $this->success('ok',$info);
- }
-
- }
|