import { http } from '../http'

const learnWordApi = {
  // 获取阶段
  getStageList: (params: object | any) => {
    return http.request({
      url: '/stage/list',
      params,
    })
  },

  // 获取混合闯关首页内容
  getMixIntrudeIndex: (stageId: string) => {
    return http.request({
      url: `/intrudeLevel/mixIntrudeIndex/${stageId}`,
    })
  },

  // 根据教材id 获取混合闯关首页内容
  getMixIntrudeIndexFromTextBookId: (textbookId: string, params: object) => {
    return http.request({
      url: `/intrudeLevel/intrudeIndex/textbook/${textbookId}`,
      params,
    })
  },

  // 获取闯关首页内容
  getLearnWordInfo: (params: object | any) => {
    return http.request({
      url: `/intrudeLevel/intrudeIndex`,
      params,
    })
  },

  /**
   * @description: 简单模式--获取四轮题目
   * @return {*}
   */
  getSimpleTopic: (levelId: string, params: object | any) => {
    return http.request({
      url: `/intrudeLevel/simpleLevelTile/${levelId}`,
      params,
    })
  },

  /**
   * @description: 普通模式-闯关记录提交，返回是否破纪录
   * @param {*} data
   * @return {*}
   */
  postSimpleRecord: (data: object | any) => {
    // return request('/intrudeLevel/simpleRecord', 'POST', data);
    return http.request({
      url: `/intrudeLevel/saveAndReturnSimpleResult`,
      method: 'POST',
      timeout: 8000,
      data,
    })
  },

  /**
   * @description: 单词对错情况提交,普通模式返回当前节点的分数与星级
   * @param {*} data
   * @return {*}
   */
  postWordRecord: (data: object | any) => {
    // return request('/intrudeLevel/wordRecord', 'POST', data);
    return http.request({
      url: `/intrudeLevel/wordRecordV2`,
      method: 'POST',
      data,
    })
  },

  /**
   * @description: 困难模式--获取两轮题目
   * @return {*}
   */
  getHardTopic: (levelId: string, data: object | any) => {
    return http.request({
      url: `/intrudeLevel/hardLevelTile/${levelId}`,
      data,
    })
  },

  /**
   * @description: 困难模式-闯关记录提交，返回是否破纪录
   * @param {*} data
   * @return {*}
   */
  postHardRecord: (data: object | any) => {
    // return request('/intrudeLevel/hardRecord', 'POST', data);
    return http.request({
      url: `/intrudeLevel/saveAndReturnHardResult`,
      method: 'POST',
      timeout: 8000,
      data,
    })
  },

  /**
   * @description: 使用道具 1使用炸弹 2使用放大镜
   * @param {*} data
   * @return {*}
   */
  postUseItems: (data: object | any) => {
    return http.request({
      url: `/sysUser/useItems`,
      method: 'POST',
      data,
    })
  },

  /* -----------------------------------------  测试用 api  ----------------------------------------- */
  simpleRecordTest: (data: object | any) => {
    return http.request({
      url: `/intrudeLevel/simpleRecordTest`,
      method: 'POST',
      data,
    })
  },

  hardRecordTest: (data: object | any) => {
    return http.request({
      url: `/intrudeLevel/hardRecordTest`,
      method: 'POST',
      data,
    })
  },
}

export default learnWordApi
