import {
	httpUrlFormat,
	ajaxCarryAuthorization,ajaxSync
} from '@/utils/httpUtils.js'

import { ApiVersion,AppVersion } from '@/config/baseConfig.js'

const headerVersion = {
	'API-Version': ApiVersion(),
	'APP-Version':AppVersion()
}

const _flag = 'apiBaseUrl' // 请求的api空间

const apiUrl = {
	'virtualOrderPreviewApi': httpUrlFormat('/virtual/order/preview', _flag),//商城订单预览
	'virtualOrderBoxPreviewApi': httpUrlFormat('/virtual/order/box/delivery/preview', _flag),//盲盒订单预览
	'virtualOrderApi': httpUrlFormat('/virtual/order/box/delivery', _flag),
	'virtualOrderPaidApi': httpUrlFormat('/virtual/order/paid', _flag),
	'virtualOrderListApi': httpUrlFormat('/virtual/order', _flag),
}


export function virtualShopOrderApi(data) {
	return ajaxCarryAuthorization({
		header: headerVersion,
		// header: {'Content-Type': 'application/x-www-form-urlencoded'},
		url: apiUrl.virtualOrderListApi,
		method: 'POST',
		data
	})
}
export function virtualOrderPreviewApi(data) {
	const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
	return ajaxCarryAuthorization({
		header: headerObj,
		url: apiUrl.virtualOrderPreviewApi,
		method: 'POST',
		data: data
	})
}
export function virtualOrderBoxPreviewApi(data) {
	const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
	return ajaxCarryAuthorization({
		header: headerObj,
		url: apiUrl.virtualOrderBoxPreviewApi,
		method: 'POST',
		data: data
	})
}

// 创建订单
export function virtualOrderApi(data) {
	return ajaxCarryAuthorization({
		header: headerVersion,
		// header: {'Content-Type': 'application/x-www-form-urlencoded'},
		url: apiUrl.virtualOrderApi,
		method: 'POST',
		data
	})
}
export function virtualOrderPaidApi(data) {
	return ajaxCarryAuthorization({
		header: headerVersion,
		// header: {'Content-Type': 'application/x-www-form-urlencoded'},
		url: apiUrl.virtualOrderPaidApi,
		method: 'GET',
		data
	})
}
export function virtualOrderListApi(data) {
	return ajaxCarryAuthorization({
		header: headerVersion,
		// header: {'Content-Type': 'application/x-www-form-urlencoded'},
		url: apiUrl.virtualOrderListApi,
		method: 'GET',
		data: data
	})
}

export function virtualOrderDetailId(id) {
	return ajaxCarryAuthorization({
		header: headerVersion,
		url: httpUrlFormat(`/virtual/order/${id}`, _flag),
		method: 'GET',
	})
}
export function virtualOrderDetail(no,data) {
	return ajaxCarryAuthorization({
		header: headerVersion,
		url: httpUrlFormat(`/virtual/order/no/${no}`, _flag),
		method: 'GET',
		data: data
	})
}