import request from '@/utils/request'
import qs from 'qs'

/**
 * 车辆管理接口
 */

// 获取车辆列表
const getBikeList = function(params) {
    return request({
        url: '/bike/findPageList.do',
        method: 'get',
        params
    })
}
// 查看车辆信息
const getBikeDetail = function(params) {
    return request({
        url: '/bike/viewDetail.do',
        method: 'get',
        params
    })
}
// 添加车辆信息
const addBike = function(params) {
    return request({
        url: '/bike/add.do',
        method: 'get',
        params
    })
}
// 修改车辆信息
const updateBike = function(params) {
    return request({
        url: '/bike/update.do',
        method: 'get',
        params
    })
}
// 删除车辆信息
const delBike = function(params) {
    return request({
        url: '/bike/delete.do',
        method: 'get',
        params
    })
}

// 根据查询条件投放所有车辆
const putAll = function(params) {
    return request({
        url: '/bike/putAllBikeByConditions.do',
        method: 'POST',
        data: qs.stringify(params)
    })
}
// 车俩批量投放
const bikePutIn = function(params) {
    return request({
        url: '/bike/bikePutIn.do',
        method: 'get',
        params
    })
}
// 批量导入车辆
const importBike = function(params) {
    var formData = new FormData()
    formData.append('file', params.file)
    return request({
        url: '/bike/importBike.do',
        method: 'post',
        data: formData
    })
}
// 查看单个车辆的二维码
const showQRcode = function(params) {
    return request({
        url: '/bike/showQRcode.do',
        method: 'get',
        params
    })
}
// 批量导出二维码
const downloadQRCode = function(params) {
    return request({
        url: '/bike/downloadQRCode.do',
        method: 'get',
        params
    })
}
// 获取车辆最近订单
const orderRentMember = function(params) {
    return request({
        url: '/bike/orderRentMember.do',
        method: 'POST',
        data: qs.stringify(params)
    })
}
// 根据条件批量导出二维码
const allQRCode = function(params) {
    return request({
        url: '/bike/downloadAllQRCodeByCondition.do',
        method: 'get',
        params
    })
}

/**
 * 车辆分布接口
 */

// 车辆分布
const getBikeDistribution = function(params) {
    return request({
        url: '/bike/bikeDistribution.do',
        method: 'get',
        params
    })
}

/**
 * 围栏接口
 */

// 查询所有围栏
const getParkFenceList = function(params) {
    return request({
        url: '/bike/findParkFenceList.do',
        method: 'get',
        params
    })
}
// 添加围栏
const addParkFence = function(params) {
    return request({
        url: '/bike/addParkFence.do',
        method: 'get',
        params
    })
}
// 编辑围栏
const updateParkFence = function(params) {
    return request({
        url: '/bike/updateParkFence.do',
        method: 'get',
        params
    })
}
// 删除围栏
const deleteParkFence = function(params) {
    return request({
        url: '/bike/deleteParkFence.do',
        method: 'get',
        params
    })
}
// 启动或者禁止围栏
const isParkFence = function(params) {
    return request({
        url: '/bike/ifDisenableParkFence.do',
        method: 'get',
        params
    })
}

// 坐标转换接口
const convertCoords = function(params) {
    return request({
        url: '/coordinate/transformation.do',
        method: 'get',
        params
    })
}

export default {
    getBikeList,
    getBikeDetail,
    addBike,
    updateBike,
    delBike,
    putAll,
    bikePutIn,
    importBike,
    showQRcode,
    downloadQRCode,
    allQRCode,
    orderRentMember,
    getBikeDistribution,
    getParkFenceList,
    addParkFence,
    updateParkFence,
    deleteParkFence,
    isParkFence,

    convertCoords
}
