import axios from 'axios';
import global from '../Global.js'

// 基础方法进行封装
function getApiBasic(url, postdata) {
    return axios.post(url, postdata).then(function (data) {
        let json = data.data;
        return json
    }, function (response) {
        console.info(response);
    })
}

// 调用的api改写成方法
export function worldDetail(postdata) {
    let url = headapi + 'worldDetail';
    return getApiBasic(url, postdata);
}

// 测试用接口
export function editbasicinfo(postdata) {
    let url = headapi + 'editbasicinfo';
    return getApiBasic(url, postdata);
}

export function modPwd(postdata) {
    let url = headapi + 'modPwd';
    return getApiBasic(url, postdata);
}

export function getLoftInfo(postdata) {
    let url = headapi + 'getLoftInfo';
    return getApiBasic(url, postdata);
}

export function wifiSingle(postdata) {
    let url = headapi + 'wifiSingle';
    return getApiBasic(url, postdata);
}

export function Scan(postdata) {
    let url = headapi + 'Scan';
    return getApiBasic(url, postdata);
}

export function Watching(postdata) {
    // let url = headapi + 'Watching';
    // return getApiBasic(url,postdata);
    let item = [];
    let t = 0;
    for (var i = 0; i < 9; i++) {
        t = i + 1;
        item.push({
            'time': "@date",
            'checkRs': "Signal设备03@integer(301,600)检测完成，206会议室安全",
        })
    }
    let res = {
        Rs: item,
        Code: 0,
        Memo: '登陆成功'
    };
    return res;
}

// 真实接口
// 用户登录
export function SignIn(postdata) {
    let url = headapi + 'v1/Auth/SignIn';
    return getApiBasic(url, postdata);
}

// 获取验证图片
export function GenVerifyPic(postdata) {
    let url = headapi + 'v1/Auth/GenVerifyPic';
    return getApiBasic(url, postdata);
}

// 用户退出
export function SignOut(postdata) {
    let url = headapi + 'v1/Auth/SignOut';
    return getApiBasic(url, postdata);
}

// 获取首页左侧组织结构信息
export function GetRegionAndDectorSelect(postdata) {
    let url = headapi + 'v1/Auth/GetRegionAndDectorSelect';
    return getApiBasic(url, postdata);
}

// 获取统计数量集合
export function GetStaticinfo(postdata) {
    // 获取统计数量集合，包括获取设备总数，在线设备，离线设备，禁用设备，当日报警数量，可疑事件总数
    let url = headapi + 'v1/Company/GetStaticinfo';
    return getApiBasic(url, postdata);
}

// 区域检出实时记录
export function RegionDetInfolist(postdata) {
    // 最小区域检出实时记录
    let url = headapi + 'v1/Company/RegionDetInfolist';
    return getApiBasic(url, postdata);
}

// 单个设备检测实时记录
export function SingleDetInfolist(postdata) {
    // 单个设备检测实时记录
    let url = headapi + 'v1/Company/SingleDetInfolist';
    return getApiBasic(url, postdata);
}

// Wifi柱状图信息传入探测器Id
export function DetectorWifixyInfolist(postdata) {
    // Wifi柱状图信息
    let url = headapi + 'v1/Detector/DetectorWifixyInfolist';
    return getApiBasic(url, postdata);
}

// Wifi柱状图信息传入区域Id
export function RegionWifixyInfolist(postdata) {
    // Wifi柱状图信息
    let url = headapi + 'v1/Detector/RegionWifixyInfolist';
    return getApiBasic(url, postdata);
}


// 0-6G折线图信息传入设备Id
export function Detector06GInfolist(postdata) {
    // 6G折线图信息传入设备Id
    let url = headapi + 'v1/Detector/Detector06GInfolist';
    return getApiBasic(url, postdata);
}

// 添加区域
export function RegionAdd(postdata) {
    // 添加区域 第一级区域填0
    let url = headapi + 'v1/Company/RegionAdd';
    return getApiBasic(url, postdata);
}

// 修改区域信息
export function RegionEdit(postdata) {
    // 修改区域 第一级区域填0
    let url = headapi + 'v1/Company/RegionEdit';
    return getApiBasic(url, postdata);
}

// 修改区域状态
export function RegionStatusEdit(postdata) {
    // 修改内部区域状态设置为 9删除
    let url = headapi + 'v1/Company/RegionStatusEdit';
    return getApiBasic(url, postdata);
}

// 区域图片上传
export function RegionPictureUpload(postdata) {
    // 上传区域图片
    let url = headapi + 'v1/Company/RegionPictureUpload';
    return getApiBasic(url, postdata);
}

// 查询信号 Wifi记录
export function LogWifiDetectedQueryByDetector(postdata) {
    // 查询检测设备的Wifi信号记录
    let url = headapi + 'v1/Detector/LogWifiDetectedQueryByDetector';
    return getApiBasic(url, postdata);
}

// 查询手机信号记录
export function LogPhoneDetectedQueryByDetector(postdata) {
    // 查询手机信号记录
    let url = headapi + 'v1/Detector/LogPhoneDetectedQueryByDetector';
    return getApiBasic(url, postdata);
}

// 获取单个区域信息
export function GetRegiononeinfo(postdata) {
    // 获取单个区域信息
    let url = headapi + 'v1/Company/GetRegiononeinfo';
    return getApiBasic(url, postdata);
}
// 区域平面图用到的单条区域信息
export function GetRegionplaneinfo(postdata) {
    // 区域平面图用到的单条区域信息
    let url = headapi + 'v1/Company/GetRegionplaneinfo';
    return getApiBasic(url, postdata);
}

// 获取企业内部区域选择框信息
export function GetRegionSelect(postdata) {
    // 根据企业id获取企业内部区域选择框信息 default:1
    let url = headapi + 'v1/Auth/GetRegionSelect';
    return getApiBasic(url, postdata);
}

// Detector part

// 查询检测设备信息
export function DetectorQuery(postdata) {
    // 查询检测设备。上级区域id，区域id必传。regionid传0，查询supregionid对应所有子区域的检测设备。 如果supregionid，regionid都传0，默认查询企业ID下所有检测设备
    let url = headapi + 'v1/Detector/DetectorQuery';
    return getApiBasic(url, postdata);
}

// 添加检测设备
export function DetectorAdd(postdata) {
    // 添加检测设备
    let url = headapi + 'v1/Detector/DetectorAdd';
    return getApiBasic(url, postdata);
}

// 修改检测设备信息
export function DetectorEdit(postdata) {
    // 添加检测设备
    let url = headapi + 'v1/Detector/DetectorEdit';
    return getApiBasic(url, postdata);
}

// 修改检测设备状态
export function DetectorEditStatus(postdata) {
    // 修改检测设备状态  //新状态0禁用1启用2已离线9删除
    let url = headapi + 'v1/Detector/DetectorEditStatus';
    return getApiBasic(url, postdata);
}

// 通过RegionId下载区域图片
export function RegionPictureGetByRegionId(postdata) {
    // 通过RegionId下载区域图片
    let url = headapi + 'v1/Company/RegionPictureGetByRegionId';
    return getApiBasic(url, postdata);
}

// 获取下级区域选择框信息
export function GetChildRegionSelect(postdata) {
    // 获取下级区域选择框信息
    let url = headapi + 'v1/Auth/GetChildRegionSelect';
    return getApiBasic(url, postdata);
}

// 修改密码
export function PassEdit(postdata) {
    // 修改密码
    let url = headapi + 'v1/Auth/PassEdit';
    return getApiBasic(url, postdata);
}

// 获取最新固件版本
export function GetLastVerionFirmwareinfo(postdata) {
    // 获取最新固件版本
    let url = headapi + 'v1/AdminSettings/GetLastVerionFirmwareinfo';
    return getApiBasic(url, postdata);
}

// 添加固件
export function FirmwareAdd(postdata) {
    // 添加固件
    let url = headapi + 'v1/AdminSettings/FirmwareAdd';
    return getApiBasic(url, postdata);
}

// 查询所有信号记录，包含手机信号和Wifi信号
export function LogFullDetectedQueryByDetector(postdata) {
    // 查询所有信号记录，包含手机信号和Wifi信号
    let url = headapi + 'v1/Detector/LogFullDetectedQueryByDetector';
    return getApiBasic(url, postdata);
}

// 获取二维码信息列表
export function GetQrcodeList(postdata) {
    // 获取二维码信息列表
    let url = headapi + 'v1/Detector/GetQrcodeList';
    return getApiBasic(url, postdata);
}

// 添加二维码
export function QrCodeAdd(postdata) {
    // 添加二维码
    let url = headapi + 'v1/Detector/QrCodeAdd';
    return getApiBasic(url, postdata);
}
// 修改二维码
export function QrCodeEdit(postdata) {
    // 修改二维码
    let url = headapi + 'v1/Detector/QrCodeEdit';
    return getApiBasic(url, postdata);
}
// 修改二维码状态
export function QrcodeEditStatus(postdata) {
    // 修改二维码状态
    let url = headapi + 'v1/Detector/QrcodeEditStatus';
    return getApiBasic(url, postdata);
}
// 某二维码下实时探测情况
export function DeviceInfoByQrCodeId(postdata) {
    // 某二维码下实时探测情况
    let url = headapi + 'v1/Detector/DeviceInfoByQrCodeId';
    return getApiBasic(url, postdata);
}
// 通过Key下载二维码对应图片
export function QrcodePictureGet(postdata) {
    // 通过Key下载二维码对应图片
    let url = headapi + 'v1/Detector/QrcodePictureGet';
    return getApiBasic(url, postdata);
}
// 获取检测设备坐标
export function GetDetectorCoords(postdata) {
    // 获取检测设备坐标
    let url = headapi + 'v1/Detector/GetDetectorCoords';
    return getApiBasic(url, postdata);
}
// 获取全部区域选择框信息
export function GeFullRegionSelect(postdata) {
    // 获取检测设备坐标
    let url = headapi + 'v1/Auth/GeFullRegionSelect';
    return getApiBasic(url, postdata);
}
// 区域检测实时记录合并
export function RegionDetDetaillist(postdata) {
    let url = headapi + 'v1/Company/RegionDetDetaillist';
    return getApiBasic(url, postdata);
}

// 单个设备检测实时记录合并
export function SingleDetDetaillist(postdata) {
    let url = headapi + 'v1/Company/SingleDetDetaillist';
    return getApiBasic(url, postdata);
}
// 0-6G折线图信息传入区域Id
export function Region06GInfolist(postdata) {
    let url = headapi + 'v1/Detector/Region06GInfolist';
    return getApiBasic(url, postdata);
}

