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);
}



