import request from '@/utils/requestTemp'
import { Message } from 'element-ui'

export function GeneralDataReception (params) {
  return request({
    url: '/openApi/generalDataReception',
    method: 'post',
    headers: {
      'content-type': 'application/json',
    },
    data: params,
  })
}

export function BaggageMessageQuery (params) {
  return request({
    // url: '/openApi/luggage/search/source',
    url: PLATFROM_CONFIG.baggageMessageURL,
    method: 'post',
    data: params,
  })
}

// 查询
export function TempQuery (params) {
  return request({
    url: '/openApi/query',
    method: 'post',
    data: params,
  })
}

export async function myQuery (id, ...dataContent) {
  const params = {
    id,
    dataContent,
  }
  try {
    const result = await TempQuery(params)
    if (Number(result.code) === 0) {
      return result.returnData.listValues
    } else {
      Message.error(result.message ?? '失败')
      return Promise.reject(result.message)
    }
  } catch (error) {
    return Promise.reject(error)
  }
}

export function GetCheckCode (params) {
  return request({
    url: '/foxlibc/verification-code',
    method: 'post',
    headers: {
      // appSecret: PLATFROM_CONFIG.appKeyString,
      Authorization: PLATFROM_CONFIG.tempToken,
    },
    data: params,
  })
}

export function CheckUser (params) {
  return request({
    url: '/foxlibc/sec-sign-in',
    method: 'post',
    data: params,
    headers: {
      Authorization: PLATFROM_CONFIG.tempToken,
    },
  })
}

// 上传文件
export function UploadFile (params) {
  return request({
    url: `${PLATFROM_CONFIG.fileUrl}/openApi/upload`,
    method: 'post',
    headers: {
      'content-type': 'multipart/form-data',
    },
    data: params,
    noToken: true,
  })
}

// 上传文件
export function stateQuery (params) {
  return request({
    url: `${PLATFROM_CONFIG.tempUrl}/openApi/query`,
    method: 'post',
    headers: {
      'content-type': 'application/json',
    },
    data: params,
  })
}

// 不知道什么的查询
export function WhatQuery (params) {
  return request({
    url: `${PLATFROM_CONFIG.expressUrl}/openApi/query`,
    method: 'post',
    headers: {
      'content-type': 'application/json',
    },
    data: params,
  })
}

