import { request } from 'umi';
import { projectObj } from '@/config/api.js';
import UserStorage from '@/config/sagacare/sagacare_user';
import Request from 'umi-request';

function getProjectId() {
  const id = projectObj.projectId;
  return id;
}

function commonParams() {
  var pubname = 'sgadmin';
  return `projectId=${getProjectId()}&pubname=${pubname}`;
}

// 获取企业信息
export const companyInfo = (params) => {
  return request(`/sgadmin/duoduo-service/custom-service/company/info`, {
    method: 'POST',
    from: 'sagacare',
    isNotShowErrorToast: true,
    errorSave: true,
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json',
    },
  });
};
// 修改企业 信息
export const companyUpdate = (params) => {
  return request(`/sgadmin/duoduo-service/custom-service/company/update`, {
    method: 'POST',
    from: 'sagacare',
    isNotShowErrorToast: true,
    errorSave: true,
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json',
    },
  });
};

// 上传 图片
export const importUsers = (file, param) => {
  const data = new FormData();
  data.append('file', file);
  return request('/sgadmin/duoduo-service/custom-service/oss/uploadOssFile', {
    data,
    method: 'post',
    parseResponse: true,
  });
};
// 查看 图片
export const getFileUrl = (param) => {
  return request(`/sgadmin/duoduo-service/custom-service/oss/getFileUrl?fileKey=${param}`, {
    method: 'post',
    parseResponse: true,
  });
};
