domain.'/user/login.do',[],[ 'name' => $this->authName, 'password' => $this->authPwd ]); //验证请求结果 if(!empty($result['ret']) && isset($result['data'])){ //设置缓存数据 Cache::set('gps_token', $result['data']['token'], $this->expTime); return $result['data']['token']; }else{ return ''; } } public function info($imei) { //获取token $token = $this->token(); //发起请求 $result = curl_post($this->domain.'/car/getByImei.do',[],[ 'token' => $token, 'imei' => $imei, ]); //返回数据 if(!empty($result['ret']) && isset($result['data'])){ return ['code'=>1,'msg'=>'请求成功','data'=>$result['data']]; }else{ return ['code'=>0,'msg'=>$result['msg']]; } } public function status($car_id):array { //获取token $token = $this->token(); //发起请求 $result = curl_post($this->domain.'/car/getCarAndStatus.do',[],[ 'token' => $token, 'carId' => $car_id, 'mapType' => 1 ]); //返回数据 if(!empty($result['ret']) && isset($result['data'])){ return ['code'=>1,'msg'=>'请求成功','data'=>$result['data']]; }else{ return ['code'=>0,'msg'=>$result['msg']]; } } public function history($params):array { //获取token $token = $this->token(); //发起请求 $result = curl_post($this->domain.'/position/queryHistory.do',[],[ 'token' => $token, 'carId' => $params['gps_car_id'], 'startTime' => $params['start_time'], 'endTime' => $params['end_time'], 'filter' => true, 'interval' => 1, 'pointType' => 2, ]); //返回数据 if(!empty($result['ret']) && isset($result['data'])){ return ['code'=>1,'msg'=>'请求成功','data'=>$result['data']]; }else{ return ['code'=>0,'msg'=>$result['msg']]; } } public function mileage($carId,$startTime,$endTime):array { //获取token $token = $this->token(); //发起请求 $result = curl_post($this->domain.'/position/mileageStaByDay.do',[],[ 'token' => $token, 'carId' => $carId, 'startTime' => $startTime.' 00:00:00', 'endTime' => $endTime.' 23:59:59' ]); //返回数据 if(!empty($result['ret']) && isset($result['data'])){ return ['code'=>1,'msg'=>'请求成功','data'=>$result['data']]; }else{ return ['code'=>0,'msg'=>$result['msg']]; } } }