import request from '@/utils/request'
// 获取设备info
export function sendPortDetailCmd(deviceInfo) {
    return request({
        url: '/device/sendPortDetailCmd',
        method: 'post',
        data:deviceInfo
    })
}
function cloneObj(obj){
    return JSON.parse(JSON.stringify(obj));
}
//获取接口状态
export function getPortDetail(deviceInfo,time) {
    let data = cloneObj(deviceInfo);
    data.time = time;
    return request({
        url: '/device/getPortDetail',
        method: 'post',
        data:data
    })
}
//开始充电
export function startCharge(deviceInfo) {
    return request({
        url: '/device/startCharge',
        method: 'post',
        data:deviceInfo
    })
}
//停止充电
export function stopCharge(deviceInfo){
    return request({
        url: '/device/stopCharge',
        method: 'post',
        data:deviceInfo
    })
}
//检测是否有端口变动
export function checkStatusChange(deviceInfo,time){
    let data = cloneObj(deviceInfo);
    data.time = time;
    return request({
        url: '/device/statusChange?time='+time,
        method: 'post',
        data:data
    })
}
//获取设备详情
export function getDeviceInfoFromQrcode(qrcode){
    qrcode = encodeURIComponent(qrcode)
    return request({
        url: '/device/getDeviceInfo?qrcode='+qrcode,
        method: 'post',
    })
}
//获取设备预约
export function getPlanInfo(deviceId,port){
    return request({
        url: '/device/getPlanInfo?deviceId='+deviceId+"&port="+port,
        method: 'post',
    })
}
//取消预约
export function cancelPlan(planId){
    return request({
        url: '/device/cancelPlan/'+planId,
        method: 'post',
    })
}
