import server from '@/utils/request'

//新增
interface Addobj{
    pkId?:String
    proxyId:String	                        //归属运营商ID
    name:String	                            //站点名称
    code:String	                            //站点编码
    status:String|Number	                //状态：1-正常营业，2-正常停运，3-故障停运，4-指令停运，9-其它
    type?:String	                        //站点类型ID
    division?:String,                        //地区          ??
    divisionNo?:String,                      //地区编码      ??
    address?:String	                        //地址
    addressProvince?:String	                //地址-省
    addressCity?:String	                    //地址-市	query
    addressArea?:String	                    //地址-区县
    registerDate?:String	                //注册日期
    contacts?:String	                    //联系人
    phone?:String	                        //联系电话
    delFlag?:String|Number	                //删除标识：1-已删除，0-未删除
    activeDate?:String	                    //激活日期
    locationPoint?:String	                //经纬度信息
    openAllDay?:String|Number	            //全天营业：1-是，0-否
    tdQuantity?:String|Number	            //通道数
    jqrQuantity?:String|Number	            //机器人数量
    cdjQuantity?:String|Number	            //充电机数量
    dccQuantity?:String|Number	            //电池仓数量
    dcQuantity?:String|Number	            //电池数量
}

export function addhdz(data:Addobj) {
  return server.request({
    url: '/cloud/battery/station/add',
    method: 'post',
    data
  })
}

//修改
export function update(data:Addobj) {
  return server.request({
    url: '/cloud/battery/station/update',
    method: 'post',
    data
  })
}

//查询
interface Querydata{
  pageSize:String|number,	    //每页条数
  pageNo:String|number	        //页数
  proxyId:String	            //归属运营商ID
  pkId?:String
  name?:String	                //站点名称
  code?:String	                //站点编码
  status?:any	            //状态：1-正常营业，2-正常停运，3-故障停运，4-指令停运，9-其它
  type?:String	                //站点类型ID
}
export function gethdzlist(params:Querydata) {
  return server.request({
    url: '/cloud/battery/station/list',
    method: 'get',
    params
  },false)
}

//删除
export function delhdz(id:string) {
  return server.request({
    url: '/cloud/battery/station/del',
    method: 'post',
    data:{
      id
    }
  })
}


//获取小程序码
interface Codeqs{
  path:String
  width:String
  env_version:String
}

export function getqrcode(params:Codeqs) {
  return server.request({
    url: '/cloud/battery/station/xcx/qrcode/get',
    method: 'get',
    params,
    responseType:'blob'
  })
}

//生成站点公钥
export function publicKey(stationCode:any) {
  return server.request({
    url: '/cloud/battery/station/rsa_secret_key',
    method: 'post',
    data:{
      stationCode
    }
  })
}

//获取小程序二维码
interface Rcode{
  path:String
  width:String
}
export function getCode(params:Rcode) {
  return server.request({
    url: '/cloud/battery/station/xcx/qrcode/create',
    method: 'get',
    params,
    responseType:'blob'
  })
}

//站点关停
export function stastop(id:any,data:any) {
  return server.request({
    url: `/cloud/battery/station/stop/${id}`,
    method: 'put',
    data
  })
}
