import { cache } from '@zenview/micro-utils';
import { Service } from '@zenview/micro-basic-library';
import moment from 'moment';

const getHeaders = () => {
  return {
    Authorization: cache.getCache('token', 'session')
  }
}

class ServiceHttp {
  /**
   * @desc 查询设备详细信息 cid
   * @param {*} cid
   */
  queryDeviceInfoByCid(cid, cancelHttp) {
    return Service.$http({
      requestId: 'getDeviceByCId',
      headers:getHeaders(),
      url: `/api/device/v1/getDeviceByCId/${cid}`,
      method: 'post',
      data: { cid },
      cancelHttp,
    });
  }
  /**
   * @desc 上传 (运营中心和用户用)
   */
  uploadImg = (data) => {
    return Service.$httpMultiPartInstance({
      requestId: 'uploadImg',
      headers:getHeaders(),
      method: 'post',
      url: `/api/user/v1/img/uploadImg`,
      data,
    });
  };
  /**
   * 获取收藏图片的列表-简版
   */
  querySimplePictureFavorites(options) {
    return Service.$http({
      requestId: 'querySimplePictureFavorites',
      headers:getHeaders(),
      method: 'post',
      url: `/api/user/favorite/v1/querySimplePictureFavorites`,
      data: options,
    });
  }
  /**
   * 删除图片
   * @param {*} options
   */
  deleteFavorite(id) {
    return Service.$http({
      requestId: 'deleteFavorite',
      headers:getHeaders(),
      method: 'post',
      url: `/api/user/favorite/v1/deleteFavorite`,
      data: {
        id,
        favoriteType: 3,
      },
    });
  }
  /**
   * 新增图片收藏
   * @param {*} options
   */
  addPictureFavorite(options) {
    return Service.$http({
      requestId: 'addPictureFavorite',
      headers:getHeaders(),
      method: 'post',
      url: `/api/user/favorite/v1/addPictureFavorite`,
      data: options,
    });
  }

  queryCaptureAllTargetByImgId(data) {
    return Service.$http({
      url: `/api/disa/v1/allTarget/queryCaptureAllTargetByImgId`,
      method: 'post',
      data,
      headers:getHeaders(),
      requestId: 'queryCaptureAllTargetByImgId',
    });
  }
}

export default new ServiceHttp();
