import Vue from 'vue';
import {post,fetch,patch,put,del,upload,ret2} 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;
Vue.prototype.$upload = upload;
Vue.prototype.$ret2 = ret2;

// 获取banner列表
const getBannerListUrl = `${_baseUrl}api/client/banner/list`;
export const getBannerListApi = function () {
  return Vue.prototype.$fetch(getBannerListUrl)
};
// 获取微信授权
const getwechatParamUrl = `${_baseUrl}api/client/jssdk`;
export const getwechatParam = function (json) {
  return Vue.prototype.$fetch(getwechatParamUrl,json)
};

// 文件上传
const uploadFileUrl = `${_baseUrl}api/public/upload/zone`;
export const uploadFileApi = function (json) {
  return Vue.prototype.$upload(uploadFileUrl,json)
};

// 获取商品详情
const getGoodsDetailUrl = `${_baseUrl}api/client/goods/info/`;
export const getGoodsDetailApi = function (id) {
  return Vue.prototype.$fetch(`${getGoodsDetailUrl}${id}`)
};
// 获取用户地址
const getUserAdressUrl = `${_baseUrl}api/client/address/info`;
export const getUserAdressApi = function () {
  return Vue.prototype.$fetch(getUserAdressUrl)
};
// 微信支付
const payUrl = `${_baseUrl}api/client/bill/wechat/pay`
export const payApi = function (json) {
  return Vue.prototype.$fetch(payUrl,json)
};
// 保存用户地址
const saveAddressUrl = `${_baseUrl}api/client/address/save`
export const saveAddressApi = function (json) {
  return Vue.prototype.$post(saveAddressUrl,json)
};
// 用户已购课程
const getUserLessonUrl = `${_baseUrl}api/client/user/course/list`
export const getUserLessonApi = function () {
  return Vue.prototype.$fetch(getUserLessonUrl)
};
// 课包列表
const getLessonListUrl = `${_baseUrl}api/client/course/category/list/`
export const getLessonListApi = function (id,json) {
  return Vue.prototype.$fetch(`${getLessonListUrl}${id}`,json)
};
// 获取主题列表
const getCourseListUrl = `${_baseUrl}api/client/course/relation/list/`
export const getCourseListApi = function (id) {
  return Vue.prototype.$fetch(`${getCourseListUrl}${id}`)
};
//获取课包详情
const getLessonDetailUrl = `${_baseUrl}api/client/element/info/`
export const getLessonDetailApi = function (periods_id,category_id,element_id) {
  return Vue.prototype.$fetch(`${getLessonDetailUrl}${periods_id}/${category_id}/${element_id}`)
};
// 获取客户详情
const getUserDetailUrl = `${_baseUrl}api/client/me`;
export const getUserDetailApi = function () {
  return Vue.prototype.$fetch(getUserDetailUrl)
};
// 提交看课数据
const subUserLessonUrl = `${_baseUrl}api/client/user/watch/log/`;
export const subUserLessonApi = function (element_id,category_id,periods_id,json) {
  return Vue.prototype.$post(`${subUserLessonUrl}${element_id}/${category_id}/${periods_id}`,json)
};
// 获取团购详情
const getGroupDetailUrl = `${_baseUrl}api/client/group/info/`;
export const getGroupDetailApi = function (group_id) {
  return Vue.prototype.$fetch(`${getGroupDetailUrl}${group_id}`)
};
// 获取订单详情
const getOrderDetailUrl = `${_baseUrl}api/client/order/info/`;
export const getOrderDetailApi = function (id) {
  return Vue.prototype.$fetch(`${getOrderDetailUrl}${id}`)
};
// 获取用户订单列表
const getOrderListUrl = `${_baseUrl}api/client/order/list`;
export const getOrderListApi = function (json) {
  return Vue.prototype.$fetch(getOrderListUrl,json)
};
// 用户看课统计
const getUserWatchUrl = `${_baseUrl}api/client/user/watch/report`;
export const getUserWatchApi = function () {
  return Vue.prototype.$fetch(getUserWatchUrl)
};
// 获取老师
const getTeacherDetailUrl = `${_baseUrl}api/client/me/teacher`;
export const getTeacherApi = function () {
  return Vue.prototype.$fetch(getTeacherDetailUrl)
};
// 获取新用户自动跳转
const getNewUrl = `${_baseUrl}api/client/new/user/direct`;
export const getNewApi = function () {
  return Vue.prototype.$fetch(getNewUrl)
};
// 查看是否可购买该商品
const getStatusWechatUrl = `${_baseUrl}api/client/bill/wechat/status`;
export const getStatusWechatApi = function (json) {
  return Vue.prototype.$fetch(getStatusWechatUrl,json)
};

// 用户可用优惠券
const getCouponListUrl = `${_baseUrl}api/client/user/coupon/list`;
export const getCouponListApi = function (id) {
  return Vue.prototype.$fetch(getCouponListUrl,{goods_id:id})
};
// 获取商品列表
const getGoodsListUrl = `${_baseUrl}api/client/goods/list`;
export const getGoodsListApi = function (json) {
  return Vue.prototype.$fetch(getGoodsListUrl,json)
};
//获取邀请战绩收益
const getInviteResultUrl = `${_baseUrl}api/client/user/invite/earnings`;
export const getInviteResultApi = function (json,id) {
  return Vue.prototype.$fetch(`${getInviteResultUrl}/${id}`,json)
};
//获取邀请战绩用户列表
const getInviteListUrl = `${_baseUrl}api/client/user/invite/list`;
export const getInviteListApi = function (json,id) {
  return Vue.prototype.$fetch(`${getInviteListUrl}/${id}`,json)
};
// 发送验证码
const sendMobileCodeUrl = `${_baseUrl}api/client/mobile/code`;
export const sendMobileCodeApi = function (json) {
  return Vue.prototype.$post(sendMobileCodeUrl,json)
};
// 绑定手机号
const bindMobileUrl = `${_baseUrl}api/client/user/mobile/bind`;
export const bindMobileApi = function (json) {
  return Vue.prototype.$put(bindMobileUrl,json)
};
// 获取引导参数
const getGuideUrl =`${_baseUrl}api/client/user/bootPage`;
export const getGuideApi = function (json) {
  return Vue.prototype.$fetch(getGuideUrl,json)
};
// 设置引导参数
const setGuideUrl =`${_baseUrl}api/client/user/bootPage`;
export const setGuideApi = function (json) {
  return Vue.prototype.$post(setGuideUrl,json)
};
// 查找跳转
const getRedirectUrl =`${_baseUrl}api/client/redirect`;
export const getRedirectApi = function (json) {
  return Vue.prototype.$fetch(getRedirectUrl,json)
};

// 获取用户收藏
const getUserCollectUrl =`${_baseUrl}api/client/user/collect`;
export const getUserCollectApi = function (json) {
  return Vue.prototype.$fetch(getUserCollectUrl,json)
};

// 用户添加收藏
const addUserCollectUrl =`${_baseUrl}api/client/user/collect`;
export const addUserCollectApi = function (json) {
  return Vue.prototype.$post(addUserCollectUrl,json)
};

// 用户取消收藏
const delUserCollectUrl =`${_baseUrl}api/client/user/collect/`;
export const delUserCollectApi = function (id) {
  return Vue.prototype.$put(delUserCollectUrl+id)
};

