import request from '@/utils/request'
import qs from 'qs'
const url = '../theme.php'

// 获取模板列表
const getTheme = () => {
  return request({
    url: url,
    method: 'get',
  })
}

// 模板重命名
const renameTheme = data => {
  return request({
    url: url + '?action=renameTheme',
    method: 'post',
    data: qs.stringify(data)
  })
}

// 删除模板
const deleteTheme = data => {
  return request({
    url: url + '?action=deleteTheme',
    method: 'post',
    data: qs.stringify(data)
  })
}

// 设为pc模板
const setPc = query => {
  return request({
    url: url + '?action=setPc',
    method: 'get',
    params: query
  })
}

// 设为手机模板
const setMobile = query => {
  return request({
    url: url + '?action=setMobile',
    method: 'get',
    params: query
  })
}

// 取消手机模板
const rmMobile = query => {
  return request({
    url: url + '?action=rmMobile',
    method: 'get',
    params: query
  })
}

// 下载模板
const downloadTheme = query => {
  return request({
    url: url + '?action=downloadTheme',
    method: 'get',
    params: query
  })
}

// 复制模板
const copyTheme = data => {
  return request({
    url: url + '?action=copyTheme',
    method: 'post',
    data: qs.stringify(data)
  })
}

// 上传模板
const uploadTheme = data => {
  return request({
    url: url + '?action=uploadTheme',
    method: 'post',
    headers: {'Content-Type': 'multipart-formdata'},
    data
  })
}

// 获取用户
const getUser = () => {
  return request({
    url: url + '?action=getUser',
    method: 'get',
  })
}

export {
  getTheme,
  renameTheme,
  deleteTheme,
  setPc,
  setMobile,
  rmMobile,
  downloadTheme,
  copyTheme,
  uploadTheme,
  getUser
}
