import { Service } from '@zenview/micro-basic-library';
import { BaseStore } from '@zenview/micro-basic-library';
import { cache } from '@zenview/micro-utils';
const getHeaders = () => {
  return {
    Authorization: cache.getCache('token', 'session')
  }
}

class Player {
  /**
   * 获取收藏图片的列表-简版
   */
  querySimplePictureFavorites(options) {
    return Service.$http({
      headers: getHeaders(),
      method: 'post',
      url: `/api/user/favorite/v1/querySimplePictureFavorites`,
      data: options,
    });
  }
  /**
   * 新增图片收藏
   * @param {*} options
   */
  addPictureFavorite(options) {
    return Service.$http({
      headers: getHeaders(),
      method: 'post',
      url: `/api/user/favorite/v1/addPictureFavorite`,
      data: options,
    });
  }
  /**
   * @desc 上传 (运营中心和用户用)
   */
  uploadImg = (data) => {
    return Service.$httpMultiPartInstance({
      headers: getHeaders(),
      method: 'POST',
      url: `/api/user/v1/img/uploadImg`,
      data,
    });
  };
  /**
 * @desc 上传图片供以图搜图使用
 * @param {Object} data
 */
  faceUploadImg(data) {
    return Service.$http({
      url: `api/disa/v1/face/img/uploadImg`,
      method: 'post',
      data: data,
      headers: getHeaders(),
      requestId: 'faceUploadImg',
    });
  }
  /**
   * 删除图片
   * @param {*} options
   */
  deleteFavorite(options) {
    return Service.$http({
      headers: getHeaders(),
      method: 'post',
      url: `/api/user/favorite/v1/deleteFavorite`,
      data: options,
    });
  }
  /**
   * 全目标结构化
   * @param {*} options
   */
  getAllTargetFeature(options) {
    return Service.$http({
      headers: getHeaders(),
      method: 'post',
      url: `/api/disa/v1/allTarget/getAllTargetFeature`,
      data: options,
    });
  }
  /**
   * @desc 根据拉流状态判断设备状态不对时，向后台反馈设备状态
   * @param {*} deviceId
   * @param {*} deviceStatus
   */
  updateDeviceStatus(deviceId, deviceStatus) {
    return Service.$http({
      headers: getHeaders(),
      url: `/api/device/v1/updateDeviceStatus`,
      method: 'POST',
      data: {
        deviceId,
        onLine: deviceStatus,
      },
    });
  }

  /**
   * @desc 查询设备详细信息
   * @param {*} id
   */
  queryDeviceInfo(id, isSoldier = false) {
    const { deviceName } = BaseStore.device.getDeviceById(id) || {};
    // BaseStore.action.setAction(device.deviceInfo.value)
    return Service.$http({
      headers: getHeaders(),
      url: `/api/device/v1/queryDeviceByCameraId/${id}`,
      method: 'get',
      data: { id },
      logInfo: isSoldier
        ? {}
        : {
          description: `查看设备【${deviceName}】信息`,
          code: 104601,
          parent: 104600,
          text: '查看设备信息',
        },
    });
  }
  /**
 * @desc 查询设备是否h265
 * @param {*} cid
 */
  queryDeviceTransfer(data) {
    return Service.$http({
      headers: getHeaders(),
      url: `/api/device/v1/transfer/get`,
      method: 'post',
      data,

    });
  }
  /**
   * SDK 设备本地录像时间轴
    {
      "cid":"753373359",
      "beginTime":"1568649600",
      "endTime":"1568736000"
    }
   */
  localRecordTimeLine(data) {
    return Service.$http({ headers: getHeaders(), url: `/api/staticResource/v1/localRecord/timeLine`, method: 'POST', data });
  }
  /**
   * 非国标云台控制
   * @param {*} data
   * @param {*} signKey
   */

  unifyControlPTZ(data) {
    return Service.$http({ headers: getHeaders(), url: `/api/command/staticResource/v2/ptz/unifyControlPTZ`, method: 'POST', data: data });
  }
  /**
   * 新版云台控制服务，外挂服务
   * @param {*} data 
   * @returns 
   */
  unifyControlPTZRaven(data) {
    return Service.$http({ headers: getHeaders(), url: `/ptzcontrol/raven/v1/ptz/move`, method: 'POST', data: data });
  }
  /**
   * 聚焦控制
   * @param {*} data
   * @param {*} signKey
   */
  controlFocus({ cid, cmd, control }) {
    return Service.$http({ headers: getHeaders(), url: `/api/command/staticResource/v2/ptz/focus`, method: 'POST', data: { cid, cmd, control } });
  }
  /**
   * 聚焦控制
   * @param {*} data
   * @param {*} signKey
   */
  voiceInfo(cid) {
    return Service.$http({ headers: getHeaders(), url: `/api/device/v1/voice/info/${cid}`, method: 'get' });
  }
  /**
* 云录像推流速度控制
* @param {*} data
* @param {*} signKey
*/
  cloudrecordControl(data) {
    return Service.$http({ headers: getHeaders(), url: `/api/staticResource/v2/video/clodRecord/control/${data.cid}`, method: 'POST', data });
  }
  /**
   * 前端录像推流速度控制,同前端录像时间轴接口
   * @param {*} data
   * @param {*} signKey
   */
  localRecordSpeed(data) {
    return Service.$http({ headers:getHeaders(), url: `/api/staticResource/v1/localRecord/url`, method: 'POST', data });
  }
}

export default new Player();
