import Vue from 'vue';
import {post,fetch,patch,put,del} from './index'
const _baseUrl=process.env.API_URL;
Vue.prototype.$post=post;
Vue.prototype.$fetch=fetch;
Vue.prototype.$patch=patch;
Vue.prototype.$put=put;
Vue.prototype.$del=del;

//登录
const loginURL = `${_baseUrl}api/admin/login`;
export const loginApi = function(json) {
  return Vue.prototype.$post(loginURL,{"username":json.username,"passwd":json.password})
};
//退出登录
const logOutUrl = `${_baseUrl}api/admin/logout`;
export const logoutApi = function() {
  return Vue.prototype.$post(logOutUrl)
};
//查询账号列表
const getAdminListUrl = `${_baseUrl}api/admin/user/list`;
export const getAdminListApi = function () {
  return Vue.prototype.$fetch(getAdminListUrl)
};
//修改账号信息
const editAdminUrl = `${_baseUrl}api/admin/user/info`;
export const editAdminListApi = function (id,json) {
  return Vue.prototype.$put(`${editAdminUrl}/${id}`,json)
};
//添加账号
const addAdminUrl = `${_baseUrl}api/admin/user/add`;
export const addAdminListApi = function (json) {
  return Vue.prototype.$post(addAdminUrl,json)
};
//删除账号
const delAdminUrl = `${_baseUrl}api/admin/user`;
export const delAdminListApi = function (id) {
  return Vue.prototype.$del(`${delAdminUrl}/${id}`)
};
//修改密码
const editPasswordUrl = `${_baseUrl}api/admin/user/passwd`;
export const editPasswordApi = function (id,json) {
  return Vue.prototype.$patch(`${editPasswordUrl}/${id}`,json)
};
//获取用户列表
const getUserListUrl = `${_baseUrl}api/admin/student/list`;
export const getUserListApi = function (json) {
  return Vue.prototype.$fetch(getUserListUrl,json)
};
//获取用户详情
const getUserDetailUrl = `${_baseUrl}api/admin/student/info`;
export const getUserDetailApi = function (id) {
  return Vue.prototype.$fetch(`${getUserDetailUrl}/${id}`)
};
//获取教师列表
const getTeacherListUrl = `${_baseUrl}api/admin/teacher/list`;
export const getTeacherListApi = function (json) {
  return Vue.prototype.$fetch(`${getTeacherListUrl}`,json)
};
//获取教师详情
const getTeacherDetailUrl = `${_baseUrl}api/admin/teacher/info`;
export const getTeacherDetailApi = function (id) {
  return Vue.prototype.$fetch(`${getTeacherDetailUrl}/${id}`)
};
//添加教师
const addTeacherUrl = `${_baseUrl}api/admin/teacher/add`;
export const addTeacherApi = function (json) {
  return Vue.prototype.$post(addTeacherUrl,json)
};
//更新教师信息
const editTeacherUrl = `${_baseUrl}api/admin/teacher/info`;
export const editTeacherApi = function (id, json) {
  return Vue.prototype.$put(`${editTeacherUrl}/${id}`,json)
};
//删除教师
const delTeacherUrl = `${_baseUrl}api/admin/teacher`;
export const delTeacherApi = function (id) {
  return Vue.prototype.$del(`${delTeacherUrl}/${id}`)
};
//获取课程列表
const getLessonUrl = `${_baseUrl}api/admin/course/list`;
export const getLessonApi = function (json) {
  return Vue.prototype.$fetch(getLessonUrl,json)
};
//获取课程详情
const getLessonDetailUrl = `${_baseUrl}api/admin/course/info`;
export const getLessonDetailApi = function (id, json) {
  return Vue.prototype.$fetch(`${getLessonDetailUrl}/${id}`,json)
};
//编辑课程详情
const editLessonDetailUrl = `${_baseUrl}api/admin/course/info`;
export const editLessonApi = function (id,json) {
  return Vue.prototype.$put(`${editLessonDetailUrl}/${id}`,json)
};
//删除课程
const deleteLessonUrl = `${_baseUrl}api/admin/course`;
export const deleteLessonAPI = function (id) {
  return Vue.prototype.$del(`${deleteLessonUrl}/${id}`)
};
//新增课程
const addLessonUrl = `${_baseUrl}api/admin/course/add`;
export const addLessonApi = function (json) {
  return Vue.prototype.$post(addLessonUrl,json)
};
//获取商品列表
const getGoodsListUrl = `${_baseUrl}api/admin/goods/list`;
export const getGoodsListApi = function (json) {
  return Vue.prototype.$fetch(getGoodsListUrl,json)
};
//获取商品详情
const getGoodsDetailUrl = `${_baseUrl}api/admin/goods/info`;
export const getGoodsDetailApi = function (id, json) {
  return Vue.prototype.$fetch(`${getGoodsDetailUrl}/${id}`,json)
};
//添加商品
const addGoodsUrl = `${_baseUrl}api/admin/goods/add`;
export const addGoodsApi = function (json) {
  return Vue.prototype.$post(addGoodsUrl,json)
};
//编辑商品
const editGoodsUrl = `${_baseUrl}api/admin/goods/info`;
export const editGoodsApi = function (id, json) {
  return Vue.prototype.$put(`${editGoodsUrl}/${id}`,json)
};
//删除商品
const deleteGoodsUrl = `${_baseUrl}api/admin/goods`;
export const deleteGoodsApi = function (id) {
  return Vue.prototype.$del(`${deleteGoodsUrl}/${id}`)
};

//查询元素、菜单分类
const getCategoryUrl = `${_baseUrl}api/admin/category/list/0`;
export const getCategoryApi = function (pid) {
  return Vue.prototype.$fetch(getCategoryUrl,{'pid':pid})
};
//删除元素分类
const delCategoryUrl = `${_baseUrl}api/admin/category`;
export const delCategoryApi = function (id) {
  return Vue.prototype.$del(`${delCategoryUrl}/${id}`)
};
//元素排序修改
const sortCategoryUrl = `${_baseUrl}api/admin/category/sort`;
export const sortCategoryApi = function (json) {
  return Vue.prototype.$patch(sortCategoryUrl,json)
};
//获取分类下的元素列表
const getCateDetailListUrl = `${_baseUrl}api/admin/element/list/0?category_id=`;
export const getCateListApi = function (id) {
  return Vue.prototype.$fetch(`${getCateDetailListUrl}${id}`)
};
// 获取单品列表
const getSingleListUrl = `${_baseUrl}api/admin/item/stock/list`;
export const getSingleListApi = function (name) {
  return Vue.prototype.$fetch(`${getSingleListUrl}`,{name:name})
};
// 获取单品详情
const getSingleDetailUrl = `${_baseUrl}api/admin/item/stock/info/`;
export const getSingleDetailApi = function (id) {
  return Vue.prototype.$fetch(`${getSingleDetailUrl}${id}`)
};
// 删除单品
const delSingleUrl = `${_baseUrl}api/admin/item/stock/`;
export const delSingleApi = function (id) {
  return Vue.prototype.$del(`${delSingleUrl}${id}`)
};
// 新增单品
const addSingleUrl = `${_baseUrl}api/admin/item/stock/add`;
export const addSingleApi = function (json) {
  return Vue.prototype.$post(addSingleUrl,json)
};
// 修改单品
const editSingleUrl = `${_baseUrl}api/admin/item/stock/info/`;
export const editSingleApi = function (id,json) {
  return Vue.prototype.$put(`${editSingleUrl}${id}`,json)
};
// 获取盒子分类
const getBoxTypeListUrl = `${_baseUrl}api/admin/category/list/1`;
export const getBoxTypeListApi = function () {
  return Vue.prototype.$fetch(getBoxTypeListUrl)
};
// 获取盒子列表
const getBoxListUrl = `${_baseUrl}api/admin/item/box/list/`;
export const getBoxListApi = function (id) {
  return Vue.prototype.$fetch(`${getBoxListUrl}${id}`)
};
// 添加盒子
const addBoxUrl = `${_baseUrl}api/admin/item/box/add/`;
export const addBoxApi = function (id, json) {
  return Vue.prototype.$post(`${addBoxUrl}${id}`,json)
};
// 删除盒子
const delBoxUrl = `${_baseUrl}api/admin/item/box/`;
export const delBoxApi = function (id) {
  return Vue.prototype.$del(`${delBoxUrl}${id}`)
};
// 获取盒子详情
const getBoxDetailUrl = `${_baseUrl}api/admin/item/box/info/`;
export const getBoxDetailApi = function (id) {
  return Vue.prototype.$fetch(`${getBoxDetailUrl}${id}`)
};
// 更新盒子
const editBoxUrl = `${_baseUrl}api/admin/item/box/info/`;
export const editBoxApi = function (id, json) {
  return Vue.prototype.$put(`${editBoxUrl}${id}`,json)
};
// 获取公众号菜单
const getPublicMenuUrl = `${_baseUrl}api/admin/open/menu`;
export const getPublicMenuApi = function (id) {
  return Vue.prototype.$fetch(getPublicMenuUrl)
};
// 添加公众号菜单
export const savePublicMenuApi = function (json) {
  return Vue.prototype.$post(getPublicMenuUrl,json)
};
// 获取商品列表
// const getGoodsListUrl = `${_baseUrl}api/admin/goods/list`;

