import request from '@/utils/request'

/**
 * 上传接口
 * @param file
 * @param title
 * @param alt
 * @param url
 * @param filename
 * @param size
 * @param ext
 * @param pic
 * @param resolution
 * @param mine_type
 * @param etag
 * @returns {*}
 */
export function upload(file,title,alt,url,filename,size,ext,pic,resolution,mine_type,etag) {
  return request({
    url: '/api/attachment/upload',
    method: 'post',
    data: {
      file,
      title,
      alt,
      url,
      filename,
      size,
      ext,
      pic,
      resolution,
      mine_type,
      etag
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * 获取邮件设置
 * @returns {*}
 */
export function getMailSettings() {
  return request({
    url: '/api/user/mail-setting',
    method: 'get'
  })
}

/**
 * 设置邮件设置
 * @param id
 * @param from_name
 * @param from_email
 * @param smtp_port
 * @param smtp_server
 * @param auth_code
 * @param is_ssl
 * @returns {*}
 */
export function saveMailSetting(id,from_name,from_email,smtp_port,smtp_server,auth_code,is_ssl) {
  return request({
    url: '/api/user/mail-setting',
    method: 'post',
    data: {
      id,
      from_name,
      from_email,
      smtp_port,
      smtp_server,
      auth_code,
      is_ssl
    }
  })
}

/**
 * 获取版本列表
 * @returns {AxiosPromise}
 */
export function getVerList (){
  return request({
    url: '/api/trade/ver-list',
    method: 'get'
  })
}

/**
 * 获取权益包列表
 * @param key EXPOREG=预登记，EXPOREG_INVITATION=邀请函
 * @returns {AxiosPromise}
 */
export function getPackList (key) {
  return request({
    url: '/api/trade/packet-list',
    method: 'get',
    params: {
      all_packet_key: key
    }
  })
}
