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

// Region

// 添加区域
export function RegionAdd(postdata) {
    let url = headapi + 'v1/Region/Add';
    return getApiBasic(url, postdata);
}

// 区域详情
export function RegionDetail(postdata) {
    let url = headapi + 'v1/Region/Detail';
    return getApiBasic(url, postdata);
}

// 区域列表
export function RegionList(postdata) {
    let url = headapi + 'v1/Region/List';
    return getApiBasic(url, postdata);
}

// Detector

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

// 检测设备详情
export function DetectorDetail(postdata) {
    let url = headapi + 'v1/Detector/Detail';
    return getApiBasic(url, postdata);
}

// 检测设备列表
export function DetectorList(postdata) {
    let url = headapi + 'v1/Detector/List';
    return getApiBasic(url, postdata);
}
