// b端的接口, 每次调用前先获取token
import axios from 'axios';
import { baseApi } from '@/config';
import prefix from '@/store/prefix';
const baseUrl = baseApi.replace('webapi', 'gateway');
const service = axios.create({
  baseURL: baseUrl
});
service.interceptors.request.use(request => {
  if (localStorage.getItem(prefix + 'gatewayToken')) {
    request.headers.AccessToken = localStorage.getItem(prefix + 'gatewayToken');
  }
  return request;
});
export const APIAlarm = {
  areaAlarmDetail, //获取告警详情
  getAuth, //获取b端接口token
  changeAlarmStatus, //修改非法区域告警推送状态
  QueryLiveBasePackage, //获取基本套餐
  payLiveBaseDevice, //微信统一下单
  GpsDeviceFence, //围栏 redis
  drownReportFilterAdd, //添加过滤危险水域区域
  getDrownReportFilterQuery, //获取水域告警白名单
  drownReportFilterDelete, //删除过滤危险水域区域
  devicePayPackage,
  CheckWzLocation //定位校准
};
/* const headerAuth = this.$store.getters.gatewayToken; */
// 获取告警详情
function areaAlarmDetail(data) {
  return service({
    url: `${baseUrl}/core/api/v1/Fence/AreaAlarmDetail`,
    method: 'get',
    params: data
  });
}
// 获取告警授权token
function getAuth(params) {
  return service({
    url: `${baseUrl}/core/api/v1/Ability/study_ai/terminal/auth`,
    method: 'post',
    data: params
  });
}
function changeAlarmStatus(params) {
  return service({
    url: `${baseUrl}/core/api/v1/Fence/AddAreaUserFilter`,
    method: 'post',
    data: params
  });
}
function GpsDeviceFence(params) {
  return service({
    url: `${baseUrl}/core/api/v1/Redis/GpsDeviceFence`,
    method: 'post',
    data: params
  });
}
// 获取基本套餐信息
function QueryLiveBasePackage(params) {
  return service({
    url: `${baseUrl}/core/api/v1/Device/QueryLiveBasePackage`,
    method: 'post',
    data: params
  });
}
// 统一下单
// 获取基本套餐信息
function payLiveBaseDevice(params) {
  return service({
    url: `${baseUrl}/core/api/v1/Device/PayLiveBaseDevice`,
    method: 'post',
    data: params
  });
}
function drownReportFilterAdd(data) {
  return service({
    url: `${baseUrl}/core/api/v1/Device/DrownReportFilterAdd`,
    method: 'post',
    data
  });
}
function getDrownReportFilterQuery(data) {
  return service({
    url: `${baseUrl}/core/api/v1/Device/DrownReportFilterQuery`,
    method: 'get',
    params: data
  });
}
function devicePayPackage(imei) {
  return service({
    url: `${baseUrl}/core/api/v1/open/card/GetDevicePayPackage`,
    method: 'get',
    params: { imei }
  });
}
function drownReportFilterDelete(data) {
  return service({
    url: `${baseUrl}/core/api/v1/Device/DrownReportFilterDelete`,
    method: 'get',
    params: data
  });
}

function CheckWzLocation(params) {
  return service({
    url: `${baseUrl}/core/api/v1/GeoCode/CheckWzLocation`,
    method: 'post',
    data: params
  });
}

export default APIAlarm;
