import Request from '@/common/request.js';
let request = new Request().http
const api = {
	// 直播订单
	liveOrderList: '/app/live/liveOrder/list', // 订单列表
	createliveOrder: '/app/live/liveOrder/create', // 创建订单
	createReward: '/app/live/liveOrder/createReward', // 创建中奖订单

	updateConfirm: (orderId, type) => `/app/live/liveOrder/updateConfirm/${orderId}/${type} `, // 取消/支付订单确认
	updateLiveOrder: '/app/live/liveOrder/update', // 取消/支付订单
	liveOrderKey: '/app/live/liveOrder/confirm', // 生成订单key
	userAddr: '/app/address/getAddressByDefault ', // 获取用户收货地址
	addAddress: '/app/address/addAddress', // 添加地址
	editAddress: '/app/address/editAddress', // 编辑地址
	delAddress: '/app/address/delAddress', // 删除地址
	getCitys: '/app/common/getCitys', // 获取省市区
	parseAddress: '/app/address/parseAddress', //地址解析 
	getAddressById: '/app/address/getAddressById', //

	queryLiveCartList: '/live/liveCart/list', //查询购物车列表
	exportLiveCartList: '(/live/liveCart/export ', //导出购物车列表
	liveCartDetails: (cardIds) => `/live/liveCart/${cardId} `, //获取购物车详情
	addLiveCart: '/live/liveCart ', //新增购物车
	modifyLiveCart: '/live/liveCart/update', //修改购物车
	delLiveCart: '/live/liveCart/delete', //删除购物车
	cartOrder: '/app/live/liveOrder/buy', //购物车订单
	checked: '/live/liveCart/checked', //获取购物车选中商品
	cancelOrder: '/app/live/liveOrder/cancelOrder', // 取消订单
	finishOrder: '/app/live/liveOrder/finishOrder', // 确认收货

	getStoreOrderItems: '/app/live/storeAfterSales/getStoreOrderItems', // 获取订单项列表
	applyAfterSales: '/app/live/storeAfterSales/applyAfterSales', // 申请售后
	revoke: '/app/live/storeAfterSales/revoke', // 撤销售后
	getStoreAfterSalesList: (liveId, pageSize, pageNum, status) =>
		`/app/live/storeAfterSales/getStoreAfterSalesList?liveId=${liveId}&pageSize=${pageSize}&pageNum=${pageNum}&status=${status}`, // 获取售后列表
	getStoreAfterSalesById: (id) => `/app/live/storeAfterSales/getStoreAfterSalesById?id=${id}`, // 获取售后详情

	liveOrder: (orderId) => `/app/live/liveOrder/info/${orderId}`, // 订单详情
	getMyStoreOrderById: (orderId) => `/app/live/liveOrder/info/${orderId}`,
	computed: '/app/live/liveOrder/computed', // 查询创建订单信息
	computedReward: '/app/live/liveOrder/computedReward', // 中奖填地址=>查询创建中奖订单信息

	// finishOrder: '/app/live/liveOrder/finishOrder', 
	// cancelOrder: '/app/live/liveOrder/cancelOrder',


}


// 直播订单

// 创建订单
export function createliveOrder(data) {
	return request(api.createliveOrder, data, 'POST', 'application/json;charset=UTF-8')
}

// 创建中奖订单
export function createReward(data) {
	return request(api.createReward, data, 'POST', 'application/json;charset=UTF-8')
}

// 生成订单key
export function liveOrderKey(data = {}) {
	return request(api.liveOrderKey, data, 'POST', 'application/json;charset=UTF-8')
}

// 点击取消/支付订单
export function updateConfirm(data) {
	return request(api.updateConfirm(orderId, type), data, 'GET', 'application/json;charset=UTF-8')
}

// 取消/支付订单
export function updateLiveOrder(data) {
	return request(api.updateLiveOrder, data, 'POST', 'application/json;charset=UTF-8')
}
// 订单列表
export function liveOrderList(data) {
	return request(api.liveOrderList, data, 'GET', 'application/json;charset=UTF-8')
}
// 订单详情
export function liveOrder(orderId, data = {}) {
	return request(api.liveOrder(orderId), data, 'GET', 'application/json;charset=UTF-8')
}

// 获取用户收货地址
export function userAddr(data = {}) {
	return request(api.userAddr, data, 'GET', 'application/json;charset=UTF-8')
}

// 添加地址
export function addAddress(data) {
	return request(api.addAddress, data, 'POST', 'application/json;charset=UTF-8')
}
// 编辑地址
export function editAddress(data) {
	return request(api.editAddress, data, 'POST', 'application/json;charset=UTF-8')
}
// 删除地址
export function delAddress(data) {
	return request(api.delAddress, data, 'POST', 'application/json;charset=UTF-8')
}

//获取省市区 
export function getCitys(data) {
	return request(api.getCitys, data, 'GET', 'application/json;charset=UTF-8')
}


//地址解析 
export function parseAddress(data) {
	return request(api.parseAddress, data, 'POST', 'application/json;charset=UTF-8')
}

// 
export function getAddressById(data) {
	return request(api.getAddressById, data, 'GET', 'application/json;charset=UTF-8')
}


// 查询购物车列表
export function queryLiveCartList(data) {
	return request(api.queryLiveCartList, data, 'GET', 'application/json;charset=UTF-8')
}
// 导出购物车列表
export function exportLiveCartList(data) {
	return request(api.exportLiveCartList, data, 'GET', 'application/json;charset=UTF-8')
}

// 获取购物车详情
export function liveCartDetails(cardIds, data = {}) {
	return request(api.liveCartDetails(cardIds), data, 'GET', 'application/json;charset=UTF-8')
}

// 新增购物车
export function addLiveCart(data) {
	return request(api.addLiveCart, data, 'POST', 'application/json;charset=UTF-8')
}

// 修改购物车
export function modifyLiveCart(data) {
	return request(api.modifyLiveCart, data, 'POST', 'application/json;charset=UTF-8')
}

// 删除购物车
export function delLiveCart(data) {
	return request(api.delLiveCart, data, 'POST', 'application/json;charset=UTF-8')
}

//购物车订单
export function cartOrder(data) {
	return request(api.cartOrder, data, 'POST', 'application/json;charset=UTF-8')
}

//获取购物车选中商品
export function checked(data) {
	return request(api.checked, data, 'GET', 'application/json;charset=UTF-8')
}

// 取消订单
export function cancelOrder(data) {
	return request(api.cancelOrder, data, 'POST', 'application/json;charset=UTF-8')
}

// 确认收货
export function finishOrder(data) {
	return request(api.finishOrder, data, 'POST', 'application/json;charset=UTF-8')
}


// 售后
// 获取订单项列表
export function getStoreOrderItems(data) {
	return request(api.getStoreOrderItems, data, 'GET', 'application/json;charset=UTF-8')
}

// 申请售后
export function applyAfterSales(data) {
	return request(api.applyAfterSales, data, 'POST', 'application/json;charset=UTF-8')
}

// 撤销售后
export function revoke(data) {
	return request(api.revoke, data, 'POST', 'application/json;charset=UTF-8')
}

//获取售后列表
export function getStoreAfterSalesList(liveId, pageSize, pageNum, status, data = {}) {
	return request(api.getStoreAfterSalesList(liveId, pageSize, pageNum, status), data, 'GET',
		'application/json;charset=UTF-8')
}

// 获取售后详情
export function getStoreAfterSalesById(id, data = {}) {
	return request(api.getStoreAfterSalesById(id), data, 'GET', 'application/json;charset=UTF-8')
}

// 申请原因
export function Dicts(data) {
	return request('/app/common/getDictByKey', data, 'GET', 'application/json;charset=UTF-8');
}






export function getMyStoreOrderById(orderId, data = {}) {
	return request(api.getMyStoreOrderById(orderId), data, 'GET', 'application/json;charset=UTF-8');
}

// 查询创建订单信息
export function computed(data) {
	return request(api.computed, data, 'POST', 'application/json;charset=UTF-8');
}
// 中奖填地址=>查询中奖创建订单信息
export function computedReward(data) {
	return request(api.computedReward, data, 'POST', 'application/json;charset=UTF-8');
}

//填写物流
export function addDelivery(data) {
	return request('/app/live/storeAfterSales/addDelivery', data, 'POST', 'application/json;charset=UTF-8');
}

export function getExpressMulti(data) {
	return request('/app/live/liveOrder/getExpressMulti', data, 'POST', 'application/json;charset=UTF-8');
}
export function getExpress(data) {
	return request('/app/live/liveOrder/getExpress', data, 'POST', 'application/json;charset=UTF-8');
}

// 抽奖中奖接口
export function payConfirmReward(data) {
	return request('/app/live/liveOrder/payConfirmReward', data, 'POST', 'application/json;charset=UTF-8');
}












/*订单接口*/
// 取消订单
export function orderCancelOrder(data) {
	return request('/app/storeOrder/cancelOrder', data, 'POST', 'application/json;charset=UTF-8');
}
// 取消支付
export function orderCancelPay(data) {
	return request('/app/storeOrder/cancelPay', data, 'POST', 'application/json;charset=UTF-8');
}
// 计算订单金额
export function orderComputed(data) {
	return request('/app/storeOrder/computed', data, 'POST', 'application/json;charset=UTF-8');
}
// 确认订单
export function orderConfirm(data) {
	return request('/app/storeOrder/confirm', data, 'POST', 'application/json;charset=UTF-8');
}
// 创建订单
export function orderCreate(data) {
	return request('/app/storeOrder/create', data, 'POST', 'application/json;charset=UTF-8');
}

// 获取我的订单详情
export function myStoreOrderById() {
	return request('/app/storeOrder/getMyStoreOrderById', null, 'GET', 'application/json;charset=UTF-8');
}
// 获取我的订单列表
export function myStoreOrderList() {
	return request('/app/storeOrder/getMyStoreOrderList', null, 'GET', 'application/json;charset=UTF-8');
}
// 获取订单总数
export function orderCount() {
	return request('/app/storeOrder/getOrderCount', null, 'GET', 'application/json;charset=UTF-8');
}
// 获取订单
export function storeOrderById() {
	return request('/app/storeOrder/getStoreOrderById', null, 'GET', 'application/json;charset=UTF-8');
}



// 支付
export function orderPay(data) {
	return request('/app/storeOrder/pay', data, 'POST', 'application/json;charset=UTF-8');
}