/*
 * @Date: 2021-12-18 15:49:01
 * @LastEditors: JinxChen
 * @LastEditTime: 2023-10-12 11:37:52
 * @FilePath: \TelpoH5FrontendWeb\src\api\core.js
 * @description:
 * b端的接口, 每次调用前先获取token
 */
import axios from 'axios';
import prefix from '@/store/prefix'
const baseUrl = process.env.VUE_APP_BASE_API + 'gateway';
const service = axios.create({
    baseURL: baseUrl,
});
const HTTP_PREFIX_CORE = process.env.VUE_APP_BASE_API + 'gateway/' + 'core';
service.interceptors.request.use(
    request => {
        if (localStorage.getItem(prefix + 'gatewayToken')) {
            request.headers.AccessToken = localStorage.getItem(prefix + 'gatewayToken');
        }
        return request;
    },
);
export const APICore = {
    areaAlarmDetail, //获取告警详情
    getAuth, //获取b端接口token
    changeAlarmStatus, //修改非法区域告警推送状态
    QueryLiveBasePackage, //获取基本套餐
    payLiveBaseDevice, //微信统一下单
    GpsDeviceFence, //围栏 redis
    cardPackageList, //零川基础套餐列表
    devicePayPackage,
    drownReportFilterAdd,//添加过滤危险水域区域
    setLocationConfig,  //设置设备定位控制参数
    getLocationConfig,  //获取设备定位控制参数
    getHealthConfig, //获取设备健康控制参数(心率、血氧、测温)
    setHealthConfig, //设置设备健康控制参数(心率、血氧、测温)
    setUploadConfig, //置设备上报周期参数
    getUploadConfig, //取设备上报周期参数
    setDrownConfig, //设置设备防溺水参数
    getDrownConfig, //获取设备防溺水参数
    setNowearConfig, //设置设备未佩戴检测参数
    getNowearConfig, //获取设备未佩戴检测参数
    setWatchConfig , //手表模式设置参数(平台)
    getWatchConfig  , //查看手表模式设置参数
    getDrownReportFilterQuery, //获取水域告警白名单
    drownReportFilterDelete, ////删除过滤危险水域区域
    setAutoPlayConfigOfDiba, //设置迪爸自动播放参数接口
    getAutoPlayConfigOfDiba, //获取迪爸自动播放列表接口
    getBloodPressList, //获取血压数据列表
    getBloodPressConfig, //获取设备血压周期性检测参数
    setBloodPressConfig, //设置设备血压周期性检测参数
    setPsychAbilityConfig, //心理监测能力开通（下发参数）
    getPsychAbilityConfig,//获取心理监测能力开通参数
    setIotCtlMode, //设置设备iot连接控制属性
    getIotCtlMode, //获取设备iot连接控制属性
    checkImei, //检查设备关联的物联网厂商信息
}
/* 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 cardPackageList(data) {
    return service({
        url: `${baseUrl}/core/api/v1/open/card/QueryIotCardPackage`,
        method: 'post',
        data,
    });
}
function devicePayPackage(imei) {
    return service({
        url: `${baseUrl}/core/api/v1/open/card/GetDevicePayPackage`,
        method: 'get',
        params: {imei},
    })
}
function drownReportFilterAdd(data) {
    return service({
        url: `${baseUrl}/core/api/v1/Device/DrownReportFilterAdd`,
        method: 'post',
        data,
    });
}

function setLocationConfig(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/SetLocationConfig`,
        method: 'post',
        data: params,
    });
}
function getLocationConfig({imei}) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/GetLocationConfig`,
        method: 'get',
        params: {imei},
    })
}
function setHealthConfig(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/SetHealthConfig`,
        method: 'post',
        headers: {authKey: 'key1'},
        data: params,
    });
}
function getHealthConfig({imei}) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/GetHealthConfig`,
        method: 'get',
        params: {imei},
    })
}

function setUploadConfig(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/SetUploadConfig`,
        method: 'post',
        data: params,
    });
}
function getUploadConfig({imei}) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/GetUploadConfig`,
        method: 'get',
        params: {imei},
    })
}
function setAutoPlayConfigOfDiba(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/OpenAbility/Diba/setConfig`,
        method: 'post',
        data: params,
    });
}

function getAutoPlayConfigOfDiba({imei}) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/OpenAbility/Diba/getConfig`,
        method: 'get',
        params: {imei},
    })
}

function setDrownConfig(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/SetDrownConfig`,
        method: 'post',
        data: params,
    });
}
function getDrownConfig({imei}) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/GetDrownConfig`,
        method: 'get',
        params: {imei},
    })
}

function setNowearConfig(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/SetNowearConfig`,
        method: 'post',
        data: params,
    });
}
function getNowearConfig({imei}) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/GetNowearConfig`,
        method: 'get',
        params: {imei},
    })
}

function setWatchConfig(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/Device/SetWatchConfig`,
        method: 'post',
        data: params,
    });
}
function getWatchConfig({imei}) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/Device/GetWatchConfig`,
        method: 'get',
        params: {imei},
    })
}
function getDrownReportFilterQuery({imei}) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/Device/DrownReportFilterQuery`,
        method: 'get',
        params: {imei},
    })
}

function drownReportFilterDelete(data) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/Device/DrownReportFilterDelete`,
        method: 'get',
        params: data,
    })
}

function getBloodPressList(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/healthy/BloodPressQuery`,
        method: 'post',
        data: params ,
    });
}

function getBloodPressConfig(data) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/GetBloodPressConfig`,
        method: 'get',
        params: data,
    })
}

function setBloodPressConfig(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/SetBloodPressConfig`,
        method: 'post',
        data: params ,
    });
}

function getPsychAbilityConfig(data) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/GetPsychAbilityConfig`,
        method: 'get',
        params: data,
    })
}

function setPsychAbilityConfig(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/SetPsychAbilityConfig`,
        method: 'post',
        data: params ,
    });
}
function setIotCtlMode(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/SetIotCtlMode`,
        method: 'post',
        data: params,
    })
}
function getIotCtlMode(imei) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/open/OpenIot/GetIotCtlMode`,
        method: 'get',
        params: { imei },
    })
}

function checkImei(params) {
    return service({
        url: `${HTTP_PREFIX_CORE}/api/v1/Device/CheckImei`,
        method: 'post',
        data: params,
    })
}

export default APICore;
