import ajax from '../utils/request.js';

/**
 * 登录
 * @param {object} ori
 * @returns
 */
export function login(ori) {
  return ajax({
    api: '/user/login',
    data: ori.data,
    method: 'POST',
  });
}

/**
 * 文案校对
 * @param {object} ori
 * @returns
 */
export function check(ori) {
  return ajax({
    api: '/api/check',
    data: ori.data,
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * 热门话题
 * @param {object} ori
 * @returns
 */
export function hotRank(ori) {
  return ajax({
    api: '/news/hotRank/list',
    data: ori.data,
    method: 'GET',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * 检索新闻接口
 * @param {object} ori
 * @returns
 */
export function searchData(ori) {
  return ajax({
    api: '/news/data/search',
    data: ori.data,
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * 获得新闻分类
 * @param {object} ori
 * @returns
 */
export function getClass(ori) {
  return ajax({
    api: '/news/data/category',
    data: ori.data,
    method: 'GET',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * h5商城接口
 * @param {Object} ori
 * @returns
 */
// export function getH5Mall(ori) {
//   return ajax({
//     api: '/topic/tool/img/cache/oridata.json?' + Date.now(),
//     data: ori.data,
//     base: 'json',
//     type: 'ajax',
//     method: 'GET',
//     headers: {
//       Authorization: localStorage.getItem('token'),
//     },
//   });
// }

/**
 * 行政区划接口
 * @param {Object} ori
 * @returns
 */
export function getEconomize(ori) {
  return ajax({
    api: '/news/area/list',
    data: ori.data,
    type: 'ajax',
    method: 'GET',
  });
}

/**
 * 报料
 * @param {object} ori
 * @returns
 */
export function getreporting(ori) {
  return ajax({
    api: '/clue/list',
    data: ori.data,
    type: 'ajax',
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}
/**
 * 报料删除
 */
export function delreporting(ori) {
  return ajax({
    api: '/clue/delete',
    data: ori.data,
    type: 'ajax',
    method: 'GET',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}
/**
 * 查看报料
 */
export function getreportingDetail(ori) {
  return ajax({
    api: '/clue/info',
    data: ori.data,
    type: 'ajax',
    method: 'GET',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}
/**
 * 审核报料
 */
export function reportingShenhe(ori) {
  return ajax({
    api: '/clue/verify',
    data: ori.data,
    type: 'ajax',
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}
/**
 * 回复报料
 */
export function reportingReply(ori) {
  return ajax({
    api: '/clue/reply',
    data: ori.data,
    type: 'ajax',
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * 获取模板列表
 */
export function getTemplateList(ori) {
  return ajax({
    api: '/h5template/list',
    data: ori.data,
    type: 'ajax',
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}
/**
 * 生成页面
 */
export function createTemplateList(ori) {
  return ajax({
    api: '/h5operate/store',
    data: ori.data,
    type: 'ajax',
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}
/**
 * 更新页面
 */
export function updateTemplateList(ori) {
  return ajax({
    api: '/h5operate/update',
    data: ori.data,
    type: 'ajax',
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * 个人页面列表
 */
export function getPersonalList(ori) {
  return ajax({
    api: '/h5operate/list',
    data: ori.data,
    type: 'ajax',
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * 删除个人列表
 */
export function deletePersonalList(ori) {
  return ajax({
    api: '/h5operate/delete',
    data: ori.data,
    type: 'ajax',
    method: 'GET',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * 获取各个平台授权账号
 */
export function getAccountList(ori) {
  return ajax({
    api: '/new-media/list',
    data: ori.data,
    type: 'ajax',
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * 获取各个平台授权账号传播数据
 */
export function getAccountData(ori) {
  return ajax({
    api: '/new-media/agg',
    data: ori.data,
    type: 'ajax',
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * 获取平台更新时间
 */
export function getUpdateTime(ori) {
  return ajax({
    api: '/new-media/platform',
    data: ori.data,
    type: 'ajax',
    method: 'POST',
    headers: {
      Authorization: localStorage.getItem('token'),
    },
  });
}

/**
 * 获取组件列表
 */
export function getComponentsList(ori) {
  return ajax({
    api: '/operate/h5Template/json/components.json?' + Date.now(),
    data: ori.data,
    type: 'ajax',
    base: 'json',
    method: 'GET',
  });
}

/**
 * 获取绘画风格
 */
export function getPaintingStyle(ori) {
  return ajax({
    api: '/get/modifiers',
    data: ori.data,
    type: 'ajax',
    base: 'easyDiffusion',
    method: 'GET',
  });
}

/**
 * 生成绘画
 */
export function createDraw(ori) {
  return ajax({
    noload: true,
    api: '/render',
    data: ori.data,
    type: 'ajax',
    base: 'easyDiffusion',
    method: 'POST',
  });
}

/**
 * 查询生成绘画
 */
export function queryDraw(ori) {
  return ajax({
    noload: true,
    api: '/image/stream/' + ori.data,
    type: 'ajax',
    base: 'easyDiffusion',
    method: 'POST',
  });
}
export function ChartGpt(data) {
  return ajax({
    noLoad: true,
    url: 'completions',
    method: 'POST',
    urlType: 'chat',
    errorToast: '当前访问人数过多，请重试。',
    data,
  });
}
